Skip to content

Commit 3a7f258

Browse files
committed
almost ready for PR
1 parent fe60486 commit 3a7f258

25 files changed

+532
-642
lines changed

Cargo.lock

Lines changed: 131 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ serde = { version = "^1.0", features = ["derive"] }
5151
serde_with = "3.9.0"
5252
shank = "0.4.2"
5353
shank_idl = "0.4.2"
54+
spl-math = { version = "0.3.0", features = ["no-entrypoint"] }
5455
solana-account-decoder = "~1.18"
5556
solana-cli-config = "~1.18"
5657
solana-program = "~1.18"

clients/js/jito_tip_router/errors/jitoTipRouter.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,44 @@ export const JITO_TIP_ROUTER_ERROR__DENOMINATOR_IS_ZERO = 0x2100; // 8448
2222
export const JITO_TIP_ROUTER_ERROR__ARITHMETIC_OVERFLOW = 0x2101; // 8449
2323
/** ModuloOverflow: Modulo Overflow */
2424
export const JITO_TIP_ROUTER_ERROR__MODULO_OVERFLOW = 0x2102; // 8450
25+
/** NewPreciseNumberError: New precise number error */
26+
export const JITO_TIP_ROUTER_ERROR__NEW_PRECISE_NUMBER_ERROR = 0x2103; // 8451
27+
/** CastToImpreciseNumberError: Cast to imprecise number error */
28+
export const JITO_TIP_ROUTER_ERROR__CAST_TO_IMPRECISE_NUMBER_ERROR = 0x2104; // 8452
2529
/** IncorrectWeightTableAdmin: Incorrect weight table admin */
2630
export const JITO_TIP_ROUTER_ERROR__INCORRECT_WEIGHT_TABLE_ADMIN = 0x2200; // 8704
2731
/** CannotCreateFutureWeightTables: Cannnot create future weight tables */
2832
export const JITO_TIP_ROUTER_ERROR__CANNOT_CREATE_FUTURE_WEIGHT_TABLES = 0x2201; // 8705
33+
/** WeightMintsDoNotMatchLength: Weight mints do not match - length */
34+
export const JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_LENGTH = 0x2202; // 8706
35+
/** WeightMintsDoNotMatchMintHash: Weight mints do not match - mint hash */
36+
export const JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_MINT_HASH = 0x2203; // 8707
2937

3038
export type JitoTipRouterError =
3139
| typeof JITO_TIP_ROUTER_ERROR__ARITHMETIC_OVERFLOW
3240
| typeof JITO_TIP_ROUTER_ERROR__CANNOT_CREATE_FUTURE_WEIGHT_TABLES
41+
| typeof JITO_TIP_ROUTER_ERROR__CAST_TO_IMPRECISE_NUMBER_ERROR
3342
| typeof JITO_TIP_ROUTER_ERROR__DENOMINATOR_IS_ZERO
3443
| typeof JITO_TIP_ROUTER_ERROR__INCORRECT_WEIGHT_TABLE_ADMIN
3544
| typeof JITO_TIP_ROUTER_ERROR__MODULO_OVERFLOW
36-
| typeof JITO_TIP_ROUTER_ERROR__NO_MORE_TABLE_SLOTS;
45+
| typeof JITO_TIP_ROUTER_ERROR__NEW_PRECISE_NUMBER_ERROR
46+
| typeof JITO_TIP_ROUTER_ERROR__NO_MORE_TABLE_SLOTS
47+
| typeof JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_LENGTH
48+
| typeof JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_MINT_HASH;
3749

3850
let jitoTipRouterErrorMessages: Record<JitoTipRouterError, string> | undefined;
3951
if (process.env.NODE_ENV !== 'production') {
4052
jitoTipRouterErrorMessages = {
4153
[JITO_TIP_ROUTER_ERROR__ARITHMETIC_OVERFLOW]: `Overflow`,
4254
[JITO_TIP_ROUTER_ERROR__CANNOT_CREATE_FUTURE_WEIGHT_TABLES]: `Cannnot create future weight tables`,
55+
[JITO_TIP_ROUTER_ERROR__CAST_TO_IMPRECISE_NUMBER_ERROR]: `Cast to imprecise number error`,
4356
[JITO_TIP_ROUTER_ERROR__DENOMINATOR_IS_ZERO]: `Zero in the denominator`,
4457
[JITO_TIP_ROUTER_ERROR__INCORRECT_WEIGHT_TABLE_ADMIN]: `Incorrect weight table admin`,
4558
[JITO_TIP_ROUTER_ERROR__MODULO_OVERFLOW]: `Modulo Overflow`,
59+
[JITO_TIP_ROUTER_ERROR__NEW_PRECISE_NUMBER_ERROR]: `New precise number error`,
4660
[JITO_TIP_ROUTER_ERROR__NO_MORE_TABLE_SLOTS]: `No more table slots available`,
61+
[JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_LENGTH]: `Weight mints do not match - length`,
62+
[JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_MINT_HASH]: `Weight mints do not match - mint hash`,
4763
};
4864
}
4965

