Skip to content

Commit

Permalink
tests getting closer
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed Nov 14, 2024
1 parent 27a164a commit 1b52c14
Show file tree
Hide file tree
Showing 15 changed files with 364 additions and 400 deletions.
1 change: 0 additions & 1 deletion clients/js/jito_tip_router/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ export * from './epochSnapshot';
export * from './ncnConfig';
export * from './operatorSnapshot';
export * from './trackedMints';
export * from './vaultOperatorDelegationSnapshot';
export * from './weightTable';
24 changes: 22 additions & 2 deletions clients/js/jito_tip_router/accounts/operatorSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ import {
type MaybeAccount,
type MaybeEncodedAccount,
} from '@solana/web3.js';
import {
getVaultOperatorVotesDecoder,
getVaultOperatorVotesEncoder,
type VaultOperatorVotes,
type VaultOperatorVotesArgs,
} from '../types';

export type OperatorSnapshot = {
discriminator: bigint;
Expand All @@ -50,12 +56,14 @@ export type OperatorSnapshot = {
slotCreated: bigint;
slotFinalized: bigint;
isActive: number;
operatorIndex: bigint;
operatorFeeBps: number;
vaultOperatorDelegationCount: bigint;
vaultOperatorDelegationsRegistered: bigint;
validOperatorVaultDelegations: bigint;
totalVotes: bigint;
reserved: Array<number>;
vaultOperatorVotes: Array<VaultOperatorVotes>;
};

export type OperatorSnapshotArgs = {
Expand All @@ -67,12 +75,14 @@ export type OperatorSnapshotArgs = {
slotCreated: number | bigint;
slotFinalized: number | bigint;
isActive: number;
operatorIndex: number | bigint;
operatorFeeBps: number;
vaultOperatorDelegationCount: number | bigint;
vaultOperatorDelegationsRegistered: number | bigint;
validOperatorVaultDelegations: number | bigint;
totalVotes: number | bigint;
reserved: Array<number>;
vaultOperatorVotes: Array<VaultOperatorVotesArgs>;
};

export function getOperatorSnapshotEncoder(): Encoder<OperatorSnapshotArgs> {
Expand All @@ -85,12 +95,17 @@ export function getOperatorSnapshotEncoder(): Encoder<OperatorSnapshotArgs> {
['slotCreated', getU64Encoder()],
['slotFinalized', getU64Encoder()],
['isActive', getBoolEncoder()],
['operatorIndex', getU64Encoder()],
['operatorFeeBps', getU16Encoder()],
['vaultOperatorDelegationCount', getU64Encoder()],
['vaultOperatorDelegationsRegistered', getU64Encoder()],
['validOperatorVaultDelegations', getU64Encoder()],
['totalVotes', getU128Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })],
['reserved', getArrayEncoder(getU8Encoder(), { size: 256 })],
[
'vaultOperatorVotes',
getArrayEncoder(getVaultOperatorVotesEncoder(), { size: 64 }),
],
]);
}

Expand All @@ -104,12 +119,17 @@ export function getOperatorSnapshotDecoder(): Decoder<OperatorSnapshot> {
['slotCreated', getU64Decoder()],
['slotFinalized', getU64Decoder()],
['isActive', getBoolDecoder()],
['operatorIndex', getU64Decoder()],
['operatorFeeBps', getU16Decoder()],
['vaultOperatorDelegationCount', getU64Decoder()],
['vaultOperatorDelegationsRegistered', getU64Decoder()],
['validOperatorVaultDelegations', getU64Decoder()],
['totalVotes', getU128Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })],
['reserved', getArrayDecoder(getU8Decoder(), { size: 256 })],
[
'vaultOperatorVotes',
getArrayDecoder(getVaultOperatorVotesDecoder(), { size: 64 }),
],
]);
}

Expand Down
189 changes: 0 additions & 189 deletions clients/js/jito_tip_router/accounts/vaultOperatorDelegationSnapshot.ts

This file was deleted.

