diff --git a/src/status_im/contexts/wallet/wallet_connect/events.cljs b/src/status_im/contexts/wallet/wallet_connect/events.cljs index cad0ca9015..48e5491cdf 100644 --- a/src/status_im/contexts/wallet/wallet_connect/events.cljs +++ b/src/status_im/contexts/wallet/wallet_connect/events.cljs @@ -164,23 +164,31 @@ current-address (get-in db [:wallet-connect/current-proposal :address]) accounts (-> (partial wallet-connect-core/format-eip155-address current-address) (map session-networks)) - network-status (:network/status db)] + network-status (:network/status db) + expiry (get-in current-proposal [:params :expiryTimestamp])] (if (= network-status :online) - {:fx [[:effects.wallet-connect/approve-session - {:web3-wallet web3-wallet - :proposal current-proposal - :networks session-networks - :accounts accounts - :on-success (fn [approved-session] - (log/info "Wallet Connect session approved") - (rf/dispatch [:wallet-connect/reset-current-session-proposal]) - (rf/dispatch [:wallet-connect/persist-session approved-session])) - :on-fail (fn [error] - (log/error "Wallet Connect session approval failed" - {:error error - :event :wallet-connect/approve-session}) - (rf/dispatch - [:wallet-connect/reset-current-session-proposal]))}] + {:fx [(if (wc-utils/timestamp-expired? expiry) + [:dispatch + [:toasts/upsert + {:id :wallet-connect-proposal-expired + :type :negative + :text (i18n/label :t/wallet-connect-proposal-expired)}]] + [:effects.wallet-connect/approve-session + {:web3-wallet web3-wallet + :proposal current-proposal + :networks session-networks + :accounts accounts + :on-success (fn [approved-session] + (log/info "Wallet Connect session approved") + (rf/dispatch [:wallet-connect/reset-current-session-proposal]) + (rf/dispatch [:wallet-connect/persist-session + approved-session])) + :on-fail (fn [error] + (log/error "Wallet Connect session approval failed" + {:error error + :event :wallet-connect/approve-session}) + (rf/dispatch + [:wallet-connect/reset-current-session-proposal]))}]) [:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]]} {:fx [[:dispatch [:wallet-connect/no-internet-toast]]]})))) diff --git a/src/status_im/contexts/wallet/wallet_connect/responding_events.cljs b/src/status_im/contexts/wallet/wallet_connect/responding_events.cljs index a487c09911..f4381fe14b 100644 --- a/src/status_im/contexts/wallet/wallet_connect/responding_events.cljs +++ b/src/status_im/contexts/wallet/wallet_connect/responding_events.cljs @@ -3,31 +3,42 @@ [react-native.wallet-connect :as wallet-connect] [status-im.constants :as constants] [status-im.contexts.wallet.wallet-connect.core :as wallet-connect-core] - [taoensso.timbre :as log])) + [status-im.contexts.wallet.wallet-connect.utils :as wc-utils] + [taoensso.timbre :as log] + [utils.i18n :as i18n])) (rf/reg-event-fx :wallet-connect/respond-current-session (fn [{:keys [db]} [password]] (let [event (get-in db [:wallet-connect/current-request :event]) - method (wallet-connect-core/get-request-method event)] - {:fx [(condp = method - constants/wallet-connect-personal-sign-method - [:dispatch [:wallet-connect/respond-sign-message password :personal-sign]] + method (wallet-connect-core/get-request-method event) + screen (wallet-connect-core/method-to-screen method) + expiry (get-in event [:params :request :expiryTimestamp])] + (if (wc-utils/timestamp-expired? expiry) + {:fx [[:dispatch + [:toasts/upsert + {:id :new-wallet-account-created + :type :negative + :text (i18n/label :t/wallet-connect-request-expired)}]] + [:dispatch [:dismiss-modal screen]]]} + {:fx [(condp = method + constants/wallet-connect-personal-sign-method + [:dispatch [:wallet-connect/respond-sign-message password :personal-sign]] - constants/wallet-connect-eth-sign-method - [:dispatch [:wallet-connect/respond-sign-message password :eth-sign]] + constants/wallet-connect-eth-sign-method + [:dispatch [:wallet-connect/respond-sign-message password :eth-sign]] - constants/wallet-connect-eth-send-transaction-method - [:dispatch [:wallet-connect/respond-send-transaction-data password]] + 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-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]] + constants/wallet-connect-eth-sign-typed-method + [:dispatch [:wallet-connect/respond-sign-typed-data password :v1]] - constants/wallet-connect-eth-sign-typed-v4-method - [:dispatch [:wallet-connect/respond-sign-typed-data password :v4]])]}))) + constants/wallet-connect-eth-sign-typed-v4-method + [:dispatch [:wallet-connect/respond-sign-typed-data password :v4]])]})))) (rf/reg-event-fx :wallet-connect/respond-sign-message diff --git a/translations/en.json b/translations/en.json index ea21007e1e..1d0cd075ab 100644 --- a/translations/en.json +++ b/translations/en.json @@ -2634,8 +2634,10 @@ "wallet-connect-networks-not-supported": "{{dapp}} requires an unsupported network.", "wallet-connect-no-internet-warning": "Oops, you have no internet. Try again later!", "wallet-connect-proposal-description": "By connecting you allow {{name}} to retrieve your account address and enable Web3", + "wallet-connect-proposal-expired": "WalletConnect proposal has expired", "wallet-connect-proposal-title": "Would like to connect with your wallet", "wallet-connect-qr-expired": "WalletConnect QR has expired", + "wallet-connect-request-expired": "WalletConnect request has expired", "wallet-connect-send-transaction-header": "wants you to send this transaction with", "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",