WalletConnect show expired toast (#20857)
* WalletConnect show expired toast * Fixes * Fix * Post-rebase fix
This commit is contained in:
parent
402eb8397d
commit
2ffbdac89e
|
@ -164,23 +164,31 @@
|
||||||
current-address (get-in db [:wallet-connect/current-proposal :address])
|
current-address (get-in db [:wallet-connect/current-proposal :address])
|
||||||
accounts (-> (partial wallet-connect-core/format-eip155-address current-address)
|
accounts (-> (partial wallet-connect-core/format-eip155-address current-address)
|
||||||
(map session-networks))
|
(map session-networks))
|
||||||
network-status (:network/status db)]
|
network-status (:network/status db)
|
||||||
|
expiry (get-in current-proposal [:params :expiryTimestamp])]
|
||||||
(if (= network-status :online)
|
(if (= network-status :online)
|
||||||
{:fx [[:effects.wallet-connect/approve-session
|
{:fx [(if (wc-utils/timestamp-expired? expiry)
|
||||||
{:web3-wallet web3-wallet
|
[:dispatch
|
||||||
:proposal current-proposal
|
[:toasts/upsert
|
||||||
:networks session-networks
|
{:id :wallet-connect-proposal-expired
|
||||||
:accounts accounts
|
:type :negative
|
||||||
:on-success (fn [approved-session]
|
:text (i18n/label :t/wallet-connect-proposal-expired)}]]
|
||||||
(log/info "Wallet Connect session approved")
|
[:effects.wallet-connect/approve-session
|
||||||
(rf/dispatch [:wallet-connect/reset-current-session-proposal])
|
{:web3-wallet web3-wallet
|
||||||
(rf/dispatch [:wallet-connect/persist-session approved-session]))
|
:proposal current-proposal
|
||||||
:on-fail (fn [error]
|
:networks session-networks
|
||||||
(log/error "Wallet Connect session approval failed"
|
:accounts accounts
|
||||||
{:error error
|
:on-success (fn [approved-session]
|
||||||
:event :wallet-connect/approve-session})
|
(log/info "Wallet Connect session approved")
|
||||||
(rf/dispatch
|
(rf/dispatch [:wallet-connect/reset-current-session-proposal])
|
||||||
[: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]]]}
|
[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]]}
|
||||||
{:fx [[:dispatch [:wallet-connect/no-internet-toast]]]}))))
|
{:fx [[:dispatch [:wallet-connect/no-internet-toast]]]}))))
|
||||||
|
|
||||||
|
|
|
@ -3,31 +3,42 @@
|
||||||
[react-native.wallet-connect :as wallet-connect]
|
[react-native.wallet-connect :as wallet-connect]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.wallet.wallet-connect.core :as wallet-connect-core]
|
[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
|
(rf/reg-event-fx
|
||||||
:wallet-connect/respond-current-session
|
:wallet-connect/respond-current-session
|
||||||
(fn [{:keys [db]} [password]]
|
(fn [{:keys [db]} [password]]
|
||||||
(let [event (get-in db [:wallet-connect/current-request :event])
|
(let [event (get-in db [:wallet-connect/current-request :event])
|
||||||
method (wallet-connect-core/get-request-method event)]
|
method (wallet-connect-core/get-request-method event)
|
||||||
{:fx [(condp = method
|
screen (wallet-connect-core/method-to-screen method)
|
||||||
constants/wallet-connect-personal-sign-method
|
expiry (get-in event [:params :request :expiryTimestamp])]
|
||||||
[:dispatch [:wallet-connect/respond-sign-message password :personal-sign]]
|
(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
|
constants/wallet-connect-eth-sign-method
|
||||||
[:dispatch [:wallet-connect/respond-sign-message password :eth-sign]]
|
[:dispatch [:wallet-connect/respond-sign-message password :eth-sign]]
|
||||||
|
|
||||||
constants/wallet-connect-eth-send-transaction-method
|
constants/wallet-connect-eth-send-transaction-method
|
||||||
[:dispatch [:wallet-connect/respond-send-transaction-data password]]
|
[:dispatch [:wallet-connect/respond-send-transaction-data password]]
|
||||||
|
|
||||||
constants/wallet-connect-eth-sign-transaction-method
|
constants/wallet-connect-eth-sign-transaction-method
|
||||||
[:dispatch [:wallet-connect/respond-sign-transaction-data password]]
|
[:dispatch [:wallet-connect/respond-sign-transaction-data password]]
|
||||||
|
|
||||||
constants/wallet-connect-eth-sign-typed-method
|
constants/wallet-connect-eth-sign-typed-method
|
||||||
[:dispatch [:wallet-connect/respond-sign-typed-data password :v1]]
|
[:dispatch [:wallet-connect/respond-sign-typed-data password :v1]]
|
||||||
|
|
||||||
constants/wallet-connect-eth-sign-typed-v4-method
|
constants/wallet-connect-eth-sign-typed-v4-method
|
||||||
[:dispatch [:wallet-connect/respond-sign-typed-data password :v4]])]})))
|
[:dispatch [:wallet-connect/respond-sign-typed-data password :v4]])]}))))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet-connect/respond-sign-message
|
:wallet-connect/respond-sign-message
|
||||||
|
|
|
@ -2634,8 +2634,10 @@
|
||||||
"wallet-connect-networks-not-supported": "{{dapp}} requires an unsupported network.",
|
"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-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-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-proposal-title": "Would like to connect with your wallet",
|
||||||
"wallet-connect-qr-expired": "WalletConnect QR has expired",
|
"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-header": "wants you to send this transaction with",
|
||||||
"wallet-connect-send-transaction-warning": "Send transactions only if you trust the dApp",
|
"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-header": "wants you to sign the message with",
|
||||||
|
|
Loading…
Reference in New Issue