@@ -16,17 +16,18 @@ import {
1616 getU8Decoder ,
1717 getU8Encoder ,
1818 transformEncoder ,
19+ type AccountMeta ,
20+ type AccountSignerMeta ,
1921 type Address ,
20- type Codec ,
21- type Decoder ,
22- type Encoder ,
23- type IAccountMeta ,
24- type IAccountSignerMeta ,
25- type IInstruction ,
26- type IInstructionWithAccounts ,
27- type IInstructionWithData ,
22+ type FixedSizeCodec ,
23+ type FixedSizeDecoder ,
24+ type FixedSizeEncoder ,
25+ type Instruction ,
26+ type InstructionWithAccounts ,
27+ type InstructionWithData ,
2828 type ReadonlyAccount ,
2929 type ReadonlySignerAccount ,
30+ type ReadonlyUint8Array ,
3031 type TransactionSigner ,
3132 type WritableAccount ,
3233} from '@solana/kit' ;
@@ -41,13 +42,13 @@ export function getApproveDiscriminatorBytes() {
4142
4243export type ApproveInstruction <
4344 TProgram extends string = typeof TOKEN_PROGRAM_ADDRESS ,
44- TAccountSource extends string | IAccountMeta < string > = string ,
45- TAccountDelegate extends string | IAccountMeta < string > = string ,
46- TAccountOwner extends string | IAccountMeta < string > = string ,
47- TRemainingAccounts extends readonly IAccountMeta < string > [ ] = [ ] ,
48- > = IInstruction < TProgram > &
49- IInstructionWithData < Uint8Array > &
50- IInstructionWithAccounts <
45+ TAccountSource extends string | AccountMeta < string > = string ,
46+ TAccountDelegate extends string | AccountMeta < string > = string ,
47+ TAccountOwner extends string | AccountMeta < string > = string ,
48+ TRemainingAccounts extends readonly AccountMeta < string > [ ] = [ ] ,
49+ > = Instruction < TProgram > &
50+ InstructionWithData < ReadonlyUint8Array > &
51+ InstructionWithAccounts <
5152 [
5253 TAccountSource extends string
5354 ? WritableAccount < TAccountSource >
@@ -73,7 +74,7 @@ export type ApproveInstructionDataArgs = {
7374 amount : number | bigint ;
7475} ;
7576
76- export function getApproveInstructionDataEncoder ( ) : Encoder < ApproveInstructionDataArgs > {
77+ export function getApproveInstructionDataEncoder ( ) : FixedSizeEncoder < ApproveInstructionDataArgs > {
7778 return transformEncoder (
7879 getStructEncoder ( [
7980 [ 'discriminator' , getU8Encoder ( ) ] ,
@@ -83,14 +84,14 @@ export function getApproveInstructionDataEncoder(): Encoder<ApproveInstructionDa
8384 ) ;
8485}
8586
86- export function getApproveInstructionDataDecoder ( ) : Decoder < ApproveInstructionData > {
87+ export function getApproveInstructionDataDecoder ( ) : FixedSizeDecoder < ApproveInstructionData > {
8788 return getStructDecoder ( [
8889 [ 'discriminator' , getU8Decoder ( ) ] ,
8990 [ 'amount' , getU64Decoder ( ) ] ,
9091 ] ) ;
9192}
9293
93- export function getApproveInstructionDataCodec ( ) : Codec <
94+ export function getApproveInstructionDataCodec ( ) : FixedSizeCodec <
9495 ApproveInstructionDataArgs ,
9596 ApproveInstructionData
9697> {
@@ -128,7 +129,7 @@ export function getApproveInstruction<
128129 TAccountSource ,
129130 TAccountDelegate ,
130131 ( typeof input ) [ 'owner' ] extends TransactionSigner < TAccountOwner >
131- ? ReadonlySignerAccount < TAccountOwner > & IAccountSignerMeta < TAccountOwner >
132+ ? ReadonlySignerAccount < TAccountOwner > & AccountSignerMeta < TAccountOwner >
132133 : TAccountOwner
133134> {
134135 // Program address.
@@ -149,7 +150,7 @@ export function getApproveInstruction<
149150 const args = { ...input } ;
150151
151152 // Remaining accounts.
152- const remainingAccounts : IAccountMeta [ ] = ( args . multiSigners ?? [ ] ) . map (
153+ const remainingAccounts : AccountMeta [ ] = ( args . multiSigners ?? [ ] ) . map (
153154 ( signer ) => ( {
154155 address : signer . address ,
155156 role : AccountRole . READONLY_SIGNER ,
@@ -174,7 +175,7 @@ export function getApproveInstruction<
174175 TAccountSource ,
175176 TAccountDelegate ,
176177 ( typeof input ) [ 'owner' ] extends TransactionSigner < TAccountOwner >
177- ? ReadonlySignerAccount < TAccountOwner > & IAccountSignerMeta < TAccountOwner >
178+ ? ReadonlySignerAccount < TAccountOwner > & AccountSignerMeta < TAccountOwner >
178179 : TAccountOwner
179180 > ;
180181
@@ -183,7 +184,7 @@ export function getApproveInstruction<
183184
184185export type ParsedApproveInstruction <
185186 TProgram extends string = typeof TOKEN_PROGRAM_ADDRESS ,
186- TAccountMetas extends readonly IAccountMeta [ ] = readonly IAccountMeta [ ] ,
187+ TAccountMetas extends readonly AccountMeta [ ] = readonly AccountMeta [ ] ,
187188> = {
188189 programAddress : Address < TProgram > ;
189190 accounts : {
@@ -199,19 +200,19 @@ export type ParsedApproveInstruction<
199200
200201export function parseApproveInstruction <
201202 TProgram extends string ,
202- TAccountMetas extends readonly IAccountMeta [ ] ,
203+ TAccountMetas extends readonly AccountMeta [ ] ,
203204> (
204- instruction : IInstruction < TProgram > &
205- IInstructionWithAccounts < TAccountMetas > &
206- IInstructionWithData < Uint8Array >
205+ instruction : Instruction < TProgram > &
206+ InstructionWithAccounts < TAccountMetas > &
207+ InstructionWithData < ReadonlyUint8Array >
207208) : ParsedApproveInstruction < TProgram , TAccountMetas > {
208209 if ( instruction . accounts . length < 3 ) {
209210 // TODO: Coded error.
210211 throw new Error ( 'Not enough accounts' ) ;
211212 }
212213 let accountIndex = 0 ;
213214 const getNextAccount = ( ) => {
214- const accountMeta = instruction . accounts ! [ accountIndex ] ! ;
215+ const accountMeta = ( instruction . accounts as TAccountMetas ) [ accountIndex ] ! ;
215216 accountIndex += 1 ;
216217 return accountMeta ;
217218 } ;
0 commit comments