-
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
Showing
35 changed files
with
2,695 additions
and
261 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 |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
* @see https://github.com/kinobi-so/kinobi | ||
*/ | ||
|
||
export * from './ncnConfig'; | ||
export * from './weightTable'; |
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,143 @@ | ||
/** | ||
* 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 { | ||
getFeesDecoder, | ||
getFeesEncoder, | ||
type Fees, | ||
type FeesArgs, | ||
} from '../types'; | ||
|
||
export type NcnConfig = { | ||
discriminator: bigint; | ||
ncn: Address; | ||
tieBreakerAdmin: Address; | ||
fees: Fees; | ||
bump: number; | ||
reserved: Array<number>; | ||
}; | ||
|
||
export type NcnConfigArgs = { | ||
discriminator: number | bigint; | ||
ncn: Address; | ||
tieBreakerAdmin: Address; | ||
fees: FeesArgs; | ||
bump: number; | ||
reserved: Array<number>; | ||
}; | ||
|
||
export function getNcnConfigEncoder(): Encoder<NcnConfigArgs> { | ||
return getStructEncoder([ | ||
['discriminator', getU64Encoder()], | ||
['ncn', getAddressEncoder()], | ||
['tieBreakerAdmin', getAddressEncoder()], | ||
['fees', getFeesEncoder()], | ||
['bump', getU8Encoder()], | ||
['reserved', getArrayEncoder(getU8Encoder(), { size: 127 })], | ||
]); | ||
} | ||
|
||
export function getNcnConfigDecoder(): Decoder<NcnConfig> { | ||
return getStructDecoder([ | ||
['discriminator', getU64Decoder()], | ||
['ncn', getAddressDecoder()], | ||
['tieBreakerAdmin', getAddressDecoder()], | ||
['fees', getFeesDecoder()], | ||
['bump', getU8Decoder()], | ||
['reserved', getArrayDecoder(getU8Decoder(), { size: 127 })], | ||
]); | ||
} | ||
|
||
export function getNcnConfigCodec(): Codec<NcnConfigArgs, NcnConfig> { | ||
return combineCodec(getNcnConfigEncoder(), getNcnConfigDecoder()); | ||
} | ||
|
||
export function decodeNcnConfig<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | ||
): Account<NcnConfig, TAddress>; | ||
export function decodeNcnConfig<TAddress extends string = string>( | ||
encodedAccount: MaybeEncodedAccount<TAddress> | ||
): MaybeAccount<NcnConfig, TAddress>; | ||
export function decodeNcnConfig<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress> | ||
): Account<NcnConfig, TAddress> | MaybeAccount<NcnConfig, TAddress> { | ||
return decodeAccount( | ||
encodedAccount as MaybeEncodedAccount<TAddress>, | ||
getNcnConfigDecoder() | ||
); | ||
} | ||
|
||
export async function fetchNcnConfig<TAddress extends string = string>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<Account<NcnConfig, TAddress>> { | ||
const maybeAccount = await fetchMaybeNcnConfig(rpc, address, config); | ||
assertAccountExists(maybeAccount); | ||
return maybeAccount; | ||
} | ||
|
||
export async function fetchMaybeNcnConfig<TAddress extends string = string>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<MaybeAccount<NcnConfig, TAddress>> { | ||
const maybeAccount = await fetchEncodedAccount(rpc, address, config); | ||
return decodeNcnConfig(maybeAccount); | ||
} | ||
|
||
export async function fetchAllNcnConfig( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<Account<NcnConfig>[]> { | ||
const maybeAccounts = await fetchAllMaybeNcnConfig(rpc, addresses, config); | ||
assertAccountsExist(maybeAccounts); | ||
return maybeAccounts; | ||
} | ||
|
||
export async function fetchAllMaybeNcnConfig( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<MaybeAccount<NcnConfig>[]> { | ||
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); | ||
return maybeAccounts.map((maybeAccount) => decodeNcnConfig(maybeAccount)); | ||
} | ||
|
||
export function getNcnConfigSize(): number { | ||
return 320; | ||
} |
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.