-
Notifications
You must be signed in to change notification settings - Fork 6
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
3613f86
commit b0908f5
Showing
49 changed files
with
1,333 additions
and
291 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/** | ||
* 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, | ||
getStructDecoder, | ||
getStructEncoder, | ||
getU64Decoder, | ||
getU64Encoder, | ||
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 EpochMarker = { | ||
discriminator: bigint; | ||
ncn: Address; | ||
epoch: bigint; | ||
slotClosed: bigint; | ||
}; | ||
|
||
export type EpochMarkerArgs = { | ||
discriminator: number | bigint; | ||
ncn: Address; | ||
epoch: number | bigint; | ||
slotClosed: number | bigint; | ||
}; | ||
|
||
export function getEpochMarkerEncoder(): Encoder<EpochMarkerArgs> { | ||
return getStructEncoder([ | ||
['discriminator', getU64Encoder()], | ||
['ncn', getAddressEncoder()], | ||
['epoch', getU64Encoder()], | ||
['slotClosed', getU64Encoder()], | ||
]); | ||
} | ||
|
||
export function getEpochMarkerDecoder(): Decoder<EpochMarker> { | ||
return getStructDecoder([ | ||
['discriminator', getU64Decoder()], | ||
['ncn', getAddressDecoder()], | ||
['epoch', getU64Decoder()], | ||
['slotClosed', getU64Decoder()], | ||
]); | ||
} | ||
|
||
export function getEpochMarkerCodec(): Codec<EpochMarkerArgs, EpochMarker> { | ||
return combineCodec(getEpochMarkerEncoder(), getEpochMarkerDecoder()); | ||
} | ||
|
||
export function decodeEpochMarker<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | ||
): Account<EpochMarker, TAddress>; | ||
export function decodeEpochMarker<TAddress extends string = string>( | ||
encodedAccount: MaybeEncodedAccount<TAddress> | ||
): MaybeAccount<EpochMarker, TAddress>; | ||
export function decodeEpochMarker<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress> | ||
): Account<EpochMarker, TAddress> | MaybeAccount<EpochMarker, TAddress> { | ||
return decodeAccount( | ||
encodedAccount as MaybeEncodedAccount<TAddress>, | ||
getEpochMarkerDecoder() | ||
); | ||
} | ||
|
||
export async function fetchEpochMarker<TAddress extends string = string>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<Account<EpochMarker, TAddress>> { | ||
const maybeAccount = await fetchMaybeEpochMarker(rpc, address, config); | ||
assertAccountExists(maybeAccount); | ||
return maybeAccount; | ||
} | ||
|
||
export async function fetchMaybeEpochMarker<TAddress extends string = string>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<MaybeAccount<EpochMarker, TAddress>> { | ||
const maybeAccount = await fetchEncodedAccount(rpc, address, config); | ||
return decodeEpochMarker(maybeAccount); | ||
} | ||
|
||
export async function fetchAllEpochMarker( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<Account<EpochMarker>[]> { | ||
const maybeAccounts = await fetchAllMaybeEpochMarker(rpc, addresses, config); | ||
assertAccountsExist(maybeAccounts); | ||
return maybeAccounts; | ||
} | ||
|
||
export async function fetchAllMaybeEpochMarker( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<MaybeAccount<EpochMarker>[]> { | ||
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); | ||
return maybeAccounts.map((maybeAccount) => decodeEpochMarker(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
Oops, something went wrong.