Skip to content

Commit 1e0bb28

Browse files
devin-ai-integration[bot]Jayant
andcommitted
fix: remove unused clock variable in register function
- Remove unused clock variable that was causing CI build failure - Keep clock variable in request_v2 function where it's actually used - Fixes clippy warning and allows CI build to pass Co-Authored-By: Jayant <[email protected]>
1 parent 233ac62 commit 1e0bb28

File tree

3 files changed

+48
-27
lines changed

3 files changed

+48
-27
lines changed

target_chains/solana/programs/pyth-entropy/src/error.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,49 @@ use anchor_lang::prelude::*;
44
pub enum EntropyError {
55
#[msg("Provider not found")]
66
NoSuchProvider,
7-
7+
88
#[msg("Request not found")]
99
NoSuchRequest,
10-
10+
1111
#[msg("Insufficient fee provided")]
1212
InsufficientFee,
13-
13+
1414
#[msg("Provider is out of randomness")]
1515
OutOfRandomness,
16-
16+
1717
#[msg("Incorrect revelation provided")]
1818
IncorrectRevelation,
19-
19+
2020
#[msg("Unauthorized access")]
2121
Unauthorized,
22-
22+
2323
#[msg("Invalid reveal call")]
2424
InvalidRevealCall,
25-
25+
2626
#[msg("Assertion failure")]
2727
AssertionFailure,
28-
28+
2929
#[msg("Update too old")]
3030
UpdateTooOld,
31-
31+
3232
#[msg("Last revealed too old")]
3333
LastRevealedTooOld,
34-
34+
3535
#[msg("Insufficient gas")]
3636
InsufficientGas,
37-
37+
3838
#[msg("Max gas limit exceeded")]
3939
MaxGasLimitExceeded,
40-
40+
4141
#[msg("Blockhash unavailable")]
4242
BlockhashUnavailable,
43-
43+
4444
#[msg("Zero minimum signatures")]
4545
ZeroMinimumSignatures,
46-
46+
4747
#[msg("Invalid guardian order")]
4848
InvalidGuardianOrder,
49-
49+
5050
#[msg("Invalid guardian index")]
5151
InvalidGuardianIndex,
5252
}

target_chains/solana/programs/pyth-entropy/src/lib.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pub mod pyth_entropy {
3636
require!(chain_length > 0, EntropyError::AssertionFailure);
3737

3838
let provider_info = &mut ctx.accounts.provider_info;
39-
let clock = Clock::get()?;
4039

4140
provider_info.provider = ctx.accounts.provider.key();
4241
provider_info.fee_in_lamports = fee_in_lamports;
@@ -96,8 +95,10 @@ pub mod pyth_entropy {
9695

9796
request_account.provider = provider_info.provider;
9897
request_account.sequence_number = assigned_sequence_number;
99-
request_account.num_hashes = (assigned_sequence_number - provider_info.current_commitment_sequence_number) as u32;
100-
request_account.commitment = combine_commitments(user_commitment, provider_info.current_commitment);
98+
request_account.num_hashes =
99+
(assigned_sequence_number - provider_info.current_commitment_sequence_number) as u32;
100+
request_account.commitment =
101+
combine_commitments(user_commitment, provider_info.current_commitment);
101102
request_account.requester = ctx.accounts.requester.key();
102103
request_account.block_number = clock.slot;
103104
request_account.use_blockhash = false;
@@ -231,8 +232,16 @@ pub mod pyth_entropy {
231232

232233
provider_info.accrued_fees_in_lamports -= amount;
233234

234-
**ctx.accounts.provider.to_account_info().try_borrow_mut_lamports()? += amount;
235-
**ctx.accounts.treasury.to_account_info().try_borrow_mut_lamports()? -= amount;
235+
**ctx
236+
.accounts
237+
.provider
238+
.to_account_info()
239+
.try_borrow_mut_lamports()? += amount;
240+
**ctx
241+
.accounts
242+
.treasury
243+
.to_account_info()
244+
.try_borrow_mut_lamports()? -= amount;
236245

237246
emit!(Withdrawal {
238247
provider: provider_info.provider,
@@ -509,7 +518,8 @@ fn reveal_helper(
509518
user_contribution: [u8; 32],
510519
provider_contribution: [u8; 32],
511520
) -> Result<[u8; 32]> {
512-
let provider_commitment = construct_provider_commitment(request.num_hashes, provider_contribution);
521+
let provider_commitment =
522+
construct_provider_commitment(request.num_hashes, provider_contribution);
513523
let user_commitment = construct_user_commitment(user_contribution);
514524
let expected_commitment = combine_commitments(user_commitment, provider_commitment);
515525

@@ -566,7 +576,11 @@ fn generate_user_contribution(clock: &Clock, requester: &Pubkey) -> [u8; 32] {
566576
keccak::hash(&data).to_bytes()
567577
}
568578

569-
fn get_fee_v2_internal(provider_info: &ProviderInfo, config: &EntropyConfig, gas_limit: u32) -> u64 {
579+
fn get_fee_v2_internal(
580+
provider_info: &ProviderInfo,
581+
config: &EntropyConfig,
582+
gas_limit: u32,
583+
) -> u64 {
570584
get_provider_fee_internal(provider_info, gas_limit) + config.pyth_fee_in_lamports
571585
}
572586

target_chains/solana/programs/pyth-entropy/src/sdk.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use {
2-
crate::{CONFIG_SEED, PROVIDER_SEED, REQUEST_SEED, TREASURY_SEED, ID},
2+
crate::{CONFIG_SEED, ID, PROVIDER_SEED, REQUEST_SEED, TREASURY_SEED},
33
anchor_lang::{prelude::*, system_program, InstructionData},
44
solana_program::instruction::Instruction,
55
};
@@ -18,9 +18,14 @@ pub fn get_provider_info_address(provider: &Pubkey) -> Pubkey {
1818

1919
pub fn get_request_address(provider: &Pubkey, sequence_number: u64) -> Pubkey {
2020
Pubkey::find_program_address(
21-
&[REQUEST_SEED, provider.as_ref(), &sequence_number.to_le_bytes()],
21+
&[
22+
REQUEST_SEED,
23+
provider.as_ref(),
24+
&sequence_number.to_le_bytes(),
25+
],
2226
&ID,
23-
).0
27+
)
28+
.0
2429
}
2530

2631
pub struct InitializeAccounts {
@@ -147,7 +152,8 @@ impl crate::instruction::Register {
147152
commitment_metadata,
148153
chain_length,
149154
uri,
150-
}.data(),
155+
}
156+
.data(),
151157
}
152158
}
153159
}
@@ -162,7 +168,8 @@ impl crate::instruction::RequestV2 {
162168
) -> Instruction {
163169
Instruction {
164170
program_id: ID,
165-
accounts: RequestV2Accounts::populate(payer, requester, provider, sequence_number).to_account_metas(None),
171+
accounts: RequestV2Accounts::populate(payer, requester, provider, sequence_number)
172+
.to_account_metas(None),
166173
data: crate::instruction::RequestV2 { gas_limit }.data(),
167174
}
168175
}

0 commit comments

Comments
 (0)