8 changes: 8 additions & 0 deletions clients/js/jito_tip_router/errors/jitoTipRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export const JITO_TIP_ROUTER_ERROR__NO_OPERATORS = 0x2214; // 8724
export const JITO_TIP_ROUTER_ERROR__VAULT_OPERATOR_DELEGATION_FINALIZED = 0x2215; // 8725
/** OperatorFinalized: Operator is already finalized - should not happen */
export const JITO_TIP_ROUTER_ERROR__OPERATOR_FINALIZED = 0x2216; // 8726
/** TooManyVaultOperatorDelegations: Too many vault operator delegations */
export const JITO_TIP_ROUTER_ERROR__TOO_MANY_VAULT_OPERATOR_DELEGATIONS = 0x2217; // 8727
/** DuplicateVaultOperatorDelegation: Duplicate vault operator delegation */
export const JITO_TIP_ROUTER_ERROR__DUPLICATE_VAULT_OPERATOR_DELEGATION = 0x2218; // 8728

export type JitoTipRouterError =
| typeof JITO_TIP_ROUTER_ERROR__ARITHMETIC_OVERFLOW
Expand All @@ -79,6 +83,7 @@ export type JitoTipRouterError =
| typeof JITO_TIP_ROUTER_ERROR__CONFIG_MINTS_NOT_UPDATED
| typeof JITO_TIP_ROUTER_ERROR__DENOMINATOR_IS_ZERO
| typeof JITO_TIP_ROUTER_ERROR__DUPLICATE_MINTS_IN_TABLE
| typeof JITO_TIP_ROUTER_ERROR__DUPLICATE_VAULT_OPERATOR_DELEGATION
| typeof JITO_TIP_ROUTER_ERROR__FEE_CAP_EXCEEDED
| typeof JITO_TIP_ROUTER_ERROR__INCORRECT_FEE_ADMIN
| typeof JITO_TIP_ROUTER_ERROR__INCORRECT_NCN
Expand All @@ -91,6 +96,7 @@ export type JitoTipRouterError =
| 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__TOO_MANY_VAULT_OPERATOR_DELEGATIONS
| typeof JITO_TIP_ROUTER_ERROR__TRACKED_MINT_LIST_FULL
| typeof JITO_TIP_ROUTER_ERROR__TRACKED_MINTS_LOCKED
| typeof JITO_TIP_ROUTER_ERROR__VAULT_INDEX_ALREADY_IN_USE
Expand All @@ -111,6 +117,7 @@ if (process.env.NODE_ENV !== 'production') {
[JITO_TIP_ROUTER_ERROR__CONFIG_MINTS_NOT_UPDATED]: `Config supported mints do not match NCN Vault Count`,
[JITO_TIP_ROUTER_ERROR__DENOMINATOR_IS_ZERO]: `Zero in the denominator`,
[JITO_TIP_ROUTER_ERROR__DUPLICATE_MINTS_IN_TABLE]: `Duplicate mints in table`,
[JITO_TIP_ROUTER_ERROR__DUPLICATE_VAULT_OPERATOR_DELEGATION]: `Duplicate vault operator delegation`,
[JITO_TIP_ROUTER_ERROR__FEE_CAP_EXCEEDED]: `Fee cap exceeded`,
[JITO_TIP_ROUTER_ERROR__INCORRECT_FEE_ADMIN]: `Incorrect fee admin`,
[JITO_TIP_ROUTER_ERROR__INCORRECT_NCN]: `Incorrect NCN`,
Expand All @@ -123,6 +130,7 @@ if (process.env.NODE_ENV !== 'production') {
[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__TOO_MANY_VAULT_OPERATOR_DELEGATIONS]: `Too many vault operator delegations`,
[JITO_TIP_ROUTER_ERROR__TRACKED_MINT_LIST_FULL]: `Tracked mints are at capacity`,
[JITO_TIP_ROUTER_ERROR__TRACKED_MINTS_LOCKED]: `Tracked mints are locked for the epoch`,
[JITO_TIP_ROUTER_ERROR__VAULT_INDEX_ALREADY_IN_USE]: `Vault index already in use by a different mint`,
Expand Down
1 change: 0 additions & 1 deletion clients/js/jito_tip_router/programs/jitoTipRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const JITO_TIP_ROUTER_PROGRAM_ADDRESS =
export enum JitoTipRouterAccount {
EpochSnapshot,
OperatorSnapshot,
VaultOperatorDelegationSnapshot,
NcnConfig,
TrackedMints,
WeightTable,
Expand Down
1 change: 1 addition & 0 deletions clients/js/jito_tip_router/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export * from './configAdminRole';
export * from './fee';
export * from './fees';
export * from './mintEntry';
export * from './vaultOperatorVotes';
export * from './weightEntry';
Loading

0 comments on commit 1b52c14

Please sign in to comment.