Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anihamde committed Jan 7, 2025
1 parent e15e583 commit 9be3f91
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion auction-server/api-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "express-relay-api-types"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
description = "Pyth Express Relay api types"
repository = "https://github.com/pyth-network/per"
Expand Down
5 changes: 1 addition & 4 deletions auction-server/src/auction/service/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,7 @@ impl Service<Svm> {
express_relay_svm::SwapArgs::try_from_slice(
&instruction.data.as_slice()[discriminator.len()..],
)
.map_err(|e| {
RestError::BadParameters(format!("Invalid submit_bid instruction data: {}", e))
})
.map_err(|e| RestError::BadParameters(format!("Invalid swap instruction data: {}", e)))
}

pub fn extract_express_relay_bid_instruction(
Expand Down Expand Up @@ -558,7 +556,6 @@ impl Service<Svm> {
.router_account_position_swap,
)
.await?;
// TODO*: should work to remove this
if router != self.config.chain_config.wallet_program_router_account {
return Err(RestError::BadParameters(
"Must use approved router for swap instruction".to_string(),
Expand Down
4 changes: 4 additions & 0 deletions auction-server/src/opportunity/service/get_quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ impl Service<ChainTypeSvm> {
program: &ProgramSvm,
) -> Result<entities::OpportunityCreateSvm, RestError> {
let router = quote_create.router;
let chain_config = self.get_config(&quote_create.chain_id)?;
if router != chain_config.wallet_program_router_account {
return Err(RestError::Forbidden);
}
let permission_account =
get_quote_permission_key(&quote_create.tokens, &quote_create.user_wallet_address);

Expand Down
9 changes: 6 additions & 3 deletions auction-server/src/opportunity/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use {
types::Address,
},
futures::future::try_join_all,
solana_sdk::pubkey::Pubkey,
std::{
collections::HashMap,
sync::Arc,
Expand Down Expand Up @@ -81,7 +82,8 @@ impl ConfigEvm {

// NOTE: Do not implement debug here. it has a circular reference to auction_service
pub struct ConfigSvm {
pub auction_service: RwLock<Option<auction_service::Service<Svm>>>,
pub auction_service: RwLock<Option<auction_service::Service<Svm>>>,
pub wallet_program_router_account: Pubkey,
}

impl ConfigSvm {
Expand Down Expand Up @@ -194,11 +196,12 @@ impl ConfigSvm {
) -> anyhow::Result<HashMap<ChainId, Self>> {
Ok(chains
.iter()
.map(|(chain_id, _)| {
.map(|(chain_id, config)| {
(
chain_id.clone(),
Self {
auction_service: RwLock::new(None),
auction_service: RwLock::new(None),
wallet_program_router_account: config.wallet_program_router_account,
},
)
})
Expand Down
9 changes: 6 additions & 3 deletions auction-server/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use {
Response,
RpcLogsResponse,
},
solana_sdk::pubkey::Pubkey,
std::{
collections::HashMap,
sync::Arc,
Expand Down Expand Up @@ -103,10 +104,11 @@ impl ChainStoreEvm {
}

pub struct ChainStoreSvm {
pub log_sender: Sender<Response<RpcLogsResponse>>,
pub log_sender: Sender<Response<RpcLogsResponse>>,
// only to avoid closing the channel
pub _dummy_log_receiver: Receiver<Response<RpcLogsResponse>>,
pub config: ConfigSvm,
pub _dummy_log_receiver: Receiver<Response<RpcLogsResponse>>,
pub config: ConfigSvm,
pub wallet_program_router_account: Pubkey,
}

impl ChainStoreSvm {
Expand All @@ -116,6 +118,7 @@ impl ChainStoreSvm {
Self {
log_sender: tx,
_dummy_log_receiver: rx,
wallet_program_router_account: config.wallet_program_router_account,
config,
}
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "express-relay-client"
version = "0.2.1"
version = "0.3.0"
edition = "2021"
description = "Pyth Express Relay client"
repository = "https://github.com/pyth-network/per"
license = "Apache-2.0"

[dependencies]
express-relay-api-types = { version = "0.1.0", path = "../../auction-server/api-types" }
express-relay-api-types = { version = "0.2.0", path = "../../auction-server/api-types" }
reqwest = { version = "0.12.9", features = ["json"] }
url = { workspace = true}
serde = { workspace = true }
Expand Down

0 comments on commit 9be3f91

Please sign in to comment.