@@ -26,8 +26,8 @@ use heima_identity_verification::{get_verification_message, web2, web3};
26
26
use parentchain_api_interface:: {
27
27
omni_account:: calls:: types:: create_account_store:: ClientId ,
28
28
runtime_types:: {
29
- frame_system:: pallet:: Call as SystemCall ,
30
- pallet_balances:: pallet:: Call as BalancesCall ,
29
+ // frame_system::pallet::Call as SystemCall,
30
+ // pallet_balances::pallet::Call as BalancesCall,
31
31
pallet_omni_account:: pallet:: { Call as OmniAccountCall , IntentCompletedDetail } ,
32
32
paseo_runtime:: RuntimeCall ,
33
33
} ,
@@ -275,9 +275,7 @@ async fn handle_native_task<
275
275
send_ok ( response_sender, NativeTaskOk :: AuthToken ( token) ) ;
276
276
return ;
277
277
} ,
278
- NativeTask :: RequestIntent ( sender, intent_id, intent) => {
279
- let omni_account = sender. to_omni_account ( client_id) ;
280
-
278
+ NativeTask :: RequestIntent ( omni_account, intent_id, intent) => {
281
279
debug ! ( "Intent requested" ) ;
282
280
283
281
let intent_id_storage = IntentIdStorage :: new ( ctx. storage_db . clone ( ) ) ;
@@ -325,40 +323,54 @@ async fn handle_native_task<
325
323
. await ;
326
324
327
325
let ( execution_result, should_notify_parentchain) = match intent {
328
- Intent :: SystemRemark ( remark) => {
329
- let remark_call = SystemCall :: remark { remark : remark. to_vec ( ) } ;
330
- let _ = dispatch_as_signed (
331
- & mut rpc_client,
332
- ctx. transaction_signer . clone ( ) ,
333
- sender,
334
- RuntimeCall :: System ( remark_call) ,
335
- auth_type,
336
- )
337
- . await ;
338
- send_ok (
326
+ Intent :: SystemRemark ( _remark) => {
327
+ // let remark_call = SystemCall::remark { remark: remark.to_vec() };
328
+ // let _ = dispatch_as_signed(
329
+ // &mut rpc_client,
330
+ // ctx.transaction_signer.clone(),
331
+ // sender,
332
+ // RuntimeCall::System(remark_call),
333
+ // auth_type,
334
+ // )
335
+ // .await;
336
+ // send_ok(
337
+ // response_sender,
338
+ // NativeTaskOk::RequestIntentResult { intent_id, success: true },
339
+ // );
340
+ // (IntentCompletedDetail::Success, true)
341
+ info ! ( "Intent rejected" ) ;
342
+ send_error (
343
+ "Intent not accepted" . to_string ( ) ,
339
344
response_sender,
340
- NativeTaskOk :: RequestIntentResult { intent_id , success : true } ,
345
+ NativeTaskError :: InternalError ,
341
346
) ;
342
- ( IntentCompletedDetail :: Success , true )
347
+ ( IntentCompletedDetail :: Failure , true )
343
348
} ,
344
- Intent :: TransferNative ( transfer) => {
345
- let transfer_call = BalancesCall :: transfer_allow_death {
346
- dest : transfer. to . to_subxt_type ( ) . into ( ) ,
347
- value : transfer. value ,
348
- } ;
349
- let _ = dispatch_as_signed (
350
- & mut rpc_client,
351
- ctx. transaction_signer . clone ( ) ,
352
- sender,
353
- RuntimeCall :: Balances ( transfer_call) ,
354
- auth_type,
355
- )
356
- . await ;
357
- send_ok (
349
+ Intent :: TransferNative ( _transfer) => {
350
+ // let transfer_call = BalancesCall::transfer_allow_death {
351
+ // dest: transfer.to.to_subxt_type().into(),
352
+ // value: transfer.value,
353
+ // };
354
+ // let _ = dispatch_as_signed(
355
+ // &mut rpc_client,
356
+ // ctx.transaction_signer.clone(),
357
+ // sender,
358
+ // RuntimeCall::Balances(transfer_call),
359
+ // auth_type,
360
+ // )
361
+ // .await;
362
+ // send_ok(
363
+ // response_sender,
364
+ // NativeTaskOk::RequestIntentResult { intent_id, success: true },
365
+ // );
366
+ // (IntentCompletedDetail::Success, true)
367
+ info ! ( "Intent rejected" ) ;
368
+ send_error (
369
+ "Intent not accepted" . to_string ( ) ,
358
370
response_sender,
359
- NativeTaskOk :: RequestIntentResult { intent_id , success : true } ,
371
+ NativeTaskError :: InternalError ,
360
372
) ;
361
- ( IntentCompletedDetail :: Success , true )
373
+ ( IntentCompletedDetail :: Failure , true )
362
374
} ,
363
375
Intent :: CallEthereum ( _) | Intent :: TransferEthereum ( _) => {
364
376
// if let Err(e) = ctx
@@ -708,15 +720,15 @@ async fn handle_native_task<
708
720
return ;
709
721
} ,
710
722
NativeTask :: PumpxExportWallet (
711
- sender ,
723
+ omni_account ,
712
724
google_code,
713
725
pumpx_chain_id,
714
726
pumpx_wallet_index,
715
727
expected_wallet_address,
716
728
) => {
717
729
let storage = HeimaJwtStorage :: new ( ctx. storage_db . clone ( ) ) ;
718
730
let Ok ( Some ( access_token) ) =
719
- storage. get ( & ( sender . to_omni_account ( client_id ) , AUTH_TOKEN_ACCESS_TYPE ) )
731
+ storage. get ( & ( omni_account . clone ( ) , AUTH_TOKEN_ACCESS_TYPE ) )
720
732
else {
721
733
send_error (
722
734
format ! ( "Failed to get pumpx_{}_jwt_token" , AUTH_TOKEN_ACCESS_TYPE ) ,
@@ -756,7 +768,7 @@ async fn handle_native_task<
756
768
. export_wallet (
757
769
chain,
758
770
pumpx_wallet_index,
759
- sender . to_omni_account ( client_id ) . into ( ) ,
771
+ omni_account . clone ( ) . into ( ) ,
760
772
// TODO: theoretically we could pass the aes_key from initial RPC to signer, so that
761
773
// we don't have to do double encryption/decryption
762
774
ctx. aes256_key . to_vec ( ) ,
@@ -781,18 +793,14 @@ async fn handle_native_task<
781
793
} ;
782
794
783
795
let omni_account_profile_storage = PumpxProfileStorage :: new ( ctx. storage_db . clone ( ) ) ;
784
- if let Ok ( maybe_profile) =
785
- omni_account_profile_storage. get ( & sender. to_omni_account ( client_id) )
786
- {
796
+ if let Ok ( maybe_profile) = omni_account_profile_storage. get ( & omni_account) {
787
797
let profile = maybe_profile
788
798
. map ( |mut p| {
789
799
p. wallet_exported = true ;
790
800
p
791
801
} )
792
802
. unwrap_or_else ( || PumpxAccountProfile { wallet_exported : true } ) ;
793
- if let Err ( e) =
794
- omni_account_profile_storage. insert ( & sender. to_omni_account ( client_id) , profile)
795
- {
803
+ if let Err ( e) = omni_account_profile_storage. insert ( & omni_account, profile) {
796
804
error ! ( "Failed to update pumpx account profile: {:?}" , e) ;
797
805
send_error (
798
806
"Failed to update omni account profile" . to_string ( ) ,
@@ -812,10 +820,9 @@ async fn handle_native_task<
812
820
send_ok ( response_sender, NativeTaskOk :: PumpxExportWallet ( decrypted_wallet) ) ;
813
821
return ;
814
822
} ,
815
- NativeTask :: PumpxAddWallet ( sender ) => {
823
+ NativeTask :: PumpxAddWallet ( omni_account ) => {
816
824
let storage = HeimaJwtStorage :: new ( ctx. storage_db . clone ( ) ) ;
817
- let Ok ( Some ( access_token) ) =
818
- storage. get ( & ( sender. to_omni_account ( client_id) , AUTH_TOKEN_ACCESS_TYPE ) )
825
+ let Ok ( Some ( access_token) ) = storage. get ( & ( omni_account, AUTH_TOKEN_ACCESS_TYPE ) )
819
826
else {
820
827
send_error (
821
828
format ! ( "Failed to get pumpx_{}_jwt_token" , AUTH_TOKEN_ACCESS_TYPE ) ,
@@ -839,19 +846,7 @@ async fn handle_native_task<
839
846
send_ok ( response_sender, NativeTaskOk :: PumpxAddWallet ( backend_response) ) ;
840
847
return ;
841
848
} ,
842
- NativeTask :: PumpxSignLimitOrder ( sender, chain_id, wallet_index, unsigned_tx) => {
843
- // This is a workaround, in this case the Substrate identity is the OmniAccount address itself
844
- let omni_account: AccountId = match sender {
845
- Identity :: Substrate ( ref account) => account. into ( ) ,
846
- _ => {
847
- send_error (
848
- "Invalid sender type for PumpxSignLimitOrder" . to_string ( ) ,
849
- response_sender,
850
- NativeTaskError :: InternalError ,
851
- ) ;
852
- return ;
853
- } ,
854
- } ;
849
+ NativeTask :: PumpxSignLimitOrder ( omni_account, chain_id, wallet_index, unsigned_tx) => {
855
850
let Some ( chain) = ChainType :: from_pumpx_chain_id ( chain_id) else {
856
851
error ! ( "Failed to map pumpx chain_id {}" , chain_id) ;
857
852
let response = NativeTaskResponse :: Err ( NativeTaskError :: InternalError ) ;
@@ -879,7 +874,7 @@ async fn handle_native_task<
879
874
return ;
880
875
} ,
881
876
NativeTask :: PumpxTransferWidthdraw (
882
- sender ,
877
+ omni_account ,
883
878
request_id,
884
879
chain_id,
885
880
wallet_index,
@@ -892,7 +887,7 @@ async fn handle_native_task<
892
887
// 1. Verify we have a valid Pumpx "access" token for the user
893
888
let storage = HeimaJwtStorage :: new ( ctx. storage_db . clone ( ) ) ;
894
889
let Ok ( Some ( access_token) ) =
895
- storage. get ( & ( sender . to_omni_account ( client_id ) , AUTH_TOKEN_ACCESS_TYPE ) )
890
+ storage. get ( & ( omni_account . clone ( ) , AUTH_TOKEN_ACCESS_TYPE ) )
896
891
else {
897
892
send_error (
898
893
"Failed to get access_token within NativeTask::PumpxTransferWidthdraw"
@@ -946,7 +941,7 @@ async fn handle_native_task<
946
941
} ;
947
942
return ;
948
943
} ,
949
- NativeTask :: PumpxNotifyLimitOrderResult ( sender , intent_id, result, message) => {
944
+ NativeTask :: PumpxNotifyLimitOrderResult ( omni_account , intent_id, result, message) => {
950
945
if result != "ok" && result != "nok" {
951
946
send_error (
952
947
format ! ( "Invalid result value: {}. Must be 'ok' or 'nok'" , result) ,
@@ -966,19 +961,6 @@ async fn handle_native_task<
966
961
info ! ( "Limit order result message for intent_id {}: {}" , intent_id, msg) ;
967
962
}
968
963
969
- // This is a workaround, in this case the Substrate identity is the OmniAccount address itself
970
- let omni_account: AccountId = match sender {
971
- Identity :: Substrate ( ref account) => account. into ( ) ,
972
- _ => {
973
- send_error (
974
- "Invalid sender type for PumpxSignLimitOrder" . to_string ( ) ,
975
- response_sender,
976
- NativeTaskError :: InternalError ,
977
- ) ;
978
- return ;
979
- } ,
980
- } ;
981
-
982
964
send_ok ( response_sender, NativeTaskOk :: PumpxNotifyLimitOrderResult ) ;
983
965
984
966
notify_intent_completed (
@@ -1030,33 +1012,33 @@ fn send_ok(sender: ResponseSender, ok_res: NativeTaskOk) {
1030
1012
send_response ( sender, NativeTaskResponse :: Ok ( ok_res) ) ;
1031
1013
}
1032
1014
1033
- async fn dispatch_as_signed <
1034
- Header : Send + Sync + ' static ,
1035
- RpcClient : SubstrateRpcClient < Header > + Send + Sync + ' static ,
1036
- > (
1037
- client : & mut RpcClient ,
1038
- signer : Arc < ParentchainTxSigner > ,
1039
- sender : Identity ,
1040
- call : RuntimeCall ,
1041
- auth_type : Option < OmniAccountAuthType > ,
1042
- ) {
1043
- let call = parentchain_api_interface:: tx ( ) . omni_account ( ) . dispatch_as_signed (
1044
- sender. hash ( ) . to_subxt_type ( ) ,
1045
- call,
1046
- auth_type. map ( |t| t. to_subxt_type ( ) ) ,
1047
- ) ;
1048
- let tx = signer. sign ( call) . await ;
1049
- // notify parentchain - for now we continue even with error
1050
- match client. submit_tx ( & tx) . await {
1051
- Ok ( _) => {
1052
- debug ! ( "Submitted dispatch_as_signed parentchain call" )
1053
- } ,
1054
- Err ( _) => {
1055
- error ! ( "Failed to submit dispatch_as_signed parentchain call" , ) ;
1056
- signer. update_nonce ( ) . await
1057
- } ,
1058
- } ;
1059
- }
1015
+ // async fn dispatch_as_signed<
1016
+ // Header: Send + Sync + 'static,
1017
+ // RpcClient: SubstrateRpcClient<Header> + Send + Sync + 'static,
1018
+ // >(
1019
+ // client: &mut RpcClient,
1020
+ // signer: Arc<ParentchainTxSigner>,
1021
+ // sender: Identity,
1022
+ // call: RuntimeCall,
1023
+ // auth_type: Option<OmniAccountAuthType>,
1024
+ // ) {
1025
+ // let call = parentchain_api_interface::tx().omni_account().dispatch_as_signed(
1026
+ // sender.hash().to_subxt_type(),
1027
+ // call,
1028
+ // auth_type.map(|t| t.to_subxt_type()),
1029
+ // );
1030
+ // let tx = signer.sign(call).await;
1031
+ // // notify parentchain - for now we continue even with error
1032
+ // match client.submit_tx(&tx).await {
1033
+ // Ok(_) => {
1034
+ // debug!("Submitted dispatch_as_signed parentchain call")
1035
+ // },
1036
+ // Err(_) => {
1037
+ // error!("Failed to submit dispatch_as_signed parentchain call",);
1038
+ // signer.update_nonce().await
1039
+ // },
1040
+ // };
1041
+ // }
1060
1042
1061
1043
async fn notify_intent_accepted <
1062
1044
Header : Send + Sync + ' static ,
0 commit comments