Skip to content

Commit

Permalink
Update Kinobi to 0.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva committed Jan 11, 2024
1 parent 64ee886 commit 5637e52
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 53 deletions.
66 changes: 41 additions & 25 deletions clients/js/src/generated/accounts/addressLookupTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {
EncodedAccount,
FetchAccountConfig,
FetchAccountsConfig,
MaybeAccount,
MaybeEncodedAccount,
assertAccountExists,
assertAccountsExist,
decodeAccount,
fetchEncodedAccount,
fetchEncodedAccounts,
Expand Down Expand Up @@ -57,6 +60,9 @@ export type AddressLookupTable<TAddress extends string = string> = Account<
TAddress
>;

export type MaybeAddressLookupTable<TAddress extends string = string> =
MaybeAccount<AddressLookupTableAccountData, TAddress>;

export type AddressLookupTableAccountData = {
discriminator: number;
deactivationSlot: bigint;
Expand Down Expand Up @@ -125,9 +131,15 @@ export function getAddressLookupTableAccountDataCodec(): Codec<

export function decodeAddressLookupTable<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress>
): AddressLookupTable<TAddress> {
): AddressLookupTable<TAddress>;
export function decodeAddressLookupTable<TAddress extends string = string>(
encodedAccount: MaybeEncodedAccount<TAddress>
): MaybeAddressLookupTable<TAddress>;
export function decodeAddressLookupTable<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>
): AddressLookupTable<TAddress> | MaybeAddressLookupTable<TAddress> {
return decodeAccount(
encodedAccount,
encodedAccount as MaybeEncodedAccount<TAddress>,
getAddressLookupTableAccountDataDecoder()
);
}
Expand All @@ -137,63 +149,67 @@ export async function fetchAddressLookupTable<TAddress extends string = string>(
address: Address<TAddress>,
config?: FetchAccountConfig
): Promise<AddressLookupTable<TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
const maybeAccount = await fetchMaybeAddressLookupTable(rpc, address, config);
assertAccountExists(maybeAccount);
return decodeAddressLookupTable(maybeAccount);
return maybeAccount;
}

export async function safeFetchAddressLookupTable<
export async function fetchMaybeAddressLookupTable<
TAddress extends string = string
>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig
): Promise<AddressLookupTable<TAddress> | null> {
): Promise<MaybeAddressLookupTable<TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return maybeAccount.exists ? decodeAddressLookupTable(maybeAccount) : null;
return decodeAddressLookupTable(maybeAccount);
}

export async function fetchAllAddressLookupTable(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig
): Promise<AddressLookupTable[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) => {
assertAccountExists(maybeAccount);
return decodeAddressLookupTable(maybeAccount);
});
const maybeAccounts = await fetchAllMaybeAddressLookupTable(
rpc,
addresses,
config
);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}

export async function safeFetchAllAddressLookupTable(
export async function fetchAllMaybeAddressLookupTable(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig
): Promise<AddressLookupTable[]> {
): Promise<MaybeAddressLookupTable[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts
.filter((maybeAccount) => maybeAccount.exists)
.map((maybeAccount) =>
decodeAddressLookupTable(maybeAccount as EncodedAccount)
);
return maybeAccounts.map((maybeAccount) =>
decodeAddressLookupTable(maybeAccount)
);
}

export async function fetchAddressLookupTableFromSeeds(
rpc: Parameters<typeof fetchEncodedAccount>[0],
seeds: AddressLookupTableSeeds,
config: FetchAccountConfig & { programAddress?: Address } = {}
): Promise<AddressLookupTable> {
const { programAddress, ...fetchConfig } = config;
const [address] = await findAddressLookupTablePda(seeds, { programAddress });
return fetchAddressLookupTable(rpc, address, fetchConfig);
const maybeAccount = await fetchMaybeAddressLookupTableFromSeeds(
rpc,
seeds,
config
);
assertAccountExists(maybeAccount);
return maybeAccount;
}

export async function safeFetchAddressLookupTableFromSeeds(
export async function fetchMaybeAddressLookupTableFromSeeds(
rpc: Parameters<typeof fetchEncodedAccount>[0],
seeds: AddressLookupTableSeeds,
config: FetchAccountConfig & { programAddress?: Address } = {}
): Promise<AddressLookupTable | null> {
): Promise<MaybeAddressLookupTable> {
const { programAddress, ...fetchConfig } = config;
const [address] = await findAddressLookupTablePda(seeds, { programAddress });
return safeFetchAddressLookupTable(rpc, address, fetchConfig);
return fetchMaybeAddressLookupTable(rpc, address, fetchConfig);
}
47 changes: 30 additions & 17 deletions clients/js/src/generated/accounts/nonce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {
EncodedAccount,
FetchAccountConfig,
FetchAccountsConfig,
MaybeAccount,
MaybeEncodedAccount,
assertAccountExists,
assertAccountsExist,
decodeAccount,
fetchEncodedAccount,
fetchEncodedAccounts,
Expand Down Expand Up @@ -43,6 +46,11 @@ export type Nonce<TAddress extends string = string> = Account<
TAddress
>;

export type MaybeNonce<TAddress extends string = string> = MaybeAccount<
NonceAccountData,
TAddress
>;

export type NonceAccountData = {
version: NonceVersion;
state: NonceState;
Expand Down Expand Up @@ -91,50 +99,55 @@ export function getNonceAccountDataCodec(): Codec<

export function decodeNonce<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress>
): Nonce<TAddress> {
return decodeAccount(encodedAccount, getNonceAccountDataDecoder());
): Nonce<TAddress>;
export function decodeNonce<TAddress extends string = string>(
encodedAccount: MaybeEncodedAccount<TAddress>
): MaybeNonce<TAddress>;
export function decodeNonce<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>
): Nonce<TAddress> | MaybeNonce<TAddress> {
return decodeAccount(
encodedAccount as MaybeEncodedAccount<TAddress>,
getNonceAccountDataDecoder()
);
}

export async function fetchNonce<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig
): Promise<Nonce<TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
const maybeAccount = await fetchMaybeNonce(rpc, address, config);
assertAccountExists(maybeAccount);
return decodeNonce(maybeAccount);
return maybeAccount;
}

