@@ -10,6 +10,8 @@ import {
1010 combineCodec ,
1111 getStructDecoder ,
1212 getStructEncoder ,
13+ getU128Decoder ,
14+ getU128Encoder ,
1315 getU64Decoder ,
1416 getU64Encoder ,
1517 getU8Decoder ,
@@ -32,17 +34,18 @@ import {
3234import { JITO_TIP_ROUTER_PROGRAM_ADDRESS } from '../programs' ;
3335import { getAccountMetaFactory , type ResolvedAccount } from '../shared' ;
3436
35- export const FINALIZE_WEIGHT_TABLE_DISCRIMINATOR = 3 ;
37+ export const ADMIN_UPDATE_WEIGHT_TABLE_DISCRIMINATOR = 4 ;
3638
37- export function getFinalizeWeightTableDiscriminatorBytes ( ) {
38- return getU8Encoder ( ) . encode ( FINALIZE_WEIGHT_TABLE_DISCRIMINATOR ) ;
39+ export function getAdminUpdateWeightTableDiscriminatorBytes ( ) {
40+ return getU8Encoder ( ) . encode ( ADMIN_UPDATE_WEIGHT_TABLE_DISCRIMINATOR ) ;
3941}
4042
41- export type FinalizeWeightTableInstruction <
43+ export type AdminUpdateWeightTableInstruction <
4244 TProgram extends string = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS ,
4345 TAccountNcn extends string | IAccountMeta < string > = string ,
4446 TAccountWeightTable extends string | IAccountMeta < string > = string ,
4547 TAccountWeightTableAdmin extends string | IAccountMeta < string > = string ,
48+ TAccountMint extends string | IAccountMeta < string > = string ,
4649 TAccountRestakingProgramId extends string | IAccountMeta < string > = string ,
4750 TRemainingAccounts extends readonly IAccountMeta < string > [ ] = [ ] ,
4851> = IInstruction < TProgram > &
@@ -57,84 +60,97 @@ export type FinalizeWeightTableInstruction<
5760 ? ReadonlySignerAccount < TAccountWeightTableAdmin > &
5861 IAccountSignerMeta < TAccountWeightTableAdmin >
5962 : TAccountWeightTableAdmin ,
63+ TAccountMint extends string
64+ ? ReadonlyAccount < TAccountMint >
65+ : TAccountMint ,
6066 TAccountRestakingProgramId extends string
6167 ? ReadonlyAccount < TAccountRestakingProgramId >
6268 : TAccountRestakingProgramId ,
6369 ...TRemainingAccounts ,
6470 ]
6571 > ;
6672
67- export type FinalizeWeightTableInstructionData = {
73+ export type AdminUpdateWeightTableInstructionData = {
6874 discriminator : number ;
6975 ncnEpoch : bigint ;
76+ weight : bigint ;
7077} ;
7178
72- export type FinalizeWeightTableInstructionDataArgs = {
79+ export type AdminUpdateWeightTableInstructionDataArgs = {
7380 ncnEpoch : number | bigint ;
81+ weight : number | bigint ;
7482} ;
7583
76- export function getFinalizeWeightTableInstructionDataEncoder ( ) : Encoder < FinalizeWeightTableInstructionDataArgs > {
84+ export function getAdminUpdateWeightTableInstructionDataEncoder ( ) : Encoder < AdminUpdateWeightTableInstructionDataArgs > {
7785 return transformEncoder (
7886 getStructEncoder ( [
7987 [ 'discriminator' , getU8Encoder ( ) ] ,
8088 [ 'ncnEpoch' , getU64Encoder ( ) ] ,
89+ [ 'weight' , getU128Encoder ( ) ] ,
8190 ] ) ,
8291 ( value ) => ( {
8392 ...value ,
84- discriminator : FINALIZE_WEIGHT_TABLE_DISCRIMINATOR ,
93+ discriminator : ADMIN_UPDATE_WEIGHT_TABLE_DISCRIMINATOR ,
8594 } )
8695 ) ;
8796}
8897
89- export function getFinalizeWeightTableInstructionDataDecoder ( ) : Decoder < FinalizeWeightTableInstructionData > {
98+ export function getAdminUpdateWeightTableInstructionDataDecoder ( ) : Decoder < AdminUpdateWeightTableInstructionData > {
9099 return getStructDecoder ( [
91100 [ 'discriminator' , getU8Decoder ( ) ] ,
92101 [ 'ncnEpoch' , getU64Decoder ( ) ] ,
102+ [ 'weight' , getU128Decoder ( ) ] ,
93103 ] ) ;
94104}
95105
96- export function getFinalizeWeightTableInstructionDataCodec ( ) : Codec <
97- FinalizeWeightTableInstructionDataArgs ,
98- FinalizeWeightTableInstructionData
106+ export function getAdminUpdateWeightTableInstructionDataCodec ( ) : Codec <
107+ AdminUpdateWeightTableInstructionDataArgs ,
108+ AdminUpdateWeightTableInstructionData
99109> {
100110 return combineCodec (
101- getFinalizeWeightTableInstructionDataEncoder ( ) ,
102- getFinalizeWeightTableInstructionDataDecoder ( )
111+ getAdminUpdateWeightTableInstructionDataEncoder ( ) ,
112+ getAdminUpdateWeightTableInstructionDataDecoder ( )
103113 ) ;
104114}
105115
106- export type FinalizeWeightTableInput <
116+ export type AdminUpdateWeightTableInput <
107117 TAccountNcn extends string = string ,
108118 TAccountWeightTable extends string = string ,
109119 TAccountWeightTableAdmin extends string = string ,
120+ TAccountMint extends string = string ,
110121 TAccountRestakingProgramId extends string = string ,
111122> = {
112123 ncn : Address < TAccountNcn > ;
113124 weightTable : Address < TAccountWeightTable > ;
114125 weightTableAdmin : TransactionSigner < TAccountWeightTableAdmin > ;
126+ mint : Address < TAccountMint > ;
115127 restakingProgramId : Address < TAccountRestakingProgramId > ;
116- ncnEpoch : FinalizeWeightTableInstructionDataArgs [ 'ncnEpoch' ] ;
128+ ncnEpoch : AdminUpdateWeightTableInstructionDataArgs [ 'ncnEpoch' ] ;
129+ weight : AdminUpdateWeightTableInstructionDataArgs [ 'weight' ] ;
117130} ;
118131
119- export function getFinalizeWeightTableInstruction <
132+ export function getAdminUpdateWeightTableInstruction <
120133 TAccountNcn extends string ,
121134 TAccountWeightTable extends string ,
122135 TAccountWeightTableAdmin extends string ,
136+ TAccountMint extends string ,
123137 TAccountRestakingProgramId extends string ,
124138 TProgramAddress extends Address = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS ,
125139> (
126- input : FinalizeWeightTableInput <
140+ input : AdminUpdateWeightTableInput <
127141 TAccountNcn ,
128142 TAccountWeightTable ,
129143 TAccountWeightTableAdmin ,
144+ TAccountMint ,
130145 TAccountRestakingProgramId
131146 > ,
132147 config ?: { programAddress ?: TProgramAddress }
133- ) : FinalizeWeightTableInstruction <
148+ ) : AdminUpdateWeightTableInstruction <
134149 TProgramAddress ,
135150 TAccountNcn ,
136151 TAccountWeightTable ,
137152 TAccountWeightTableAdmin ,
153+ TAccountMint ,
138154 TAccountRestakingProgramId
139155> {
140156 // Program address.
@@ -149,6 +165,7 @@ export function getFinalizeWeightTableInstruction<
149165 value : input . weightTableAdmin ?? null ,
150166 isWritable : false ,
151167 } ,
168+ mint : { value : input . mint ?? null , isWritable : false } ,
152169 restakingProgramId : {
153170 value : input . restakingProgramId ?? null ,
154171 isWritable : false ,
@@ -168,24 +185,26 @@ export function getFinalizeWeightTableInstruction<
168185 getAccountMeta ( accounts . ncn ) ,
169186 getAccountMeta ( accounts . weightTable ) ,
170187 getAccountMeta ( accounts . weightTableAdmin ) ,
188+ getAccountMeta ( accounts . mint ) ,
171189 getAccountMeta ( accounts . restakingProgramId ) ,
172190 ] ,
173191 programAddress,
174- data : getFinalizeWeightTableInstructionDataEncoder ( ) . encode (
175- args as FinalizeWeightTableInstructionDataArgs
192+ data : getAdminUpdateWeightTableInstructionDataEncoder ( ) . encode (
193+ args as AdminUpdateWeightTableInstructionDataArgs
176194 ) ,
177- } as FinalizeWeightTableInstruction <
195+ } as AdminUpdateWeightTableInstruction <
178196 TProgramAddress ,
179197 TAccountNcn ,
180198 TAccountWeightTable ,
181199 TAccountWeightTableAdmin ,
200+ TAccountMint ,
182201 TAccountRestakingProgramId
183202 > ;
184203
185204 return instruction ;
186205}
187206
188- export type ParsedFinalizeWeightTableInstruction <
207+ export type ParsedAdminUpdateWeightTableInstruction <
189208 TProgram extends string = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS ,
190209 TAccountMetas extends readonly IAccountMeta [ ] = readonly IAccountMeta [ ] ,
191210> = {
@@ -194,20 +213,21 @@ export type ParsedFinalizeWeightTableInstruction<
194213 ncn : TAccountMetas [ 0 ] ;
195214 weightTable : TAccountMetas [ 1 ] ;
196215 weightTableAdmin : TAccountMetas [ 2 ] ;
197- restakingProgramId : TAccountMetas [ 3 ] ;
216+ mint : TAccountMetas [ 3 ] ;
217+ restakingProgramId : TAccountMetas [ 4 ] ;
198218 } ;
199- data : FinalizeWeightTableInstructionData ;
219+ data : AdminUpdateWeightTableInstructionData ;
200220} ;
201221
202- export function parseFinalizeWeightTableInstruction <
222+ export function parseAdminUpdateWeightTableInstruction <
203223 TProgram extends string ,
204224 TAccountMetas extends readonly IAccountMeta [ ] ,
205225> (
206226 instruction : IInstruction < TProgram > &
207227 IInstructionWithAccounts < TAccountMetas > &
208228 IInstructionWithData < Uint8Array >
209- ) : ParsedFinalizeWeightTableInstruction < TProgram , TAccountMetas > {
210- if ( instruction . accounts . length < 4 ) {
229+ ) : ParsedAdminUpdateWeightTableInstruction < TProgram , TAccountMetas > {
230+ if ( instruction . accounts . length < 5 ) {
211231 // TODO: Coded error.
212232 throw new Error ( 'Not enough accounts' ) ;
213233 }
@@ -223,9 +243,10 @@ export function parseFinalizeWeightTableInstruction<
223243 ncn : getNextAccount ( ) ,
224244 weightTable : getNextAccount ( ) ,
225245 weightTableAdmin : getNextAccount ( ) ,
246+ mint : getNextAccount ( ) ,
226247 restakingProgramId : getNextAccount ( ) ,
227248 } ,
228- data : getFinalizeWeightTableInstructionDataDecoder ( ) . decode (
249+ data : getAdminUpdateWeightTableInstructionDataDecoder ( ) . decode (
229250 instruction . data
230251 ) ,
231252 } ;
0 commit comments