-
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.
Merge pull request #1 from jito-foundation/eb/ncn-config
NCN Config Setup
- Loading branch information
Showing
57 changed files
with
4,613 additions
and
265 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
TIP_ROUTER_PROGRAM_ID=Fv9aHCgvPQSr4jg9W8eTS6Ys1SNmh2qjyATrbsjEMaSH | ||
RESTAKING_PROGRAM_ID=6Weyp6uFyjJ3pzYz7XbXvCPAyvzLUhESEhHarFRm53Nb | ||
VAULT_PROGRAM_ID=4vB3bvqKEmxV68J7XtS1HqZomjok4ZXc1ELJH9p1K1D2 | ||
RESTAKING_PROGRAM_ID=RestkWeAVL8fRGgzhfeoqFhsqKRchg6aa1XrcH96z4Q | ||
VAULT_PROGRAM_ID=Vau1t6sLNxnzB7ZDsef8TLbPLfyZMYXH8WTNqUdm9g8 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,147 @@ | ||
/** | ||
* 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; | ||
feeAdmin: Address; | ||
fees: Fees; | ||
bump: number; | ||
reserved: Array<number>; | ||
}; | ||
|
||
export type NcnConfigArgs = { | ||
discriminator: number | bigint; | ||
ncn: Address; | ||
tieBreakerAdmin: Address; | ||
feeAdmin: Address; | ||
fees: FeesArgs; | ||
bump: number; | ||
reserved: Array<number>; | ||
}; | ||
|
||
export function getNcnConfigEncoder(): Encoder<NcnConfigArgs> { | ||
return getStructEncoder([ | ||
['discriminator', getU64Encoder()], | ||
['ncn', getAddressEncoder()], | ||
['tieBreakerAdmin', getAddressEncoder()], | ||
['feeAdmin', getAddressEncoder()], | ||
['fees', getFeesEncoder()], | ||
['bump', getU8Encoder()], | ||
['reserved', getArrayEncoder(getU8Encoder(), { size: 127 })], | ||
]); | ||
} | ||
|
||
export function getNcnConfigDecoder(): Decoder<NcnConfig> { | ||
return getStructDecoder([ | ||
['discriminator', getU64Decoder()], | ||
['ncn', getAddressDecoder()], | ||
['tieBreakerAdmin', getAddressDecoder()], | ||
['feeAdmin', 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 352; | ||
} |
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.