-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf4c10d
commit 4d58ac5
Showing
32 changed files
with
2,517 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/** | ||
* 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, | ||
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'; | ||
import { | ||
getFeesDecoder, | ||
getFeesEncoder, | ||
type Fees, | ||
type FeesArgs, | ||
} from '../types'; | ||
|
||
export type EpochSnapshot = { | ||
discriminator: bigint; | ||
ncn: Address; | ||
ncnEpoch: bigint; | ||
slotCreated: bigint; | ||
bump: number; | ||
ncnFees: Fees; | ||
operatorCount: bigint; | ||
operatorsRegistered: bigint; | ||
totalVotes: bigint; | ||
reserved: Array<number>; | ||
}; | ||
|
||
export type EpochSnapshotArgs = { | ||
discriminator: number | bigint; | ||
ncn: Address; | ||
ncnEpoch: number | bigint; | ||
slotCreated: number | bigint; | ||
bump: number; | ||
ncnFees: FeesArgs; | ||
operatorCount: number | bigint; | ||
operatorsRegistered: number | bigint; | ||
totalVotes: number | bigint; | ||
reserved: Array<number>; | ||
}; | ||
|
||
export function getEpochSnapshotEncoder(): Encoder<EpochSnapshotArgs> { | ||
return getStructEncoder([ | ||
['discriminator', getU64Encoder()], | ||
['ncn', getAddressEncoder()], | ||
['ncnEpoch', getU64Encoder()], | ||
['slotCreated', getU64Encoder()], | ||
['bump', getU8Encoder()], | ||
['ncnFees', getFeesEncoder()], | ||
['operatorCount', getU64Encoder()], | ||
['operatorsRegistered', getU64Encoder()], | ||
['totalVotes', getU128Encoder()], | ||
['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })], | ||
]); | ||
} | ||
|
||
export function getEpochSnapshotDecoder(): Decoder<EpochSnapshot> { | ||
return getStructDecoder([ | ||
['discriminator', getU64Decoder()], | ||
['ncn', getAddressDecoder()], | ||
['ncnEpoch', getU64Decoder()], | ||
['slotCreated', getU64Decoder()], | ||
['bump', getU8Decoder()], | ||
['ncnFees', getFeesDecoder()], | ||
['operatorCount', getU64Decoder()], | ||
['operatorsRegistered', getU64Decoder()], | ||
['totalVotes', getU128Decoder()], | ||
['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })], | ||
]); | ||
} | ||
|
||
export function getEpochSnapshotCodec(): Codec< | ||
EpochSnapshotArgs, | ||
EpochSnapshot | ||
> { | ||
return combineCodec(getEpochSnapshotEncoder(), getEpochSnapshotDecoder()); | ||
} | ||
|
||
export function decodeEpochSnapshot<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | ||
): Account<EpochSnapshot, TAddress>; | ||
export function decodeEpochSnapshot<TAddress extends string = string>( | ||
encodedAccount: MaybeEncodedAccount<TAddress> | ||
): MaybeAccount<EpochSnapshot, TAddress>; | ||
export function decodeEpochSnapshot<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress> | ||
): Account<EpochSnapshot, TAddress> | MaybeAccount<EpochSnapshot, TAddress> { | ||
return decodeAccount( | ||
encodedAccount as MaybeEncodedAccount<TAddress>, | ||
getEpochSnapshotDecoder() | ||
); | ||
} | ||
|
||
export async function fetchEpochSnapshot<TAddress extends string = string>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<Account<EpochSnapshot, TAddress>> { | ||
const maybeAccount = await fetchMaybeEpochSnapshot(rpc, address, config); | ||
assertAccountExists(maybeAccount); | ||
return maybeAccount; | ||
} | ||
|
||
export async function fetchMaybeEpochSnapshot<TAddress extends string = string>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<MaybeAccount<EpochSnapshot, TAddress>> { | ||
const maybeAccount = await fetchEncodedAccount(rpc, address, config); | ||
return decodeEpochSnapshot(maybeAccount); | ||
} | ||
|
||
export async function fetchAllEpochSnapshot( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<Account<EpochSnapshot>[]> { | ||
const maybeAccounts = await fetchAllMaybeEpochSnapshot( | ||
rpc, | ||
addresses, | ||
config | ||
); | ||
assertAccountsExist(maybeAccounts); | ||
return maybeAccounts; | ||
} | ||
|
||
export async function fetchAllMaybeEpochSnapshot( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<MaybeAccount<EpochSnapshot>[]> { | ||
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); | ||
return maybeAccounts.map((maybeAccount) => decodeEpochSnapshot(maybeAccount)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 197 additions & 0 deletions
197
clients/js/jito_tip_router/accounts/operatorSnapshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
/** | ||
* 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, | ||
getU128Decoder, | ||
getU128Encoder, | ||
getU16Decoder, | ||
getU16Encoder, | ||
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 { | ||
getVaultOperatorDelegationSnapshotDecoder, | ||
getVaultOperatorDelegationSnapshotEncoder, | ||
type VaultOperatorDelegationSnapshot, | ||
type VaultOperatorDelegationSnapshotArgs, | ||
} from '../types'; | ||
|
||
export type OperatorSnapshot = { | ||
discriminator: bigint; | ||
operator: Address; | ||
ncn: Address; | ||
ncnEpoch: bigint; | ||
slotCreated: bigint; | ||
bump: number; | ||
operatorFeeBps: number; | ||
totalVotes: bigint; | ||
numVaultOperatorDelegations: number; | ||
vaultOperatorDelegationsRegistered: number; | ||
slotSet: bigint; | ||
vaultOperatorDelegations: Array<VaultOperatorDelegationSnapshot>; | ||
reserved: Array<number>; | ||
}; | ||
|
||
export type OperatorSnapshotArgs = { | ||
discriminator: number | bigint; | ||
operator: Address; | ||
ncn: Address; | ||
ncnEpoch: number | bigint; | ||
slotCreated: number | bigint; | ||
bump: number; | ||
operatorFeeBps: number; | ||
totalVotes: number | bigint; | ||
numVaultOperatorDelegations: number; | ||
vaultOperatorDelegationsRegistered: number; | ||
slotSet: number | bigint; | ||
vaultOperatorDelegations: Array<VaultOperatorDelegationSnapshotArgs>; | ||
reserved: Array<number>; | ||
}; | ||
|
||
export function getOperatorSnapshotEncoder(): Encoder<OperatorSnapshotArgs> { | ||
return getStructEncoder([ | ||
['discriminator', getU64Encoder()], | ||
['operator', getAddressEncoder()], | ||
['ncn', getAddressEncoder()], | ||
['ncnEpoch', getU64Encoder()], | ||
['slotCreated', getU64Encoder()], | ||
['bump', getU8Encoder()], | ||
['operatorFeeBps', getU16Encoder()], | ||
['totalVotes', getU128Encoder()], | ||
['numVaultOperatorDelegations', getU16Encoder()], | ||
['vaultOperatorDelegationsRegistered', getU16Encoder()], | ||
['slotSet', getU64Encoder()], | ||
[ | ||
'vaultOperatorDelegations', | ||
getArrayEncoder(getVaultOperatorDelegationSnapshotEncoder(), { | ||
size: 32, | ||
}), | ||
], | ||
['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })], | ||
]); | ||
} | ||
|
||
export function getOperatorSnapshotDecoder(): Decoder<OperatorSnapshot> { | ||
return getStructDecoder([ | ||
['discriminator', getU64Decoder()], | ||
['operator', getAddressDecoder()], | ||
['ncn', getAddressDecoder()], | ||
['ncnEpoch', getU64Decoder()], | ||
['slotCreated', getU64Decoder()], | ||
['bump', getU8Decoder()], | ||
['operatorFeeBps', getU16Decoder()], | ||
['totalVotes', getU128Decoder()], | ||
['numVaultOperatorDelegations', getU16Decoder()], | ||
['vaultOperatorDelegationsRegistered', getU16Decoder()], | ||
['slotSet', getU64Decoder()], | ||
[ | ||
'vaultOperatorDelegations', | ||
getArrayDecoder(getVaultOperatorDelegationSnapshotDecoder(), { | ||
size: 32, | ||
}), | ||
], | ||
['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })], | ||
]); | ||
} | ||
|
||
export function getOperatorSnapshotCodec(): Codec< | ||
OperatorSnapshotArgs, | ||
OperatorSnapshot | ||
> { | ||
return combineCodec( | ||
getOperatorSnapshotEncoder(), | ||
getOperatorSnapshotDecoder() | ||
); | ||
} | ||
|
||
export function decodeOperatorSnapshot<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | ||
): Account<OperatorSnapshot, TAddress>; | ||
export function decodeOperatorSnapshot<TAddress extends string = string>( | ||
encodedAccount: MaybeEncodedAccount<TAddress> | ||
): MaybeAccount<OperatorSnapshot, TAddress>; | ||
export function decodeOperatorSnapshot<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress> | ||
): | ||
| Account<OperatorSnapshot, TAddress> | ||
| MaybeAccount<OperatorSnapshot, TAddress> { | ||
return decodeAccount( | ||
encodedAccount as MaybeEncodedAccount<TAddress>, | ||
getOperatorSnapshotDecoder() | ||
); | ||
} | ||
|
||
export async function fetchOperatorSnapshot<TAddress extends string = string>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<Account<OperatorSnapshot, TAddress>> { | ||
const maybeAccount = await fetchMaybeOperatorSnapshot(rpc, address, config); | ||
assertAccountExists(maybeAccount); | ||
return maybeAccount; | ||
} | ||
|
||
export async function fetchMaybeOperatorSnapshot< | ||
TAddress extends string = string, | ||
>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<MaybeAccount<OperatorSnapshot, TAddress>> { | ||
const maybeAccount = await fetchEncodedAccount(rpc, address, config); | ||
return decodeOperatorSnapshot(maybeAccount); | ||
} | ||
|
||
export async function fetchAllOperatorSnapshot( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<Account<OperatorSnapshot>[]> { | ||
const maybeAccounts = await fetchAllMaybeOperatorSnapshot( | ||
rpc, | ||
addresses, | ||
config | ||
); | ||
assertAccountsExist(maybeAccounts); | ||
return maybeAccounts; | ||
} | ||
|
||
export async function fetchAllMaybeOperatorSnapshot( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<MaybeAccount<OperatorSnapshot>[]> { | ||
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); | ||
return maybeAccounts.map((maybeAccount) => | ||
decodeOperatorSnapshot(maybeAccount) | ||
); | ||
} |
Oops, something went wrong.