From ad7ad96397673a29bdb474ad7b48101556622a07 Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Wed, 20 Dec 2023 17:36:48 +0000 Subject: [PATCH] Update Kinobi --- .../js/src/generated/instructions/addMemo.ts | 12 ++++--- .../instructions/advanceNonceAccount.ts | 28 ++++++++++------ .../js/src/generated/instructions/allocate.ts | 24 +++++++++----- .../instructions/allocateWithSeed.ts | 26 +++++++++------ .../js/src/generated/instructions/assign.ts | 24 +++++++++----- .../generated/instructions/assignWithSeed.ts | 26 +++++++++------ .../instructions/authorizeNonceAccount.ts | 26 +++++++++------ .../instructions/closeLookupTable.ts | 28 ++++++++++------ .../generated/instructions/createAccount.ts | 26 +++++++++------ .../instructions/createAccountWithSeed.ts | 28 ++++++++++------ .../instructions/createLookupTable.ts | 30 ++++++++++------- .../instructions/deactivateLookupTable.ts | 26 +++++++++------ .../instructions/extendLookupTable.ts | 30 ++++++++++------- .../instructions/freezeLookupTable.ts | 26 +++++++++------ .../instructions/initializeNonceAccount.ts | 28 ++++++++++------ .../instructions/requestHeapFrame.ts | 12 ++++--- .../generated/instructions/requestUnits.ts | 12 ++++--- .../instructions/setComputeUnitLimit.ts | 12 ++++--- .../instructions/setComputeUnitPrice.ts | 12 ++++--- .../setLoadedAccountsDataSizeLimit.ts | 10 ++++-- .../src/generated/instructions/transferSol.ts | 26 +++++++++------ .../instructions/transferSolWithSeed.ts | 28 ++++++++++------ .../instructions/upgradeNonceAccount.ts | 24 +++++++++----- .../instructions/withdrawNonceAccount.ts | 32 ++++++++++++------- clients/js/test/transferSol.test.ts | 19 ++++++++--- 25 files changed, 372 insertions(+), 203 deletions(-) diff --git a/clients/js/src/generated/instructions/addMemo.ts b/clients/js/src/generated/instructions/addMemo.ts index a18f168..1602fd3 100644 --- a/clients/js/src/generated/instructions/addMemo.ts +++ b/clients/js/src/generated/instructions/addMemo.ts @@ -107,16 +107,18 @@ export function getAddMemoInstructionRaw< } as AddMemoInstruction; } -export type ParsedAddMemoInstruction = { +export type ParsedAddMemoInstruction< + TProgram extends string = 'Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo' +> = { + programAddress: Address; data: AddMemoInstructionData; }; -export function parseAddMemoInstruction< - TProgram extends string = 'Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo' ->( +export function parseAddMemoInstruction( instruction: IInstruction & IInstructionWithData -): ParsedAddMemoInstruction { +): ParsedAddMemoInstruction { return { + programAddress: instruction.programAddress, data: getAddMemoInstructionDataDecoder().decode(instruction.data), }; } diff --git a/clients/js/src/generated/instructions/advanceNonceAccount.ts b/clients/js/src/generated/instructions/advanceNonceAccount.ts index e275c82..654fbc1 100644 --- a/clients/js/src/generated/instructions/advanceNonceAccount.ts +++ b/clients/js/src/generated/instructions/advanceNonceAccount.ts @@ -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; 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 & IInstructionWithData -): ParsedAdvanceNonceAccountInstruction { - if (!instruction.accounts || instruction.accounts.length < 3) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedAdvanceNonceAccountInstruction { + 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(), diff --git a/clients/js/src/generated/instructions/allocate.ts b/clients/js/src/generated/instructions/allocate.ts index f252c49..16d21f9 100644 --- a/clients/js/src/generated/instructions/allocate.ts +++ b/clients/js/src/generated/instructions/allocate.ts @@ -182,29 +182,37 @@ export function getAllocateInstructionRaw< } as AllocateInstruction; } -export type ParsedAllocateInstruction = { +export type ParsedAllocateInstruction< + TProgram extends string = '11111111111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - newAccount: Address; + newAccount: TAccountMetas[0]; }; data: AllocateInstructionData; }; export function parseAllocateInstruction< - TProgram extends string = '11111111111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedAllocateInstruction { - if (!instruction.accounts || instruction.accounts.length < 1) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedAllocateInstruction { + 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(), }, diff --git a/clients/js/src/generated/instructions/allocateWithSeed.ts b/clients/js/src/generated/instructions/allocateWithSeed.ts index 48c85a3..487fb1e 100644 --- a/clients/js/src/generated/instructions/allocateWithSeed.ts +++ b/clients/js/src/generated/instructions/allocateWithSeed.ts @@ -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; 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 & IInstructionWithData -): ParsedAllocateWithSeedInstruction { - if (!instruction.accounts || instruction.accounts.length < 2) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedAllocateWithSeedInstruction { + 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(), diff --git a/clients/js/src/generated/instructions/assign.ts b/clients/js/src/generated/instructions/assign.ts index b73808b..8b6a54f 100644 --- a/clients/js/src/generated/instructions/assign.ts +++ b/clients/js/src/generated/instructions/assign.ts @@ -184,29 +184,37 @@ export function getAssignInstructionRaw< } as AssignInstruction; } -export type ParsedAssignInstruction = { +export type ParsedAssignInstruction< + TProgram extends string = '11111111111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - account: Address; + account: TAccountMetas[0]; }; data: AssignInstructionData; }; export function parseAssignInstruction< - TProgram extends string = '11111111111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedAssignInstruction { - if (!instruction.accounts || instruction.accounts.length < 1) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedAssignInstruction { + 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(), }, diff --git a/clients/js/src/generated/instructions/assignWithSeed.ts b/clients/js/src/generated/instructions/assignWithSeed.ts index 8ecda55..e43866a 100644 --- a/clients/js/src/generated/instructions/assignWithSeed.ts +++ b/clients/js/src/generated/instructions/assignWithSeed.ts @@ -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; 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 & IInstructionWithData -): ParsedAssignWithSeedInstruction { - if (!instruction.accounts || instruction.accounts.length < 2) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedAssignWithSeedInstruction { + 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(), diff --git a/clients/js/src/generated/instructions/authorizeNonceAccount.ts b/clients/js/src/generated/instructions/authorizeNonceAccount.ts index a6ee5fb..382118a 100644 --- a/clients/js/src/generated/instructions/authorizeNonceAccount.ts +++ b/clients/js/src/generated/instructions/authorizeNonceAccount.ts @@ -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; 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 & IInstructionWithData -): ParsedAuthorizeNonceAccountInstruction { - if (!instruction.accounts || instruction.accounts.length < 2) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedAuthorizeNonceAccountInstruction { + 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(), diff --git a/clients/js/src/generated/instructions/closeLookupTable.ts b/clients/js/src/generated/instructions/closeLookupTable.ts index 59fe95c..08e19a0 100644 --- a/clients/js/src/generated/instructions/closeLookupTable.ts +++ b/clients/js/src/generated/instructions/closeLookupTable.ts @@ -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; 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 & IInstructionWithData -): ParsedCloseLookupTableInstruction { - if (!instruction.accounts || instruction.accounts.length < 3) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedCloseLookupTableInstruction { + 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(), diff --git a/clients/js/src/generated/instructions/createAccount.ts b/clients/js/src/generated/instructions/createAccount.ts index 616508f..3122c89 100644 --- a/clients/js/src/generated/instructions/createAccount.ts +++ b/clients/js/src/generated/instructions/createAccount.ts @@ -256,30 +256,38 @@ export function getCreateAccountInstructionRaw< >; } -export type ParsedCreateAccountInstruction = { +export type ParsedCreateAccountInstruction< + TProgram extends string = '11111111111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - payer: Address; - newAccount: Address; + payer: TAccountMetas[0]; + newAccount: TAccountMetas[1]; }; data: CreateAccountInstructionData; }; export function parseCreateAccountInstruction< - TProgram extends string = '11111111111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedCreateAccountInstruction { - if (!instruction.accounts || instruction.accounts.length < 2) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedCreateAccountInstruction { + 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: { payer: getNextAccount(), newAccount: getNextAccount(), diff --git a/clients/js/src/generated/instructions/createAccountWithSeed.ts b/clients/js/src/generated/instructions/createAccountWithSeed.ts index aebcd38..c9a40a4 100644 --- a/clients/js/src/generated/instructions/createAccountWithSeed.ts +++ b/clients/js/src/generated/instructions/createAccountWithSeed.ts @@ -307,31 +307,39 @@ export function getCreateAccountWithSeedInstructionRaw< >; } -export type ParsedCreateAccountWithSeedInstruction = { +export type ParsedCreateAccountWithSeedInstruction< + TProgram extends string = '11111111111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - payer: Address; - newAccount: Address; - baseAccount: Address; + payer: TAccountMetas[0]; + newAccount: TAccountMetas[1]; + baseAccount: TAccountMetas[2]; }; data: CreateAccountWithSeedInstructionData; }; export function parseCreateAccountWithSeedInstruction< - TProgram extends string = '11111111111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedCreateAccountWithSeedInstruction { - if (!instruction.accounts || instruction.accounts.length < 3) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedCreateAccountWithSeedInstruction { + 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: { payer: getNextAccount(), newAccount: getNextAccount(), diff --git a/clients/js/src/generated/instructions/createLookupTable.ts b/clients/js/src/generated/instructions/createLookupTable.ts index 5e7b043..0372383 100644 --- a/clients/js/src/generated/instructions/createLookupTable.ts +++ b/clients/js/src/generated/instructions/createLookupTable.ts @@ -493,32 +493,40 @@ export function getCreateLookupTableInstructionRaw< >; } -export type ParsedCreateLookupTableInstruction = { +export type ParsedCreateLookupTableInstruction< + TProgram extends string = 'AddressLookupTab1e1111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - address: Address; - authority: Address; - payer: Address; - systemProgram: Address; + address: TAccountMetas[0]; + authority: TAccountMetas[1]; + payer: TAccountMetas[2]; + systemProgram: TAccountMetas[3]; }; data: CreateLookupTableInstructionData; }; export function parseCreateLookupTableInstruction< - TProgram extends string = 'AddressLookupTab1e1111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedCreateLookupTableInstruction { - if (!instruction.accounts || instruction.accounts.length < 4) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedCreateLookupTableInstruction { + if (instruction.accounts.length < 4) { // 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(), diff --git a/clients/js/src/generated/instructions/deactivateLookupTable.ts b/clients/js/src/generated/instructions/deactivateLookupTable.ts index ae840b8..c39dfe9 100644 --- a/clients/js/src/generated/instructions/deactivateLookupTable.ts +++ b/clients/js/src/generated/instructions/deactivateLookupTable.ts @@ -216,30 +216,38 @@ export function getDeactivateLookupTableInstructionRaw< >; } -export type ParsedDeactivateLookupTableInstruction = { +export type ParsedDeactivateLookupTableInstruction< + TProgram extends string = 'AddressLookupTab1e1111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - address: Address; - authority: Address; + address: TAccountMetas[0]; + authority: TAccountMetas[1]; }; data: DeactivateLookupTableInstructionData; }; export function parseDeactivateLookupTableInstruction< - TProgram extends string = 'AddressLookupTab1e1111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedDeactivateLookupTableInstruction { - if (!instruction.accounts || instruction.accounts.length < 2) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedDeactivateLookupTableInstruction { + 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: { address: getNextAccount(), authority: getNextAccount(), diff --git a/clients/js/src/generated/instructions/extendLookupTable.ts b/clients/js/src/generated/instructions/extendLookupTable.ts index 6c709eb..a8f3d8c 100644 --- a/clients/js/src/generated/instructions/extendLookupTable.ts +++ b/clients/js/src/generated/instructions/extendLookupTable.ts @@ -342,32 +342,40 @@ export function getExtendLookupTableInstructionRaw< >; } -export type ParsedExtendLookupTableInstruction = { +export type ParsedExtendLookupTableInstruction< + TProgram extends string = 'AddressLookupTab1e1111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - address: Address; - authority: Address; - payer: Address; - systemProgram: Address; + address: TAccountMetas[0]; + authority: TAccountMetas[1]; + payer: TAccountMetas[2]; + systemProgram: TAccountMetas[3]; }; data: ExtendLookupTableInstructionData; }; export function parseExtendLookupTableInstruction< - TProgram extends string = 'AddressLookupTab1e1111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedExtendLookupTableInstruction { - if (!instruction.accounts || instruction.accounts.length < 4) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedExtendLookupTableInstruction { + if (instruction.accounts.length < 4) { // 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(), diff --git a/clients/js/src/generated/instructions/freezeLookupTable.ts b/clients/js/src/generated/instructions/freezeLookupTable.ts index 5ff811c..62abd91 100644 --- a/clients/js/src/generated/instructions/freezeLookupTable.ts +++ b/clients/js/src/generated/instructions/freezeLookupTable.ts @@ -209,30 +209,38 @@ export function getFreezeLookupTableInstructionRaw< >; } -export type ParsedFreezeLookupTableInstruction = { +export type ParsedFreezeLookupTableInstruction< + TProgram extends string = 'AddressLookupTab1e1111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - address: Address; - authority: Address; + address: TAccountMetas[0]; + authority: TAccountMetas[1]; }; data: FreezeLookupTableInstructionData; }; export function parseFreezeLookupTableInstruction< - TProgram extends string = 'AddressLookupTab1e1111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedFreezeLookupTableInstruction { - if (!instruction.accounts || instruction.accounts.length < 2) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedFreezeLookupTableInstruction { + 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: { address: getNextAccount(), authority: getNextAccount(), diff --git a/clients/js/src/generated/instructions/initializeNonceAccount.ts b/clients/js/src/generated/instructions/initializeNonceAccount.ts index 055a78b..6ce5c58 100644 --- a/clients/js/src/generated/instructions/initializeNonceAccount.ts +++ b/clients/js/src/generated/instructions/initializeNonceAccount.ts @@ -298,31 +298,39 @@ export function getInitializeNonceAccountInstructionRaw< >; } -export type ParsedInitializeNonceAccountInstruction = { +export type ParsedInitializeNonceAccountInstruction< + TProgram extends string = '11111111111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - nonceAccount: Address; - recentBlockhashesSysvar: Address; - rentSysvar: Address; + nonceAccount: TAccountMetas[0]; + recentBlockhashesSysvar: TAccountMetas[1]; + rentSysvar: TAccountMetas[2]; }; data: InitializeNonceAccountInstructionData; }; export function parseInitializeNonceAccountInstruction< - TProgram extends string = '11111111111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedInitializeNonceAccountInstruction { - if (!instruction.accounts || instruction.accounts.length < 3) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedInitializeNonceAccountInstruction { + 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(), diff --git a/clients/js/src/generated/instructions/requestHeapFrame.ts b/clients/js/src/generated/instructions/requestHeapFrame.ts index 81d818b..a1c2ec9 100644 --- a/clients/js/src/generated/instructions/requestHeapFrame.ts +++ b/clients/js/src/generated/instructions/requestHeapFrame.ts @@ -145,16 +145,18 @@ export function getRequestHeapFrameInstructionRaw< } as RequestHeapFrameInstruction; } -export type ParsedRequestHeapFrameInstruction = { +export type ParsedRequestHeapFrameInstruction< + TProgram extends string = 'ComputeBudget111111111111111111111111111111' +> = { + programAddress: Address; data: RequestHeapFrameInstructionData; }; -export function parseRequestHeapFrameInstruction< - TProgram extends string = 'ComputeBudget111111111111111111111111111111' ->( +export function parseRequestHeapFrameInstruction( instruction: IInstruction & IInstructionWithData -): ParsedRequestHeapFrameInstruction { +): ParsedRequestHeapFrameInstruction { return { + programAddress: instruction.programAddress, data: getRequestHeapFrameInstructionDataDecoder().decode(instruction.data), }; } diff --git a/clients/js/src/generated/instructions/requestUnits.ts b/clients/js/src/generated/instructions/requestUnits.ts index b34ec33..ef79e5e 100644 --- a/clients/js/src/generated/instructions/requestUnits.ts +++ b/clients/js/src/generated/instructions/requestUnits.ts @@ -146,16 +146,18 @@ export function getRequestUnitsInstructionRaw< } as RequestUnitsInstruction; } -export type ParsedRequestUnitsInstruction = { +export type ParsedRequestUnitsInstruction< + TProgram extends string = 'ComputeBudget111111111111111111111111111111' +> = { + programAddress: Address; data: RequestUnitsInstructionData; }; -export function parseRequestUnitsInstruction< - TProgram extends string = 'ComputeBudget111111111111111111111111111111' ->( +export function parseRequestUnitsInstruction( instruction: IInstruction & IInstructionWithData -): ParsedRequestUnitsInstruction { +): ParsedRequestUnitsInstruction { return { + programAddress: instruction.programAddress, data: getRequestUnitsInstructionDataDecoder().decode(instruction.data), }; } diff --git a/clients/js/src/generated/instructions/setComputeUnitLimit.ts b/clients/js/src/generated/instructions/setComputeUnitLimit.ts index 233a487..e903ae8 100644 --- a/clients/js/src/generated/instructions/setComputeUnitLimit.ts +++ b/clients/js/src/generated/instructions/setComputeUnitLimit.ts @@ -136,16 +136,18 @@ export function getSetComputeUnitLimitInstructionRaw< } as SetComputeUnitLimitInstruction; } -export type ParsedSetComputeUnitLimitInstruction = { +export type ParsedSetComputeUnitLimitInstruction< + TProgram extends string = 'ComputeBudget111111111111111111111111111111' +> = { + programAddress: Address; data: SetComputeUnitLimitInstructionData; }; -export function parseSetComputeUnitLimitInstruction< - TProgram extends string = 'ComputeBudget111111111111111111111111111111' ->( +export function parseSetComputeUnitLimitInstruction( instruction: IInstruction & IInstructionWithData -): ParsedSetComputeUnitLimitInstruction { +): ParsedSetComputeUnitLimitInstruction { return { + programAddress: instruction.programAddress, data: getSetComputeUnitLimitInstructionDataDecoder().decode( instruction.data ), diff --git a/clients/js/src/generated/instructions/setComputeUnitPrice.ts b/clients/js/src/generated/instructions/setComputeUnitPrice.ts index 793dbb2..80184b1 100644 --- a/clients/js/src/generated/instructions/setComputeUnitPrice.ts +++ b/clients/js/src/generated/instructions/setComputeUnitPrice.ts @@ -136,16 +136,18 @@ export function getSetComputeUnitPriceInstructionRaw< } as SetComputeUnitPriceInstruction; } -export type ParsedSetComputeUnitPriceInstruction = { +export type ParsedSetComputeUnitPriceInstruction< + TProgram extends string = 'ComputeBudget111111111111111111111111111111' +> = { + programAddress: Address; data: SetComputeUnitPriceInstructionData; }; -export function parseSetComputeUnitPriceInstruction< - TProgram extends string = 'ComputeBudget111111111111111111111111111111' ->( +export function parseSetComputeUnitPriceInstruction( instruction: IInstruction & IInstructionWithData -): ParsedSetComputeUnitPriceInstruction { +): ParsedSetComputeUnitPriceInstruction { return { + programAddress: instruction.programAddress, data: getSetComputeUnitPriceInstructionDataDecoder().decode( instruction.data ), diff --git a/clients/js/src/generated/instructions/setLoadedAccountsDataSizeLimit.ts b/clients/js/src/generated/instructions/setLoadedAccountsDataSizeLimit.ts index 626b0af..2fb4588 100644 --- a/clients/js/src/generated/instructions/setLoadedAccountsDataSizeLimit.ts +++ b/clients/js/src/generated/instructions/setLoadedAccountsDataSizeLimit.ts @@ -134,16 +134,20 @@ export function getSetLoadedAccountsDataSizeLimitInstructionRaw< } as SetLoadedAccountsDataSizeLimitInstruction; } -export type ParsedSetLoadedAccountsDataSizeLimitInstruction = { +export type ParsedSetLoadedAccountsDataSizeLimitInstruction< + TProgram extends string = 'ComputeBudget111111111111111111111111111111' +> = { + programAddress: Address; data: SetLoadedAccountsDataSizeLimitInstructionData; }; export function parseSetLoadedAccountsDataSizeLimitInstruction< - TProgram extends string = 'ComputeBudget111111111111111111111111111111' + TProgram extends string >( instruction: IInstruction & IInstructionWithData -): ParsedSetLoadedAccountsDataSizeLimitInstruction { +): ParsedSetLoadedAccountsDataSizeLimitInstruction { return { + programAddress: instruction.programAddress, data: getSetLoadedAccountsDataSizeLimitInstructionDataDecoder().decode( instruction.data ), diff --git a/clients/js/src/generated/instructions/transferSol.ts b/clients/js/src/generated/instructions/transferSol.ts index 62b8b2b..ceb5a61 100644 --- a/clients/js/src/generated/instructions/transferSol.ts +++ b/clients/js/src/generated/instructions/transferSol.ts @@ -224,30 +224,38 @@ export function getTransferSolInstructionRaw< >; } -export type ParsedTransferSolInstruction = { +export type ParsedTransferSolInstruction< + TProgram extends string = '11111111111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - source: Address; - destination: Address; + source: TAccountMetas[0]; + destination: TAccountMetas[1]; }; data: TransferSolInstructionData; }; export function parseTransferSolInstruction< - TProgram extends string = '11111111111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedTransferSolInstruction { - if (!instruction.accounts || instruction.accounts.length < 2) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedTransferSolInstruction { + 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: { source: getNextAccount(), destination: getNextAccount(), diff --git a/clients/js/src/generated/instructions/transferSolWithSeed.ts b/clients/js/src/generated/instructions/transferSolWithSeed.ts index 56c9643..3ea8010 100644 --- a/clients/js/src/generated/instructions/transferSolWithSeed.ts +++ b/clients/js/src/generated/instructions/transferSolWithSeed.ts @@ -291,31 +291,39 @@ export function getTransferSolWithSeedInstructionRaw< >; } -export type ParsedTransferSolWithSeedInstruction = { +export type ParsedTransferSolWithSeedInstruction< + TProgram extends string = '11111111111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - source: Address; - baseAccount: Address; - destination: Address; + source: TAccountMetas[0]; + baseAccount: TAccountMetas[1]; + destination: TAccountMetas[2]; }; data: TransferSolWithSeedInstructionData; }; export function parseTransferSolWithSeedInstruction< - TProgram extends string = '11111111111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedTransferSolWithSeedInstruction { - if (!instruction.accounts || instruction.accounts.length < 3) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedTransferSolWithSeedInstruction { + 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: { source: getNextAccount(), baseAccount: getNextAccount(), diff --git a/clients/js/src/generated/instructions/upgradeNonceAccount.ts b/clients/js/src/generated/instructions/upgradeNonceAccount.ts index bdc88d2..2c8950c 100644 --- a/clients/js/src/generated/instructions/upgradeNonceAccount.ts +++ b/clients/js/src/generated/instructions/upgradeNonceAccount.ts @@ -172,29 +172,37 @@ export function getUpgradeNonceAccountInstructionRaw< >; } -export type ParsedUpgradeNonceAccountInstruction = { +export type ParsedUpgradeNonceAccountInstruction< + TProgram extends string = '11111111111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - nonceAccount: Address; + nonceAccount: TAccountMetas[0]; }; data: UpgradeNonceAccountInstructionData; }; export function parseUpgradeNonceAccountInstruction< - TProgram extends string = '11111111111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedUpgradeNonceAccountInstruction { - if (!instruction.accounts || instruction.accounts.length < 1) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedUpgradeNonceAccountInstruction { + 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: { nonceAccount: getNextAccount(), }, diff --git a/clients/js/src/generated/instructions/withdrawNonceAccount.ts b/clients/js/src/generated/instructions/withdrawNonceAccount.ts index aa55b8c..de8a6f3 100644 --- a/clients/js/src/generated/instructions/withdrawNonceAccount.ts +++ b/clients/js/src/generated/instructions/withdrawNonceAccount.ts @@ -367,33 +367,41 @@ export function getWithdrawNonceAccountInstructionRaw< >; } -export type ParsedWithdrawNonceAccountInstruction = { +export type ParsedWithdrawNonceAccountInstruction< + TProgram extends string = '11111111111111111111111111111111', + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[] +> = { + programAddress: Address; accounts: { - nonceAccount: Address; - recipientAccount: Address; - recentBlockhashesSysvar: Address; - rentSysvar: Address; - nonceAuthority: Address; + nonceAccount: TAccountMetas[0]; + recipientAccount: TAccountMetas[1]; + recentBlockhashesSysvar: TAccountMetas[2]; + rentSysvar: TAccountMetas[3]; + nonceAuthority: TAccountMetas[4]; }; data: WithdrawNonceAccountInstructionData; }; export function parseWithdrawNonceAccountInstruction< - TProgram extends string = '11111111111111111111111111111111' + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[] >( - instruction: IInstruction & IInstructionWithData -): ParsedWithdrawNonceAccountInstruction { - if (!instruction.accounts || instruction.accounts.length < 5) { + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedWithdrawNonceAccountInstruction { + if (instruction.accounts.length < 5) { // 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(), recipientAccount: getNextAccount(), diff --git a/clients/js/test/transferSol.test.ts b/clients/js/test/transferSol.test.ts index eaca061..b0dc9b5 100644 --- a/clients/js/test/transferSol.test.ts +++ b/clients/js/test/transferSol.test.ts @@ -1,7 +1,11 @@ import { pipe } from '@solana/functional'; import { lamports } from '@solana/rpc-types'; import { generateKeyPairSigner } from '@solana/signers'; -import { appendTransactionInstruction } from '@solana/web3.js'; +import { + AccountRole, + Address, + appendTransactionInstruction, +} from '@solana/web3.js'; import test from 'ava'; import { getTransferSolInstruction, parseTransferSolInstruction } from '../src'; import { @@ -41,7 +45,7 @@ test('it can transfer SOL from one account to another', async (t) => { test('it can parse the accounts and data of an existing transfer SOL instruction', async (t) => { // Given a transfer SOL instruction with the following accounts and data. - const source = (await generateKeyPairSigner()).address; + const source = await generateKeyPairSigner(); const destination = (await generateKeyPairSigner()).address; const transferSol = getTransferSolInstruction({ source, @@ -53,7 +57,14 @@ test('it can parse the accounts and data of an existing transfer SOL instruction const parsedTransferSol = parseTransferSolInstruction(transferSol); // Then we expect the following accounts and data. - t.is(parsedTransferSol.accounts.source, source); - t.is(parsedTransferSol.accounts.destination, destination); + t.is(parsedTransferSol.accounts.source.address, source.address); + t.is(parsedTransferSol.accounts.source.role, AccountRole.WRITABLE_SIGNER); + t.is(parsedTransferSol.accounts.source.signer, source); + t.is(parsedTransferSol.accounts.destination.address, destination); + t.is(parsedTransferSol.accounts.destination.role, AccountRole.WRITABLE); t.is(parsedTransferSol.data.amount, 1_000_000_000n); + t.is( + parsedTransferSol.programAddress, + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'> + ); });