-
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.
Move tracked_mints to its own account
- Loading branch information
Showing
28 changed files
with
1,400 additions
and
149 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 |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
*/ | ||
|
||
export * from './ncnConfig'; | ||
export * from './trackedMints'; | ||
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
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,135 @@ | ||
/** | ||
* 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 { | ||
getMintEntryDecoder, | ||
getMintEntryEncoder, | ||
type MintEntry, | ||
type MintEntryArgs, | ||
} from '../types'; | ||
|
||
export type TrackedMints = { | ||
discriminator: bigint; | ||
ncn: Address; | ||
bump: number; | ||
reserved: Array<number>; | ||
stMintList: Array<MintEntry>; | ||
}; | ||
|
||
export type TrackedMintsArgs = { | ||
discriminator: number | bigint; | ||
ncn: Address; | ||
bump: number; | ||
reserved: Array<number>; | ||
stMintList: Array<MintEntryArgs>; | ||
}; | ||
|
||
export function getTrackedMintsEncoder(): Encoder<TrackedMintsArgs> { | ||
return getStructEncoder([ | ||
['discriminator', getU64Encoder()], | ||
['ncn', getAddressEncoder()], | ||
['bump', getU8Encoder()], | ||
['reserved', getArrayEncoder(getU8Encoder(), { size: 7 })], | ||
['stMintList', getArrayEncoder(getMintEntryEncoder(), { size: 64 })], | ||
]); | ||
} | ||
|
||
export function getTrackedMintsDecoder(): Decoder<TrackedMints> { | ||
return getStructDecoder([ | ||
['discriminator', getU64Decoder()], | ||
['ncn', getAddressDecoder()], | ||
['bump', getU8Decoder()], | ||
['reserved', getArrayDecoder(getU8Decoder(), { size: 7 })], | ||
['stMintList', getArrayDecoder(getMintEntryDecoder(), { size: 64 })], | ||
]); | ||
} | ||
|
||
export function getTrackedMintsCodec(): Codec<TrackedMintsArgs, TrackedMints> { | ||
return combineCodec(getTrackedMintsEncoder(), getTrackedMintsDecoder()); | ||
} | ||
|
||
export function decodeTrackedMints<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | ||
): Account<TrackedMints, TAddress>; | ||
export function decodeTrackedMints<TAddress extends string = string>( | ||
encodedAccount: MaybeEncodedAccount<TAddress> | ||
): MaybeAccount<TrackedMints, TAddress>; | ||
export function decodeTrackedMints<TAddress extends string = string>( | ||
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress> | ||
): Account<TrackedMints, TAddress> | MaybeAccount<TrackedMints, TAddress> { | ||
return decodeAccount( | ||
encodedAccount as MaybeEncodedAccount<TAddress>, | ||
getTrackedMintsDecoder() | ||
); | ||
} | ||
|
||
export async function fetchTrackedMints<TAddress extends string = string>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<Account<TrackedMints, TAddress>> { | ||
const maybeAccount = await fetchMaybeTrackedMints(rpc, address, config); | ||
assertAccountExists(maybeAccount); | ||
return maybeAccount; | ||
} | ||
|
||
export async function fetchMaybeTrackedMints<TAddress extends string = string>( | ||
rpc: Parameters<typeof fetchEncodedAccount>[0], | ||
address: Address<TAddress>, | ||
config?: FetchAccountConfig | ||
): Promise<MaybeAccount<TrackedMints, TAddress>> { | ||
const maybeAccount = await fetchEncodedAccount(rpc, address, config); | ||
return decodeTrackedMints(maybeAccount); | ||
} | ||
|
||
export async function fetchAllTrackedMints( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<Account<TrackedMints>[]> { | ||
const maybeAccounts = await fetchAllMaybeTrackedMints(rpc, addresses, config); | ||
assertAccountsExist(maybeAccounts); | ||
return maybeAccounts; | ||
} | ||
|
||
export async function fetchAllMaybeTrackedMints( | ||
rpc: Parameters<typeof fetchEncodedAccounts>[0], | ||
addresses: Array<Address>, | ||
config?: FetchAccountsConfig | ||
): Promise<MaybeAccount<TrackedMints>[]> { | ||
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); | ||
return maybeAccounts.map((maybeAccount) => decodeTrackedMints(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.