export async function safeFetchNonce<TAddress extends string = string>(
export async function fetchMaybeNonce<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig
): Promise<Nonce<TAddress> | null> {
): Promise<MaybeNonce<TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return maybeAccount.exists ? decodeNonce(maybeAccount) : null;
return decodeNonce(maybeAccount);
}

export async function fetchAllNonce(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig
): Promise<Nonce[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) => {
assertAccountExists(maybeAccount);
return decodeNonce(maybeAccount);
});
const maybeAccounts = await fetchAllMaybeNonce(rpc, addresses, config);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}

export async function safeFetchAllNonce(
export async function fetchAllMaybeNonce(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig
): Promise<Nonce[]> {
): Promise<MaybeNonce[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts
.filter((maybeAccount) => maybeAccount.exists)
.map((maybeAccount) => decodeNonce(maybeAccount as EncodedAccount));
return maybeAccounts.map((maybeAccount) => decodeNonce(maybeAccount));
}

export function getNonceSize(): number {
Expand Down
1 change: 0 additions & 1 deletion clients/js/src/generated/instructions/addMemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
IInstructionWithAccounts,
IInstructionWithData,
} from '@solana/instructions';
import {} from '../shared';

export type AddMemoInstruction<
TProgram extends string = 'Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo',
Expand Down
1 change: 0 additions & 1 deletion clients/js/src/generated/instructions/requestHeapFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
IInstructionWithAccounts,
IInstructionWithData,
} from '@solana/instructions';
import {} from '../shared';

export type RequestHeapFrameInstruction<
TProgram extends string = 'ComputeBudget111111111111111111111111111111',
Expand Down
1 change: 0 additions & 1 deletion clients/js/src/generated/instructions/requestUnits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
IInstructionWithAccounts,
IInstructionWithData,
} from '@solana/instructions';
import {} from '../shared';

export type RequestUnitsInstruction<
TProgram extends string = 'ComputeBudget111111111111111111111111111111',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
IInstructionWithAccounts,
IInstructionWithData,
} from '@solana/instructions';
import {} from '../shared';

export type SetComputeUnitLimitInstruction<
TProgram extends string = 'ComputeBudget111111111111111111111111111111',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
IInstructionWithAccounts,
IInstructionWithData,
} from '@solana/instructions';
import {} from '../shared';

export type SetComputeUnitPriceInstruction<
TProgram extends string = 'ComputeBudget111111111111111111111111111111',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
IInstructionWithAccounts,
IInstructionWithData,
} from '@solana/instructions';
import {} from '../shared';

export type SetLoadedAccountsDataSizeLimitInstruction<
TProgram extends string = 'ComputeBudget111111111111111111111111111111',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"validator:stop": "amman stop"
},
"devDependencies": {
"@metaplex-foundation/kinobi": "^0.17.0",
"@metaplex-foundation/kinobi": "^0.17.1",
"@metaplex-foundation/amman": "^0.12.1",
"typescript": "^4.9.4"
},
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5637e52

Please sign in to comment.