From b5d77e02478bdef8a825de6288754a6291201cb5 Mon Sep 17 00:00:00 2001 From: Christian Krueger Date: Tue, 12 Nov 2024 09:00:53 -0800 Subject: [PATCH] updated clients --- .../jito_tip_router/accounts/epochSnapshot.ts | 16 +- clients/js/jito_tip_router/accounts/index.ts | 1 + .../accounts/operatorSnapshot.ts | 62 +- .../vaultOperatorDelegationSnapshot.ts | 189 ++++ .../jito_tip_router/errors/jitoTipRouter.ts | 12 + .../js/jito_tip_router/instructions/index.ts | 2 + .../initializeOperatorSnapshot.ts | 334 +++++++ ...itializeVaultOperatorDelegationSnapshot.ts | 417 ++++++++ .../jito_tip_router/programs/jitoTipRouter.ts | 19 +- clients/js/jito_tip_router/types/index.ts | 1 - .../types/vaultOperatorDelegationSnapshot.ts | 77 -- .../src/generated/accounts/epoch_snapshot.rs | 4 +- .../src/generated/accounts/mod.rs | 6 +- .../generated/accounts/operator_snapshot.rs | 13 +- .../vault_operator_delegation_snapshot.rs | 88 ++ .../src/generated/errors/jito_tip_router.rs | 9 + .../initialize_operator_snapshot.rs | 692 ++++++++++++++ ...lize_vault_operator_delegation_snapshot.rs | 899 ++++++++++++++++++ .../src/generated/instructions/mod.rs | 3 + .../src/generated/types/mod.rs | 6 +- .../vault_operator_delegation_snapshot.rs | 28 - core/src/epoch_snapshot.rs | 9 +- idl/jito_tip_router.json | 329 +++++-- scripts/generate-clients.js | 16 + 24 files changed, 3009 insertions(+), 223 deletions(-) create mode 100644 clients/js/jito_tip_router/accounts/vaultOperatorDelegationSnapshot.ts create mode 100644 clients/js/jito_tip_router/instructions/initializeOperatorSnapshot.ts create mode 100644 clients/js/jito_tip_router/instructions/initializeVaultOperatorDelegationSnapshot.ts delete mode 100644 clients/js/jito_tip_router/types/vaultOperatorDelegationSnapshot.ts create mode 100644 clients/rust/jito_tip_router/src/generated/accounts/vault_operator_delegation_snapshot.rs create mode 100644 clients/rust/jito_tip_router/src/generated/instructions/initialize_operator_snapshot.rs create mode 100644 clients/rust/jito_tip_router/src/generated/instructions/initialize_vault_operator_delegation_snapshot.rs delete mode 100644 clients/rust/jito_tip_router/src/generated/types/vault_operator_delegation_snapshot.rs diff --git a/clients/js/jito_tip_router/accounts/epochSnapshot.ts b/clients/js/jito_tip_router/accounts/epochSnapshot.ts index 3c6a279d..86bfa4c9 100644 --- a/clients/js/jito_tip_router/accounts/epochSnapshot.ts +++ b/clients/js/jito_tip_router/accounts/epochSnapshot.ts @@ -47,11 +47,13 @@ export type EpochSnapshot = { discriminator: bigint; ncn: Address; ncnEpoch: bigint; - slotCreated: bigint; bump: number; + slotCreated: bigint; + slotFinalized: bigint; ncnFees: Fees; operatorCount: bigint; operatorsRegistered: bigint; + validOperatorVaultDelegations: bigint; totalVotes: bigint; reserved: Array; }; @@ -60,11 +62,13 @@ export type EpochSnapshotArgs = { discriminator: number | bigint; ncn: Address; ncnEpoch: number | bigint; - slotCreated: number | bigint; bump: number; + slotCreated: number | bigint; + slotFinalized: number | bigint; ncnFees: FeesArgs; operatorCount: number | bigint; operatorsRegistered: number | bigint; + validOperatorVaultDelegations: number | bigint; totalVotes: number | bigint; reserved: Array; }; @@ -74,11 +78,13 @@ export function getEpochSnapshotEncoder(): Encoder { ['discriminator', getU64Encoder()], ['ncn', getAddressEncoder()], ['ncnEpoch', getU64Encoder()], - ['slotCreated', getU64Encoder()], ['bump', getU8Encoder()], + ['slotCreated', getU64Encoder()], + ['slotFinalized', getU64Encoder()], ['ncnFees', getFeesEncoder()], ['operatorCount', getU64Encoder()], ['operatorsRegistered', getU64Encoder()], + ['validOperatorVaultDelegations', getU64Encoder()], ['totalVotes', getU128Encoder()], ['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })], ]); @@ -89,11 +95,13 @@ export function getEpochSnapshotDecoder(): Decoder { ['discriminator', getU64Decoder()], ['ncn', getAddressDecoder()], ['ncnEpoch', getU64Decoder()], - ['slotCreated', getU64Decoder()], ['bump', getU8Decoder()], + ['slotCreated', getU64Decoder()], + ['slotFinalized', getU64Decoder()], ['ncnFees', getFeesDecoder()], ['operatorCount', getU64Decoder()], ['operatorsRegistered', getU64Decoder()], + ['validOperatorVaultDelegations', getU64Decoder()], ['totalVotes', getU128Decoder()], ['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })], ]); diff --git a/clients/js/jito_tip_router/accounts/index.ts b/clients/js/jito_tip_router/accounts/index.ts index 6fa7098a..9aba2f1a 100644 --- a/clients/js/jito_tip_router/accounts/index.ts +++ b/clients/js/jito_tip_router/accounts/index.ts @@ -9,4 +9,5 @@ export * from './epochSnapshot'; export * from './ncnConfig'; export * from './operatorSnapshot'; +export * from './vaultOperatorDelegationSnapshot'; export * from './weightTable'; diff --git a/clients/js/jito_tip_router/accounts/operatorSnapshot.ts b/clients/js/jito_tip_router/accounts/operatorSnapshot.ts index ae46a968..ff9dddfd 100644 --- a/clients/js/jito_tip_router/accounts/operatorSnapshot.ts +++ b/clients/js/jito_tip_router/accounts/operatorSnapshot.ts @@ -17,6 +17,8 @@ import { getAddressEncoder, getArrayDecoder, getArrayEncoder, + getBoolDecoder, + getBoolEncoder, getStructDecoder, getStructEncoder, getU128Decoder, @@ -38,26 +40,21 @@ import { type MaybeAccount, type MaybeEncodedAccount, } from '@solana/web3.js'; -import { - getVaultOperatorDelegationSnapshotDecoder, - getVaultOperatorDelegationSnapshotEncoder, - type VaultOperatorDelegationSnapshot, - type VaultOperatorDelegationSnapshotArgs, -} from '../types'; export type OperatorSnapshot = { discriminator: bigint; operator: Address; ncn: Address; ncnEpoch: bigint; - slotCreated: bigint; bump: number; + slotCreated: bigint; + slotFinalized: bigint; + isActive: number; operatorFeeBps: number; + vaultOperatorDelegationCount: bigint; + vaultOperatorDelegationsRegistered: bigint; + validOperatorVaultDelegations: bigint; totalVotes: bigint; - numVaultOperatorDelegations: number; - vaultOperatorDelegationsRegistered: number; - slotSet: bigint; - vaultOperatorDelegations: Array; reserved: Array; }; @@ -66,14 +63,15 @@ export type OperatorSnapshotArgs = { operator: Address; ncn: Address; ncnEpoch: number | bigint; - slotCreated: number | bigint; bump: number; + slotCreated: number | bigint; + slotFinalized: number | bigint; + isActive: number; operatorFeeBps: number; + vaultOperatorDelegationCount: number | bigint; + vaultOperatorDelegationsRegistered: number | bigint; + validOperatorVaultDelegations: number | bigint; totalVotes: number | bigint; - numVaultOperatorDelegations: number; - vaultOperatorDelegationsRegistered: number; - slotSet: number | bigint; - vaultOperatorDelegations: Array; reserved: Array; }; @@ -83,19 +81,15 @@ export function getOperatorSnapshotEncoder(): Encoder { ['operator', getAddressEncoder()], ['ncn', getAddressEncoder()], ['ncnEpoch', getU64Encoder()], - ['slotCreated', getU64Encoder()], ['bump', getU8Encoder()], + ['slotCreated', getU64Encoder()], + ['slotFinalized', getU64Encoder()], + ['isActive', getBoolEncoder()], ['operatorFeeBps', getU16Encoder()], + ['vaultOperatorDelegationCount', getU64Encoder()], + ['vaultOperatorDelegationsRegistered', getU64Encoder()], + ['validOperatorVaultDelegations', getU64Encoder()], ['totalVotes', getU128Encoder()], - ['numVaultOperatorDelegations', getU16Encoder()], - ['vaultOperatorDelegationsRegistered', getU16Encoder()], - ['slotSet', getU64Encoder()], - [ - 'vaultOperatorDelegations', - getArrayEncoder(getVaultOperatorDelegationSnapshotEncoder(), { - size: 32, - }), - ], ['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })], ]); } @@ -106,19 +100,15 @@ export function getOperatorSnapshotDecoder(): Decoder { ['operator', getAddressDecoder()], ['ncn', getAddressDecoder()], ['ncnEpoch', getU64Decoder()], - ['slotCreated', getU64Decoder()], ['bump', getU8Decoder()], + ['slotCreated', getU64Decoder()], + ['slotFinalized', getU64Decoder()], + ['isActive', getBoolDecoder()], ['operatorFeeBps', getU16Decoder()], + ['vaultOperatorDelegationCount', getU64Decoder()], + ['vaultOperatorDelegationsRegistered', getU64Decoder()], + ['validOperatorVaultDelegations', getU64Decoder()], ['totalVotes', getU128Decoder()], - ['numVaultOperatorDelegations', getU16Decoder()], - ['vaultOperatorDelegationsRegistered', getU16Decoder()], - ['slotSet', getU64Decoder()], - [ - 'vaultOperatorDelegations', - getArrayDecoder(getVaultOperatorDelegationSnapshotDecoder(), { - size: 32, - }), - ], ['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })], ]); } diff --git a/clients/js/jito_tip_router/accounts/vaultOperatorDelegationSnapshot.ts b/clients/js/jito_tip_router/accounts/vaultOperatorDelegationSnapshot.ts new file mode 100644 index 00000000..c0233f58 --- /dev/null +++ b/clients/js/jito_tip_router/accounts/vaultOperatorDelegationSnapshot.ts @@ -0,0 +1,189 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/kinobi-so/kinobi + */ + +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBoolDecoder, + getBoolEncoder, + getStructDecoder, + getStructEncoder, + getU128Decoder, + getU128Encoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, +} from '@solana/web3.js'; + +export type VaultOperatorDelegationSnapshot = { + discriminator: bigint; + vault: Address; + operator: Address; + ncn: Address; + ncnEpoch: bigint; + bump: number; + slotCreated: bigint; + isActive: number; + stMint: Address; + totalSecurity: bigint; + totalVotes: bigint; + reserved: Array; +}; + +export type VaultOperatorDelegationSnapshotArgs = { + discriminator: number | bigint; + vault: Address; + operator: Address; + ncn: Address; + ncnEpoch: number | bigint; + bump: number; + slotCreated: number | bigint; + isActive: number; + stMint: Address; + totalSecurity: number | bigint; + totalVotes: number | bigint; + reserved: Array; +}; + +export function getVaultOperatorDelegationSnapshotEncoder(): Encoder { + return getStructEncoder([ + ['discriminator', getU64Encoder()], + ['vault', getAddressEncoder()], + ['operator', getAddressEncoder()], + ['ncn', getAddressEncoder()], + ['ncnEpoch', getU64Encoder()], + ['bump', getU8Encoder()], + ['slotCreated', getU64Encoder()], + ['isActive', getBoolEncoder()], + ['stMint', getAddressEncoder()], + ['totalSecurity', getU64Encoder()], + ['totalVotes', getU128Encoder()], + ['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })], + ]); +} + +export function getVaultOperatorDelegationSnapshotDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', getU64Decoder()], + ['vault', getAddressDecoder()], + ['operator', getAddressDecoder()], + ['ncn', getAddressDecoder()], + ['ncnEpoch', getU64Decoder()], + ['bump', getU8Decoder()], + ['slotCreated', getU64Decoder()], + ['isActive', getBoolDecoder()], + ['stMint', getAddressDecoder()], + ['totalSecurity', getU64Decoder()], + ['totalVotes', getU128Decoder()], + ['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })], + ]); +} + +export function getVaultOperatorDelegationSnapshotCodec(): Codec< + VaultOperatorDelegationSnapshotArgs, + VaultOperatorDelegationSnapshot +> { + return combineCodec( + getVaultOperatorDelegationSnapshotEncoder(), + getVaultOperatorDelegationSnapshotDecoder() + ); +} + +export function decodeVaultOperatorDelegationSnapshot< + TAddress extends string = string, +>( + encodedAccount: EncodedAccount +): Account; +export function decodeVaultOperatorDelegationSnapshot< + TAddress extends string = string, +>( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeVaultOperatorDelegationSnapshot< + TAddress extends string = string, +>( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getVaultOperatorDelegationSnapshotDecoder() + ); +} + +export async function fetchVaultOperatorDelegationSnapshot< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeVaultOperatorDelegationSnapshot( + rpc, + address, + config + ); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeVaultOperatorDelegationSnapshot< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeVaultOperatorDelegationSnapshot(maybeAccount); +} + +export async function fetchAllVaultOperatorDelegationSnapshot( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeVaultOperatorDelegationSnapshot( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeVaultOperatorDelegationSnapshot( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeVaultOperatorDelegationSnapshot(maybeAccount) + ); +} diff --git a/clients/js/jito_tip_router/errors/jitoTipRouter.ts b/clients/js/jito_tip_router/errors/jitoTipRouter.ts index 62f76791..11a6a323 100644 --- a/clients/js/jito_tip_router/errors/jitoTipRouter.ts +++ b/clients/js/jito_tip_router/errors/jitoTipRouter.ts @@ -54,6 +54,12 @@ export const JITO_TIP_ROUTER_ERROR__INCORRECT_FEE_ADMIN = 0x220c; // 8716 export const JITO_TIP_ROUTER_ERROR__WEIGHT_TABLE_NOT_FINALIZED = 0x220d; // 8717 /** WeightNotFound: Weight not found */ export const JITO_TIP_ROUTER_ERROR__WEIGHT_NOT_FOUND = 0x220e; // 8718 +/** NoOperators: No operators in ncn */ +export const JITO_TIP_ROUTER_ERROR__NO_OPERATORS = 0x220f; // 8719 +/** VaultOperatorDelegationFinalized: Vault operator delegation is already finalized - should not happen */ +export const JITO_TIP_ROUTER_ERROR__VAULT_OPERATOR_DELEGATION_FINALIZED = 0x2210; // 8720 +/** OperatorFinalized: Operator is already finalized - should not happen */ +export const JITO_TIP_ROUTER_ERROR__OPERATOR_FINALIZED = 0x2211; // 8721 export type JitoTipRouterError = | typeof JITO_TIP_ROUTER_ERROR__ARITHMETIC_OVERFLOW @@ -70,7 +76,10 @@ export type JitoTipRouterError = | typeof JITO_TIP_ROUTER_ERROR__MODULO_OVERFLOW | typeof JITO_TIP_ROUTER_ERROR__NEW_PRECISE_NUMBER_ERROR | typeof JITO_TIP_ROUTER_ERROR__NO_MINTS_IN_TABLE + | typeof JITO_TIP_ROUTER_ERROR__NO_OPERATORS + | typeof JITO_TIP_ROUTER_ERROR__OPERATOR_FINALIZED | typeof JITO_TIP_ROUTER_ERROR__TOO_MANY_MINTS_FOR_TABLE + | typeof JITO_TIP_ROUTER_ERROR__VAULT_OPERATOR_DELEGATION_FINALIZED | typeof JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_LENGTH | typeof JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_MINT_HASH | typeof JITO_TIP_ROUTER_ERROR__WEIGHT_NOT_FOUND @@ -94,7 +103,10 @@ if (process.env.NODE_ENV !== 'production') { [JITO_TIP_ROUTER_ERROR__MODULO_OVERFLOW]: `Modulo Overflow`, [JITO_TIP_ROUTER_ERROR__NEW_PRECISE_NUMBER_ERROR]: `New precise number error`, [JITO_TIP_ROUTER_ERROR__NO_MINTS_IN_TABLE]: `There are no mints in the table`, + [JITO_TIP_ROUTER_ERROR__NO_OPERATORS]: `No operators in ncn`, + [JITO_TIP_ROUTER_ERROR__OPERATOR_FINALIZED]: `Operator is already finalized - should not happen`, [JITO_TIP_ROUTER_ERROR__TOO_MANY_MINTS_FOR_TABLE]: `Too many mints for table`, + [JITO_TIP_ROUTER_ERROR__VAULT_OPERATOR_DELEGATION_FINALIZED]: `Vault operator delegation is already finalized - should not happen`, [JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_LENGTH]: `Weight mints do not match - length`, [JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_MINT_HASH]: `Weight mints do not match - mint hash`, [JITO_TIP_ROUTER_ERROR__WEIGHT_NOT_FOUND]: `Weight not found`, diff --git a/clients/js/jito_tip_router/instructions/index.ts b/clients/js/jito_tip_router/instructions/index.ts index 18c4550e..3ea3457c 100644 --- a/clients/js/jito_tip_router/instructions/index.ts +++ b/clients/js/jito_tip_router/instructions/index.ts @@ -9,6 +9,8 @@ export * from './adminUpdateWeightTable'; export * from './initializeEpochSnapshot'; export * from './initializeNCNConfig'; +export * from './initializeOperatorSnapshot'; +export * from './initializeVaultOperatorDelegationSnapshot'; export * from './initializeWeightTable'; export * from './setConfigFees'; export * from './setNewAdmin'; diff --git a/clients/js/jito_tip_router/instructions/initializeOperatorSnapshot.ts b/clients/js/jito_tip_router/instructions/initializeOperatorSnapshot.ts new file mode 100644 index 00000000..aa74bff2 --- /dev/null +++ b/clients/js/jito_tip_router/instructions/initializeOperatorSnapshot.ts @@ -0,0 +1,334 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/kinobi-so/kinobi + */ + +import { + combineCodec, + getOptionDecoder, + getOptionEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type IAccountMeta, + type IAccountSignerMeta, + type IInstruction, + type IInstructionWithAccounts, + type IInstructionWithData, + type Option, + type OptionOrNullable, + type ReadonlyAccount, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/web3.js'; +import { JITO_TIP_ROUTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const INITIALIZE_OPERATOR_SNAPSHOT_DISCRIMINATOR = 6; + +export function getInitializeOperatorSnapshotDiscriminatorBytes() { + return getU8Encoder().encode(INITIALIZE_OPERATOR_SNAPSHOT_DISCRIMINATOR); +} + +export type InitializeOperatorSnapshotInstruction< + TProgram extends string = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS, + TAccountNcnConfig extends string | IAccountMeta = string, + TAccountRestakingConfig extends string | IAccountMeta = string, + TAccountNcn extends string | IAccountMeta = string, + TAccountOperator extends string | IAccountMeta = string, + TAccountNcnOperatorState extends string | IAccountMeta = string, + TAccountEpochSnapshot extends string | IAccountMeta = string, + TAccountOperatorSnapshot extends string | IAccountMeta = string, + TAccountPayer extends string | IAccountMeta = string, + TAccountRestakingProgramId extends string | IAccountMeta = string, + TAccountSystemProgram extends + | string + | IAccountMeta = '11111111111111111111111111111111', + TRemainingAccounts extends readonly IAccountMeta[] = [], +> = IInstruction & + IInstructionWithData & + IInstructionWithAccounts< + [ + TAccountNcnConfig extends string + ? ReadonlyAccount + : TAccountNcnConfig, + TAccountRestakingConfig extends string + ? ReadonlyAccount + : TAccountRestakingConfig, + TAccountNcn extends string ? ReadonlyAccount : TAccountNcn, + TAccountOperator extends string + ? ReadonlyAccount + : TAccountOperator, + TAccountNcnOperatorState extends string + ? ReadonlyAccount + : TAccountNcnOperatorState, + TAccountEpochSnapshot extends string + ? WritableAccount + : TAccountEpochSnapshot, + TAccountOperatorSnapshot extends string + ? WritableAccount + : TAccountOperatorSnapshot, + TAccountPayer extends string + ? WritableSignerAccount & + IAccountSignerMeta + : TAccountPayer, + TAccountRestakingProgramId extends string + ? ReadonlyAccount + : TAccountRestakingProgramId, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeOperatorSnapshotInstructionData = { + discriminator: number; + firstSlotOfNcnEpoch: Option; +}; + +export type InitializeOperatorSnapshotInstructionDataArgs = { + firstSlotOfNcnEpoch: OptionOrNullable; +}; + +export function getInitializeOperatorSnapshotInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['firstSlotOfNcnEpoch', getOptionEncoder(getU64Encoder())], + ]), + (value) => ({ + ...value, + discriminator: INITIALIZE_OPERATOR_SNAPSHOT_DISCRIMINATOR, + }) + ); +} + +export function getInitializeOperatorSnapshotInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['firstSlotOfNcnEpoch', getOptionDecoder(getU64Decoder())], + ]); +} + +export function getInitializeOperatorSnapshotInstructionDataCodec(): Codec< + InitializeOperatorSnapshotInstructionDataArgs, + InitializeOperatorSnapshotInstructionData +> { + return combineCodec( + getInitializeOperatorSnapshotInstructionDataEncoder(), + getInitializeOperatorSnapshotInstructionDataDecoder() + ); +} + +export type InitializeOperatorSnapshotInput< + TAccountNcnConfig extends string = string, + TAccountRestakingConfig extends string = string, + TAccountNcn extends string = string, + TAccountOperator extends string = string, + TAccountNcnOperatorState extends string = string, + TAccountEpochSnapshot extends string = string, + TAccountOperatorSnapshot extends string = string, + TAccountPayer extends string = string, + TAccountRestakingProgramId extends string = string, + TAccountSystemProgram extends string = string, +> = { + ncnConfig: Address; + restakingConfig: Address; + ncn: Address; + operator: Address; + ncnOperatorState: Address; + epochSnapshot: Address; + operatorSnapshot: Address; + payer: TransactionSigner; + restakingProgramId: Address; + systemProgram?: Address; + firstSlotOfNcnEpoch: InitializeOperatorSnapshotInstructionDataArgs['firstSlotOfNcnEpoch']; +}; + +export function getInitializeOperatorSnapshotInstruction< + TAccountNcnConfig extends string, + TAccountRestakingConfig extends string, + TAccountNcn extends string, + TAccountOperator extends string, + TAccountNcnOperatorState extends string, + TAccountEpochSnapshot extends string, + TAccountOperatorSnapshot extends string, + TAccountPayer extends string, + TAccountRestakingProgramId extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS, +>( + input: InitializeOperatorSnapshotInput< + TAccountNcnConfig, + TAccountRestakingConfig, + TAccountNcn, + TAccountOperator, + TAccountNcnOperatorState, + TAccountEpochSnapshot, + TAccountOperatorSnapshot, + TAccountPayer, + TAccountRestakingProgramId, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): InitializeOperatorSnapshotInstruction< + TProgramAddress, + TAccountNcnConfig, + TAccountRestakingConfig, + TAccountNcn, + TAccountOperator, + TAccountNcnOperatorState, + TAccountEpochSnapshot, + TAccountOperatorSnapshot, + TAccountPayer, + TAccountRestakingProgramId, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? JITO_TIP_ROUTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + ncnConfig: { value: input.ncnConfig ?? null, isWritable: false }, + restakingConfig: { + value: input.restakingConfig ?? null, + isWritable: false, + }, + ncn: { value: input.ncn ?? null, isWritable: false }, + operator: { value: input.operator ?? null, isWritable: false }, + ncnOperatorState: { + value: input.ncnOperatorState ?? null, + isWritable: false, + }, + epochSnapshot: { value: input.epochSnapshot ?? null, isWritable: true }, + operatorSnapshot: { + value: input.operatorSnapshot ?? null, + isWritable: true, + }, + payer: { value: input.payer ?? null, isWritable: true }, + restakingProgramId: { + value: input.restakingProgramId ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.ncnConfig), + getAccountMeta(accounts.restakingConfig), + getAccountMeta(accounts.ncn), + getAccountMeta(accounts.operator), + getAccountMeta(accounts.ncnOperatorState), + getAccountMeta(accounts.epochSnapshot), + getAccountMeta(accounts.operatorSnapshot), + getAccountMeta(accounts.payer), + getAccountMeta(accounts.restakingProgramId), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeOperatorSnapshotInstructionDataEncoder().encode( + args as InitializeOperatorSnapshotInstructionDataArgs + ), + } as InitializeOperatorSnapshotInstruction< + TProgramAddress, + TAccountNcnConfig, + TAccountRestakingConfig, + TAccountNcn, + TAccountOperator, + TAccountNcnOperatorState, + TAccountEpochSnapshot, + TAccountOperatorSnapshot, + TAccountPayer, + TAccountRestakingProgramId, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedInitializeOperatorSnapshotInstruction< + TProgram extends string = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], +> = { + programAddress: Address; + accounts: { + ncnConfig: TAccountMetas[0]; + restakingConfig: TAccountMetas[1]; + ncn: TAccountMetas[2]; + operator: TAccountMetas[3]; + ncnOperatorState: TAccountMetas[4]; + epochSnapshot: TAccountMetas[5]; + operatorSnapshot: TAccountMetas[6]; + payer: TAccountMetas[7]; + restakingProgramId: TAccountMetas[8]; + systemProgram: TAccountMetas[9]; + }; + data: InitializeOperatorSnapshotInstructionData; +}; + +export function parseInitializeOperatorSnapshotInstruction< + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[], +>( + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedInitializeOperatorSnapshotInstruction { + if (instruction.accounts.length < 10) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + ncnConfig: getNextAccount(), + restakingConfig: getNextAccount(), + ncn: getNextAccount(), + operator: getNextAccount(), + ncnOperatorState: getNextAccount(), + epochSnapshot: getNextAccount(), + operatorSnapshot: getNextAccount(), + payer: getNextAccount(), + restakingProgramId: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitializeOperatorSnapshotInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/clients/js/jito_tip_router/instructions/initializeVaultOperatorDelegationSnapshot.ts b/clients/js/jito_tip_router/instructions/initializeVaultOperatorDelegationSnapshot.ts new file mode 100644 index 00000000..9416e77f --- /dev/null +++ b/clients/js/jito_tip_router/instructions/initializeVaultOperatorDelegationSnapshot.ts @@ -0,0 +1,417 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/kinobi-so/kinobi + */ + +import { + combineCodec, + getOptionDecoder, + getOptionEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type IAccountMeta, + type IAccountSignerMeta, + type IInstruction, + type IInstructionWithAccounts, + type IInstructionWithData, + type Option, + type OptionOrNullable, + type ReadonlyAccount, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/web3.js'; +import { JITO_TIP_ROUTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const INITIALIZE_VAULT_OPERATOR_DELEGATION_SNAPSHOT_DISCRIMINATOR = 7; + +export function getInitializeVaultOperatorDelegationSnapshotDiscriminatorBytes() { + return getU8Encoder().encode( + INITIALIZE_VAULT_OPERATOR_DELEGATION_SNAPSHOT_DISCRIMINATOR + ); +} + +export type InitializeVaultOperatorDelegationSnapshotInstruction< + TProgram extends string = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS, + TAccountNcnConfig extends string | IAccountMeta = string, + TAccountRestakingConfig extends string | IAccountMeta = string, + TAccountNcn extends string | IAccountMeta = string, + TAccountOperator extends string | IAccountMeta = string, + TAccountVault extends string | IAccountMeta = string, + TAccountVaultNcnTicket extends string | IAccountMeta = string, + TAccountNcnVaultTicket extends string | IAccountMeta = string, + TAccountVaultOperatorDelegation extends + | string + | IAccountMeta = string, + TAccountWeightTable extends string | IAccountMeta = string, + TAccountEpochSnapshot extends string | IAccountMeta = string, + TAccountOperatorSnapshot extends string | IAccountMeta = string, + TAccountVaultOperatorDelegationSnapshot extends + | string + | IAccountMeta = string, + TAccountPayer extends string | IAccountMeta = string, + TAccountRestakingProgramId extends string | IAccountMeta = string, + TAccountSystemProgram extends + | string + | IAccountMeta = '11111111111111111111111111111111', + TRemainingAccounts extends readonly IAccountMeta[] = [], +> = IInstruction & + IInstructionWithData & + IInstructionWithAccounts< + [ + TAccountNcnConfig extends string + ? ReadonlyAccount + : TAccountNcnConfig, + TAccountRestakingConfig extends string + ? ReadonlyAccount + : TAccountRestakingConfig, + TAccountNcn extends string ? ReadonlyAccount : TAccountNcn, + TAccountOperator extends string + ? ReadonlyAccount + : TAccountOperator, + TAccountVault extends string + ? ReadonlyAccount + : TAccountVault, + TAccountVaultNcnTicket extends string + ? ReadonlyAccount + : TAccountVaultNcnTicket, + TAccountNcnVaultTicket extends string + ? ReadonlyAccount + : TAccountNcnVaultTicket, + TAccountVaultOperatorDelegation extends string + ? ReadonlyAccount + : TAccountVaultOperatorDelegation, + TAccountWeightTable extends string + ? ReadonlyAccount + : TAccountWeightTable, + TAccountEpochSnapshot extends string + ? WritableAccount + : TAccountEpochSnapshot, + TAccountOperatorSnapshot extends string + ? WritableAccount + : TAccountOperatorSnapshot, + TAccountVaultOperatorDelegationSnapshot extends string + ? WritableAccount + : TAccountVaultOperatorDelegationSnapshot, + TAccountPayer extends string + ? WritableSignerAccount & + IAccountSignerMeta + : TAccountPayer, + TAccountRestakingProgramId extends string + ? ReadonlyAccount + : TAccountRestakingProgramId, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeVaultOperatorDelegationSnapshotInstructionData = { + discriminator: number; + firstSlotOfNcnEpoch: Option; +}; + +export type InitializeVaultOperatorDelegationSnapshotInstructionDataArgs = { + firstSlotOfNcnEpoch: OptionOrNullable; +}; + +export function getInitializeVaultOperatorDelegationSnapshotInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['firstSlotOfNcnEpoch', getOptionEncoder(getU64Encoder())], + ]), + (value) => ({ + ...value, + discriminator: + INITIALIZE_VAULT_OPERATOR_DELEGATION_SNAPSHOT_DISCRIMINATOR, + }) + ); +} + +export function getInitializeVaultOperatorDelegationSnapshotInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['firstSlotOfNcnEpoch', getOptionDecoder(getU64Decoder())], + ]); +} + +export function getInitializeVaultOperatorDelegationSnapshotInstructionDataCodec(): Codec< + InitializeVaultOperatorDelegationSnapshotInstructionDataArgs, + InitializeVaultOperatorDelegationSnapshotInstructionData +> { + return combineCodec( + getInitializeVaultOperatorDelegationSnapshotInstructionDataEncoder(), + getInitializeVaultOperatorDelegationSnapshotInstructionDataDecoder() + ); +} + +export type InitializeVaultOperatorDelegationSnapshotInput< + TAccountNcnConfig extends string = string, + TAccountRestakingConfig extends string = string, + TAccountNcn extends string = string, + TAccountOperator extends string = string, + TAccountVault extends string = string, + TAccountVaultNcnTicket extends string = string, + TAccountNcnVaultTicket extends string = string, + TAccountVaultOperatorDelegation extends string = string, + TAccountWeightTable extends string = string, + TAccountEpochSnapshot extends string = string, + TAccountOperatorSnapshot extends string = string, + TAccountVaultOperatorDelegationSnapshot extends string = string, + TAccountPayer extends string = string, + TAccountRestakingProgramId extends string = string, + TAccountSystemProgram extends string = string, +> = { + ncnConfig: Address; + restakingConfig: Address; + ncn: Address; + operator: Address; + vault: Address; + vaultNcnTicket: Address; + ncnVaultTicket: Address; + vaultOperatorDelegation: Address; + weightTable: Address; + epochSnapshot: Address; + operatorSnapshot: Address; + vaultOperatorDelegationSnapshot: Address; + payer: TransactionSigner; + restakingProgramId: Address; + systemProgram?: Address; + firstSlotOfNcnEpoch: InitializeVaultOperatorDelegationSnapshotInstructionDataArgs['firstSlotOfNcnEpoch']; +}; + +export function getInitializeVaultOperatorDelegationSnapshotInstruction< + TAccountNcnConfig extends string, + TAccountRestakingConfig extends string, + TAccountNcn extends string, + TAccountOperator extends string, + TAccountVault extends string, + TAccountVaultNcnTicket extends string, + TAccountNcnVaultTicket extends string, + TAccountVaultOperatorDelegation extends string, + TAccountWeightTable extends string, + TAccountEpochSnapshot extends string, + TAccountOperatorSnapshot extends string, + TAccountVaultOperatorDelegationSnapshot extends string, + TAccountPayer extends string, + TAccountRestakingProgramId extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS, +>( + input: InitializeVaultOperatorDelegationSnapshotInput< + TAccountNcnConfig, + TAccountRestakingConfig, + TAccountNcn, + TAccountOperator, + TAccountVault, + TAccountVaultNcnTicket, + TAccountNcnVaultTicket, + TAccountVaultOperatorDelegation, + TAccountWeightTable, + TAccountEpochSnapshot, + TAccountOperatorSnapshot, + TAccountVaultOperatorDelegationSnapshot, + TAccountPayer, + TAccountRestakingProgramId, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): InitializeVaultOperatorDelegationSnapshotInstruction< + TProgramAddress, + TAccountNcnConfig, + TAccountRestakingConfig, + TAccountNcn, + TAccountOperator, + TAccountVault, + TAccountVaultNcnTicket, + TAccountNcnVaultTicket, + TAccountVaultOperatorDelegation, + TAccountWeightTable, + TAccountEpochSnapshot, + TAccountOperatorSnapshot, + TAccountVaultOperatorDelegationSnapshot, + TAccountPayer, + TAccountRestakingProgramId, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? JITO_TIP_ROUTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + ncnConfig: { value: input.ncnConfig ?? null, isWritable: false }, + restakingConfig: { + value: input.restakingConfig ?? null, + isWritable: false, + }, + ncn: { value: input.ncn ?? null, isWritable: false }, + operator: { value: input.operator ?? null, isWritable: false }, + vault: { value: input.vault ?? null, isWritable: false }, + vaultNcnTicket: { value: input.vaultNcnTicket ?? null, isWritable: false }, + ncnVaultTicket: { value: input.ncnVaultTicket ?? null, isWritable: false }, + vaultOperatorDelegation: { + value: input.vaultOperatorDelegation ?? null, + isWritable: false, + }, + weightTable: { value: input.weightTable ?? null, isWritable: false }, + epochSnapshot: { value: input.epochSnapshot ?? null, isWritable: true }, + operatorSnapshot: { + value: input.operatorSnapshot ?? null, + isWritable: true, + }, + vaultOperatorDelegationSnapshot: { + value: input.vaultOperatorDelegationSnapshot ?? null, + isWritable: true, + }, + payer: { value: input.payer ?? null, isWritable: true }, + restakingProgramId: { + value: input.restakingProgramId ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.ncnConfig), + getAccountMeta(accounts.restakingConfig), + getAccountMeta(accounts.ncn), + getAccountMeta(accounts.operator), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.vaultNcnTicket), + getAccountMeta(accounts.ncnVaultTicket), + getAccountMeta(accounts.vaultOperatorDelegation), + getAccountMeta(accounts.weightTable), + getAccountMeta(accounts.epochSnapshot), + getAccountMeta(accounts.operatorSnapshot), + getAccountMeta(accounts.vaultOperatorDelegationSnapshot), + getAccountMeta(accounts.payer), + getAccountMeta(accounts.restakingProgramId), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeVaultOperatorDelegationSnapshotInstructionDataEncoder().encode( + args as InitializeVaultOperatorDelegationSnapshotInstructionDataArgs + ), + } as InitializeVaultOperatorDelegationSnapshotInstruction< + TProgramAddress, + TAccountNcnConfig, + TAccountRestakingConfig, + TAccountNcn, + TAccountOperator, + TAccountVault, + TAccountVaultNcnTicket, + TAccountNcnVaultTicket, + TAccountVaultOperatorDelegation, + TAccountWeightTable, + TAccountEpochSnapshot, + TAccountOperatorSnapshot, + TAccountVaultOperatorDelegationSnapshot, + TAccountPayer, + TAccountRestakingProgramId, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedInitializeVaultOperatorDelegationSnapshotInstruction< + TProgram extends string = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], +> = { + programAddress: Address; + accounts: { + ncnConfig: TAccountMetas[0]; + restakingConfig: TAccountMetas[1]; + ncn: TAccountMetas[2]; + operator: TAccountMetas[3]; + vault: TAccountMetas[4]; + vaultNcnTicket: TAccountMetas[5]; + ncnVaultTicket: TAccountMetas[6]; + vaultOperatorDelegation: TAccountMetas[7]; + weightTable: TAccountMetas[8]; + epochSnapshot: TAccountMetas[9]; + operatorSnapshot: TAccountMetas[10]; + vaultOperatorDelegationSnapshot: TAccountMetas[11]; + payer: TAccountMetas[12]; + restakingProgramId: TAccountMetas[13]; + systemProgram: TAccountMetas[14]; + }; + data: InitializeVaultOperatorDelegationSnapshotInstructionData; +}; + +export function parseInitializeVaultOperatorDelegationSnapshotInstruction< + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[], +>( + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedInitializeVaultOperatorDelegationSnapshotInstruction< + TProgram, + TAccountMetas +> { + if (instruction.accounts.length < 15) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + ncnConfig: getNextAccount(), + restakingConfig: getNextAccount(), + ncn: getNextAccount(), + operator: getNextAccount(), + vault: getNextAccount(), + vaultNcnTicket: getNextAccount(), + ncnVaultTicket: getNextAccount(), + vaultOperatorDelegation: getNextAccount(), + weightTable: getNextAccount(), + epochSnapshot: getNextAccount(), + operatorSnapshot: getNextAccount(), + vaultOperatorDelegationSnapshot: getNextAccount(), + payer: getNextAccount(), + restakingProgramId: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitializeVaultOperatorDelegationSnapshotInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/clients/js/jito_tip_router/programs/jitoTipRouter.ts b/clients/js/jito_tip_router/programs/jitoTipRouter.ts index f23e4134..8ab4386a 100644 --- a/clients/js/jito_tip_router/programs/jitoTipRouter.ts +++ b/clients/js/jito_tip_router/programs/jitoTipRouter.ts @@ -16,6 +16,8 @@ import { type ParsedAdminUpdateWeightTableInstruction, type ParsedInitializeEpochSnapshotInstruction, type ParsedInitializeNCNConfigInstruction, + type ParsedInitializeOperatorSnapshotInstruction, + type ParsedInitializeVaultOperatorDelegationSnapshotInstruction, type ParsedInitializeWeightTableInstruction, type ParsedSetConfigFeesInstruction, type ParsedSetNewAdminInstruction, @@ -27,6 +29,7 @@ export const JITO_TIP_ROUTER_PROGRAM_ADDRESS = export enum JitoTipRouterAccount { EpochSnapshot, OperatorSnapshot, + VaultOperatorDelegationSnapshot, NcnConfig, WeightTable, } @@ -38,6 +41,8 @@ export enum JitoTipRouterInstruction { InitializeWeightTable, AdminUpdateWeightTable, InitializeEpochSnapshot, + InitializeOperatorSnapshot, + InitializeVaultOperatorDelegationSnapshot, } export function identifyJitoTipRouterInstruction( @@ -62,6 +67,12 @@ export function identifyJitoTipRouterInstruction( if (containsBytes(data, getU8Encoder().encode(5), 0)) { return JitoTipRouterInstruction.InitializeEpochSnapshot; } + if (containsBytes(data, getU8Encoder().encode(6), 0)) { + return JitoTipRouterInstruction.InitializeOperatorSnapshot; + } + if (containsBytes(data, getU8Encoder().encode(7), 0)) { + return JitoTipRouterInstruction.InitializeVaultOperatorDelegationSnapshot; + } throw new Error( 'The provided instruction could not be identified as a jitoTipRouter instruction.' ); @@ -87,4 +98,10 @@ export type ParsedJitoTipRouterInstruction< } & ParsedAdminUpdateWeightTableInstruction) | ({ instructionType: JitoTipRouterInstruction.InitializeEpochSnapshot; - } & ParsedInitializeEpochSnapshotInstruction); + } & ParsedInitializeEpochSnapshotInstruction) + | ({ + instructionType: JitoTipRouterInstruction.InitializeOperatorSnapshot; + } & ParsedInitializeOperatorSnapshotInstruction) + | ({ + instructionType: JitoTipRouterInstruction.InitializeVaultOperatorDelegationSnapshot; + } & ParsedInitializeVaultOperatorDelegationSnapshotInstruction); diff --git a/clients/js/jito_tip_router/types/index.ts b/clients/js/jito_tip_router/types/index.ts index dd0513a2..a78e6058 100644 --- a/clients/js/jito_tip_router/types/index.ts +++ b/clients/js/jito_tip_router/types/index.ts @@ -9,5 +9,4 @@ export * from './configAdminRole'; export * from './fee'; export * from './fees'; -export * from './vaultOperatorDelegationSnapshot'; export * from './weightEntry'; diff --git a/clients/js/jito_tip_router/types/vaultOperatorDelegationSnapshot.ts b/clients/js/jito_tip_router/types/vaultOperatorDelegationSnapshot.ts deleted file mode 100644 index 22529c76..00000000 --- a/clients/js/jito_tip_router/types/vaultOperatorDelegationSnapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * This code was AUTOGENERATED using the kinobi library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun kinobi to update it. - * - * @see https://github.com/kinobi-so/kinobi - */ - -import { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getArrayDecoder, - getArrayEncoder, - getStructDecoder, - getStructEncoder, - getU128Decoder, - getU128Encoder, - getU64Decoder, - getU64Encoder, - getU8Decoder, - getU8Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/web3.js'; - -export type VaultOperatorDelegationSnapshot = { - vault: Address; - stMint: Address; - totalSecurity: bigint; - totalVotes: bigint; - slotSet: bigint; - reserved: Array; -}; - -export type VaultOperatorDelegationSnapshotArgs = { - vault: Address; - stMint: Address; - totalSecurity: number | bigint; - totalVotes: number | bigint; - slotSet: number | bigint; - reserved: Array; -}; - -export function getVaultOperatorDelegationSnapshotEncoder(): Encoder { - return getStructEncoder([ - ['vault', getAddressEncoder()], - ['stMint', getAddressEncoder()], - ['totalSecurity', getU64Encoder()], - ['totalVotes', getU128Encoder()], - ['slotSet', getU64Encoder()], - ['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })], - ]); -} - -export function getVaultOperatorDelegationSnapshotDecoder(): Decoder { - return getStructDecoder([ - ['vault', getAddressDecoder()], - ['stMint', getAddressDecoder()], - ['totalSecurity', getU64Decoder()], - ['totalVotes', getU128Decoder()], - ['slotSet', getU64Decoder()], - ['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })], - ]); -} - -export function getVaultOperatorDelegationSnapshotCodec(): Codec< - VaultOperatorDelegationSnapshotArgs, - VaultOperatorDelegationSnapshot -> { - return combineCodec( - getVaultOperatorDelegationSnapshotEncoder(), - getVaultOperatorDelegationSnapshotDecoder() - ); -} diff --git a/clients/rust/jito_tip_router/src/generated/accounts/epoch_snapshot.rs b/clients/rust/jito_tip_router/src/generated/accounts/epoch_snapshot.rs index da51aeb5..20a1e24f 100644 --- a/clients/rust/jito_tip_router/src/generated/accounts/epoch_snapshot.rs +++ b/clients/rust/jito_tip_router/src/generated/accounts/epoch_snapshot.rs @@ -19,11 +19,13 @@ pub struct EpochSnapshot { )] pub ncn: Pubkey, pub ncn_epoch: u64, - pub slot_created: u64, pub bump: u8, + pub slot_created: u64, + pub slot_finalized: u64, pub ncn_fees: Fees, pub operator_count: u64, pub operators_registered: u64, + pub valid_operator_vault_delegations: u64, pub total_votes: u128, #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] pub reserved: [u8; 128], diff --git a/clients/rust/jito_tip_router/src/generated/accounts/mod.rs b/clients/rust/jito_tip_router/src/generated/accounts/mod.rs index 4655dd21..6cdf26e0 100644 --- a/clients/rust/jito_tip_router/src/generated/accounts/mod.rs +++ b/clients/rust/jito_tip_router/src/generated/accounts/mod.rs @@ -7,6 +7,10 @@ pub(crate) mod r#epoch_snapshot; pub(crate) mod r#ncn_config; pub(crate) mod r#operator_snapshot; +pub(crate) mod r#vault_operator_delegation_snapshot; pub(crate) mod r#weight_table; -pub use self::{r#epoch_snapshot::*, r#ncn_config::*, r#operator_snapshot::*, r#weight_table::*}; +pub use self::{ + r#epoch_snapshot::*, r#ncn_config::*, r#operator_snapshot::*, + r#vault_operator_delegation_snapshot::*, r#weight_table::*, +}; diff --git a/clients/rust/jito_tip_router/src/generated/accounts/operator_snapshot.rs b/clients/rust/jito_tip_router/src/generated/accounts/operator_snapshot.rs index 80038f5d..988e4f16 100644 --- a/clients/rust/jito_tip_router/src/generated/accounts/operator_snapshot.rs +++ b/clients/rust/jito_tip_router/src/generated/accounts/operator_snapshot.rs @@ -7,8 +7,6 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::pubkey::Pubkey; -use crate::generated::types::VaultOperatorDelegationSnapshot; - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct OperatorSnapshot { @@ -24,14 +22,15 @@ pub struct OperatorSnapshot { )] pub ncn: Pubkey, pub ncn_epoch: u64, - pub slot_created: u64, pub bump: u8, + pub slot_created: u64, + pub slot_finalized: u64, + pub is_active: bool, pub operator_fee_bps: u16, + pub vault_operator_delegation_count: u64, + pub vault_operator_delegations_registered: u64, + pub valid_operator_vault_delegations: u64, pub total_votes: u128, - pub num_vault_operator_delegations: u16, - pub vault_operator_delegations_registered: u16, - pub slot_set: u64, - pub vault_operator_delegations: [VaultOperatorDelegationSnapshot; 32], #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] pub reserved: [u8; 128], } diff --git a/clients/rust/jito_tip_router/src/generated/accounts/vault_operator_delegation_snapshot.rs b/clients/rust/jito_tip_router/src/generated/accounts/vault_operator_delegation_snapshot.rs new file mode 100644 index 00000000..c33af9c0 --- /dev/null +++ b/clients/rust/jito_tip_router/src/generated/accounts/vault_operator_delegation_snapshot.rs @@ -0,0 +1,88 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! + +use borsh::{BorshDeserialize, BorshSerialize}; +use solana_program::pubkey::Pubkey; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct VaultOperatorDelegationSnapshot { + pub discriminator: u64, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub vault: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub operator: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub ncn: Pubkey, + pub ncn_epoch: u64, + pub bump: u8, + pub slot_created: u64, + pub is_active: bool, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub st_mint: Pubkey, + pub total_security: u64, + pub total_votes: u128, + #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] + pub reserved: [u8; 128], +} + +impl VaultOperatorDelegationSnapshot { + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } +} + +impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> + for VaultOperatorDelegationSnapshot +{ + type Error = std::io::Error; + + fn try_from( + account_info: &solana_program::account_info::AccountInfo<'a>, + ) -> Result { + let mut data: &[u8] = &(*account_info.data).borrow(); + Self::deserialize(&mut data) + } +} + +#[cfg(feature = "anchor")] +impl anchor_lang::AccountDeserialize for VaultOperatorDelegationSnapshot { + fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { + Ok(Self::deserialize(buf)?) + } +} + +#[cfg(feature = "anchor")] +impl anchor_lang::AccountSerialize for VaultOperatorDelegationSnapshot {} + +#[cfg(feature = "anchor")] +impl anchor_lang::Owner for VaultOperatorDelegationSnapshot { + fn owner() -> Pubkey { + crate::JITO_TIP_ROUTER_ID + } +} + +#[cfg(feature = "anchor-idl-build")] +impl anchor_lang::IdlBuild for VaultOperatorDelegationSnapshot {} + +#[cfg(feature = "anchor-idl-build")] +impl anchor_lang::Discriminator for VaultOperatorDelegationSnapshot { + const DISCRIMINATOR: [u8; 8] = [0; 8]; +} diff --git a/clients/rust/jito_tip_router/src/generated/errors/jito_tip_router.rs b/clients/rust/jito_tip_router/src/generated/errors/jito_tip_router.rs index efaa971e..65ac98fe 100644 --- a/clients/rust/jito_tip_router/src/generated/errors/jito_tip_router.rs +++ b/clients/rust/jito_tip_router/src/generated/errors/jito_tip_router.rs @@ -69,6 +69,15 @@ pub enum JitoTipRouterError { /// 8718 - Weight not found #[error("Weight not found")] WeightNotFound = 0x220E, + /// 8719 - No operators in ncn + #[error("No operators in ncn")] + NoOperators = 0x220F, + /// 8720 - Vault operator delegation is already finalized - should not happen + #[error("Vault operator delegation is already finalized - should not happen")] + VaultOperatorDelegationFinalized = 0x2210, + /// 8721 - Operator is already finalized - should not happen + #[error("Operator is already finalized - should not happen")] + OperatorFinalized = 0x2211, } impl solana_program::program_error::PrintProgramError for JitoTipRouterError { diff --git a/clients/rust/jito_tip_router/src/generated/instructions/initialize_operator_snapshot.rs b/clients/rust/jito_tip_router/src/generated/instructions/initialize_operator_snapshot.rs new file mode 100644 index 00000000..c367681b --- /dev/null +++ b/clients/rust/jito_tip_router/src/generated/instructions/initialize_operator_snapshot.rs @@ -0,0 +1,692 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! + +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct InitializeOperatorSnapshot { + pub ncn_config: solana_program::pubkey::Pubkey, + + pub restaking_config: solana_program::pubkey::Pubkey, + + pub ncn: solana_program::pubkey::Pubkey, + + pub operator: solana_program::pubkey::Pubkey, + + pub ncn_operator_state: solana_program::pubkey::Pubkey, + + pub epoch_snapshot: solana_program::pubkey::Pubkey, + + pub operator_snapshot: solana_program::pubkey::Pubkey, + + pub payer: solana_program::pubkey::Pubkey, + + pub restaking_program_id: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, +} + +impl InitializeOperatorSnapshot { + pub fn instruction( + &self, + args: InitializeOperatorSnapshotInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: InitializeOperatorSnapshotInstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.ncn_config, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.restaking_config, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.ncn, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.operator, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.ncn_operator_state, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.epoch_snapshot, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.operator_snapshot, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.payer, true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.restaking_program_id, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.system_program, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = InitializeOperatorSnapshotInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::JITO_TIP_ROUTER_ID, + accounts, + data, + } + } +} + +#[derive(BorshDeserialize, BorshSerialize)] +pub struct InitializeOperatorSnapshotInstructionData { + discriminator: u8, +} + +impl InitializeOperatorSnapshotInstructionData { + pub fn new() -> Self { + Self { discriminator: 6 } + } +} + +impl Default for InitializeOperatorSnapshotInstructionData { + fn default() -> Self { + Self::new() + } +} + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct InitializeOperatorSnapshotInstructionArgs { + pub first_slot_of_ncn_epoch: Option, +} + +/// Instruction builder for `InitializeOperatorSnapshot`. +/// +/// ### Accounts: +/// +/// 0. `[]` ncn_config +/// 1. `[]` restaking_config +/// 2. `[]` ncn +/// 3. `[]` operator +/// 4. `[]` ncn_operator_state +/// 5. `[writable]` epoch_snapshot +/// 6. `[writable]` operator_snapshot +/// 7. `[writable, signer]` payer +/// 8. `[]` restaking_program_id +/// 9. `[optional]` system_program (default to `11111111111111111111111111111111`) +#[derive(Clone, Debug, Default)] +pub struct InitializeOperatorSnapshotBuilder { + ncn_config: Option, + restaking_config: Option, + ncn: Option, + operator: Option, + ncn_operator_state: Option, + epoch_snapshot: Option, + operator_snapshot: Option, + payer: Option, + restaking_program_id: Option, + system_program: Option, + first_slot_of_ncn_epoch: Option, + __remaining_accounts: Vec, +} + +impl InitializeOperatorSnapshotBuilder { + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn ncn_config(&mut self, ncn_config: solana_program::pubkey::Pubkey) -> &mut Self { + self.ncn_config = Some(ncn_config); + self + } + #[inline(always)] + pub fn restaking_config( + &mut self, + restaking_config: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.restaking_config = Some(restaking_config); + self + } + #[inline(always)] + pub fn ncn(&mut self, ncn: solana_program::pubkey::Pubkey) -> &mut Self { + self.ncn = Some(ncn); + self + } + #[inline(always)] + pub fn operator(&mut self, operator: solana_program::pubkey::Pubkey) -> &mut Self { + self.operator = Some(operator); + self + } + #[inline(always)] + pub fn ncn_operator_state( + &mut self, + ncn_operator_state: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.ncn_operator_state = Some(ncn_operator_state); + self + } + #[inline(always)] + pub fn epoch_snapshot(&mut self, epoch_snapshot: solana_program::pubkey::Pubkey) -> &mut Self { + self.epoch_snapshot = Some(epoch_snapshot); + self + } + #[inline(always)] + pub fn operator_snapshot( + &mut self, + operator_snapshot: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.operator_snapshot = Some(operator_snapshot); + self + } + #[inline(always)] + pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self { + self.payer = Some(payer); + self + } + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.restaking_program_id = Some(restaking_program_id); + self + } + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] + pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.system_program = Some(system_program); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn first_slot_of_ncn_epoch(&mut self, first_slot_of_ncn_epoch: u64) -> &mut Self { + self.first_slot_of_ncn_epoch = Some(first_slot_of_ncn_epoch); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::instruction::AccountMeta], + ) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } + #[allow(clippy::clone_on_copy)] + pub fn instruction(&self) -> solana_program::instruction::Instruction { + let accounts = InitializeOperatorSnapshot { + ncn_config: self.ncn_config.expect("ncn_config is not set"), + restaking_config: self.restaking_config.expect("restaking_config is not set"), + ncn: self.ncn.expect("ncn is not set"), + operator: self.operator.expect("operator is not set"), + ncn_operator_state: self + .ncn_operator_state + .expect("ncn_operator_state is not set"), + epoch_snapshot: self.epoch_snapshot.expect("epoch_snapshot is not set"), + operator_snapshot: self + .operator_snapshot + .expect("operator_snapshot is not set"), + payer: self.payer.expect("payer is not set"), + restaking_program_id: self + .restaking_program_id + .expect("restaking_program_id is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + }; + let args = InitializeOperatorSnapshotInstructionArgs { + first_slot_of_ncn_epoch: self.first_slot_of_ncn_epoch.clone(), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} + +/// `initialize_operator_snapshot` CPI accounts. +pub struct InitializeOperatorSnapshotCpiAccounts<'a, 'b> { + pub ncn_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub operator: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn_operator_state: &'b solana_program::account_info::AccountInfo<'a>, + + pub epoch_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub operator_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub payer: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `initialize_operator_snapshot` CPI instruction. +pub struct InitializeOperatorSnapshotCpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub operator: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn_operator_state: &'b solana_program::account_info::AccountInfo<'a>, + + pub epoch_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub operator_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub payer: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. + pub __args: InitializeOperatorSnapshotInstructionArgs, +} + +impl<'a, 'b> InitializeOperatorSnapshotCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: InitializeOperatorSnapshotCpiAccounts<'a, 'b>, + args: InitializeOperatorSnapshotInstructionArgs, + ) -> Self { + Self { + __program: program, + ncn_config: accounts.ncn_config, + restaking_config: accounts.restaking_config, + ncn: accounts.ncn, + operator: accounts.operator, + ncn_operator_state: accounts.ncn_operator_state, + epoch_snapshot: accounts.epoch_snapshot, + operator_snapshot: accounts.operator_snapshot, + payer: accounts.payer, + restaking_program_id: accounts.restaking_program_id, + system_program: accounts.system_program, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed_with_remaining_accounts( + &self, + signers_seeds: &[&[&[u8]]], + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.ncn_config.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.restaking_config.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.ncn.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.operator.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.ncn_operator_state.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.epoch_snapshot.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.operator_snapshot.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.payer.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.restaking_program_id.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.system_program.key, + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = InitializeOperatorSnapshotInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::JITO_TIP_ROUTER_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(10 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.ncn_config.clone()); + account_infos.push(self.restaking_config.clone()); + account_infos.push(self.ncn.clone()); + account_infos.push(self.operator.clone()); + account_infos.push(self.ncn_operator_state.clone()); + account_infos.push(self.epoch_snapshot.clone()); + account_infos.push(self.operator_snapshot.clone()); + account_infos.push(self.payer.clone()); + account_infos.push(self.restaking_program_id.clone()); + account_infos.push(self.system_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `InitializeOperatorSnapshot` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[]` ncn_config +/// 1. `[]` restaking_config +/// 2. `[]` ncn +/// 3. `[]` operator +/// 4. `[]` ncn_operator_state +/// 5. `[writable]` epoch_snapshot +/// 6. `[writable]` operator_snapshot +/// 7. `[writable, signer]` payer +/// 8. `[]` restaking_program_id +/// 9. `[]` system_program +#[derive(Clone, Debug)] +pub struct InitializeOperatorSnapshotCpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> InitializeOperatorSnapshotCpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(InitializeOperatorSnapshotCpiBuilderInstruction { + __program: program, + ncn_config: None, + restaking_config: None, + ncn: None, + operator: None, + ncn_operator_state: None, + epoch_snapshot: None, + operator_snapshot: None, + payer: None, + restaking_program_id: None, + system_program: None, + first_slot_of_ncn_epoch: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] + pub fn ncn_config( + &mut self, + ncn_config: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.ncn_config = Some(ncn_config); + self + } + #[inline(always)] + pub fn restaking_config( + &mut self, + restaking_config: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.restaking_config = Some(restaking_config); + self + } + #[inline(always)] + pub fn ncn(&mut self, ncn: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.ncn = Some(ncn); + self + } + #[inline(always)] + pub fn operator( + &mut self, + operator: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.operator = Some(operator); + self + } + #[inline(always)] + pub fn ncn_operator_state( + &mut self, + ncn_operator_state: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.ncn_operator_state = Some(ncn_operator_state); + self + } + #[inline(always)] + pub fn epoch_snapshot( + &mut self, + epoch_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.epoch_snapshot = Some(epoch_snapshot); + self + } + #[inline(always)] + pub fn operator_snapshot( + &mut self, + operator_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.operator_snapshot = Some(operator_snapshot); + self + } + #[inline(always)] + pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.payer = Some(payer); + self + } + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.restaking_program_id = Some(restaking_program_id); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn first_slot_of_ncn_epoch(&mut self, first_slot_of_ncn_epoch: u64) -> &mut Self { + self.instruction.first_slot_of_ncn_epoch = Some(first_slot_of_ncn_epoch); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let args = InitializeOperatorSnapshotInstructionArgs { + first_slot_of_ncn_epoch: self.instruction.first_slot_of_ncn_epoch.clone(), + }; + let instruction = InitializeOperatorSnapshotCpi { + __program: self.instruction.__program, + + ncn_config: self.instruction.ncn_config.expect("ncn_config is not set"), + + restaking_config: self + .instruction + .restaking_config + .expect("restaking_config is not set"), + + ncn: self.instruction.ncn.expect("ncn is not set"), + + operator: self.instruction.operator.expect("operator is not set"), + + ncn_operator_state: self + .instruction + .ncn_operator_state + .expect("ncn_operator_state is not set"), + + epoch_snapshot: self + .instruction + .epoch_snapshot + .expect("epoch_snapshot is not set"), + + operator_snapshot: self + .instruction + .operator_snapshot + .expect("operator_snapshot is not set"), + + payer: self.instruction.payer.expect("payer is not set"), + + restaking_program_id: self + .instruction + .restaking_program_id + .expect("restaking_program_id is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +#[derive(Clone, Debug)] +struct InitializeOperatorSnapshotCpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + ncn_config: Option<&'b solana_program::account_info::AccountInfo<'a>>, + restaking_config: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ncn: Option<&'b solana_program::account_info::AccountInfo<'a>>, + operator: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ncn_operator_state: Option<&'b solana_program::account_info::AccountInfo<'a>>, + epoch_snapshot: Option<&'b solana_program::account_info::AccountInfo<'a>>, + operator_snapshot: Option<&'b solana_program::account_info::AccountInfo<'a>>, + payer: Option<&'b solana_program::account_info::AccountInfo<'a>>, + restaking_program_id: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + first_slot_of_ncn_epoch: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/jito_tip_router/src/generated/instructions/initialize_vault_operator_delegation_snapshot.rs b/clients/rust/jito_tip_router/src/generated/instructions/initialize_vault_operator_delegation_snapshot.rs new file mode 100644 index 00000000..26524002 --- /dev/null +++ b/clients/rust/jito_tip_router/src/generated/instructions/initialize_vault_operator_delegation_snapshot.rs @@ -0,0 +1,899 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! + +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct InitializeVaultOperatorDelegationSnapshot { + pub ncn_config: solana_program::pubkey::Pubkey, + + pub restaking_config: solana_program::pubkey::Pubkey, + + pub ncn: solana_program::pubkey::Pubkey, + + pub operator: solana_program::pubkey::Pubkey, + + pub vault: solana_program::pubkey::Pubkey, + + pub vault_ncn_ticket: solana_program::pubkey::Pubkey, + + pub ncn_vault_ticket: solana_program::pubkey::Pubkey, + + pub vault_operator_delegation: solana_program::pubkey::Pubkey, + + pub weight_table: solana_program::pubkey::Pubkey, + + pub epoch_snapshot: solana_program::pubkey::Pubkey, + + pub operator_snapshot: solana_program::pubkey::Pubkey, + + pub vault_operator_delegation_snapshot: solana_program::pubkey::Pubkey, + + pub payer: solana_program::pubkey::Pubkey, + + pub restaking_program_id: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, +} + +impl InitializeVaultOperatorDelegationSnapshot { + pub fn instruction( + &self, + args: InitializeVaultOperatorDelegationSnapshotInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: InitializeVaultOperatorDelegationSnapshotInstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.ncn_config, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.restaking_config, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.ncn, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.operator, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.vault, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.vault_ncn_ticket, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.ncn_vault_ticket, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.vault_operator_delegation, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.weight_table, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.epoch_snapshot, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.operator_snapshot, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.vault_operator_delegation_snapshot, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.payer, true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.restaking_program_id, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.system_program, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = InitializeVaultOperatorDelegationSnapshotInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::JITO_TIP_ROUTER_ID, + accounts, + data, + } + } +} + +#[derive(BorshDeserialize, BorshSerialize)] +pub struct InitializeVaultOperatorDelegationSnapshotInstructionData { + discriminator: u8, +} + +impl InitializeVaultOperatorDelegationSnapshotInstructionData { + pub fn new() -> Self { + Self { discriminator: 7 } + } +} + +impl Default for InitializeVaultOperatorDelegationSnapshotInstructionData { + fn default() -> Self { + Self::new() + } +} + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct InitializeVaultOperatorDelegationSnapshotInstructionArgs { + pub first_slot_of_ncn_epoch: Option, +} + +/// Instruction builder for `InitializeVaultOperatorDelegationSnapshot`. +/// +/// ### Accounts: +/// +/// 0. `[]` ncn_config +/// 1. `[]` restaking_config +/// 2. `[]` ncn +/// 3. `[]` operator +/// 4. `[]` vault +/// 5. `[]` vault_ncn_ticket +/// 6. `[]` ncn_vault_ticket +/// 7. `[]` vault_operator_delegation +/// 8. `[]` weight_table +/// 9. `[writable]` epoch_snapshot +/// 10. `[writable]` operator_snapshot +/// 11. `[writable]` vault_operator_delegation_snapshot +/// 12. `[writable, signer]` payer +/// 13. `[]` restaking_program_id +/// 14. `[optional]` system_program (default to `11111111111111111111111111111111`) +#[derive(Clone, Debug, Default)] +pub struct InitializeVaultOperatorDelegationSnapshotBuilder { + ncn_config: Option, + restaking_config: Option, + ncn: Option, + operator: Option, + vault: Option, + vault_ncn_ticket: Option, + ncn_vault_ticket: Option, + vault_operator_delegation: Option, + weight_table: Option, + epoch_snapshot: Option, + operator_snapshot: Option, + vault_operator_delegation_snapshot: Option, + payer: Option, + restaking_program_id: Option, + system_program: Option, + first_slot_of_ncn_epoch: Option, + __remaining_accounts: Vec, +} + +impl InitializeVaultOperatorDelegationSnapshotBuilder { + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn ncn_config(&mut self, ncn_config: solana_program::pubkey::Pubkey) -> &mut Self { + self.ncn_config = Some(ncn_config); + self + } + #[inline(always)] + pub fn restaking_config( + &mut self, + restaking_config: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.restaking_config = Some(restaking_config); + self + } + #[inline(always)] + pub fn ncn(&mut self, ncn: solana_program::pubkey::Pubkey) -> &mut Self { + self.ncn = Some(ncn); + self + } + #[inline(always)] + pub fn operator(&mut self, operator: solana_program::pubkey::Pubkey) -> &mut Self { + self.operator = Some(operator); + self + } + #[inline(always)] + pub fn vault(&mut self, vault: solana_program::pubkey::Pubkey) -> &mut Self { + self.vault = Some(vault); + self + } + #[inline(always)] + pub fn vault_ncn_ticket( + &mut self, + vault_ncn_ticket: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.vault_ncn_ticket = Some(vault_ncn_ticket); + self + } + #[inline(always)] + pub fn ncn_vault_ticket( + &mut self, + ncn_vault_ticket: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.ncn_vault_ticket = Some(ncn_vault_ticket); + self + } + #[inline(always)] + pub fn vault_operator_delegation( + &mut self, + vault_operator_delegation: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.vault_operator_delegation = Some(vault_operator_delegation); + self + } + #[inline(always)] + pub fn weight_table(&mut self, weight_table: solana_program::pubkey::Pubkey) -> &mut Self { + self.weight_table = Some(weight_table); + self + } + #[inline(always)] + pub fn epoch_snapshot(&mut self, epoch_snapshot: solana_program::pubkey::Pubkey) -> &mut Self { + self.epoch_snapshot = Some(epoch_snapshot); + self + } + #[inline(always)] + pub fn operator_snapshot( + &mut self, + operator_snapshot: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.operator_snapshot = Some(operator_snapshot); + self + } + #[inline(always)] + pub fn vault_operator_delegation_snapshot( + &mut self, + vault_operator_delegation_snapshot: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.vault_operator_delegation_snapshot = Some(vault_operator_delegation_snapshot); + self + } + #[inline(always)] + pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self { + self.payer = Some(payer); + self + } + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.restaking_program_id = Some(restaking_program_id); + self + } + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] + pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.system_program = Some(system_program); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn first_slot_of_ncn_epoch(&mut self, first_slot_of_ncn_epoch: u64) -> &mut Self { + self.first_slot_of_ncn_epoch = Some(first_slot_of_ncn_epoch); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::instruction::AccountMeta], + ) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } + #[allow(clippy::clone_on_copy)] + pub fn instruction(&self) -> solana_program::instruction::Instruction { + let accounts = InitializeVaultOperatorDelegationSnapshot { + ncn_config: self.ncn_config.expect("ncn_config is not set"), + restaking_config: self.restaking_config.expect("restaking_config is not set"), + ncn: self.ncn.expect("ncn is not set"), + operator: self.operator.expect("operator is not set"), + vault: self.vault.expect("vault is not set"), + vault_ncn_ticket: self.vault_ncn_ticket.expect("vault_ncn_ticket is not set"), + ncn_vault_ticket: self.ncn_vault_ticket.expect("ncn_vault_ticket is not set"), + vault_operator_delegation: self + .vault_operator_delegation + .expect("vault_operator_delegation is not set"), + weight_table: self.weight_table.expect("weight_table is not set"), + epoch_snapshot: self.epoch_snapshot.expect("epoch_snapshot is not set"), + operator_snapshot: self + .operator_snapshot + .expect("operator_snapshot is not set"), + vault_operator_delegation_snapshot: self + .vault_operator_delegation_snapshot + .expect("vault_operator_delegation_snapshot is not set"), + payer: self.payer.expect("payer is not set"), + restaking_program_id: self + .restaking_program_id + .expect("restaking_program_id is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + }; + let args = InitializeVaultOperatorDelegationSnapshotInstructionArgs { + first_slot_of_ncn_epoch: self.first_slot_of_ncn_epoch.clone(), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} + +/// `initialize_vault_operator_delegation_snapshot` CPI accounts. +pub struct InitializeVaultOperatorDelegationSnapshotCpiAccounts<'a, 'b> { + pub ncn_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub operator: &'b solana_program::account_info::AccountInfo<'a>, + + pub vault: &'b solana_program::account_info::AccountInfo<'a>, + + pub vault_ncn_ticket: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn_vault_ticket: &'b solana_program::account_info::AccountInfo<'a>, + + pub vault_operator_delegation: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, + + pub epoch_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub operator_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub vault_operator_delegation_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub payer: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `initialize_vault_operator_delegation_snapshot` CPI instruction. +pub struct InitializeVaultOperatorDelegationSnapshotCpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub operator: &'b solana_program::account_info::AccountInfo<'a>, + + pub vault: &'b solana_program::account_info::AccountInfo<'a>, + + pub vault_ncn_ticket: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn_vault_ticket: &'b solana_program::account_info::AccountInfo<'a>, + + pub vault_operator_delegation: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, + + pub epoch_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub operator_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub vault_operator_delegation_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + + pub payer: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. + pub __args: InitializeVaultOperatorDelegationSnapshotInstructionArgs, +} + +impl<'a, 'b> InitializeVaultOperatorDelegationSnapshotCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: InitializeVaultOperatorDelegationSnapshotCpiAccounts<'a, 'b>, + args: InitializeVaultOperatorDelegationSnapshotInstructionArgs, + ) -> Self { + Self { + __program: program, + ncn_config: accounts.ncn_config, + restaking_config: accounts.restaking_config, + ncn: accounts.ncn, + operator: accounts.operator, + vault: accounts.vault, + vault_ncn_ticket: accounts.vault_ncn_ticket, + ncn_vault_ticket: accounts.ncn_vault_ticket, + vault_operator_delegation: accounts.vault_operator_delegation, + weight_table: accounts.weight_table, + epoch_snapshot: accounts.epoch_snapshot, + operator_snapshot: accounts.operator_snapshot, + vault_operator_delegation_snapshot: accounts.vault_operator_delegation_snapshot, + payer: accounts.payer, + restaking_program_id: accounts.restaking_program_id, + system_program: accounts.system_program, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed_with_remaining_accounts( + &self, + signers_seeds: &[&[&[u8]]], + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.ncn_config.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.restaking_config.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.ncn.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.operator.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.vault.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.vault_ncn_ticket.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.ncn_vault_ticket.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.vault_operator_delegation.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.weight_table.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.epoch_snapshot.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.operator_snapshot.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.vault_operator_delegation_snapshot.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.payer.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.restaking_program_id.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.system_program.key, + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = InitializeVaultOperatorDelegationSnapshotInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::JITO_TIP_ROUTER_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(15 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.ncn_config.clone()); + account_infos.push(self.restaking_config.clone()); + account_infos.push(self.ncn.clone()); + account_infos.push(self.operator.clone()); + account_infos.push(self.vault.clone()); + account_infos.push(self.vault_ncn_ticket.clone()); + account_infos.push(self.ncn_vault_ticket.clone()); + account_infos.push(self.vault_operator_delegation.clone()); + account_infos.push(self.weight_table.clone()); + account_infos.push(self.epoch_snapshot.clone()); + account_infos.push(self.operator_snapshot.clone()); + account_infos.push(self.vault_operator_delegation_snapshot.clone()); + account_infos.push(self.payer.clone()); + account_infos.push(self.restaking_program_id.clone()); + account_infos.push(self.system_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `InitializeVaultOperatorDelegationSnapshot` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[]` ncn_config +/// 1. `[]` restaking_config +/// 2. `[]` ncn +/// 3. `[]` operator +/// 4. `[]` vault +/// 5. `[]` vault_ncn_ticket +/// 6. `[]` ncn_vault_ticket +/// 7. `[]` vault_operator_delegation +/// 8. `[]` weight_table +/// 9. `[writable]` epoch_snapshot +/// 10. `[writable]` operator_snapshot +/// 11. `[writable]` vault_operator_delegation_snapshot +/// 12. `[writable, signer]` payer +/// 13. `[]` restaking_program_id +/// 14. `[]` system_program +#[derive(Clone, Debug)] +pub struct InitializeVaultOperatorDelegationSnapshotCpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> InitializeVaultOperatorDelegationSnapshotCpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new( + InitializeVaultOperatorDelegationSnapshotCpiBuilderInstruction { + __program: program, + ncn_config: None, + restaking_config: None, + ncn: None, + operator: None, + vault: None, + vault_ncn_ticket: None, + ncn_vault_ticket: None, + vault_operator_delegation: None, + weight_table: None, + epoch_snapshot: None, + operator_snapshot: None, + vault_operator_delegation_snapshot: None, + payer: None, + restaking_program_id: None, + system_program: None, + first_slot_of_ncn_epoch: None, + __remaining_accounts: Vec::new(), + }, + ); + Self { instruction } + } + #[inline(always)] + pub fn ncn_config( + &mut self, + ncn_config: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.ncn_config = Some(ncn_config); + self + } + #[inline(always)] + pub fn restaking_config( + &mut self, + restaking_config: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.restaking_config = Some(restaking_config); + self + } + #[inline(always)] + pub fn ncn(&mut self, ncn: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.ncn = Some(ncn); + self + } + #[inline(always)] + pub fn operator( + &mut self, + operator: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.operator = Some(operator); + self + } + #[inline(always)] + pub fn vault(&mut self, vault: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.vault = Some(vault); + self + } + #[inline(always)] + pub fn vault_ncn_ticket( + &mut self, + vault_ncn_ticket: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.vault_ncn_ticket = Some(vault_ncn_ticket); + self + } + #[inline(always)] + pub fn ncn_vault_ticket( + &mut self, + ncn_vault_ticket: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.ncn_vault_ticket = Some(ncn_vault_ticket); + self + } + #[inline(always)] + pub fn vault_operator_delegation( + &mut self, + vault_operator_delegation: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.vault_operator_delegation = Some(vault_operator_delegation); + self + } + #[inline(always)] + pub fn weight_table( + &mut self, + weight_table: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.weight_table = Some(weight_table); + self + } + #[inline(always)] + pub fn epoch_snapshot( + &mut self, + epoch_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.epoch_snapshot = Some(epoch_snapshot); + self + } + #[inline(always)] + pub fn operator_snapshot( + &mut self, + operator_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.operator_snapshot = Some(operator_snapshot); + self + } + #[inline(always)] + pub fn vault_operator_delegation_snapshot( + &mut self, + vault_operator_delegation_snapshot: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.vault_operator_delegation_snapshot = + Some(vault_operator_delegation_snapshot); + self + } + #[inline(always)] + pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.payer = Some(payer); + self + } + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.restaking_program_id = Some(restaking_program_id); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn first_slot_of_ncn_epoch(&mut self, first_slot_of_ncn_epoch: u64) -> &mut Self { + self.instruction.first_slot_of_ncn_epoch = Some(first_slot_of_ncn_epoch); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let args = InitializeVaultOperatorDelegationSnapshotInstructionArgs { + first_slot_of_ncn_epoch: self.instruction.first_slot_of_ncn_epoch.clone(), + }; + let instruction = InitializeVaultOperatorDelegationSnapshotCpi { + __program: self.instruction.__program, + + ncn_config: self.instruction.ncn_config.expect("ncn_config is not set"), + + restaking_config: self + .instruction + .restaking_config + .expect("restaking_config is not set"), + + ncn: self.instruction.ncn.expect("ncn is not set"), + + operator: self.instruction.operator.expect("operator is not set"), + + vault: self.instruction.vault.expect("vault is not set"), + + vault_ncn_ticket: self + .instruction + .vault_ncn_ticket + .expect("vault_ncn_ticket is not set"), + + ncn_vault_ticket: self + .instruction + .ncn_vault_ticket + .expect("ncn_vault_ticket is not set"), + + vault_operator_delegation: self + .instruction + .vault_operator_delegation + .expect("vault_operator_delegation is not set"), + + weight_table: self + .instruction + .weight_table + .expect("weight_table is not set"), + + epoch_snapshot: self + .instruction + .epoch_snapshot + .expect("epoch_snapshot is not set"), + + operator_snapshot: self + .instruction + .operator_snapshot + .expect("operator_snapshot is not set"), + + vault_operator_delegation_snapshot: self + .instruction + .vault_operator_delegation_snapshot + .expect("vault_operator_delegation_snapshot is not set"), + + payer: self.instruction.payer.expect("payer is not set"), + + restaking_program_id: self + .instruction + .restaking_program_id + .expect("restaking_program_id is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +#[derive(Clone, Debug)] +struct InitializeVaultOperatorDelegationSnapshotCpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + ncn_config: Option<&'b solana_program::account_info::AccountInfo<'a>>, + restaking_config: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ncn: Option<&'b solana_program::account_info::AccountInfo<'a>>, + operator: Option<&'b solana_program::account_info::AccountInfo<'a>>, + vault: Option<&'b solana_program::account_info::AccountInfo<'a>>, + vault_ncn_ticket: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ncn_vault_ticket: Option<&'b solana_program::account_info::AccountInfo<'a>>, + vault_operator_delegation: Option<&'b solana_program::account_info::AccountInfo<'a>>, + weight_table: Option<&'b solana_program::account_info::AccountInfo<'a>>, + epoch_snapshot: Option<&'b solana_program::account_info::AccountInfo<'a>>, + operator_snapshot: Option<&'b solana_program::account_info::AccountInfo<'a>>, + vault_operator_delegation_snapshot: Option<&'b solana_program::account_info::AccountInfo<'a>>, + payer: Option<&'b solana_program::account_info::AccountInfo<'a>>, + restaking_program_id: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + first_slot_of_ncn_epoch: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/jito_tip_router/src/generated/instructions/mod.rs b/clients/rust/jito_tip_router/src/generated/instructions/mod.rs index 076a2216..9446715c 100644 --- a/clients/rust/jito_tip_router/src/generated/instructions/mod.rs +++ b/clients/rust/jito_tip_router/src/generated/instructions/mod.rs @@ -7,11 +7,14 @@ pub(crate) mod r#admin_update_weight_table; pub(crate) mod r#initialize_epoch_snapshot; pub(crate) mod r#initialize_n_c_n_config; +pub(crate) mod r#initialize_operator_snapshot; +pub(crate) mod r#initialize_vault_operator_delegation_snapshot; pub(crate) mod r#initialize_weight_table; pub(crate) mod r#set_config_fees; pub(crate) mod r#set_new_admin; pub use self::{ r#admin_update_weight_table::*, r#initialize_epoch_snapshot::*, r#initialize_n_c_n_config::*, + r#initialize_operator_snapshot::*, r#initialize_vault_operator_delegation_snapshot::*, r#initialize_weight_table::*, r#set_config_fees::*, r#set_new_admin::*, }; diff --git a/clients/rust/jito_tip_router/src/generated/types/mod.rs b/clients/rust/jito_tip_router/src/generated/types/mod.rs index 19402632..ea35df80 100644 --- a/clients/rust/jito_tip_router/src/generated/types/mod.rs +++ b/clients/rust/jito_tip_router/src/generated/types/mod.rs @@ -7,10 +7,6 @@ pub(crate) mod r#config_admin_role; pub(crate) mod r#fee; pub(crate) mod r#fees; -pub(crate) mod r#vault_operator_delegation_snapshot; pub(crate) mod r#weight_entry; -pub use self::{ - r#config_admin_role::*, r#fee::*, r#fees::*, r#vault_operator_delegation_snapshot::*, - r#weight_entry::*, -}; +pub use self::{r#config_admin_role::*, r#fee::*, r#fees::*, r#weight_entry::*}; diff --git a/clients/rust/jito_tip_router/src/generated/types/vault_operator_delegation_snapshot.rs b/clients/rust/jito_tip_router/src/generated/types/vault_operator_delegation_snapshot.rs deleted file mode 100644 index 1b4099d5..00000000 --- a/clients/rust/jito_tip_router/src/generated/types/vault_operator_delegation_snapshot.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the kinobi library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun kinobi to update it. -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_program::pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VaultOperatorDelegationSnapshot { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vault: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub st_mint: Pubkey, - pub total_security: u64, - pub total_votes: u128, - pub slot_set: u64, - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub reserved: [u8; 128], -} diff --git a/core/src/epoch_snapshot.rs b/core/src/epoch_snapshot.rs index 5a7122ed..d5d934fb 100644 --- a/core/src/epoch_snapshot.rs +++ b/core/src/epoch_snapshot.rs @@ -155,7 +155,7 @@ impl EpochSnapshot { votes: u128, ) -> Result<(), TipRouterError> { if self.finalized() { - return Err(TipRouterError::OperatorFinalized.into()); + return Err(TipRouterError::OperatorFinalized); } self.operators_registered = PodU64::from( @@ -214,6 +214,7 @@ impl Discriminator for OperatorSnapshot { } impl OperatorSnapshot { + #[allow(clippy::too_many_arguments)] pub fn new( operator: Pubkey, ncn: Pubkey, @@ -361,7 +362,7 @@ impl OperatorSnapshot { votes: u128, ) -> Result<(), TipRouterError> { if self.finalized() { - return Err(TipRouterError::VaultOperatorDelegationFinalized.into()); + return Err(TipRouterError::VaultOperatorDelegationFinalized); } self.vault_operator_delegations_registered = PodU64::from( @@ -416,6 +417,7 @@ impl Discriminator for VaultOperatorDelegationSnapshot { } impl VaultOperatorDelegationSnapshot { + #[allow(clippy::too_many_arguments)] pub fn new( vault: Pubkey, operator: Pubkey, @@ -442,7 +444,7 @@ impl VaultOperatorDelegationSnapshot { reserved: [0; 128], } } - + #[allow(clippy::too_many_arguments)] pub fn new_active( vault: Pubkey, operator: Pubkey, @@ -491,6 +493,7 @@ impl VaultOperatorDelegationSnapshot { ) } + #[allow(clippy::too_many_arguments)] pub fn create_snapshot( vault: Pubkey, operator: Pubkey, diff --git a/idl/jito_tip_router.json b/idl/jito_tip_router.json index b7d32e8f..62150a72 100644 --- a/idl/jito_tip_router.json +++ b/idl/jito_tip_router.json @@ -319,6 +319,165 @@ "type": "u8", "value": 5 } + }, + { + "name": "InitializeOperatorSnapshot", + "accounts": [ + { + "name": "ncnConfig", + "isMut": false, + "isSigner": false + }, + { + "name": "restakingConfig", + "isMut": false, + "isSigner": false + }, + { + "name": "ncn", + "isMut": false, + "isSigner": false + }, + { + "name": "operator", + "isMut": false, + "isSigner": false + }, + { + "name": "ncnOperatorState", + "isMut": false, + "isSigner": false + }, + { + "name": "epochSnapshot", + "isMut": true, + "isSigner": false + }, + { + "name": "operatorSnapshot", + "isMut": true, + "isSigner": false + }, + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "restakingProgramId", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "firstSlotOfNcnEpoch", + "type": { + "option": "u64" + } + } + ], + "discriminant": { + "type": "u8", + "value": 6 + } + }, + { + "name": "InitializeVaultOperatorDelegationSnapshot", + "accounts": [ + { + "name": "ncnConfig", + "isMut": false, + "isSigner": false + }, + { + "name": "restakingConfig", + "isMut": false, + "isSigner": false + }, + { + "name": "ncn", + "isMut": false, + "isSigner": false + }, + { + "name": "operator", + "isMut": false, + "isSigner": false + }, + { + "name": "vault", + "isMut": false, + "isSigner": false + }, + { + "name": "vaultNcnTicket", + "isMut": false, + "isSigner": false + }, + { + "name": "ncnVaultTicket", + "isMut": false, + "isSigner": false + }, + { + "name": "vaultOperatorDelegation", + "isMut": false, + "isSigner": false + }, + { + "name": "weightTable", + "isMut": false, + "isSigner": false + }, + { + "name": "epochSnapshot", + "isMut": true, + "isSigner": false + }, + { + "name": "operatorSnapshot", + "isMut": true, + "isSigner": false + }, + { + "name": "vaultOperatorDelegationSnapshot", + "isMut": true, + "isSigner": false + }, + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "restakingProgramId", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "firstSlotOfNcnEpoch", + "type": { + "option": "u64" + } + } + ], + "discriminant": { + "type": "u8", + "value": 7 + } } ], "accounts": [ @@ -337,6 +496,10 @@ "defined": "PodU64" } }, + { + "name": "bump", + "type": "u8" + }, { "name": "slotCreated", "type": { @@ -344,8 +507,10 @@ } }, { - "name": "bump", - "type": "u8" + "name": "slotFinalized", + "type": { + "defined": "PodU64" + } }, { "name": "ncnFees", @@ -365,6 +530,12 @@ "defined": "PodU64" } }, + { + "name": "validOperatorVaultDelegations", + "type": { + "defined": "PodU64" + } + }, { "name": "totalVotes", "type": { @@ -402,6 +573,10 @@ "defined": "PodU64" } }, + { + "name": "bump", + "type": "u8" + }, { "name": "slotCreated", "type": { @@ -409,8 +584,16 @@ } }, { - "name": "bump", - "type": "u8" + "name": "slotFinalized", + "type": { + "defined": "PodU64" + } + }, + { + "name": "isActive", + "type": { + "defined": "PodBool" + } }, { "name": "operatorFeeBps", @@ -418,6 +601,24 @@ "defined": "PodU16" } }, + { + "name": "vaultOperatorDelegationCount", + "type": { + "defined": "PodU64" + } + }, + { + "name": "vaultOperatorDelegationsRegistered", + "type": { + "defined": "PodU64" + } + }, + { + "name": "validOperatorVaultDelegations", + "type": { + "defined": "PodU64" + } + }, { "name": "totalVotes", "type": { @@ -425,32 +626,70 @@ } }, { - "name": "numVaultOperatorDelegations", + "name": "reserved", "type": { - "defined": "PodU16" + "array": [ + "u8", + 128 + ] } + } + ] + } + }, + { + "name": "VaultOperatorDelegationSnapshot", + "type": { + "kind": "struct", + "fields": [ + { + "name": "vault", + "type": "publicKey" }, { - "name": "vaultOperatorDelegationsRegistered", + "name": "operator", + "type": "publicKey" + }, + { + "name": "ncn", + "type": "publicKey" + }, + { + "name": "ncnEpoch", "type": { - "defined": "PodU16" + "defined": "PodU64" } }, { - "name": "slotSet", + "name": "bump", + "type": "u8" + }, + { + "name": "slotCreated", "type": { "defined": "PodU64" } }, { - "name": "vaultOperatorDelegations", + "name": "isActive", "type": { - "array": [ - { - "defined": "VaultOperatorDelegationSnapshot" - }, - 32 - ] + "defined": "PodBool" + } + }, + { + "name": "stMint", + "type": "publicKey" + }, + { + "name": "totalSecurity", + "type": { + "defined": "PodU64" + } + }, + { + "name": "totalVotes", + "type": { + "defined": "PodU128" } }, { @@ -554,49 +793,6 @@ } ], "types": [ - { - "name": "VaultOperatorDelegationSnapshot", - "type": { - "kind": "struct", - "fields": [ - { - "name": "vault", - "type": "publicKey" - }, - { - "name": "stMint", - "type": "publicKey" - }, - { - "name": "totalSecurity", - "type": { - "defined": "PodU64" - } - }, - { - "name": "totalVotes", - "type": { - "defined": "PodU128" - } - }, - { - "name": "slotSet", - "type": { - "defined": "PodU64" - } - }, - { - "name": "reserved", - "type": { - "array": [ - "u8", - 128 - ] - } - } - ] - } - }, { "name": "Fees", "type": { @@ -807,6 +1003,21 @@ "code": 8718, "name": "WeightNotFound", "msg": "Weight not found" + }, + { + "code": 8719, + "name": "NoOperators", + "msg": "No operators in ncn" + }, + { + "code": 8720, + "name": "VaultOperatorDelegationFinalized", + "msg": "Vault operator delegation is already finalized - should not happen" + }, + { + "code": 8721, + "name": "OperatorFinalized", + "msg": "Operator is already finalized - should not happen" } ], "metadata": { diff --git a/scripts/generate-clients.js b/scripts/generate-clients.js index 73a0d1ea..3119c703 100644 --- a/scripts/generate-clients.js +++ b/scripts/generate-clients.js @@ -81,6 +81,22 @@ weightTableKinobi.update(kinobi.bottomUpTransformerVisitor([ }; }, }, + { + // PodBool -> bool + select: (node) => { + return ( + kinobi.isNode(node, "structFieldTypeNode") && + node.type.name === "podBool" + ); + }, + transform: (node) => { + kinobi.assertIsNode(node, "structFieldTypeNode"); + return { + ...node, + type: kinobi.numberTypeNode("bool"), + }; + }, + }, // add 8 byte discriminator to accountNode { select: (node) => {