clients/js/jito_tip_router/instructions/finalizeWeightTable.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,23 @@ export type FinalizeWeightTableInstruction<
6767
export type FinalizeWeightTableInstructionData = {
6868
discriminator: number;
6969
ncnEpoch: bigint;
70+
mintHash: bigint;
71+
mintCount: number;
7072
};
7173

7274
export type FinalizeWeightTableInstructionDataArgs = {
7375
ncnEpoch: number | bigint;
76+
mintHash: number | bigint;
77+
mintCount: number;
7478
};
7579

7680
export function getFinalizeWeightTableInstructionDataEncoder(): Encoder<FinalizeWeightTableInstructionDataArgs> {
7781
return transformEncoder(
7882
getStructEncoder([
7983
['discriminator', getU8Encoder()],
8084
['ncnEpoch', getU64Encoder()],
85+
['mintHash', getU64Encoder()],
86+
['mintCount', getU8Encoder()],
8187
]),
8288
(value) => ({
8389
...value,
@@ -90,6 +96,8 @@ export function getFinalizeWeightTableInstructionDataDecoder(): Decoder<Finalize
9096
return getStructDecoder([
9197
['discriminator', getU8Decoder()],
9298
['ncnEpoch', getU64Decoder()],
99+
['mintHash', getU64Decoder()],
100+
['mintCount', getU8Decoder()],
93101
]);
94102
}
95103

@@ -114,6 +122,8 @@ export type FinalizeWeightTableInput<
114122
weightTableAdmin: TransactionSigner<TAccountWeightTableAdmin>;
115123
restakingProgramId: Address<TAccountRestakingProgramId>;
116124
ncnEpoch: FinalizeWeightTableInstructionDataArgs['ncnEpoch'];
125+
mintHash: FinalizeWeightTableInstructionDataArgs['mintHash'];
126+
mintCount: FinalizeWeightTableInstructionDataArgs['mintCount'];
117127
};
118128

119129
export function getFinalizeWeightTableInstruction<

clients/js/jito_tip_router/instructions/updateWeightTable.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
combineCodec,
1111
getStructDecoder,
1212
getStructEncoder,
13+
getU128Decoder,
14+
getU128Encoder,
1315
getU64Decoder,
1416
getU64Encoder,
1517
getU8Decoder,
@@ -67,23 +69,20 @@ export type UpdateWeightTableInstruction<
6769
export type UpdateWeightTableInstructionData = {
6870
discriminator: number;
6971
ncnEpoch: bigint;
70-
weightNumerator: bigint;
71-
weightDenominator: bigint;
72+
weight: bigint;
7273
};
7374

7475
export type UpdateWeightTableInstructionDataArgs = {
7576
ncnEpoch: number | bigint;
76-
weightNumerator: number | bigint;
77-
weightDenominator: number | bigint;
77+
weight: number | bigint;
7878
};
7979

8080
export function getUpdateWeightTableInstructionDataEncoder(): Encoder<UpdateWeightTableInstructionDataArgs> {
8181
return transformEncoder(
8282
getStructEncoder([
8383
['discriminator', getU8Encoder()],
8484
['ncnEpoch', getU64Encoder()],
85-
['weightNumerator', getU64Encoder()],
86-
['weightDenominator', getU64Encoder()],
85+
['weight', getU128Encoder()],
8786
]),
8887
(value) => ({ ...value, discriminator: UPDATE_WEIGHT_TABLE_DISCRIMINATOR })
8988
);
@@ -93,8 +92,7 @@ export function getUpdateWeightTableInstructionDataDecoder(): Decoder<UpdateWeig
9392
return getStructDecoder([
9493
['discriminator', getU8Decoder()],
9594
['ncnEpoch', getU64Decoder()],
96-
['weightNumerator', getU64Decoder()],
97-
['weightDenominator', getU64Decoder()],
95+
['weight', getU128Decoder()],
9896
]);
9997
}
10098

@@ -119,8 +117,7 @@ export type UpdateWeightTableInput<
119117
weightTableAdmin: TransactionSigner<TAccountWeightTableAdmin>;
120118
restakingProgramId: Address<TAccountRestakingProgramId>;
121119
ncnEpoch: UpdateWeightTableInstructionDataArgs['ncnEpoch'];
122-
weightNumerator: UpdateWeightTableInstructionDataArgs['weightNumerator'];
123-
weightDenominator: UpdateWeightTableInstructionDataArgs['weightDenominator'];
120+
weight: UpdateWeightTableInstructionDataArgs['weight'];
124121
};
125122

126123
export function getUpdateWeightTableInstruction<

clients/js/jito_tip_router/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
* @see https://github.com/kinobi-so/kinobi
77
*/
88

9+
export * from './jitoNumber';
910
export * from './weightEntry';
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* This code was AUTOGENERATED using the kinobi library.
3+
* Please DO NOT EDIT THIS FILE, instead use visitors
4+
* to add features, then rerun kinobi to update it.
5+
*
6+
* @see https://github.com/kinobi-so/kinobi
7+
*/
8+
9+
import {
10+
combineCodec,
11+
getArrayDecoder,
12+
getArrayEncoder,
13+
getStructDecoder,
14+
getStructEncoder,
15+
getU8Decoder,
16+
getU8Encoder,
17+
type Codec,
18+
type Decoder,
19+
type Encoder,
20+
} from '@solana/web3.js';
21+
22+
export type JitoNumber = { value: Array<number> };
23+
24+
export type JitoNumberArgs = JitoNumber;
25+
26+
export function getJitoNumberEncoder(): Encoder<JitoNumberArgs> {
27+
return getStructEncoder([
28+
['value', getArrayEncoder(getU8Encoder(), { size: 16 })],
29+
]);
30+
}
31+
32+
export function getJitoNumberDecoder(): Decoder<JitoNumber> {
33+
return getStructDecoder([
34+
['value', getArrayDecoder(getU8Decoder(), { size: 16 })],
35+
]);
36+
}
37+
38+
export function getJitoNumberCodec(): Codec<JitoNumberArgs, JitoNumber> {
39+
return combineCodec(getJitoNumberEncoder(), getJitoNumberDecoder());
40+
}

clients/js/jito_tip_router/types/weightEntry.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,33 @@ import {
1212
getAddressEncoder,
1313
getStructDecoder,
1414
getStructEncoder,
15-
getU64Decoder,
16-
getU64Encoder,
1715
type Address,
1816
type Codec,
1917
type Decoder,
2018
type Encoder,
2119
} from '@solana/web3.js';
20+
import {
21+
getJitoNumberDecoder,
22+
getJitoNumberEncoder,
23+
type JitoNumber,
24+
type JitoNumberArgs,
25+
} from '.';
2226

23-
export type WeightEntry = { mint: Address; weight: bigint };
27+
export type WeightEntry = { mint: Address; weight: JitoNumber };
2428

25-
export type WeightEntryArgs = { mint: Address; weight: number | bigint };
29+
export type WeightEntryArgs = { mint: Address; weight: JitoNumberArgs };
2630

2731
export function getWeightEntryEncoder(): Encoder<WeightEntryArgs> {
2832
return getStructEncoder([
2933
['mint', getAddressEncoder()],
30-
['weight', getU64Encoder()],
34+
['weight', getJitoNumberEncoder()],
3135
]);
3236
}
3337

3438
export function getWeightEntryDecoder(): Decoder<WeightEntry> {
3539
return getStructDecoder([
3640
['mint', getAddressDecoder()],
37-
['weight', getU64Decoder()],
41+
['weight', getJitoNumberDecoder()],
3842
]);
3943
}
4044

clients/rust/jito_tip_router/src/generated/errors/jito_tip_router.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,24 @@ pub enum JitoTipRouterError {
2121
/// 8450 - Modulo Overflow
2222
#[error("Modulo Overflow")]
2323
ModuloOverflow = 0x2102,
24+
/// 8451 - New precise number error
25+
#[error("New precise number error")]
26+
NewPreciseNumberError = 0x2103,
27+
/// 8452 - Cast to imprecise number error
28+
#[error("Cast to imprecise number error")]
29+
CastToImpreciseNumberError = 0x2104,
2430
/// 8704 - Incorrect weight table admin
2531
#[error("Incorrect weight table admin")]
2632
IncorrectWeightTableAdmin = 0x2200,
2733
/// 8705 - Cannnot create future weight tables
2834
#[error("Cannnot create future weight tables")]
2935
CannotCreateFutureWeightTables = 0x2201,
36+
/// 8706 - Weight mints do not match - length
37+
#[error("Weight mints do not match - length")]
38+
WeightMintsDoNotMatchLength = 0x2202,
39+
/// 8707 - Weight mints do not match - mint hash
40+
#[error("Weight mints do not match - mint hash")]
41+
WeightMintsDoNotMatchMintHash = 0x2203,
3042
}
3143

3244
impl solana_program::program_error::PrintProgramError for JitoTipRouterError {

clients/rust/jito_tip_router/src/generated/instructions/finalize_weight_table.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ impl Default for FinalizeWeightTableInstructionData {
8282
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8383
pub struct FinalizeWeightTableInstructionArgs {
8484
pub ncn_epoch: u64,
85+
pub mint_hash: u64,
86+
pub mint_count: u8,
8587
}
8688

8789
/// Instruction builder for `FinalizeWeightTable`.
@@ -99,6 +101,8 @@ pub struct FinalizeWeightTableBuilder {
99101
weight_table_admin: Option<solana_program::pubkey::Pubkey>,
100102
restaking_program_id: Option<solana_program::pubkey::Pubkey>,
101103
ncn_epoch: Option<u64>,
104+
mint_hash: Option<u64>,
105+
mint_count: Option<u8>,
102106
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
103107
}
104108

@@ -137,6 +141,16 @@ impl FinalizeWeightTableBuilder {
137141
self.ncn_epoch = Some(ncn_epoch);
138142
self
139143
}
144+
#[inline(always)]
145+
pub fn mint_hash(&mut self, mint_hash: u64) -> &mut Self {
146+
self.mint_hash = Some(mint_hash);
147+
self
148+
}
149+
#[inline(always)]
150+
pub fn mint_count(&mut self, mint_count: u8) -> &mut Self {
151+
self.mint_count = Some(mint_count);
152+
self
153+
}
140154
/// Add an additional account to the instruction.
141155
#[inline(always)]
142156
pub fn add_remaining_account(
@@ -169,6 +183,8 @@ impl FinalizeWeightTableBuilder {
169183
};
170184
let args = FinalizeWeightTableInstructionArgs {
171185
ncn_epoch: self.ncn_epoch.clone().expect("ncn_epoch is not set"),
186+
mint_hash: self.mint_hash.clone().expect("mint_hash is not set"),
187+
mint_count: self.mint_count.clone().expect("mint_count is not set"),
172188
};
173189

174190
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
@@ -325,6 +341,8 @@ impl<'a, 'b> FinalizeWeightTableCpiBuilder<'a, 'b> {
325341
weight_table_admin: None,
326342
restaking_program_id: None,
327343
ncn_epoch: None,
344+
mint_hash: None,
345+
mint_count: None,
328346
__remaining_accounts: Vec::new(),
329347
});
330348
Self { instruction }
@@ -363,6 +381,16 @@ impl<'a, 'b> FinalizeWeightTableCpiBuilder<'a, 'b> {
363381
self.instruction.ncn_epoch = Some(ncn_epoch);
364382
self
365383
}
384+
#[inline(always)]
385+
pub fn mint_hash(&mut self, mint_hash: u64) -> &mut Self {
386+
self.instruction.mint_hash = Some(mint_hash);
387+
self
388+
}
389+
#[inline(always)]
390+
pub fn mint_count(&mut self, mint_count: u8) -> &mut Self {
391+
self.instruction.mint_count = Some(mint_count);
392+
self
393+
}
366394
/// Add an additional account to the instruction.
367395
#[inline(always)]
368396
pub fn add_remaining_account(
@@ -410,6 +438,16 @@ impl<'a, 'b> FinalizeWeightTableCpiBuilder<'a, 'b> {
410438
.ncn_epoch
411439
.clone()
412440
.expect("ncn_epoch is not set"),
441+
mint_hash: self
442+
.instruction
443+
.mint_hash
444+
.clone()
445+
.expect("mint_hash is not set"),
446+
mint_count: self
447+
.instruction
448+
.mint_count
449+
.clone()
450+
.expect("mint_count is not set"),
413451
};
414452
let instruction = FinalizeWeightTableCpi {
415453
__program: self.instruction.__program,
@@ -447,6 +485,8 @@ struct FinalizeWeightTableCpiBuilderInstruction<'a, 'b> {
447485
weight_table_admin: Option<&'b solana_program::account_info::AccountInfo<'a>>,
448486
restaking_program_id: Option<&'b solana_program::account_info::AccountInfo<'a>>,
449487
ncn_epoch: Option<u64>,
488+
mint_hash: Option<u64>,
489+
mint_count: Option<u8>,
450490
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
451491
__remaining_accounts: Vec<(
452492
&'b solana_program::account_info::AccountInfo<'a>,

0 commit comments

Comments
 (0)