Skip to content

Commit

Permalink
almost there
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed Nov 25, 2024
1 parent 47c4a00 commit 22c86b8
Show file tree
Hide file tree
Showing 54 changed files with 2,286 additions and 484 deletions.
169 changes: 169 additions & 0 deletions clients/js/jito_tip_router/accounts/epochRewardRouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/**
* 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,
getStructDecoder,
getStructEncoder,
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';
import {
getOperatorRewardDecoder,
getOperatorRewardEncoder,
type OperatorReward,
type OperatorRewardArgs,
} from '../types';

export type EpochRewardRouter = {
discriminator: bigint;
ncn: Address;
ncnEpoch: bigint;
bump: number;
slotCreated: bigint;
reserved: Array<number>;
rewardPool: bigint;
operatorRewards: Array<OperatorReward>;
};

export type EpochRewardRouterArgs = {
discriminator: number | bigint;
ncn: Address;
ncnEpoch: number | bigint;
bump: number;
slotCreated: number | bigint;
reserved: Array<number>;
rewardPool: number | bigint;
operatorRewards: Array<OperatorRewardArgs>;
};

export function getEpochRewardRouterEncoder(): Encoder<EpochRewardRouterArgs> {
return getStructEncoder([
['discriminator', getU64Encoder()],
['ncn', getAddressEncoder()],
['ncnEpoch', getU64Encoder()],
['bump', getU8Encoder()],
['slotCreated', getU64Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })],
['rewardPool', getU64Encoder()],
[
'operatorRewards',
getArrayEncoder(getOperatorRewardEncoder(), { size: 32 }),
],
]);
}

export function getEpochRewardRouterDecoder(): Decoder<EpochRewardRouter> {
return getStructDecoder([
['discriminator', getU64Decoder()],
['ncn', getAddressDecoder()],
['ncnEpoch', getU64Decoder()],
['bump', getU8Decoder()],
['slotCreated', getU64Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })],
['rewardPool', getU64Decoder()],
[
'operatorRewards',
getArrayDecoder(getOperatorRewardDecoder(), { size: 32 }),
],
]);
}

export function getEpochRewardRouterCodec(): Codec<
EpochRewardRouterArgs,
EpochRewardRouter
> {
return combineCodec(
getEpochRewardRouterEncoder(),
getEpochRewardRouterDecoder()
);
}

export function decodeEpochRewardRouter<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress>
): Account<EpochRewardRouter, TAddress>;
export function decodeEpochRewardRouter<TAddress extends string = string>(
encodedAccount: MaybeEncodedAccount<TAddress>
): MaybeAccount<EpochRewardRouter, TAddress>;
export function decodeEpochRewardRouter<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>
):
| Account<EpochRewardRouter, TAddress>
| MaybeAccount<EpochRewardRouter, TAddress> {
return decodeAccount(
encodedAccount as MaybeEncodedAccount<TAddress>,
getEpochRewardRouterDecoder()
);
}

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

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

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

export async function fetchAllMaybeEpochRewardRouter(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig
): Promise<MaybeAccount<EpochRewardRouter>[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) =>
decodeEpochRewardRouter(maybeAccount)
);
}
20 changes: 12 additions & 8 deletions clients/js/jito_tip_router/accounts/epochSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import {
type MaybeEncodedAccount,
} from '@solana/web3.js';
import {
getFeesDecoder,
getFeesEncoder,
type Fees,
type FeesArgs,
getFeeConfigDecoder,
getFeeConfigEncoder,
type FeeConfig,
type FeeConfigArgs,
} from '../types';

export type EpochSnapshot = {
Expand All @@ -50,12 +50,13 @@ export type EpochSnapshot = {
bump: number;
slotCreated: bigint;
slotFinalized: bigint;
ncnFees: Fees;
fees: FeeConfig;
operatorCount: bigint;
vaultCount: bigint;
operatorsRegistered: bigint;
validOperatorVaultDelegations: bigint;
stakeWeight: bigint;
rewardStakeWeight: bigint;
reserved: Array<number>;
};

Expand All @@ -66,12 +67,13 @@ export type EpochSnapshotArgs = {
bump: number;
slotCreated: number | bigint;
slotFinalized: number | bigint;
ncnFees: FeesArgs;
fees: FeeConfigArgs;
operatorCount: number | bigint;
vaultCount: number | bigint;
operatorsRegistered: number | bigint;
validOperatorVaultDelegations: number | bigint;
stakeWeight: number | bigint;
rewardStakeWeight: number | bigint;
reserved: Array<number>;
};

Expand All @@ -83,12 +85,13 @@ export function getEpochSnapshotEncoder(): Encoder<EpochSnapshotArgs> {
['bump', getU8Encoder()],
['slotCreated', getU64Encoder()],
['slotFinalized', getU64Encoder()],
['ncnFees', getFeesEncoder()],
['fees', getFeeConfigEncoder()],
['operatorCount', getU64Encoder()],
['vaultCount', getU64Encoder()],
['operatorsRegistered', getU64Encoder()],
['validOperatorVaultDelegations', getU64Encoder()],
['stakeWeight', getU128Encoder()],
['rewardStakeWeight', getU128Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })],
]);
}
Expand All @@ -101,12 +104,13 @@ export function getEpochSnapshotDecoder(): Decoder<EpochSnapshot> {
['bump', getU8Decoder()],
['slotCreated', getU64Decoder()],
['slotFinalized', getU64Decoder()],
['ncnFees', getFeesDecoder()],
['fees', getFeeConfigDecoder()],
['operatorCount', getU64Decoder()],
['vaultCount', getU64Decoder()],
['operatorsRegistered', getU64Decoder()],
['validOperatorVaultDelegations', getU64Decoder()],
['stakeWeight', getU128Decoder()],
['rewardStakeWeight', getU128Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })],
]);
}
Expand Down
2 changes: 2 additions & 0 deletions clients/js/jito_tip_router/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*/

