Skip to content

Commit

Permalink
Update Kinobi
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva committed Dec 20, 2023
1 parent 6b6153c commit ad7ad96
Show file tree
Hide file tree
Showing 25 changed files with 372 additions and 203 deletions.
12 changes: 7 additions & 5 deletions clients/js/src/generated/instructions/addMemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ export function getAddMemoInstructionRaw<
} as AddMemoInstruction<TProgram, TRemainingAccounts>;
}

export type ParsedAddMemoInstruction = {
export type ParsedAddMemoInstruction<
TProgram extends string = 'Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo'
> = {
programAddress: Address<TProgram>;
data: AddMemoInstructionData;
};

export function parseAddMemoInstruction<
TProgram extends string = 'Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo'
>(
export function parseAddMemoInstruction<TProgram extends string>(
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
): ParsedAddMemoInstruction {
): ParsedAddMemoInstruction<TProgram> {
return {
programAddress: instruction.programAddress,
data: getAddMemoInstructionDataDecoder().decode(instruction.data),
};
}
28 changes: 18 additions & 10 deletions clients/js/src/generated/instructions/advanceNonceAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,31 +273,39 @@ export function getAdvanceNonceAccountInstructionRaw<
>;
}

export type ParsedAdvanceNonceAccountInstruction = {
export type ParsedAdvanceNonceAccountInstruction<
TProgram extends string = '11111111111111111111111111111111',
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[]
> = {
programAddress: Address<TProgram>;
accounts: {
nonceAccount: Address;
recentBlockhashesSysvar: Address;
nonceAuthority: Address;
nonceAccount: TAccountMetas[0];
recentBlockhashesSysvar: TAccountMetas[1];
nonceAuthority: TAccountMetas[2];
};
data: AdvanceNonceAccountInstructionData;
};

export function parseAdvanceNonceAccountInstruction<
TProgram extends string = '11111111111111111111111111111111'
TProgram extends string,
TAccountMetas extends readonly IAccountMeta[]
>(
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
): ParsedAdvanceNonceAccountInstruction {
if (!instruction.accounts || instruction.accounts.length < 3) {
instruction: IInstruction<TProgram> &
IInstructionWithAccounts<TAccountMetas> &
IInstructionWithData<Uint8Array>
): ParsedAdvanceNonceAccountInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 3) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
const { address } = instruction.accounts![accountIndex]!;
const accountMeta = instruction.accounts![accountIndex]!;
accountIndex += 1;
return address;
return accountMeta;
};
return {
programAddress: instruction.programAddress,
accounts: {
nonceAccount: getNextAccount(),
recentBlockhashesSysvar: getNextAccount(),
Expand Down
24 changes: 16 additions & 8 deletions clients/js/src/generated/instructions/allocate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,29 +182,37 @@ export function getAllocateInstructionRaw<
} as AllocateInstruction<TProgram, TAccountNewAccount, TRemainingAccounts>;
}

export type ParsedAllocateInstruction = {
export type ParsedAllocateInstruction<
TProgram extends string = '11111111111111111111111111111111',
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[]
> = {
programAddress: Address<TProgram>;
accounts: {
newAccount: Address;
newAccount: TAccountMetas[0];
};
data: AllocateInstructionData;
};

export function parseAllocateInstruction<
TProgram extends string = '11111111111111111111111111111111'
TProgram extends string,
TAccountMetas extends readonly IAccountMeta[]
>(
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
): ParsedAllocateInstruction {
if (!instruction.accounts || instruction.accounts.length < 1) {
instruction: IInstruction<TProgram> &
IInstructionWithAccounts<TAccountMetas> &
IInstructionWithData<Uint8Array>
): ParsedAllocateInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 1) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
const { address } = instruction.accounts![accountIndex]!;
const accountMeta = instruction.accounts![accountIndex]!;
accountIndex += 1;
return address;
return accountMeta;
};
return {
programAddress: instruction.programAddress,
accounts: {
newAccount: getNextAccount(),
},
Expand Down
26 changes: 17 additions & 9 deletions clients/js/src/generated/instructions/allocateWithSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,30 +264,38 @@ export function getAllocateWithSeedInstructionRaw<
>;
}

export type ParsedAllocateWithSeedInstruction = {
export type ParsedAllocateWithSeedInstruction<
TProgram extends string = '11111111111111111111111111111111',
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[]
> = {
programAddress: Address<TProgram>;
accounts: {
newAccount: Address;
baseAccount: Address;
newAccount: TAccountMetas[0];
baseAccount: TAccountMetas[1];
};
data: AllocateWithSeedInstructionData;
};

export function parseAllocateWithSeedInstruction<
TProgram extends string = '11111111111111111111111111111111'
TProgram extends string,
TAccountMetas extends readonly IAccountMeta[]
>(
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
): ParsedAllocateWithSeedInstruction {
if (!instruction.accounts || instruction.accounts.length < 2) {
instruction: IInstruction<TProgram> &
IInstructionWithAccounts<TAccountMetas> &
IInstructionWithData<Uint8Array>
): ParsedAllocateWithSeedInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 2) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
const { address } = instruction.accounts![accountIndex]!;
const accountMeta = instruction.accounts![accountIndex]!;
accountIndex += 1;
return address;
return accountMeta;
};
return {
programAddress: instruction.programAddress,
accounts: {
newAccount: getNextAccount(),
baseAccount: getNextAccount(),
Expand Down
24 changes: 16 additions & 8 deletions clients/js/src/generated/instructions/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,29 +184,37 @@ export function getAssignInstructionRaw<
} as AssignInstruction<TProgram, TAccountAccount, TRemainingAccounts>;
}

export type ParsedAssignInstruction = {
export type ParsedAssignInstruction<
TProgram extends string = '11111111111111111111111111111111',
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[]
> = {
programAddress: Address<TProgram>;
accounts: {
account: Address;
account: TAccountMetas[0];
};
data: AssignInstructionData;
};

export function parseAssignInstruction<
TProgram extends string = '11111111111111111111111111111111'
TProgram extends string,
TAccountMetas extends readonly IAccountMeta[]
>(
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
): ParsedAssignInstruction {
if (!instruction.accounts || instruction.accounts.length < 1) {
instruction: IInstruction<TProgram> &
IInstructionWithAccounts<TAccountMetas> &
IInstructionWithData<Uint8Array>
): ParsedAssignInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 1) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
const { address } = instruction.accounts![accountIndex]!;
const accountMeta = instruction.accounts![accountIndex]!;
accountIndex += 1;
return address;
return accountMeta;
};
return {
programAddress: instruction.programAddress,
accounts: {
account: getNextAccount(),
},
Expand Down
26 changes: 17 additions & 9 deletions clients/js/src/generated/instructions/assignWithSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,30 +245,38 @@ export function getAssignWithSeedInstructionRaw<
>;
}

export type ParsedAssignWithSeedInstruction = {
export type ParsedAssignWithSeedInstruction<
TProgram extends string = '11111111111111111111111111111111',
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[]
> = {
programAddress: Address<TProgram>;
accounts: {
account: Address;
baseAccount: Address;
account: TAccountMetas[0];
baseAccount: TAccountMetas[1];
};
data: AssignWithSeedInstructionData;
};

export function parseAssignWithSeedInstruction<
TProgram extends string = '11111111111111111111111111111111'
TProgram extends string,
TAccountMetas extends readonly IAccountMeta[]
>(
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
): ParsedAssignWithSeedInstruction {
if (!instruction.accounts || instruction.accounts.length < 2) {
instruction: IInstruction<TProgram> &
IInstructionWithAccounts<TAccountMetas> &
IInstructionWithData<Uint8Array>
): ParsedAssignWithSeedInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 2) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
const { address } = instruction.accounts![accountIndex]!;
const accountMeta = instruction.accounts![accountIndex]!;
accountIndex += 1;
return address;
return accountMeta;
};
return {
programAddress: instruction.programAddress,
accounts: {
account: getNextAccount(),
baseAccount: getNextAccount(),
Expand Down
26 changes: 17 additions & 9 deletions clients/js/src/generated/instructions/authorizeNonceAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,30 +243,38 @@ export function getAuthorizeNonceAccountInstructionRaw<
>;
}

export type ParsedAuthorizeNonceAccountInstruction = {
export type ParsedAuthorizeNonceAccountInstruction<
TProgram extends string = '11111111111111111111111111111111',
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[]
> = {
programAddress: Address<TProgram>;
accounts: {
nonceAccount: Address;
nonceAuthority: Address;
nonceAccount: TAccountMetas[0];
nonceAuthority: TAccountMetas[1];
};
data: AuthorizeNonceAccountInstructionData;
};

export function parseAuthorizeNonceAccountInstruction<
TProgram extends string = '11111111111111111111111111111111'
TProgram extends string,
TAccountMetas extends readonly IAccountMeta[]
>(
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
): ParsedAuthorizeNonceAccountInstruction {
if (!instruction.accounts || instruction.accounts.length < 2) {
instruction: IInstruction<TProgram> &
IInstructionWithAccounts<TAccountMetas> &
IInstructionWithData<Uint8Array>
): ParsedAuthorizeNonceAccountInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 2) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
const { address } = instruction.accounts![accountIndex]!;
const accountMeta = instruction.accounts![accountIndex]!;
accountIndex += 1;
return address;
return accountMeta;
};
return {
programAddress: instruction.programAddress,
accounts: {
nonceAccount: getNextAccount(),
nonceAuthority: getNextAccount(),
Expand Down
28 changes: 18 additions & 10 deletions clients/js/src/generated/instructions/closeLookupTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,31 +250,39 @@ export function getCloseLookupTableInstructionRaw<
>;
}

export type ParsedCloseLookupTableInstruction = {
export type ParsedCloseLookupTableInstruction<
TProgram extends string = 'AddressLookupTab1e1111111111111111111111111',
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[]
> = {
programAddress: Address<TProgram>;
accounts: {
address: Address;
authority: Address;
recipient: Address;
address: TAccountMetas[0];
authority: TAccountMetas[1];
recipient: TAccountMetas[2];
};
data: CloseLookupTableInstructionData;
};

export function parseCloseLookupTableInstruction<
TProgram extends string = 'AddressLookupTab1e1111111111111111111111111'
TProgram extends string,
TAccountMetas extends readonly IAccountMeta[]
>(
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
): ParsedCloseLookupTableInstruction {
if (!instruction.accounts || instruction.accounts.length < 3) {
instruction: IInstruction<TProgram> &
IInstructionWithAccounts<TAccountMetas> &
IInstructionWithData<Uint8Array>
): ParsedCloseLookupTableInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 3) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
const { address } = instruction.accounts![accountIndex]!;
const accountMeta = instruction.accounts![accountIndex]!;
accountIndex += 1;
return address;
return accountMeta;
};
return {
programAddress: instruction.programAddress,
accounts: {
address: getNextAccount(),
authority: getNextAccount(),
Expand Down
Loading

0 comments on commit ad7ad96

Please sign in to comment.