15
15
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.
16
16
17
17
use super :: common:: handle_omni_native_task;
18
- use crate :: error_code:: AUTH_VERIFICATION_FAILED_CODE ;
19
- use crate :: methods:: omni:: common:: check_auth;
20
18
use crate :: methods:: omni:: PumpxRpcError ;
21
19
use crate :: server:: RpcContext ;
22
20
use crate :: ErrorCode ;
@@ -37,6 +35,8 @@ pub struct EstimateUserOpGasParams {
37
35
pub user_operation : SerializablePackedUserOperation ,
38
36
pub chain_id : ChainId ,
39
37
pub wallet_index : u32 ,
38
+ pub omni_account : String ,
39
+ pub client_id : String ,
40
40
}
41
41
42
42
#[ derive( Serialize , Clone ) ]
@@ -51,14 +51,7 @@ pub struct EstimateUserOpGasResponse {
51
51
52
52
pub fn register_estimate_user_op_gas ( module : & mut RpcModule < RpcContext > ) {
53
53
module
54
- . register_async_method ( "omni_estimateUserOpGas" , |params, ctx, ext| async move {
55
- let user = check_auth ( & ext) . map_err ( |e| {
56
- error ! ( "Authentication check failed: {:?}" , e) ;
57
- PumpxRpcError :: from_error_code ( ErrorCode :: ServerError (
58
- AUTH_VERIFICATION_FAILED_CODE ,
59
- ) )
60
- } ) ?;
61
-
54
+ . register_async_method ( "omni_estimateUserOpGas" , |params, ctx, _ext| async move {
62
55
let params = params. parse :: < EstimateUserOpGasParams > ( ) . map_err ( |e| {
63
56
error ! ( "Failed to parse params: {:?}" , e) ;
64
57
PumpxRpcError :: from_error_code ( ErrorCode :: ParseError )
@@ -67,7 +60,7 @@ pub fn register_estimate_user_op_gas(module: &mut RpcModule<RpcContext>) {
67
60
debug ! ( "Received omni_estimateUserOpGas, params: {:?}" , params) ;
68
61
69
62
let account_id =
70
- decode_account_id ( & user . omni_account ) . map_err ( PumpxRpcError :: from_error_code) ?;
63
+ decode_account_id ( & params . omni_account ) . map_err ( PumpxRpcError :: from_error_code) ?;
71
64
72
65
validate_sender_address ( & params. user_operation . sender )
73
66
. map_err ( PumpxRpcError :: from_error_code) ?;
@@ -81,7 +74,7 @@ pub fn register_estimate_user_op_gas(module: &mut RpcModule<RpcContext>) {
81
74
) ,
82
75
None ,
83
76
None ,
84
- user . client_id ,
77
+ params . client_id ,
85
78
) ;
86
79
87
80
handle_omni_native_task ( & ctx, wrapper, |task_ok| match task_ok {
@@ -264,12 +257,19 @@ mod tests {
264
257
"signature" : "0x1234"
265
258
} ,
266
259
"chain_id" : 1 ,
267
- "wallet_index" : 0
260
+ "wallet_index" : 0 ,
261
+ "omni_account" : "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ,
262
+ "client_id" : "test-client-123"
268
263
} ) ;
269
264
270
265
let params: EstimateUserOpGasParams = serde_json:: from_value ( json) . unwrap ( ) ;
271
266
assert_eq ! ( params. chain_id, 1 ) ;
272
267
assert_eq ! ( params. wallet_index, 0 ) ;
268
+ assert_eq ! (
269
+ params. omni_account,
270
+ "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
271
+ ) ;
272
+ assert_eq ! ( params. client_id, "test-client-123" ) ;
273
273
assert_eq ! ( params. user_operation. sender, "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb9" ) ;
274
274
assert_eq ! ( params. user_operation. nonce, 42 ) ;
275
275
}
@@ -289,7 +289,9 @@ mod tests {
289
289
"paymaster_and_data" : "0x" ,
290
290
"signature" : null
291
291
} ,
292
- "wallet_index" : 0
292
+ "wallet_index" : 0 ,
293
+ "omni_account" : "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ,
294
+ "client_id" : "test-client-123"
293
295
// Missing chain_id
294
296
} ) ;
295
297
0 commit comments