Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed Dec 10, 2024
1 parent 6fc27d9 commit cfe6ebb
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-audit
- run: cargo audit --ignore RUSTSEC-2022-0093 --ignore RUSTSEC-2023-0065 --ignore RUSTSEC-2024-0344
- run: cargo audit --ignore RUSTSEC-2022-0093 --ignore RUSTSEC-2023-0065 --ignore RUSTSEC-2024-0344 --ignore RUSTSEC-2024-0421

code_gen:
name: code generation
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ export type DistributeNcnVaultRewardsInstruction<
TAccountOperator extends string | IAccountMeta<string> = string,
TAccountVault extends string | IAccountMeta<string> = string,
TAccountNcnRewardRouter extends string | IAccountMeta<string> = string,
TAccountRestakingProgram extends string | IAccountMeta<string> = string,
TAccountVaultProgram extends string | IAccountMeta<string> = string,
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
> = IInstruction<TProgram> &
IInstructionWithData<Uint8Array> &
Expand All @@ -70,12 +68,6 @@ export type DistributeNcnVaultRewardsInstruction<
TAccountNcnRewardRouter extends string
? WritableAccount<TAccountNcnRewardRouter>
: TAccountNcnRewardRouter,
TAccountRestakingProgram extends string
? ReadonlyAccount<TAccountRestakingProgram>
: TAccountRestakingProgram,
TAccountVaultProgram extends string
? ReadonlyAccount<TAccountVaultProgram>
: TAccountVaultProgram,
...TRemainingAccounts,
]
>;
Expand Down Expand Up @@ -130,17 +122,13 @@ export type DistributeNcnVaultRewardsInput<
TAccountOperator extends string = string,
TAccountVault extends string = string,
TAccountNcnRewardRouter extends string = string,
TAccountRestakingProgram extends string = string,
TAccountVaultProgram extends string = string,
> = {
restakingConfig: Address<TAccountRestakingConfig>;
ncnConfig: Address<TAccountNcnConfig>;
ncn: Address<TAccountNcn>;
operator: Address<TAccountOperator>;
vault: Address<TAccountVault>;
ncnRewardRouter: Address<TAccountNcnRewardRouter>;
restakingProgram: Address<TAccountRestakingProgram>;
vaultProgram: Address<TAccountVaultProgram>;
ncnFeeGroup: DistributeNcnVaultRewardsInstructionDataArgs['ncnFeeGroup'];
firstSlotOfNcnEpoch: DistributeNcnVaultRewardsInstructionDataArgs['firstSlotOfNcnEpoch'];
};
Expand All @@ -152,8 +140,6 @@ export function getDistributeNcnVaultRewardsInstruction<
TAccountOperator extends string,
TAccountVault extends string,
TAccountNcnRewardRouter extends string,
TAccountRestakingProgram extends string,
TAccountVaultProgram extends string,
TProgramAddress extends Address = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS,
>(
input: DistributeNcnVaultRewardsInput<
Expand All @@ -162,9 +148,7 @@ export function getDistributeNcnVaultRewardsInstruction<
TAccountNcn,
TAccountOperator,
TAccountVault,
TAccountNcnRewardRouter,
TAccountRestakingProgram,
TAccountVaultProgram
TAccountNcnRewardRouter
>,
config?: { programAddress?: TProgramAddress }
): DistributeNcnVaultRewardsInstruction<
Expand All @@ -174,9 +158,7 @@ export function getDistributeNcnVaultRewardsInstruction<
TAccountNcn,
TAccountOperator,
TAccountVault,
TAccountNcnRewardRouter,
TAccountRestakingProgram,
TAccountVaultProgram
TAccountNcnRewardRouter
> {
// Program address.
const programAddress =
Expand All @@ -193,11 +175,6 @@ export function getDistributeNcnVaultRewardsInstruction<
operator: { value: input.operator ?? null, isWritable: false },
vault: { value: input.vault ?? null, isWritable: true },
ncnRewardRouter: { value: input.ncnRewardRouter ?? null, isWritable: true },
restakingProgram: {
value: input.restakingProgram ?? null,
isWritable: false,
},
vaultProgram: { value: input.vaultProgram ?? null, isWritable: false },
};
const accounts = originalAccounts as Record<
keyof typeof originalAccounts,
Expand All @@ -216,8 +193,6 @@ export function getDistributeNcnVaultRewardsInstruction<
getAccountMeta(accounts.operator),
getAccountMeta(accounts.vault),
getAccountMeta(accounts.ncnRewardRouter),
getAccountMeta(accounts.restakingProgram),
getAccountMeta(accounts.vaultProgram),
],
programAddress,
data: getDistributeNcnVaultRewardsInstructionDataEncoder().encode(
Expand All @@ -230,9 +205,7 @@ export function getDistributeNcnVaultRewardsInstruction<
TAccountNcn,
TAccountOperator,
TAccountVault,
TAccountNcnRewardRouter,
TAccountRestakingProgram,
TAccountVaultProgram
TAccountNcnRewardRouter
>;

return instruction;
Expand All @@ -250,8 +223,6 @@ export type ParsedDistributeNcnVaultRewardsInstruction<
operator: TAccountMetas[3];
vault: TAccountMetas[4];
ncnRewardRouter: TAccountMetas[5];
restakingProgram: TAccountMetas[6];
vaultProgram: TAccountMetas[7];
};
data: DistributeNcnVaultRewardsInstructionData;
};
Expand All @@ -264,7 +235,7 @@ export function parseDistributeNcnVaultRewardsInstruction<
IInstructionWithAccounts<TAccountMetas> &
IInstructionWithData<Uint8Array>
): ParsedDistributeNcnVaultRewardsInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 8) {
if (instruction.accounts.length < 6) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
Expand All @@ -283,8 +254,6 @@ export function parseDistributeNcnVaultRewardsInstruction<
operator: getNextAccount(),
vault: getNextAccount(),
ncnRewardRouter: getNextAccount(),
restakingProgram: getNextAccount(),
vaultProgram: getNextAccount(),
},
data: getDistributeNcnVaultRewardsInstructionDataDecoder().decode(
instruction.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ pub struct DistributeNcnVaultRewards {
pub vault: solana_program::pubkey::Pubkey,

pub ncn_reward_router: solana_program::pubkey::Pubkey,

pub restaking_program: solana_program::pubkey::Pubkey,

pub vault_program: solana_program::pubkey::Pubkey,
}

impl DistributeNcnVaultRewards {
Expand All @@ -38,7 +34,7 @@ impl DistributeNcnVaultRewards {
args: DistributeNcnVaultRewardsInstructionArgs,
remaining_accounts: &[solana_program::instruction::AccountMeta],
) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.restaking_config,
false,
Expand All @@ -61,14 +57,6 @@ impl DistributeNcnVaultRewards {
self.ncn_reward_router,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.restaking_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.vault_program,
false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = DistributeNcnVaultRewardsInstructionData::new()
.try_to_vec()
Expand Down Expand Up @@ -118,8 +106,6 @@ pub struct DistributeNcnVaultRewardsInstructionArgs {
/// 3. `[]` operator
/// 4. `[writable]` vault
/// 5. `[writable]` ncn_reward_router
/// 6. `[]` restaking_program
/// 7. `[]` vault_program
#[derive(Clone, Debug, Default)]
pub struct DistributeNcnVaultRewardsBuilder {
restaking_config: Option<solana_program::pubkey::Pubkey>,
Expand All @@ -128,8 +114,6 @@ pub struct DistributeNcnVaultRewardsBuilder {
operator: Option<solana_program::pubkey::Pubkey>,
vault: Option<solana_program::pubkey::Pubkey>,
ncn_reward_router: Option<solana_program::pubkey::Pubkey>,
restaking_program: Option<solana_program::pubkey::Pubkey>,
vault_program: Option<solana_program::pubkey::Pubkey>,
ncn_fee_group: Option<u8>,
first_slot_of_ncn_epoch: Option<u64>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
Expand Down Expand Up @@ -176,19 +160,6 @@ impl DistributeNcnVaultRewardsBuilder {
self
}
#[inline(always)]
pub fn restaking_program(
&mut self,
restaking_program: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.restaking_program = Some(restaking_program);
self
}
#[inline(always)]
pub fn vault_program(&mut self, vault_program: solana_program::pubkey::Pubkey) -> &mut Self {
self.vault_program = Some(vault_program);
self
}
#[inline(always)]
pub fn ncn_fee_group(&mut self, ncn_fee_group: u8) -> &mut Self {
self.ncn_fee_group = Some(ncn_fee_group);
self
Expand Down Expand Up @@ -228,10 +199,6 @@ impl DistributeNcnVaultRewardsBuilder {
ncn_reward_router: self
.ncn_reward_router
.expect("ncn_reward_router is not set"),
restaking_program: self
.restaking_program
.expect("restaking_program is not set"),
vault_program: self.vault_program.expect("vault_program is not set"),
};
let args = DistributeNcnVaultRewardsInstructionArgs {
ncn_fee_group: self
Expand All @@ -258,10 +225,6 @@ pub struct DistributeNcnVaultRewardsCpiAccounts<'a, 'b> {
pub vault: &'b solana_program::account_info::AccountInfo<'a>,

pub ncn_reward_router: &'b solana_program::account_info::AccountInfo<'a>,

pub restaking_program: &'b solana_program::account_info::AccountInfo<'a>,

pub vault_program: &'b solana_program::account_info::AccountInfo<'a>,
}

/// `distribute_ncn_vault_rewards` CPI instruction.
Expand All @@ -280,10 +243,6 @@ pub struct DistributeNcnVaultRewardsCpi<'a, 'b> {
pub vault: &'b solana_program::account_info::AccountInfo<'a>,

pub ncn_reward_router: &'b solana_program::account_info::AccountInfo<'a>,

pub restaking_program: &'b solana_program::account_info::AccountInfo<'a>,

pub vault_program: &'b solana_program::account_info::AccountInfo<'a>,
/// The arguments for the instruction.
pub __args: DistributeNcnVaultRewardsInstructionArgs,
}
Expand All @@ -302,8 +261,6 @@ impl<'a, 'b> DistributeNcnVaultRewardsCpi<'a, 'b> {
operator: accounts.operator,
vault: accounts.vault,
ncn_reward_router: accounts.ncn_reward_router,
restaking_program: accounts.restaking_program,
vault_program: accounts.vault_program,
__args: args,
}
}
Expand Down Expand Up @@ -340,7 +297,7 @@ impl<'a, 'b> DistributeNcnVaultRewardsCpi<'a, 'b> {
bool,
)],
) -> solana_program::entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.restaking_config.key,
false,
Expand All @@ -365,14 +322,6 @@ impl<'a, 'b> DistributeNcnVaultRewardsCpi<'a, 'b> {
*self.ncn_reward_router.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.restaking_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.vault_program.key,
false,
));
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_program::instruction::AccountMeta {
pubkey: *remaining_account.0.key,
Expand All @@ -391,16 +340,14 @@ impl<'a, 'b> DistributeNcnVaultRewardsCpi<'a, 'b> {
accounts,
data,
};
let mut account_infos = Vec::with_capacity(8 + 1 + remaining_accounts.len());
let mut account_infos = Vec::with_capacity(6 + 1 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.restaking_config.clone());
account_infos.push(self.ncn_config.clone());
account_infos.push(self.ncn.clone());
account_infos.push(self.operator.clone());
account_infos.push(self.vault.clone());
account_infos.push(self.ncn_reward_router.clone());
account_infos.push(self.restaking_program.clone());
account_infos.push(self.vault_program.clone());
remaining_accounts
.iter()
.for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
Expand All @@ -423,8 +370,6 @@ impl<'a, 'b> DistributeNcnVaultRewardsCpi<'a, 'b> {
/// 3. `[]` operator
/// 4. `[writable]` vault
/// 5. `[writable]` ncn_reward_router
/// 6. `[]` restaking_program
/// 7. `[]` vault_program
#[derive(Clone, Debug)]
pub struct DistributeNcnVaultRewardsCpiBuilder<'a, 'b> {
instruction: Box<DistributeNcnVaultRewardsCpiBuilderInstruction<'a, 'b>>,
Expand All @@ -440,8 +385,6 @@ impl<'a, 'b> DistributeNcnVaultRewardsCpiBuilder<'a, 'b> {
operator: None,
vault: None,
ncn_reward_router: None,
restaking_program: None,
vault_program: None,
ncn_fee_group: None,
first_slot_of_ncn_epoch: None,
__remaining_accounts: Vec::new(),
Expand Down Expand Up @@ -491,22 +434,6 @@ impl<'a, 'b> DistributeNcnVaultRewardsCpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn restaking_program(
&mut self,
restaking_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.restaking_program = Some(restaking_program);
self
}
#[inline(always)]
pub fn vault_program(
&mut self,
vault_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.vault_program = Some(vault_program);
self
}
#[inline(always)]
pub fn ncn_fee_group(&mut self, ncn_fee_group: u8) -> &mut Self {
self.instruction.ncn_fee_group = Some(ncn_fee_group);
self
Expand Down Expand Up @@ -586,16 +513,6 @@ impl<'a, 'b> DistributeNcnVaultRewardsCpiBuilder<'a, 'b> {
.instruction
.ncn_reward_router
.expect("ncn_reward_router is not set"),

restaking_program: self
.instruction
.restaking_program
.expect("restaking_program is not set"),

vault_program: self
.instruction
.vault_program
.expect("vault_program is not set"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(
Expand All @@ -614,8 +531,6 @@ struct DistributeNcnVaultRewardsCpiBuilderInstruction<'a, 'b> {
operator: Option<&'b solana_program::account_info::AccountInfo<'a>>,
vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
ncn_reward_router: Option<&'b solana_program::account_info::AccountInfo<'a>>,
restaking_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
vault_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
ncn_fee_group: Option<u8>,
first_slot_of_ncn_epoch: Option<u64>,
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
Expand Down
Loading

0 comments on commit cfe6ebb

Please sign in to comment.