export * from './ballotBox';
export * from './epochRewardRouter';
export * from './epochSnapshot';
export * from './ncnConfig';
export * from './operatorRewardRouter';
export * from './operatorSnapshot';
export * from './trackedMints';
export * from './weightTable';
16 changes: 8 additions & 8 deletions clients/js/jito_tip_router/accounts/ncnConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ import {
type MaybeEncodedAccount,
} from '@solana/web3.js';
import {
getFeesDecoder,
getFeesEncoder,
type Fees,
type FeesArgs,
getFeeConfigDecoder,
getFeeConfigEncoder,
type FeeConfig,
type FeeConfigArgs,
} from '../types';

export type NcnConfig = {
discriminator: bigint;
ncn: Address;
tieBreakerAdmin: Address;
feeAdmin: Address;
fees: Fees;
feeConfig: FeeConfig;
bump: number;
reserved: Array<number>;
};
Expand All @@ -56,7 +56,7 @@ export type NcnConfigArgs = {
ncn: Address;
tieBreakerAdmin: Address;
feeAdmin: Address;
fees: FeesArgs;
feeConfig: FeeConfigArgs;
bump: number;
reserved: Array<number>;
};
Expand All @@ -67,7 +67,7 @@ export function getNcnConfigEncoder(): Encoder<NcnConfigArgs> {
['ncn', getAddressEncoder()],
['tieBreakerAdmin', getAddressEncoder()],
['feeAdmin', getAddressEncoder()],
['fees', getFeesEncoder()],
['feeConfig', getFeeConfigEncoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 127 })],
]);
Expand All @@ -79,7 +79,7 @@ export function getNcnConfigDecoder(): Decoder<NcnConfig> {
['ncn', getAddressDecoder()],
['tieBreakerAdmin', getAddressDecoder()],
['feeAdmin', getAddressDecoder()],
['fees', getFeesDecoder()],
['feeConfig', getFeeConfigDecoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 127 })],
]);
Expand Down
Loading

0 comments on commit 22c86b8

Please sign in to comment.