Skip to content

Commit

Permalink
updated clients
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed Nov 12, 2024
1 parent bd7e3b1 commit b5d77e0
Show file tree
Hide file tree
Showing 24 changed files with 3,009 additions and 223 deletions.
16 changes: 12 additions & 4 deletions clients/js/jito_tip_router/accounts/epochSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>;
};
Expand All @@ -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<number>;
};
Expand All @@ -74,11 +78,13 @@ export function getEpochSnapshotEncoder(): Encoder<EpochSnapshotArgs> {
['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 })],
]);
Expand All @@ -89,11 +95,13 @@ export function getEpochSnapshotDecoder(): Decoder<EpochSnapshot> {
['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 })],
]);
Expand Down
1 change: 1 addition & 0 deletions clients/js/jito_tip_router/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
export * from './epochSnapshot';
export * from './ncnConfig';
export * from './operatorSnapshot';
export * from './vaultOperatorDelegationSnapshot';
export * from './weightTable';
62 changes: 26 additions & 36 deletions clients/js/jito_tip_router/accounts/operatorSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
getAddressEncoder,
getArrayDecoder,
getArrayEncoder,
getBoolDecoder,
getBoolEncoder,
getStructDecoder,
getStructEncoder,
getU128Decoder,
Expand All @@ -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<VaultOperatorDelegationSnapshot>;
reserved: Array<number>;
};

Expand All @@ -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<VaultOperatorDelegationSnapshotArgs>;
reserved: Array<number>;
};

Expand All @@ -83,19 +81,15 @@ export function getOperatorSnapshotEncoder(): Encoder<OperatorSnapshotArgs> {
['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 })],
]);
}
Expand All @@ -106,19 +100,15 @@ export function getOperatorSnapshotDecoder(): Decoder<OperatorSnapshot> {
['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 })],
]);
}
Expand Down
189 changes: 189 additions & 0 deletions clients/js/jito_tip_router/accounts/vaultOperatorDelegationSnapshot.ts
Original file line number Diff line number Diff line change
@@ -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<number>;
};

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<number>;
};

export function getVaultOperatorDelegationSnapshotEncoder(): Encoder<VaultOperatorDelegationSnapshotArgs> {
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<VaultOperatorDelegationSnapshot> {
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<TAddress>
): Account<VaultOperatorDelegationSnapshot, TAddress>;
export function decodeVaultOperatorDelegationSnapshot<
TAddress extends string = string,
>(
encodedAccount: MaybeEncodedAccount<TAddress>
): MaybeAccount<VaultOperatorDelegationSnapshot, TAddress>;
export function decodeVaultOperatorDelegationSnapshot<
TAddress extends string = string,
>(
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>
):
| Account<VaultOperatorDelegationSnapshot, TAddress>
| MaybeAccount<VaultOperatorDelegationSnapshot, TAddress> {
return decodeAccount(
encodedAccount as MaybeEncodedAccount<TAddress>,
getVaultOperatorDelegationSnapshotDecoder()
);
}

export async function fetchVaultOperatorDelegationSnapshot<
TAddress extends string = string,
>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig
): Promise<Account<VaultOperatorDelegationSnapshot, TAddress>> {
const maybeAccount = await fetchMaybeVaultOperatorDelegationSnapshot(
rpc,
address,
config
);
assertAccountExists(maybeAccount);
return maybeAccount;
}

export async function fetchMaybeVaultOperatorDelegationSnapshot<
TAddress extends string = string,
>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig
): Promise<MaybeAccount<VaultOperatorDelegationSnapshot, TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeVaultOperatorDelegationSnapshot(maybeAccount);
}

export async function fetchAllVaultOperatorDelegationSnapshot(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig
): Promise<Account<VaultOperatorDelegationSnapshot>[]> {
const maybeAccounts = await fetchAllMaybeVaultOperatorDelegationSnapshot(
rpc,
addresses,
config
);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}

export async function fetchAllMaybeVaultOperatorDelegationSnapshot(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig
): Promise<MaybeAccount<VaultOperatorDelegationSnapshot>[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) =>
decodeVaultOperatorDelegationSnapshot(maybeAccount)
);
}
Loading

0 comments on commit b5d77e0

Please sign in to comment.