Skip to content

Commit bec60fc

Browse files
author
wli-pro
committed
fix: P-1485 update optional fields in submit_swap_order
1 parent 6ce1bce commit bec60fc

File tree

1 file changed

+50
-7
lines changed

1 file changed

+50
-7
lines changed

tee-worker/omni-executor/rpc-server/src/methods/omni/submit_swap_order.rs

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,54 @@ pub fn register_submit_swap_order(module: &mut RpcModule<RpcContext>) {
177177
PUMPX_API_GET_ACCOUNT_USER_ID_FAILED_CODE,
178178
)));
179179
};
180+
181+
let Some(gas_type_base) = user_trade_info_data.gas_type_base else {
182+
log::error!("Response data.gas_type_base of call get_user_trade_info is none");
183+
return Err(PumpxRpcError::from_error_code(ErrorCode::ServerError(
184+
PUMPX_API_GET_ACCOUNT_USER_ID_FAILED_CODE,
185+
)));
186+
};
187+
188+
let Some(gas_type_bsc) = user_trade_info_data.gas_type_bsc else {
189+
log::error!("Response data.gas_type_bsc of call get_user_trade_info is none");
190+
return Err(PumpxRpcError::from_error_code(ErrorCode::ServerError(
191+
PUMPX_API_GET_ACCOUNT_USER_ID_FAILED_CODE,
192+
)));
193+
};
194+
195+
let Some(gas_type_eth) = user_trade_info_data.gas_type_eth else {
196+
log::error!("Response data.gas_type_eth of call get_user_trade_info is none");
197+
return Err(PumpxRpcError::from_error_code(ErrorCode::ServerError(
198+
PUMPX_API_GET_ACCOUNT_USER_ID_FAILED_CODE,
199+
)));
200+
};
201+
202+
let Some(is_anti_mev) = user_trade_info_data.is_anti_mev else {
203+
log::error!("Response data.is_anti_mev of call get_user_trade_info is none");
204+
return Err(PumpxRpcError::from_error_code(ErrorCode::ServerError(
205+
PUMPX_API_GET_ACCOUNT_USER_ID_FAILED_CODE,
206+
)));
207+
};
208+
209+
let Some(is_auto_slippage) = user_trade_info_data.is_auto_slippage else {
210+
log::error!("Response data.is_auto_slippage of call get_user_trade_info is none");
211+
return Err(PumpxRpcError::from_error_code(ErrorCode::ServerError(
212+
PUMPX_API_GET_ACCOUNT_USER_ID_FAILED_CODE,
213+
)));
214+
};
215+
216+
let Some(slippage) = user_trade_info_data.slippage else {
217+
log::error!("Response data.slippage of call get_user_trade_info is none");
218+
return Err(PumpxRpcError::from_error_code(ErrorCode::ServerError(
219+
PUMPX_API_GET_ACCOUNT_USER_ID_FAILED_CODE,
220+
)));
221+
};
222+
180223
let gas_type = match params.to_chain_id {
181-
BASE_CHAIN_ID => user_trade_info_data.gas_type_base.to_number() as u32,
182-
ETHEREUM_CHAIN_ID => user_trade_info_data.gas_type_eth.to_number() as u32,
183-
BSC_CHAIN_ID => user_trade_info_data.gas_type_bsc.to_number() as u32,
184-
SOLANA_CHAIN_ID => user_trade_info_data.gas_type_base.to_number() as u32,
224+
BASE_CHAIN_ID => gas_type_base.to_number() as u32,
225+
ETHEREUM_CHAIN_ID => gas_type_eth.to_number() as u32,
226+
BSC_CHAIN_ID => gas_type_bsc.to_number() as u32,
227+
SOLANA_CHAIN_ID => gas_type_base.to_number() as u32,
185228
_ => {
186229
log::error!("Unsupported chain id: {}", params.to_chain_id);
187230
return Err(PumpxRpcError::from_error_code(ErrorCode::InvalidParams));
@@ -238,10 +281,10 @@ pub fn register_submit_swap_order(module: &mut RpcModule<RpcContext>) {
238281
)?,
239282
double_out: params.double_out,
240283
is_one_click: params.is_one_click,
241-
is_anti_mev: user_trade_info_data.is_anti_mev,
242-
is_auto_slippage: user_trade_info_data.is_auto_slippage,
284+
is_anti_mev,
285+
is_auto_slippage,
243286
gas_type,
244-
slippage: user_trade_info_data.slippage,
287+
slippage,
245288
wallet_index: params.wallet_index,
246289
token_cap,
247290
price_usd,

0 commit comments

Comments
 (0)