-
Notifications
You must be signed in to change notification settings - Fork 5
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
47c4a00
commit 22c86b8
Showing
54 changed files
with
2,286 additions
and
484 deletions.
There are no files selected for viewing
169 changes: 169 additions & 0 deletions
169
clients/js/jito_tip_router/accounts/epochRewardRouter.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,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) | ||
); | ||
} |
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
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
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
Oops, something went wrong.