From 80ae1b4734bc5786e381b2d357d8228f393a8cd3 Mon Sep 17 00:00:00 2001 From: Cristian Lungu Date: Fri, 18 Oct 2024 11:53:59 +0300 Subject: [PATCH] feat: removed eth_signTransaction flow (was disabled) --- src/status_im/constants.cljs | 2 - .../wallet/wallet_connect/events/effects.cljs | 11 ---- .../events/session_requests.cljs | 3 - .../events/session_responses.cljs | 17 ------ .../modals/sign_transaction/view.cljs | 57 ------------------- .../wallet_connect/utils/data_store.cljs | 3 +- .../wallet_connect/utils/transactions.cljs | 11 +--- src/status_im/navigation/screens.cljs | 6 -- translations/en.json | 2 - 9 files changed, 2 insertions(+), 110 deletions(-) delete mode 100644 src/status_im/contexts/wallet/wallet_connect/modals/sign_transaction/view.cljs diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 6d41398963..19f299d7df 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -279,8 +279,6 @@ #{wallet-connect-personal-sign-method wallet-connect-eth-sign-method wallet-connect-eth-send-transaction-method - ;; NOTE: disabled, as we have no clear use cases for it and other wallets don't support it - ;; wallet-connect-eth-sign-transaction-method wallet-connect-eth-sign-typed-method wallet-connect-eth-sign-typed-v4-method}) (def ^:const wallet-connect-supported-events #{"accountsChanged" "chainChanged"}) diff --git a/src/status_im/contexts/wallet/wallet_connect/events/effects.cljs b/src/status_im/contexts/wallet/wallet_connect/events/effects.cljs index 63a0ea0a8b..2efb87bf97 100644 --- a/src/status_im/contexts/wallet/wallet_connect/events/effects.cljs +++ b/src/status_im/contexts/wallet/wallet_connect/events/effects.cljs @@ -84,17 +84,6 @@ (promesa/then on-success) (promesa/catch on-error)))) -(rf/reg-fx - :effects.wallet-connect/sign-transaction - (fn [{:keys [password address chain-id tx-hash tx-args on-success on-error]}] - (-> (transactions/sign-transaction (security/safe-unmask-data password) - address - tx-hash - tx-args - chain-id) - (promesa/then (partial rf/call-continuation on-success)) - (promesa/catch (partial rf/call-continuation on-error))))) - (rf/reg-fx :effects.wallet-connect/send-transaction (fn [{:keys [password address chain-id tx-hash tx-args on-success on-error]}] diff --git a/src/status_im/contexts/wallet/wallet_connect/events/session_requests.cljs b/src/status_im/contexts/wallet/wallet_connect/events/session_requests.cljs index 630679a578..6faef94ffd 100644 --- a/src/status_im/contexts/wallet/wallet_connect/events/session_requests.cljs +++ b/src/status_im/contexts/wallet/wallet_connect/events/session_requests.cljs @@ -44,9 +44,6 @@ constants/wallet-connect-eth-sign-method [:dispatch [:wallet-connect/process-eth-sign]] - constants/wallet-connect-eth-sign-transaction-method - [:dispatch [:wallet-connect/process-eth-sign-transaction]] - constants/wallet-connect-eth-sign-typed-method [:dispatch [:wallet-connect/process-sign-typed]] diff --git a/src/status_im/contexts/wallet/wallet_connect/events/session_responses.cljs b/src/status_im/contexts/wallet/wallet_connect/events/session_responses.cljs index 91d0f8ec7a..02f262b549 100644 --- a/src/status_im/contexts/wallet/wallet_connect/events/session_responses.cljs +++ b/src/status_im/contexts/wallet/wallet_connect/events/session_responses.cljs @@ -33,9 +33,6 @@ constants/wallet-connect-eth-send-transaction-method [:dispatch [:wallet-connect/respond-send-transaction-data password]] - constants/wallet-connect-eth-sign-transaction-method - [:dispatch [:wallet-connect/respond-sign-transaction-data password]] - constants/wallet-connect-eth-sign-typed-method [:dispatch [:wallet-connect/respond-sign-typed-data password :v1]] @@ -82,20 +79,6 @@ :on-error [:wallet-connect/on-sign-error] :on-success [:wallet-connect/finish-session-request]}]]}))) -(rf/reg-event-fx - :wallet-connect/respond-sign-transaction-data - (fn [{:keys [db]} [password]] - (let [{:keys [chain-id raw-data address]} (get db :wallet-connect/current-request) - {:keys [tx-hash tx-args]} raw-data] - {:fx [[:effects.wallet-connect/sign-transaction - {:password password - :address address - :chain-id chain-id - :tx-hash tx-hash - :tx-params tx-args - :on-error [:wallet-connect/on-sign-error] - :on-success [:wallet-connect/finish-session-request]}]]}))) - (rf/reg-event-fx :wallet-connect/on-sign-error (fn [{:keys [db]} [error]] diff --git a/src/status_im/contexts/wallet/wallet_connect/modals/sign_transaction/view.cljs b/src/status_im/contexts/wallet/wallet_connect/modals/sign_transaction/view.cljs deleted file mode 100644 index 3aa090401c..0000000000 --- a/src/status_im/contexts/wallet/wallet_connect/modals/sign_transaction/view.cljs +++ /dev/null @@ -1,57 +0,0 @@ -(ns status-im.contexts.wallet.wallet-connect.modals.sign-transaction.view - (:require [quo.core :as quo] - [react-native.core :as rn] - [react-native.safe-area :as safe-area] - [status-im.contexts.wallet.wallet-connect.modals.common.data-block.view :as data-block] - [status-im.contexts.wallet.wallet-connect.modals.common.fees-data-item.view :as - fees-data-item] - [status-im.contexts.wallet.wallet-connect.modals.common.footer.view :as footer] - [status-im.contexts.wallet.wallet-connect.modals.common.header.view :as header] - [status-im.contexts.wallet.wallet-connect.modals.common.page-nav.view :as page-nav] - [status-im.contexts.wallet.wallet-connect.modals.common.style :as style] - [utils.i18n :as i18n] - [utils.re-frame :as rf])) - -(defn view - [] - (let [bottom (safe-area/get-bottom) - {:keys [customization-color] - :as account} (rf/sub [:wallet-connect/current-request-account-details]) - dapp (rf/sub [:wallet-connect/current-request-dapp]) - network (rf/sub [:wallet-connect/current-request-network]) - {:keys [max-fees-fiat-formatted - error-state]} (rf/sub [:wallet-connect/current-request-transaction-information])] - (rn/use-unmount #(rf/dispatch [:wallet-connect/on-request-modal-dismissed])) - [rn/view {:style (style/container bottom)} - [quo/gradient-cover {:customization-color customization-color}] - [page-nav/view - {:accessibility-label :wallet-connect-sign-message-close}] - [rn/view {:flex 1} - [rn/view {:style style/data-content-container} - [header/view - {:label (i18n/label :t/wallet-connect-sign-transaction-header) - :dapp dapp - :account account}] - [data-block/view]] - [footer/view - {:warning-label (i18n/label :t/wallet-connect-sign-warning) - :slide-button-text (i18n/label :t/slide-to-sign) - :error-text (when error-state - (i18n/label (condp = error-state - :not-enough-assets-to-pay-gas-fees - :t/not-enough-assets-to-pay-gas-fees - - :not-enough-assets - :t/not-enough-assets)))} - [quo/data-item - {:status :default - :card? false - :container-style style/data-item - :title (i18n/label :t/network) - :subtitle-type :network - :network-image (:source network) - :subtitle (:full-name network)}] - [fees-data-item/view - {:fees max-fees-fiat-formatted - :fees-error error-state}]]]])) - diff --git a/src/status_im/contexts/wallet/wallet_connect/utils/data_store.cljs b/src/status_im/contexts/wallet/wallet_connect/utils/data_store.cljs index 64036a1909..5b023c3973 100644 --- a/src/status_im/contexts/wallet/wallet_connect/utils/data_store.cljs +++ b/src/status_im/contexts/wallet/wallet_connect/utils/data_store.cljs @@ -31,8 +31,7 @@ constants/wallet-connect-eth-sign-typed-method :screen/wallet-connect.sign-message constants/wallet-connect-eth-sign-method :screen/wallet-connect.sign-message constants/wallet-connect-eth-sign-typed-v4-method :screen/wallet-connect.sign-message - constants/wallet-connect-eth-send-transaction-method :screen/wallet-connect.send-transaction - constants/wallet-connect-eth-sign-transaction-method :screen/wallet-connect.sign-transaction}) + constants/wallet-connect-eth-send-transaction-method :screen/wallet-connect.send-transaction}) (defn extract-native-call-signature [data] diff --git a/src/status_im/contexts/wallet/wallet_connect/utils/transactions.cljs b/src/status_im/contexts/wallet/wallet_connect/utils/transactions.cljs index f637d53d69..da156ced7c 100644 --- a/src/status_im/contexts/wallet/wallet_connect/utils/transactions.cljs +++ b/src/status_im/contexts/wallet/wallet_connect/utils/transactions.cljs @@ -1,6 +1,5 @@ (ns status-im.contexts.wallet.wallet-connect.utils.transactions (:require [cljs-bean.core :as bean] - [cljs.pprint :as pprint] [clojure.string :as string] [native-module.core :as native-module] [promesa.core :as promesa] @@ -14,8 +13,7 @@ (defn transaction-request? [event] (->> (data-store/get-request-method event) - (contains? #{constants/wallet-connect-eth-send-transaction-method - constants/wallet-connect-eth-sign-transaction-method}))) + (contains? #{constants/wallet-connect-eth-send-transaction-method}))) ;; NOTE: Currently we don't allow the user to configure the tx priority as we don't ;; show the estimated time, but when we implement it, we should allow to change it @@ -137,13 +135,6 @@ :suggested-fees suggested-fees :estimated-time estimated-time})) -(defn sign-transaction - [password address tx-hash tx-args chain-id] - (promesa/let - [signature (rpc/wallet-sign-message tx-hash address password) - raw-tx (rpc/wallet-build-raw-transaction chain-id tx-args signature)] - raw-tx)) - (defn send-transaction [password address tx-hash tx-args chain-id] (promesa/let diff --git a/src/status_im/navigation/screens.cljs b/src/status_im/navigation/screens.cljs index a993fabde1..24dd80d98b 100644 --- a/src/status_im/navigation/screens.cljs +++ b/src/status_im/navigation/screens.cljs @@ -136,8 +136,6 @@ [status-im.contexts.wallet.wallet-connect.modals.session-proposal.view :as wallet-connect-session-proposal] [status-im.contexts.wallet.wallet-connect.modals.sign-message.view :as wallet-connect-sign-message] - [status-im.contexts.wallet.wallet-connect.modals.sign-transaction.view :as - wallet-connect-sign-transaction] [status-im.navigation.options :as options] [status-im.navigation.transitions :as transitions])) @@ -563,10 +561,6 @@ :options {:sheet? true} :component wallet-connect-sign-message/view} - {:name :screen/wallet-connect.sign-transaction - :options {:sheet? true} - :component wallet-connect-sign-transaction/view} - {:name :screen/wallet-connect.send-transaction :options {:sheet? true} :component wallet-connect-send-transaction/view} diff --git a/translations/en.json b/translations/en.json index c100d37330..0c0257e21f 100644 --- a/translations/en.json +++ b/translations/en.json @@ -2745,8 +2745,6 @@ "wallet-connect-send-transaction-warning": "Send transactions only if you trust the dApp", "wallet-connect-sign-message-header": "wants you to sign the message with", "wallet-connect-sign-message-warning": "Sign messages only if you trust the dApp", - "wallet-connect-sign-transaction-header": "wants you to sign this transaction with", - "wallet-connect-sign-transaction-warning": "Sign transactions only if you trust the dApp", "wallet-connect-sign-warning": "Sign only if you trust the dApp", "wallet-connect-typed-data-wrong-chain-id-warning": "Wrong network in the request data. Expected '{{expected-chain}}', but got '{{wrong-chain}}'", "wallet-connect-version-not-supported": "WalletConnect version {{version}} is not supported",