remove obsolete code (#18094)
This commit is contained in:
parent
3ad345519b
commit
536ebf56cb
|
@ -1,46 +0,0 @@
|
||||||
(ns status-im.commands.core
|
|
||||||
(:require
|
|
||||||
[re-frame.core :as re-frame]
|
|
||||||
[status-im.wallet.utils :as wallet.utils]
|
|
||||||
[utils.re-frame :as rf]))
|
|
||||||
|
|
||||||
(rf/defn handle-prepare-accept-request-address-for-transaction
|
|
||||||
{:events [::prepare-accept-request-address-for-transaction]}
|
|
||||||
[{:keys [db]} message]
|
|
||||||
{:db (assoc db
|
|
||||||
:commands/select-account
|
|
||||||
{:message message
|
|
||||||
:from (wallet.utils/get-default-account (:profile/wallet-accounts
|
|
||||||
db))})
|
|
||||||
:show-select-acc-sheet nil})
|
|
||||||
|
|
||||||
(rf/defn set-selected-account
|
|
||||||
{:events [::set-selected-account]}
|
|
||||||
[{:keys [db]} _ account]
|
|
||||||
{:db (-> (assoc-in db [:commands/select-account :from] account)
|
|
||||||
(assoc :bottom-sheet/show? false))})
|
|
||||||
|
|
||||||
(rf/defn handle-accept-request-address-for-transaction
|
|
||||||
{:events [::accept-request-address-for-transaction]}
|
|
||||||
[{:keys [db]} message-id address]
|
|
||||||
{:db (dissoc db :commands/select-account)
|
|
||||||
:json-rpc/call [{:method "wakuext_acceptRequestAddressForTransaction"
|
|
||||||
:params [message-id address]
|
|
||||||
:js-response true
|
|
||||||
:on-success #(re-frame/dispatch [:transport/message-sent %])}]})
|
|
||||||
|
|
||||||
(rf/defn handle-decline-request-address-for-transaction
|
|
||||||
{:events [::decline-request-address-for-transaction]}
|
|
||||||
[_ message-id]
|
|
||||||
{:json-rpc/call [{:method "wakuext_declineRequestAddressForTransaction"
|
|
||||||
:params [message-id]
|
|
||||||
:js-response true
|
|
||||||
:on-success #(re-frame/dispatch [:transport/message-sent %])}]})
|
|
||||||
|
|
||||||
(rf/defn handle-decline-request-transaction
|
|
||||||
{:events [::decline-request-transaction]}
|
|
||||||
[cofx message-id]
|
|
||||||
{:json-rpc/call [{:method "wakuext_declineRequestTransaction"
|
|
||||||
:params [message-id]
|
|
||||||
:js-response true
|
|
||||||
:on-success #(re-frame/dispatch [:transport/message-sent %])}]})
|
|
|
@ -1,18 +0,0 @@
|
||||||
(ns status-im.contact.chat
|
|
||||||
(:require
|
|
||||||
[re-frame.core :as re-frame]
|
|
||||||
[status-im2.contexts.contacts.events :as contact]
|
|
||||||
[status-im2.navigation.events :as navigation]
|
|
||||||
[utils.re-frame :as rf]))
|
|
||||||
|
|
||||||
(rf/defn contact-code-submitted
|
|
||||||
{:events [:contact.ui/contact-code-submitted]
|
|
||||||
:interceptors [(re-frame/inject-cofx :random-id-generator)]}
|
|
||||||
[{{:contacts/keys [new-identity]} :db :as cofx} new-contact? nickname]
|
|
||||||
(let [{:keys [public-key ens-name]} new-identity]
|
|
||||||
(rf/merge cofx
|
|
||||||
#(if new-contact?
|
|
||||||
(contact/send-contact-request % public-key)
|
|
||||||
{:dispatch [:chat.ui/start-chat public-key ens-name]})
|
|
||||||
#(when new-contact?
|
|
||||||
(navigation/navigate-back %)))))
|
|
|
@ -1,13 +0,0 @@
|
||||||
(ns status-im.contact.core
|
|
||||||
(:require
|
|
||||||
[status-im2.navigation.events :as navigation]
|
|
||||||
[utils.re-frame :as rf]))
|
|
||||||
|
|
||||||
(rf/defn open-contact-toggle-list
|
|
||||||
{:events [:contact.ui/start-group-chat-pressed]}
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(rf/merge cofx
|
|
||||||
{:db (assoc db
|
|
||||||
:group/selected-contacts #{}
|
|
||||||
:new-chat-name "")}
|
|
||||||
(navigation/navigate-to :contact-toggle-list nil)))
|
|
|
@ -85,12 +85,3 @@
|
||||||
(assoc acc public-key (enrich-contact contact profile-pictures-visibility own-public-key)))
|
(assoc acc public-key (enrich-contact contact profile-pictures-visibility own-public-key)))
|
||||||
{}
|
{}
|
||||||
contacts))
|
contacts))
|
||||||
|
|
||||||
(defn get-blocked-contacts
|
|
||||||
[contacts]
|
|
||||||
(reduce (fn [acc {:keys [public-key] :as contact}]
|
|
||||||
(if (:blocked? contact)
|
|
||||||
(conj acc public-key)
|
|
||||||
acc))
|
|
||||||
#{}
|
|
||||||
contacts))
|
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
status-im.chat.models.input
|
status-im.chat.models.input
|
||||||
status-im.chat.models.loading
|
status-im.chat.models.loading
|
||||||
status-im.contact.block
|
status-im.contact.block
|
||||||
status-im.contact.chat
|
|
||||||
status-im.contact.core
|
|
||||||
status-im.currency.core
|
status-im.currency.core
|
||||||
status-im.ethereum.subscriptions
|
status-im.ethereum.subscriptions
|
||||||
status-im.fleet.core
|
status-im.fleet.core
|
||||||
|
@ -43,7 +41,6 @@
|
||||||
status-im.visibility-status-popover.core
|
status-im.visibility-status-popover.core
|
||||||
status-im.visibility-status-updates.core
|
status-im.visibility-status-updates.core
|
||||||
status-im.waku.core
|
status-im.waku.core
|
||||||
status-im.wallet-connect.core
|
|
||||||
status-im.wallet.accounts.core
|
status-im.wallet.accounts.core
|
||||||
status-im.wallet.choose-recipient.core
|
status-im.wallet.choose-recipient.core
|
||||||
[status-im.wallet.core :as wallet]
|
[status-im.wallet.core :as wallet]
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
[status-im.multiaccounts.model :as multiaccounts.model]
|
[status-im.multiaccounts.model :as multiaccounts.model]
|
||||||
[status-im.popover.core :as popover]
|
[status-im.popover.core :as popover]
|
||||||
[status-im.utils.deprecated-types :as types]
|
[status-im.utils.deprecated-types :as types]
|
||||||
[status-im.utils.keychain.core :as keychain]
|
|
||||||
[status-im2.constants :as constants]
|
[status-im2.constants :as constants]
|
||||||
[status-im2.navigation.events :as navigation]
|
[status-im2.navigation.events :as navigation]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
|
@ -278,7 +277,7 @@
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc-in [:profile/profiles-overview key-uid :keycard-pairing] pairing)
|
(assoc-in [:profile/profiles-overview key-uid :keycard-pairing] pairing)
|
||||||
(assoc :profile/login account)
|
(assoc :profile/login account)
|
||||||
(assoc :auth-method keychain/auth-method-none)
|
(assoc :auth-method "none")
|
||||||
(update :keycard dissoc :flow :migration-password)
|
(update :keycard dissoc :flow :migration-password)
|
||||||
(dissoc :recovered-account?))
|
(dissoc :recovered-account?))
|
||||||
::finish-migration [account settings password encryption-pass login-params]}))
|
::finish-migration [account settings password encryption-pass login-params]}))
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
(ns status-im.ui.screens.wallet.send.views
|
(ns status-im.ui.screens.wallet.send.views
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs] :as views])
|
(:require-macros [status-im.utils.views :as views])
|
||||||
(:require
|
(:require
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.commands.core :as commands]
|
|
||||||
[status-im.ui.components.bottom-panel.views :as bottom-panel]
|
|
||||||
[status-im.ui.components.chat-icon.screen :as chat-icon]
|
[status-im.ui.components.chat-icon.screen :as chat-icon]
|
||||||
[status-im.ui.components.colors :as colors]
|
[status-im.ui.components.colors :as colors]
|
||||||
[status-im.ui.components.core :as components.core]
|
[status-im.ui.components.core :as components.core]
|
||||||
|
@ -129,47 +127,6 @@
|
||||||
" "
|
" "
|
||||||
(:code wallet-currency))])))
|
(:code wallet-currency))])))
|
||||||
|
|
||||||
(defn select-account-sheet
|
|
||||||
[{:keys [from message]}]
|
|
||||||
[react/view {:style (styles/acc-sheet)}
|
|
||||||
[header
|
|
||||||
{:small-screen? false
|
|
||||||
:label :t/select-account}]
|
|
||||||
[react/view
|
|
||||||
{:flex-direction :row
|
|
||||||
:padding-horizontal 24
|
|
||||||
:align-items :center
|
|
||||||
:margin-vertical 16}]
|
|
||||||
[components.core/list-header
|
|
||||||
(i18n/label :t/from-capitalized)]
|
|
||||||
[react/view {:flex-direction :row :flex 1 :align-items :center}
|
|
||||||
[react/view {:flex 1}
|
|
||||||
[render-account from nil ::commands/set-selected-account]]]
|
|
||||||
[toolbar/toolbar
|
|
||||||
{:left
|
|
||||||
[react/view {:padding-horizontal 8}
|
|
||||||
[components.core/button
|
|
||||||
{:type :secondary
|
|
||||||
:on-press #(re-frame/dispatch [:set :commands/select-account nil])}
|
|
||||||
(i18n/label :t/cancel)]]
|
|
||||||
:right
|
|
||||||
[components.core/button
|
|
||||||
{:accessibility-label :select-account-bottom-sheet
|
|
||||||
:disabled (nil? from)
|
|
||||||
:on-press #(re-frame/dispatch
|
|
||||||
[::commands/accept-request-address-for-transaction
|
|
||||||
(:message-id message)
|
|
||||||
(:address from)])}
|
|
||||||
(i18n/label :t/share)]}]])
|
|
||||||
|
|
||||||
(defview select-account
|
|
||||||
[]
|
|
||||||
(letsubs [data [:commands/select-account]]
|
|
||||||
[bottom-panel/animated-bottom-panel
|
|
||||||
data
|
|
||||||
select-account-sheet
|
|
||||||
#(re-frame/dispatch [:hide-select-acc-sheet])]))
|
|
||||||
|
|
||||||
(views/defview request-transaction
|
(views/defview request-transaction
|
||||||
[_]
|
[_]
|
||||||
(views/letsubs [{:keys [amount-error amount-text from token sign-enabled?] :as tx}
|
(views/letsubs [{:keys [amount-error amount-text from token sign-enabled?] :as tx}
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(def auth-method-biometric "biometric")
|
|
||||||
(def auth-method-biometric-prepare "biometric-prepare")
|
|
||||||
(def auth-method-none "none")
|
|
||||||
|
|
||||||
(defn- whisper-key-name
|
(defn- whisper-key-name
|
||||||
[address]
|
[address]
|
||||||
(str address "-whisper"))
|
(str address "-whisper"))
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
(ns ^{:doc "Pairing utils"} status-im.utils.pairing)
|
|
||||||
|
|
||||||
(defn has-paired-installations?
|
|
||||||
[cofx]
|
|
||||||
(let [our-installation-id (get-in cofx [:db :profile/profile :installation-id])]
|
|
||||||
(->>
|
|
||||||
(get-in cofx [:db :pairing/installations])
|
|
||||||
vals
|
|
||||||
(some (fn [{:keys [enabled? installation-id]}]
|
|
||||||
(and (not= installation-id our-installation-id)
|
|
||||||
enabled?))))))
|
|
|
@ -1,120 +0,0 @@
|
||||||
(ns status-im.utils.snoopy
|
|
||||||
(:require
|
|
||||||
["react-native/Libraries/vendor/emitter/EventEmitter" :refer [EventEmitter]]
|
|
||||||
["rn-snoopy" :default snoopy]
|
|
||||||
["rn-snoopy/stream/bars" :default bars]
|
|
||||||
["rn-snoopy/stream/buffer" :default buffer]
|
|
||||||
["rn-snoopy/stream/filter" :default sn-filter]
|
|
||||||
[clojure.string :as string]
|
|
||||||
[status-im2.config :as config]))
|
|
||||||
|
|
||||||
(defn create-filter
|
|
||||||
[f]
|
|
||||||
(fn [^js message]
|
|
||||||
(let [method (.-method message)
|
|
||||||
module (.-module message)
|
|
||||||
^js args (.-args message)
|
|
||||||
first-arg (when (pos? (.-length args))
|
|
||||||
(aget args 0))]
|
|
||||||
(f {:method method
|
|
||||||
:module module
|
|
||||||
:first-arg first-arg}))))
|
|
||||||
|
|
||||||
(defn status-module-filter
|
|
||||||
[{:keys [method module first-arg]}]
|
|
||||||
(or (= module "Status")
|
|
||||||
(and (= module "RCTNativeAppEventEmitter")
|
|
||||||
(= method "emit")
|
|
||||||
(= first-arg "gethEvent"))
|
|
||||||
(and
|
|
||||||
(string? method)
|
|
||||||
(string/starts-with? method "<callback for Status."))))
|
|
||||||
|
|
||||||
(defn timer-filter
|
|
||||||
[{:keys [method]}]
|
|
||||||
(contains? #{"callTimers" "createTimer"} method))
|
|
||||||
|
|
||||||
(defn websocket-filter
|
|
||||||
[{:keys [module first-arg]}]
|
|
||||||
(or (= module "WebSocketModule")
|
|
||||||
(and (= module "RCTDeviceEventEmitter")
|
|
||||||
(contains? #{"websocketFailed" "websocketMessage"} first-arg))))
|
|
||||||
|
|
||||||
(defn ui-manager-filter
|
|
||||||
[{:keys [module]}]
|
|
||||||
(= module "UIManager"))
|
|
||||||
|
|
||||||
(defn touches-filter
|
|
||||||
[{:keys [method module]}]
|
|
||||||
(and (= module "RCTEventEmitter")
|
|
||||||
(= method "receiveTouches")))
|
|
||||||
|
|
||||||
(defn native-animation-filter
|
|
||||||
[{:keys [method module]}]
|
|
||||||
(or (= module "NativeAnimatedModule")
|
|
||||||
(and
|
|
||||||
(string? method)
|
|
||||||
(string/starts-with? method "<callback for NativeAnimatedModule."))))
|
|
||||||
|
|
||||||
(defn keyboard-observer-filter
|
|
||||||
[{:keys [module]}]
|
|
||||||
;; mostly all calls to KeyboardObserver are done by FlatList
|
|
||||||
(= module "KeyboardObserver"))
|
|
||||||
|
|
||||||
(defn threshold-warnings
|
|
||||||
[{:keys [filter-fn label tick? print-events? threshold events threshold-message]}]
|
|
||||||
(.subscribe ^js
|
|
||||||
((bars
|
|
||||||
(fn [^js a] (.-length a))
|
|
||||||
threshold
|
|
||||||
tick?
|
|
||||||
true
|
|
||||||
label
|
|
||||||
threshold-message)
|
|
||||||
((buffer)
|
|
||||||
((sn-filter (create-filter filter-fn)
|
|
||||||
print-events?)
|
|
||||||
events)))))
|
|
||||||
|
|
||||||
;; In order to enable snoopy set SNOOPY=1 in .env file.
|
|
||||||
;; By default events are not printed and you will see warnings only when
|
|
||||||
;; the number of events is exceeding the threshold.
|
|
||||||
;; For debugging UI perf, in particular the number of bridge calls caused
|
|
||||||
;; by view components set `:print-events?=true` for `ui-manager-filter`,
|
|
||||||
;; and then collect printed data in logs.
|
|
||||||
(defn subscribe!
|
|
||||||
[]
|
|
||||||
(when config/snoopy-enabled?
|
|
||||||
(let [emitter-class EventEmitter
|
|
||||||
emitter (emitter-class.)
|
|
||||||
events (.stream snoopy emitter)]
|
|
||||||
(threshold-warnings
|
|
||||||
{:filter-fn (constantly true)
|
|
||||||
:label "all messages"
|
|
||||||
:threshold-message "too many calls to bridge, something suspicious is happening"
|
|
||||||
:tick? false
|
|
||||||
:print-events? false
|
|
||||||
:threshold 400
|
|
||||||
:events events})
|
|
||||||
|
|
||||||
(threshold-warnings
|
|
||||||
{:filter-fn timer-filter
|
|
||||||
:label "timer"
|
|
||||||
:threshold-message "too many setTimeout/setInterval calls"
|
|
||||||
:tick? false
|
|
||||||
:print-events? false
|
|
||||||
:threshold 70
|
|
||||||
:events events})
|
|
||||||
|
|
||||||
(threshold-warnings
|
|
||||||
{:filter-fn ui-manager-filter
|
|
||||||
:label "timer"
|
|
||||||
:threshold-message (str
|
|
||||||
"too many calls to UIManager, most likely during navigation. "
|
|
||||||
"Please consider preloading of screens or lazy loading of some components")
|
|
||||||
:tick? false
|
|
||||||
:print-events? true
|
|
||||||
;; todo(rasom): revisit this number when/if
|
|
||||||
;; https://github.com/status-im/status-mobile/pull/2849 will be merged
|
|
||||||
:threshold 200
|
|
||||||
:events events}))))
|
|
|
@ -1,31 +0,0 @@
|
||||||
(ns status-im.utils.wallet-connect
|
|
||||||
(:require
|
|
||||||
["@react-native-async-storage/async-storage" :default AsyncStorage]
|
|
||||||
["@walletconnect/client" :refer [CLIENT_EVENTS] :default WalletConnectClient]
|
|
||||||
[clojure.string :as string]
|
|
||||||
[status-im2.config :as config]))
|
|
||||||
|
|
||||||
(defn init
|
|
||||||
[on-success on-error]
|
|
||||||
(-> ^js WalletConnectClient
|
|
||||||
(.init (clj->js {:controller true
|
|
||||||
:projectId config/wallet-connect-project-id
|
|
||||||
:logger "debug"
|
|
||||||
:metadata config/default-wallet-connect-metadata
|
|
||||||
:storageOptions {:asyncStorage ^js AsyncStorage}}))
|
|
||||||
(.then on-success)
|
|
||||||
(.catch on-error)))
|
|
||||||
|
|
||||||
(defn session-request-event [] (.-request (.-session CLIENT_EVENTS)))
|
|
||||||
|
|
||||||
(defn session-created-event [] (.-created (.-session CLIENT_EVENTS)))
|
|
||||||
|
|
||||||
(defn session-deleted-event [] (.-deleted (.-session CLIENT_EVENTS)))
|
|
||||||
|
|
||||||
(defn session-proposal-event [] (.-proposal (.-session CLIENT_EVENTS)))
|
|
||||||
|
|
||||||
(defn session-updated-event [] (.-updated (.-session CLIENT_EVENTS)))
|
|
||||||
|
|
||||||
(defn url?
|
|
||||||
[url]
|
|
||||||
(string/starts-with? url "wc:"))
|
|
|
@ -7,7 +7,6 @@
|
||||||
[status-im.ethereum.ens :as ens]
|
[status-im.ethereum.ens :as ens]
|
||||||
[status-im.ethereum.tokens :as tokens]
|
[status-im.ethereum.tokens :as tokens]
|
||||||
[status-im.qr-scanner.core :as qr-scaner]
|
[status-im.qr-scanner.core :as qr-scaner]
|
||||||
[status-im.utils.wallet-connect :as wallet-connect]
|
|
||||||
[status-im.wallet.utils :as wallet.utils]
|
[status-im.wallet.utils :as wallet.utils]
|
||||||
[status-im2.common.router :as router]
|
[status-im2.common.router :as router]
|
||||||
[status-im2.navigation.events :as navigation]
|
[status-im2.navigation.events :as navigation]
|
||||||
|
@ -173,11 +172,7 @@
|
||||||
(if (links/universal-link? uri)
|
(if (links/universal-link? uri)
|
||||||
{:dispatch [:universal-links/handle-url uri]}
|
{:dispatch [:universal-links/handle-url uri]}
|
||||||
{:browser/show-browser-selection uri})
|
{:browser/show-browser-selection uri})
|
||||||
(if (wallet-connect/url? uri)
|
{:ui/show-error (i18n/label :t/wallet-invalid-address {:data uri})})))
|
||||||
{:ui/show-error "Wallet Connect not implemented"}
|
|
||||||
;; Re-enable with https://github.com/status-im/status-mobile/issues/13429
|
|
||||||
;; {:dispatch [::qr-scaner/handle-wallet-connect-uri {:data uri}]}
|
|
||||||
{:ui/show-error (i18n/label :t/wallet-invalid-address {:data uri})}))))
|
|
||||||
|
|
||||||
(rf/defn qr-scanner-result
|
(rf/defn qr-scanner-result
|
||||||
{:events [:wallet-legacy.send/qr-scanner-result]}
|
{:events [:wallet-legacy.send/qr-scanner-result]}
|
||||||
|
|
|
@ -1,288 +0,0 @@
|
||||||
(ns status-im.wallet-connect.core
|
|
||||||
(:require
|
|
||||||
[clojure.string :as string]
|
|
||||||
[re-frame.core :as re-frame]
|
|
||||||
[status-im.browser.core :as browser]
|
|
||||||
[status-im.signing.core :as signing]
|
|
||||||
[status-im.utils.deprecated-types :as types]
|
|
||||||
[status-im.utils.wallet-connect :as wallet-connect]
|
|
||||||
[status-im2.config :as config]
|
|
||||||
[status-im2.constants :as constants]
|
|
||||||
[taoensso.timbre :as log]
|
|
||||||
[utils.address :as address]
|
|
||||||
[utils.re-frame :as rf]))
|
|
||||||
|
|
||||||
(rf/defn proposal-handler
|
|
||||||
{:events [:wallet-connect/proposal]}
|
|
||||||
[{:keys [db] :as cofx} request-event]
|
|
||||||
(let [proposal (types/js->clj request-event)
|
|
||||||
proposer (:proposer proposal)
|
|
||||||
metadata (:metadata proposer)]
|
|
||||||
{:db (assoc db
|
|
||||||
:wallet-connect/proposal proposal
|
|
||||||
:wallet-connect/proposal-metadata metadata)
|
|
||||||
:show-wallet-connect-sheet nil}))
|
|
||||||
|
|
||||||
(rf/defn session-connected
|
|
||||||
{:events [:wallet-connect/created]}
|
|
||||||
[{:keys [db]} session]
|
|
||||||
(let [session (merge (types/js->clj session) {:wc-version 2})
|
|
||||||
client (get db :wallet-connect/client)]
|
|
||||||
(log/debug "[wallet connect] session created - " session)
|
|
||||||
{:show-wallet-connect-success-sheet nil
|
|
||||||
:db (assoc db
|
|
||||||
:wallet-connect/session-connected session
|
|
||||||
:wallet-connect/sessions (types/js->clj
|
|
||||||
(.-values
|
|
||||||
(.-session
|
|
||||||
client))))}))
|
|
||||||
|
|
||||||
(rf/defn manage-app
|
|
||||||
{:events [:wallet-connect/manage-app]}
|
|
||||||
[{:keys [db]} session]
|
|
||||||
(let [session (types/js->clj session)]
|
|
||||||
{:db (assoc db
|
|
||||||
:wallet-connect/session-managed session
|
|
||||||
:wallet-connect/showing-app-management-sheet? true)
|
|
||||||
:show-wallet-connect-app-management-sheet nil}))
|
|
||||||
|
|
||||||
(rf/defn request-handler
|
|
||||||
{:events [:wallet-connect/request]}
|
|
||||||
[{:keys [db] :as cofx} request-event]
|
|
||||||
(let [request (types/js->clj request-event)
|
|
||||||
params (:request request)
|
|
||||||
pending-requests (or (:wallet-connect/pending-requests db) [])
|
|
||||||
new-pending-requests (conj pending-requests request)
|
|
||||||
client (get db :wallet-connect/client)
|
|
||||||
topic (:topic request)]
|
|
||||||
{:db (assoc db :wallet-connect/pending-requests new-pending-requests)
|
|
||||||
:dispatch [:wallet-connect/request-received request]}))
|
|
||||||
|
|
||||||
(rf/defn request-handler-test
|
|
||||||
{:events [:wallet-connect/request-test]}
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
{:show-wallet-connect-sheet nil})
|
|
||||||
|
|
||||||
(defn subscribe-to-events
|
|
||||||
[^js wallet-connect-client]
|
|
||||||
(.on wallet-connect-client
|
|
||||||
(wallet-connect/session-request-event)
|
|
||||||
#(re-frame/dispatch [:wallet-connect/request %]))
|
|
||||||
(.on wallet-connect-client
|
|
||||||
(wallet-connect/session-created-event)
|
|
||||||
#(re-frame/dispatch [:wallet-connect/created %]))
|
|
||||||
(.on wallet-connect-client
|
|
||||||
(wallet-connect/session-deleted-event)
|
|
||||||
#(re-frame/dispatch [:wallet-connect/update-sessions]))
|
|
||||||
(.on wallet-connect-client
|
|
||||||
(wallet-connect/session-updated-event)
|
|
||||||
#(re-frame/dispatch [:wallet-connect/update-sessions]))
|
|
||||||
(.on wallet-connect-client
|
|
||||||
(wallet-connect/session-proposal-event)
|
|
||||||
#(re-frame/dispatch [:wallet-connect/proposal %])))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:wc-2-init
|
|
||||||
(fn []
|
|
||||||
(wallet-connect/init
|
|
||||||
#(re-frame/dispatch [:wallet-connect/client-init %])
|
|
||||||
#(log/error "[wallet-connect]" %))))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:wc-2-subscribe-to-events
|
|
||||||
(fn [client]
|
|
||||||
(subscribe-to-events client)))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:wc-2-client-approve-proposal
|
|
||||||
(fn [[client proposal response]]
|
|
||||||
(-> ^js client
|
|
||||||
(.approve (clj->js {:proposal proposal :response response}))
|
|
||||||
(.then #(log/debug "[wallet-connect] session proposal approved"))
|
|
||||||
(.catch #(log/error "[wallet-connect] session proposal approval error:" %)))))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:wc-2-client-reject-proposal
|
|
||||||
(fn [[client proposal]]
|
|
||||||
(-> ^js client
|
|
||||||
(.reject (clj->js {:proposal proposal}))
|
|
||||||
(.then #(log/debug "[wallet-connect] session proposal rejected"))
|
|
||||||
(.catch #(log/error "[wallet-connect] " %)))))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:wc-2-client-disconnect
|
|
||||||
(fn [[client topic]]
|
|
||||||
(-> ^js client
|
|
||||||
(.disconnect (clj->js {:topic topic}))
|
|
||||||
(.then #(log/debug "[wallet-connect] session disconnected - topic " topic))
|
|
||||||
(.catch #(log/error "[wallet-connect] " %)))))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:wc-2-change-session
|
|
||||||
(fn [[client topic accounts]]
|
|
||||||
(-> ^js client
|
|
||||||
(.update (clj->js {:topic topic
|
|
||||||
:state {:accounts accounts}}))
|
|
||||||
(.then #(log/debug "[wallet-connect] session topic " topic
|
|
||||||
" changed to account " (first accounts)))
|
|
||||||
(.catch #(log/error "[wallet-connect] " %)))))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:wc-2-pair
|
|
||||||
(fn [[client uri]]
|
|
||||||
(.pair client (clj->js {:uri uri}))))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:wc-2-respond
|
|
||||||
(fn [[client response]]
|
|
||||||
(.respond client (clj->js response))))
|
|
||||||
|
|
||||||
(rf/defn approve-proposal
|
|
||||||
{:events [:wallet-connect/approve-proposal]}
|
|
||||||
[{:keys [db]} account]
|
|
||||||
(let [client (get db :wallet-connect/client)
|
|
||||||
proposal (get db :wallet-connect/proposal)
|
|
||||||
topic (:topic proposal)
|
|
||||||
permissions (:permissions proposal)
|
|
||||||
blockchain (:blockchain permissions)
|
|
||||||
proposal-chain-ids (map #(last (string/split % #":")) (:chains blockchain))
|
|
||||||
available-chain-ids (map #(get-in % [:config :NetworkId]) (vals (get db :networks/networks)))
|
|
||||||
supported-chain-ids (filter (fn [chain-id] #(boolean (some #{chain-id} available-chain-ids)))
|
|
||||||
proposal-chain-ids)
|
|
||||||
address (:address account)
|
|
||||||
accounts (map #(str "eip155:" % ":" (address/normalized-hex address))
|
|
||||||
supported-chain-ids)
|
|
||||||
;; TODO: Check for unsupported
|
|
||||||
metadata (get db :wallet-connect/proposal-metadata)
|
|
||||||
response {:state {:accounts accounts}
|
|
||||||
:metadata config/default-wallet-connect-metadata}]
|
|
||||||
{:hide-wallet-connect-sheet nil
|
|
||||||
:wc-2-client-approve-proposal [client proposal response]}))
|
|
||||||
|
|
||||||
(rf/defn reject-proposal
|
|
||||||
{:events [:wallet-connect/reject-proposal]}
|
|
||||||
[{:keys [db]} account]
|
|
||||||
(let [client (get db :wallet-connect/client)
|
|
||||||
proposal (get db :wallet-connect/proposal)]
|
|
||||||
{:hide-wallet-connect-sheet nil
|
|
||||||
:wc-2-client-reject-proposal client}))
|
|
||||||
|
|
||||||
(rf/defn change-session-account
|
|
||||||
{:events [:wallet-connect/change-session-account]}
|
|
||||||
[{:keys [db]} topic account]
|
|
||||||
(let [client (get db :wallet-connect/client)
|
|
||||||
sessions (get db :wallet-connect/sessions)
|
|
||||||
session (first (filter #(= (:topic %) topic) sessions))
|
|
||||||
permissions (:permissions session)
|
|
||||||
blockchain (:blockchain permissions)
|
|
||||||
proposal-chain-ids (map #(last (string/split % #":")) (:chains blockchain))
|
|
||||||
address (:address account)
|
|
||||||
available-chain-ids (map #(get-in % [:config :NetworkId]) (vals (get db :networks/networks)))
|
|
||||||
supported-chain-ids (filter (fn [chain-id] #(boolean (some #{chain-id} available-chain-ids)))
|
|
||||||
proposal-chain-ids)
|
|
||||||
accounts (map #(str "eip155:" % ":" (address/normalized-hex address))
|
|
||||||
supported-chain-ids)]
|
|
||||||
{:db (assoc db
|
|
||||||
:wallet-connect/showing-app-management-sheet?
|
|
||||||
false)
|
|
||||||
:hide-wallet-connect-app-management-sheet nil
|
|
||||||
:wc-2-change-session [client topic accounts]}))
|
|
||||||
|
|
||||||
(rf/defn disconnect-session
|
|
||||||
{:events [:wallet-connect/disconnect]}
|
|
||||||
[{:keys [db]} topic]
|
|
||||||
(let [client (get db :wallet-connect/client)]
|
|
||||||
{:hide-wallet-connect-app-management-sheet nil
|
|
||||||
:hide-wallet-connect-success-sheet nil
|
|
||||||
:wc-2-client-disconnect [client topic]
|
|
||||||
:db (-> db
|
|
||||||
(assoc :wallet-connect/sessions
|
|
||||||
(types/js->clj (.-values (.-session client))))
|
|
||||||
(dissoc :wallet-connect/session-managed))}))
|
|
||||||
|
|
||||||
(rf/defn pair-session
|
|
||||||
{:events [:wallet-connect/pair]}
|
|
||||||
[{:keys [db]} {:keys [data]}]
|
|
||||||
(let [client (get db :wallet-connect/client)]
|
|
||||||
{:db (assoc db :wallet-connect/scanned-uri data)
|
|
||||||
:dispatch [:navigate-back]
|
|
||||||
:wc-2-pair [client data]}))
|
|
||||||
|
|
||||||
(rf/defn wallet-connect-client-initate
|
|
||||||
{:events [:wallet-connect/client-init]}
|
|
||||||
[{:keys [db] :as cofx} ^js client]
|
|
||||||
{:db (assoc db
|
|
||||||
:wallet-connect/client client
|
|
||||||
:wallet-connect/sessions (types/js->clj (.-values (.-session
|
|
||||||
client))))
|
|
||||||
:wc-2-subscribe-to-events client})
|
|
||||||
|
|
||||||
(rf/defn update-sessions
|
|
||||||
{:events [:wallet-connect/update-sessions]}
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(let [client (get db :wallet-connect/client)]
|
|
||||||
{:db (-> db
|
|
||||||
(assoc :wallet-connect/sessions (types/js->clj (.-values (.-session client))))
|
|
||||||
(dissoc :wallet-connect/session-managed))}))
|
|
||||||
|
|
||||||
(rf/defn wallet-connect-complete-transaction
|
|
||||||
{:events [:wallet-connect.dapp/transaction-on-result]}
|
|
||||||
[{:keys [db]} message-id topic result]
|
|
||||||
(let [client (get db :wallet-connect/client)
|
|
||||||
response {:topic topic
|
|
||||||
:response {:jsonrpc "2.0"
|
|
||||||
:id message-id
|
|
||||||
:result result}}]
|
|
||||||
{:db (assoc db :wallet-connect/response response)
|
|
||||||
:wc-2-respond [client response]}))
|
|
||||||
|
|
||||||
(rf/defn wallet-connect-send-async
|
|
||||||
[cofx {:keys [method params id] :as payload} message-id topic]
|
|
||||||
(let [message? (browser/web3-sign-message? method)
|
|
||||||
dapps-address (get-in cofx [:db :profile/profile :dapps-address])
|
|
||||||
accounts (get-in cofx [:db :multiaccount/visible-accounts])
|
|
||||||
typed? (and (not= constants/web3-personal-sign method)
|
|
||||||
(not= constants/web3-eth-sign method))]
|
|
||||||
(if (or message? (= constants/web3-send-transaction method))
|
|
||||||
(let [[address data] (cond (and (= method constants/web3-keycard-sign-typed-data)
|
|
||||||
(not (vector? params)))
|
|
||||||
;; We don't use signer argument for keycard sign-typed-data
|
|
||||||
["0x0" params]
|
|
||||||
message? (browser/normalize-sign-message-params
|
|
||||||
params
|
|
||||||
typed?)
|
|
||||||
:else [nil nil])]
|
|
||||||
(when (or (not message?) (and address data))
|
|
||||||
(signing/sign cofx
|
|
||||||
(merge
|
|
||||||
(if message?
|
|
||||||
{:message {:address address
|
|
||||||
:data data
|
|
||||||
:v4 (= constants/web3-sign-typed-data-v4 method)
|
|
||||||
:typed? typed?
|
|
||||||
:pinless? (= method constants/web3-keycard-sign-typed-data)
|
|
||||||
:from address}}
|
|
||||||
{:tx-obj (-> params
|
|
||||||
first
|
|
||||||
(update :from #(or % dapps-address))
|
|
||||||
(dissoc :gasPrice))})
|
|
||||||
{:on-result [:wallet-connect.dapp/transaction-on-result message-id topic]
|
|
||||||
:on-error [:wallet-connect.dapp/transaction-on-error message-id topic]}))))
|
|
||||||
(when (#{"eth_accounts" "eth_coinbase"} method)
|
|
||||||
(wallet-connect-complete-transaction
|
|
||||||
cofx
|
|
||||||
message-id
|
|
||||||
topic
|
|
||||||
(if (= method "eth_coinbase") dapps-address [dapps-address]))))))
|
|
||||||
|
|
||||||
(rf/defn wallet-connect-send-async-read-only
|
|
||||||
[{:keys [db] :as cofx} {:keys [method] :as payload} message-id topic]
|
|
||||||
(wallet-connect-send-async cofx payload message-id topic))
|
|
||||||
|
|
||||||
(rf/defn process-request
|
|
||||||
{:events [:wallet-connect/request-received]}
|
|
||||||
[{:keys [db] :as cofx} session-request]
|
|
||||||
(let [pending-requests (get db :wallet-connect/pending-requests)
|
|
||||||
{:keys [topic request]} session-request
|
|
||||||
{:keys [id]} request]
|
|
||||||
(wallet-connect-send-async-read-only cofx request id topic)))
|
|
|
@ -129,9 +129,4 @@
|
||||||
(navigation/register-component
|
(navigation/register-component
|
||||||
"signing-sheet"
|
"signing-sheet"
|
||||||
(fn [] (gesture/gesture-handler-root-hoc views/signing-comp))
|
(fn [] (gesture/gesture-handler-root-hoc views/signing-comp))
|
||||||
(fn [] views/signing-comp))
|
(fn [] views/signing-comp))])
|
||||||
|
|
||||||
(navigation/register-component
|
|
||||||
"select-acc-sheet"
|
|
||||||
(fn [] (gesture/gesture-handler-root-hoc views/select-acc-comp))
|
|
||||||
(fn [] views/select-acc-comp))])
|
|
||||||
|
|
|
@ -240,9 +240,3 @@
|
||||||
|
|
||||||
(rf/reg-fx :hide-signing-sheet
|
(rf/reg-fx :hide-signing-sheet
|
||||||
(fn [] (navigation/dissmiss-overlay "signing-sheet")))
|
(fn [] (navigation/dissmiss-overlay "signing-sheet")))
|
||||||
|
|
||||||
(rf/reg-fx :show-select-acc-sheet
|
|
||||||
(fn [] (show-overlay "select-acc-sheet")))
|
|
||||||
|
|
||||||
(rf/reg-fx :hide-select-acc-sheet
|
|
||||||
(fn [] (navigation/dissmiss-overlay "select-acc-sheet")))
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
[status-im.ui.screens.profile.visibility-status.views :as visibility-status-views]
|
[status-im.ui.screens.profile.visibility-status.views :as visibility-status-views]
|
||||||
[status-im.ui.screens.signing.views :as signing]
|
[status-im.ui.screens.signing.views :as signing]
|
||||||
[status-im.ui.screens.wallet-connect.session-proposal.views :as wallet-connect]
|
[status-im.ui.screens.wallet-connect.session-proposal.views :as wallet-connect]
|
||||||
[status-im.ui.screens.wallet.send.views :as wallet.send.views]
|
|
||||||
[status-im2.common.bottom-sheet-screen.view :as bottom-sheet-screen]
|
[status-im2.common.bottom-sheet-screen.view :as bottom-sheet-screen]
|
||||||
[status-im2.common.bottom-sheet.view :as bottom-sheet]
|
[status-im2.common.bottom-sheet.view :as bottom-sheet]
|
||||||
[status-im2.common.toasts.view :as toasts]
|
[status-im2.common.toasts.view :as toasts]
|
||||||
|
@ -135,16 +134,6 @@
|
||||||
(when js/goog.DEBUG
|
(when js/goog.DEBUG
|
||||||
[reloader/reload-view])])))
|
[reloader/reload-view])])))
|
||||||
|
|
||||||
(def select-acc-comp
|
|
||||||
(reagent/reactify-component
|
|
||||||
(fn []
|
|
||||||
^{:key (str "select-acc-sheet" @reloader/cnt)}
|
|
||||||
[:<>
|
|
||||||
[inactive]
|
|
||||||
[wallet.send.views/select-account]
|
|
||||||
(when js/goog.DEBUG
|
|
||||||
[reloader/reload-view])])))
|
|
||||||
|
|
||||||
(def wallet-connect-comp
|
(def wallet-connect-comp
|
||||||
(reagent/reactify-component
|
(reagent/reactify-component
|
||||||
(fn []
|
(fn []
|
||||||
|
|
Loading…
Reference in New Issue