Skip to content

Commit

Permalink
working with 2...
Browse files Browse the repository at this point in the history
  • Loading branch information
ebatsell committed Nov 12, 2024
1 parent 01bee5a commit 4e75bca
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 69 deletions.
4 changes: 2 additions & 2 deletions clients/js/jito_tip_router/accounts/trackedMints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function getTrackedMintsEncoder(): Encoder<TrackedMintsArgs> {
['ncn', getAddressEncoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 7 })],
['stMintList', getArrayEncoder(getMintEntryEncoder(), { size: 64 })],
['stMintList', getArrayEncoder(getMintEntryEncoder(), { size: 2 })],
]);
}

Expand All @@ -73,7 +73,7 @@ export function getTrackedMintsDecoder(): Decoder<TrackedMints> {
['ncn', getAddressDecoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 7 })],
['stMintList', getArrayDecoder(getMintEntryDecoder(), { size: 64 })],
['stMintList', getArrayDecoder(getMintEntryDecoder(), { size: 2 })],
]);
}

Expand Down
32 changes: 2 additions & 30 deletions clients/js/jito_tip_router/types/mintEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,31 @@ import {
combineCodec,
getAddressDecoder,
getAddressEncoder,
getArrayDecoder,
getArrayEncoder,
getStructDecoder,
getStructEncoder,
getU128Decoder,
getU128Encoder,
getU64Decoder,
getU64Encoder,
getU8Decoder,
getU8Encoder,
type Address,
type Codec,
type Decoder,
type Encoder,
} from '@solana/web3.js';

export type MintEntry = {
stMint: Address;
vaultIndex: bigint;
weight: bigint;
slotSet: bigint;
slotUpdated: bigint;
reserved: Array<number>;
};
export type MintEntry = { stMint: Address; vaultIndex: bigint };

export type MintEntryArgs = {
stMint: Address;
vaultIndex: number | bigint;
weight: number | bigint;
slotSet: number | bigint;
slotUpdated: number | bigint;
reserved: Array<number>;
};
export type MintEntryArgs = { stMint: Address; vaultIndex: number | bigint };

export function getMintEntryEncoder(): Encoder<MintEntryArgs> {
return getStructEncoder([
['stMint', getAddressEncoder()],
['vaultIndex', getU64Encoder()],
['weight', getU128Encoder()],
['slotSet', getU64Encoder()],
['slotUpdated', getU64Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })],
]);
}

export function getMintEntryDecoder(): Decoder<MintEntry> {
return getStructDecoder([
['stMint', getAddressDecoder()],
['vaultIndex', getU64Decoder()],
['weight', getU128Decoder()],
['slotSet', getU64Decoder()],
['slotUpdated', getU64Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })],
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ pub struct TrackedMints {
pub ncn: Pubkey,
pub bump: u8,
pub reserved: [u8; 7],
#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::Bytes>"))]
pub st_mint_list: [MintEntry; 64],
pub st_mint_list: [MintEntry; 2],
}

impl TrackedMints {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,4 @@ pub struct MintEntry {
)]
pub st_mint: Pubkey,
pub vault_index: u64,
pub weight: u128,
pub slot_set: u64,
pub slot_updated: u64,
#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::Bytes>"))]
pub reserved: [u8; 128],
}
4 changes: 2 additions & 2 deletions core/src/tracked_mints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct TrackedMints {
pub ncn: Pubkey,
pub bump: u8,
pub reserved: [u8; 7],
pub st_mint_list: [MintEntry; 64],
pub st_mint_list: [MintEntry; 2],
}

impl Discriminator for TrackedMints {
Expand All @@ -52,7 +52,7 @@ impl TrackedMints {
ncn,
bump,
reserved: [0; 7],
st_mint_list: [MintEntry::default(); 64],
st_mint_list: [MintEntry::default(); 2],
}
}

Expand Down
29 changes: 1 addition & 28 deletions idl/jito_tip_router.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
{
"defined": "MintEntry"
},
64
2
]
}
}
Expand Down Expand Up @@ -545,33 +545,6 @@
"type": {
"defined": "PodU64"
}
},
{
"name": "weight",
"type": {
"defined": "PodU128"
}
},
{
"name": "slotSet",
"type": {
"defined": "PodU64"
}
},
{
"name": "slotUpdated",
"type": {
"defined": "PodU64"
}
},
{
"name": "reserved",
"type": {
"array": [
"u8",
128
]
}
}
]
}
Expand Down

0 comments on commit 4e75bca

Please sign in to comment.