Implement Wallet Connect 1.0
Signed-off-by: Brian Sztamfater <brian@status.im>
This commit is contained in:
parent
60cfca1107
commit
a7b0764759
|
@ -22,6 +22,7 @@
|
|||
"@react-native-community/push-notification-ios": "^1.4.1",
|
||||
"@react-native-community/slider": "^3.0.0",
|
||||
"@walletconnect/client": "^2.0.0-beta.23",
|
||||
"@walletconnect/client-legacy": "npm:@walletconnect/client@^1.7.1",
|
||||
"bignumber.js": "git+https://github.com/status-im/bignumber.js.git#v4.0.2-status",
|
||||
"buffer": "^5.4.2",
|
||||
"chance": "^1.1.0",
|
||||
|
|
|
@ -169,3 +169,6 @@
|
|||
(def ^:const visibility-status-dnd 2)
|
||||
(def ^:const visibility-status-always-online 3)
|
||||
(def ^:const visibility-status-inactive 4)
|
||||
|
||||
(def ^:const wallet-connect-version-1 1)
|
||||
(def ^:const wallet-connect-version-2 2)
|
|
@ -62,7 +62,8 @@
|
|||
[status-im.navigation.core :as navigation.core]
|
||||
[status-im.multiaccounts.login.core :as login.core]
|
||||
[status-im.signing.core :as signing]
|
||||
status-im.wallet-connect.core))
|
||||
status-im.wallet-connect.core
|
||||
status-im.wallet-connect-legacy.core))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:dismiss-keyboard
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.add-new.db :as new-chat.db]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.group-chats.core :as group-chats]))
|
||||
[status-im.group-chats.core :as group-chats]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(fx/defn scan-qr-code
|
||||
{:events [::scan-code]}
|
||||
|
@ -78,8 +79,13 @@
|
|||
(navigation/change-tab :wallet)
|
||||
(navigation/pop-to-root-tab :wallet-stack)))
|
||||
|
||||
(fx/defn handle-wallet-connect [cofx data]
|
||||
{:dispatch [:wallet-connect/pair data]})
|
||||
(fx/defn handle-wallet-connect
|
||||
{:events [::handle-wallet-connect-uri]}
|
||||
[cofx data]
|
||||
(let [wc-version (last (string/split (first (string/split data "?")) "@"))]
|
||||
(if (= wc-version "1")
|
||||
{:dispatch [:wallet-connect-legacy/pair data]}
|
||||
{:dispatch [:wallet-connect/pair data]})))
|
||||
|
||||
(fx/defn match-scan
|
||||
{:events [::match-scanned-value]}
|
||||
|
|
|
@ -274,6 +274,7 @@
|
|||
(reg-root-key-sub :wallet-connect/session-connected :wallet-connect/session-connected)
|
||||
(reg-root-key-sub :wallet-connect/showing-app-management-sheet? :wallet-connect/showing-app-management-sheet?)
|
||||
(reg-root-key-sub :wallet-connect/sessions :wallet-connect/sessions)
|
||||
(reg-root-key-sub :wallet-connect-legacy/sessions :wallet-connect-legacy/sessions)
|
||||
(reg-root-key-sub :wallet-connect/session-managed :wallet-connect/session-managed)
|
||||
|
||||
(re-frame/reg-sub
|
||||
|
|
|
@ -114,4 +114,4 @@
|
|||
|
||||
(views/defview animated-bottom-panel [val view on-close on-touch-outside show-overlay?]
|
||||
(views/letsubs [{window-height :height} [:dimensions/window]]
|
||||
[bottom-panel (when val (select-keys val [:from :contact :amount :token :approve? :message :cancel? :hash :name :url :icons :description :topic :relay :self :peer :permissions :state])) view window-height on-close on-touch-outside (if-not (nil? show-overlay?) show-overlay? true)]))
|
||||
[bottom-panel (when val (select-keys val [:from :contact :amount :token :approve? :message :cancel? :hash :name :url :icons :wc-version :params :connector :description :topic :relay :self :peer :permissions :state])) view window-height on-close on-touch-outside (if-not (nil? show-overlay?) show-overlay? true)]))
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
:accessory :switch
|
||||
:active waku-bloom-filter-mode}
|
||||
{:size :small
|
||||
:title (i18n/label :t/wallet-connect-2.0)
|
||||
:title (i18n/label :t/wallet-connect)
|
||||
:accessibility-label :wallet-connect-settings-switch
|
||||
:container-margin-bottom 8
|
||||
:on-press
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
[status-im.ui.components.list.views :as list]
|
||||
[reagent.core :as reagent]
|
||||
[clojure.string :as string]
|
||||
[quo.platform :as platform]))
|
||||
[quo.platform :as platform]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
(def chevron-icon-container-width 24)
|
||||
|
||||
|
@ -65,17 +66,23 @@
|
|||
:background-color (:color @selected-account-atom)
|
||||
:on-press on-press}]]))
|
||||
|
||||
(defview success-sheet-view [{:keys [topic]}]
|
||||
(defview success-sheet-view [{:keys [wc-version] :as session-data}]
|
||||
(letsubs [visible-accounts [:visible-accounts-without-watch-only]
|
||||
dapps-account [:dapps-account]
|
||||
sessions [:wallet-connect/sessions]
|
||||
sessions-legacy [:wallet-connect-legacy/sessions]
|
||||
managed-session [:wallet-connect/session-managed]]
|
||||
(let [{:keys [peer state] :as session} (first (filter #(= (:topic %) topic) sessions))
|
||||
{:keys [accounts]} state
|
||||
(let [{:keys [topic]} (when-not (= wc-version constants/wallet-connect-version-1) session-data)
|
||||
peerId (when (= wc-version constants/wallet-connect-version-1) (get-in session-data [:params 0 :peerId]))
|
||||
session-legacy (when (= wc-version constants/wallet-connect-version-1) (first (filter #(= (get-in % [:params 0 :peerId]) peerId) sessions-legacy)))
|
||||
{:keys [peer state] :as session} (first (filter #(= (:topic %) topic) sessions))
|
||||
{:keys [params]} (when (= wc-version constants/wallet-connect-version-1) session-legacy)
|
||||
{:keys [metadata]} peer
|
||||
{:keys [name icons]} metadata
|
||||
icon-uri (when (and icons (> (count icons) 0)) (first icons))
|
||||
address (last (string/split (first accounts) #":"))
|
||||
{:keys [peerMeta]} (first params)
|
||||
{:keys [accounts]} (if (= wc-version constants/wallet-connect-version-1) (first params) state)
|
||||
{:keys [name icons]} (if (= wc-version constants/wallet-connect-version-1) peerMeta metadata)
|
||||
icon-uri (when (and icons (pos? (count icons))) (first icons))
|
||||
address (if (= wc-version constants/wallet-connect-version-1) (first accounts) (last (string/split (first accounts) #":")))
|
||||
account (first (filter #(= (:address %) address) visible-accounts))
|
||||
selected-account-atom (reagent/atom account)]
|
||||
[react/view (styles/proposal-sheet-container)
|
||||
|
@ -97,7 +104,7 @@
|
|||
(vector dapps-account)
|
||||
selected-account-atom
|
||||
{:on-press #(do
|
||||
(re-frame/dispatch [:wallet-connect/manage-app session])
|
||||
(re-frame/dispatch (if (= wc-version constants/wallet-connect-version-1) [:wallet-connect-legacy/manage-app session-data] [:wallet-connect/manage-app session]))
|
||||
(reset! show-account-selector? true))}]
|
||||
[quo/text {:weight :regular
|
||||
:color :secondary
|
||||
|
@ -117,16 +124,23 @@
|
|||
:blurType (if (colors/dark?) :dark :light)}]
|
||||
[react/view (styles/blur-view)]))])))
|
||||
|
||||
(defview app-management-sheet-view [{:keys [topic]}]
|
||||
(defview app-management-sheet-view [{:keys [wc-version] :as session}]
|
||||
(letsubs [sessions [:wallet-connect/sessions]
|
||||
sessions-legacy [:wallet-connect-legacy/sessions]
|
||||
visible-accounts [:visible-accounts-without-watch-only]]
|
||||
(let [{:keys [peer state]} (first (filter #(= (:topic %) topic) sessions))
|
||||
{:keys [accounts]} state
|
||||
(let [peerId (when (= wc-version constants/wallet-connect-version-1) (get-in session [:params 0 :peerId]))
|
||||
session-legacy (when (= wc-version constants/wallet-connect-version-1) (first (filter #(= (get-in % [:params 0 :peerId]) peerId) sessions-legacy)))
|
||||
{:keys [topic]} (when-not (= wc-version constants/wallet-connect-version-1) session)
|
||||
{:keys [peer state]} (first (filter #(= (:topic %) topic) sessions))
|
||||
{:keys [params]} (when (= wc-version constants/wallet-connect-version-1) session-legacy)
|
||||
{:keys [metadata]} peer
|
||||
{:keys [name icons url]} metadata
|
||||
icon-uri (when (and icons (> (count icons) 0)) (first icons))
|
||||
account-address (last (string/split (first accounts) #":"))
|
||||
selected-account-atom (reagent/atom (first (filter #(= (:address %) account-address) visible-accounts)))]
|
||||
{:keys [peerMeta]} (first params)
|
||||
{:keys [accounts]} (if (= wc-version constants/wallet-connect-version-1) (first params) state)
|
||||
{:keys [name icons url]} (if (= wc-version constants/wallet-connect-version-1) peerMeta metadata)
|
||||
icon-uri (when (and icons (pos? (count icons))) (first icons))
|
||||
address (if (= wc-version constants/wallet-connect-version-1) (first accounts) (last (string/split (first accounts) #":")))
|
||||
account (first (filter #(= (:address %) address) visible-accounts))
|
||||
selected-account-atom (reagent/atom account)]
|
||||
[react/view {:style (merge (styles/acc-sheet) {:background-color "rgba(0,0,0,0)"})}
|
||||
[react/linear-gradient {:colors ["rgba(0,0,0,0)" "rgba(0,0,0,0.3)"]
|
||||
:start {:x 0 :y 0} :end {:x 0 :y 1}
|
||||
|
@ -143,14 +157,14 @@
|
|||
[quo/button
|
||||
{:type :secondary
|
||||
:theme :secondary
|
||||
:on-press #(re-frame/dispatch [:wallet-connect/disconnect topic])}
|
||||
:on-press #(re-frame/dispatch (if (= wc-version constants/wallet-connect-version-1) [:wallet-connect-legacy/disconnect session-legacy] [:wallet-connect/disconnect topic]))}
|
||||
(i18n/label :t/disconnect)]]
|
||||
[account-selector
|
||||
visible-accounts
|
||||
selected-account-atom
|
||||
#(re-frame/dispatch [:wallet-connect/change-session-account topic @selected-account-atom])]]])))
|
||||
#(re-frame/dispatch (if (= wc-version constants/wallet-connect-version-1) [:wallet-connect-legacy/change-session-account session-legacy @selected-account-atom] [:wallet-connect/change-session-account topic @selected-account-atom]))]]])))
|
||||
|
||||
(defview session-proposal-sheet [{:keys [name icons]}]
|
||||
(defview session-proposal-sheet [{:keys [name icons wc-version]}]
|
||||
(letsubs [visible-accounts [:visible-accounts-without-watch-only]
|
||||
dapps-account [:dapps-account]]
|
||||
(let [icon-uri (when (and icons (> (count icons) 0)) (first icons))
|
||||
|
@ -174,11 +188,15 @@
|
|||
[react/view (merge (styles/proposal-buttons-container) (when (= (count visible-accounts) 1) {:margin-top 12}))
|
||||
[quo/button
|
||||
{:type :secondary
|
||||
:on-press #(re-frame/dispatch [:wallet-connect/reject-proposal])}
|
||||
:on-press #(if (= wc-version constants/wallet-connect-version-1)
|
||||
(re-frame/dispatch [:wallet-connect-legacy/reject-proposal])
|
||||
(re-frame/dispatch [:wallet-connect/reject-proposal]))}
|
||||
(i18n/label :t/reject)]
|
||||
[quo/button
|
||||
{:theme :accent
|
||||
:on-press #(re-frame/dispatch [:wallet-connect/approve-proposal @selected-account-atom])}
|
||||
:on-press #(if (= wc-version constants/wallet-connect-version-1)
|
||||
(re-frame/dispatch [:wallet-connect-legacy/approve-proposal @selected-account-atom])
|
||||
(re-frame/dispatch [:wallet-connect/approve-proposal @selected-account-atom]))}
|
||||
(i18n/label :t/connect)]]])))
|
||||
|
||||
(defview wallet-connect-proposal-sheet []
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
(ns status-im.utils.wallet-connect-legacy
|
||||
(:require ["@walletconnect/client-legacy" :default WalletConnect]
|
||||
[status-im.utils.config :as config]))
|
||||
|
||||
(defn create-connector [uri]
|
||||
(WalletConnect.
|
||||
(clj->js {:uri uri
|
||||
:clientMeta config/default-wallet-connect-metadata})))
|
|
@ -12,7 +12,8 @@
|
|||
[status-im.bottom-sheet.core :as bottom-sheet]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.http :as http]
|
||||
[status-im.utils.universal-links.utils :as links]))
|
||||
[status-im.utils.universal-links.utils :as links]
|
||||
[status-im.utils.wallet-connect :as wallet-connect]))
|
||||
|
||||
;; FIXME(Ferossgp): Should be part of QR scanner not wallet
|
||||
(fx/defn toggle-flashlight
|
||||
|
@ -124,7 +125,9 @@
|
|||
(if (links/universal-link? uri)
|
||||
{:dispatch [:universal-links/handle-url uri]}
|
||||
{:browser/show-browser-selection uri})
|
||||
{:ui/show-error (i18n/label :t/wallet-invalid-address {:data uri})})))
|
||||
(if (wallet-connect/url? uri)
|
||||
{:dispatch [::qr-scaner/handle-wallet-connect-uri {:data uri}]}
|
||||
{:ui/show-error (i18n/label :t/wallet-invalid-address {:data uri})}))))
|
||||
|
||||
(fx/defn qr-scanner-result
|
||||
{:events [:wallet.send/qr-scanner-result]}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
(fx/defn session-connected
|
||||
{:events [:wallet-connect/created]}
|
||||
[{:keys [db]} session]
|
||||
(let [session (types/js->clj 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
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
(ns status-im.wallet-connect-legacy.core
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.signing.core :as signing]
|
||||
[status-im.utils.wallet-connect-legacy :as wallet-connect-legacy]
|
||||
[status-im.browser.core :as browser]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.types :as types]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:wc-1-subscribe-to-events
|
||||
(fn [^js connector]
|
||||
(.on connector "session_request" (fn [_ payload]
|
||||
(re-frame/dispatch [:wallet-connect-legacy/proposal payload connector])))
|
||||
(.on connector "connect" (fn [_ payload]
|
||||
(re-frame/dispatch [:wallet-connect-legacy/created payload])))
|
||||
(.on connector "call_request" (fn [_ payload]
|
||||
(re-frame/dispatch [:wallet-connect-legacy/request-received (types/js->clj payload) connector])))
|
||||
(.on connector "session_update" (fn [_ payload]
|
||||
(re-frame/dispatch [:wallet-connect-legacy/update-sessions (types/js->clj payload) connector])))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:wc-1-approve-session
|
||||
(fn [[^js connector accounts proposal-chain-id]]
|
||||
(.approveSession connector (clj->js {:accounts accounts :chainId proposal-chain-id}))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:wc-1-reject-session
|
||||
(fn [^js connector]
|
||||
(.rejectSession connector)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:wc-1-update-session
|
||||
(fn [[^js connector chain-id address]]
|
||||
(.updateSession connector (clj->js {:chainId chain-id :accounts [address]}))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:wc-1-kill-session
|
||||
(fn [^js connector]
|
||||
(.killSession connector)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:wc-1-approve-request
|
||||
(fn [[^js connector response]]
|
||||
(.approveRequest connector (clj->js response))))
|
||||
|
||||
(fx/defn proposal-handler
|
||||
{:events [:wallet-connect-legacy/proposal]}
|
||||
[{:keys [db] :as cofx} request-event connector]
|
||||
(let [proposal (types/js->clj request-event)
|
||||
params (first (:params proposal))
|
||||
metadata (merge (:peerMeta params) {:wc-version constants/wallet-connect-version-1})
|
||||
networks (get db :networks/networks)
|
||||
current-network-id (get db :networks/current-network)
|
||||
current-network (get networks current-network-id)
|
||||
chain-id (get-in current-network [:config :NetworkId])]
|
||||
{:db (assoc db :wallet-connect-legacy/proposal-connector connector :wallet-connect-legacy/proposal-chain-id chain-id :wallet-connect/proposal-metadata metadata)
|
||||
:show-wallet-connect-sheet nil}))
|
||||
|
||||
(fx/defn session-connected
|
||||
{:events [:wallet-connect-legacy/created]}
|
||||
[{:keys [db]} session]
|
||||
(let [connector (get db :wallet-connect-legacy/proposal-connector)
|
||||
session (merge (types/js->clj session) {:wc-version constants/wallet-connect-version-1
|
||||
:connector connector})
|
||||
params (first (:params session))
|
||||
metadata (:peerMeta params)
|
||||
account (first (:accounts params))
|
||||
sessions (get db :wallet-connect-legacy/sessions)
|
||||
updated-sessions (if sessions (conj sessions session) [session])]
|
||||
(log/debug "[wallet connect 1.0] session created - " session)
|
||||
{:show-wallet-connect-success-sheet nil
|
||||
:db (assoc db :wallet-connect/session-connected session :wallet-connect-legacy/sessions updated-sessions)}))
|
||||
|
||||
(fx/defn manage-app
|
||||
{:events [:wallet-connect-legacy/manage-app]}
|
||||
[{:keys [db]} session]
|
||||
{:db (assoc db :wallet-connect/session-managed session :wallet-connect/showing-app-management-sheet? true)
|
||||
:show-wallet-connect-app-management-sheet nil})
|
||||
|
||||
(fx/defn request-handler
|
||||
{:events [:wallet-connect-legacy/request]}
|
||||
[{:keys [db] :as cofx} request-event]
|
||||
(let [request (types/js->clj request-event)
|
||||
params (:request request)
|
||||
pending-requests (or (:wallet-connect-legacy/pending-requests db) [])
|
||||
new-pending-requests (conj pending-requests request)
|
||||
client (get db :wallet-connect-legacy/client)
|
||||
topic (:topic request)]
|
||||
{:db (assoc db :wallet-connect-legacy/pending-requests new-pending-requests)
|
||||
:dispatch [:wallet-connect-legacy/request-received request]}))
|
||||
|
||||
(fx/defn request-handler-test
|
||||
{:events [:wallet-connect-legacy/request-test]}
|
||||
[{:keys [db] :as cofx}]
|
||||
{:show-wallet-connect-sheet nil})
|
||||
|
||||
(fx/defn approve-proposal
|
||||
{:events [:wallet-connect-legacy/approve-proposal]}
|
||||
[{:keys [db]} account]
|
||||
(let [connector (get db :wallet-connect-legacy/proposal-connector)
|
||||
proposal-chain-id (get db :wallet-connect-legacy/proposal-chain-id)
|
||||
address (ethereum/normalized-hex (:address account))
|
||||
accounts [address]]
|
||||
{:hide-wallet-connect-sheet nil
|
||||
:wc-1-approve-session [connector accounts proposal-chain-id]}))
|
||||
|
||||
(fx/defn reject-proposal
|
||||
{:events [:wallet-connect-legacy/reject-proposal]}
|
||||
[{:keys [db]} account]
|
||||
(let [connector (get db :wallet-connect-legacy/proposal-connector)]
|
||||
{:hide-wallet-connect-sheet nil
|
||||
:wc-1-reject-session connector}))
|
||||
|
||||
(fx/defn change-session-account
|
||||
{:events [:wallet-connect-legacy/change-session-account]}
|
||||
[{:keys [db]} session account]
|
||||
(let [connector (:connector session)
|
||||
address (:address account)
|
||||
networks (get db :networks/networks)
|
||||
current-network-id (get db :networks/current-network)
|
||||
current-network (get networks current-network-id)
|
||||
chain-id (get-in current-network [:config :NetworkId])]
|
||||
{:hide-wallet-connect-app-management-sheet nil
|
||||
:wc-1-update-session [connector chain-id address]
|
||||
:db (assoc db :wallet-connect/showing-app-management-sheet? false)}))
|
||||
|
||||
(fx/defn disconnect-session
|
||||
{:events [:wallet-connect-legacy/disconnect]}
|
||||
[{:keys [db]} session]
|
||||
(let [sessions (get db :wallet-connect-legacy/sessions)
|
||||
connector (:connector session)]
|
||||
{:hide-wallet-connect-app-management-sheet nil
|
||||
:hide-wallet-connect-success-sheet nil
|
||||
:wc-1-kill-session connector
|
||||
:db (-> db
|
||||
(assoc :wallet-connect-legacy/sessions (filter #(not= (:connector %) connector) sessions))
|
||||
(dissoc :wallet-connect/session-managed))}))
|
||||
|
||||
(fx/defn pair-session
|
||||
{:events [:wallet-connect-legacy/pair]}
|
||||
[{:keys [db]} {:keys [data]}]
|
||||
(let [connector (wallet-connect-legacy/create-connector data)
|
||||
wallet-connect-enabled? (get db :wallet-connect/enabled?)]
|
||||
(merge
|
||||
{:dispatch [:navigate-back]}
|
||||
(when wallet-connect-enabled?
|
||||
{:db (assoc db :wallet-connect-legacy/scanned-uri data)
|
||||
:wc-1-subscribe-to-events connector}))))
|
||||
|
||||
(fx/defn update-sessions
|
||||
{:events [:wallet-connect-legacy/update-sessions]}
|
||||
[{:keys [db] :as cofx} payload connector]
|
||||
(let [sessions (get db :wallet-connect-legacy/sessions)
|
||||
accounts-new (:accounts (first (:params payload)))
|
||||
session (first (filter #(= (:connector %) connector) sessions))
|
||||
updated-session (assoc-in session [:params 0 :accounts] accounts-new)]
|
||||
{:db (-> db
|
||||
(assoc :wallet-connect-legacy/sessions (conj (filter #(not= (:connector %) connector) sessions) updated-session))
|
||||
(dissoc :wallet-connect/session-managed))}))
|
||||
|
||||
(fx/defn wallet-connect-legacy-complete-transaction
|
||||
{:events [:wallet-connect-legacy.dapp/transaction-on-result]}
|
||||
[{:keys [db]} message-id connector result]
|
||||
(let [response {:id message-id
|
||||
:result result}]
|
||||
{:db (assoc db :wallet-connect-legacy/response response)
|
||||
:wc-1-approve-request [connector response]}))
|
||||
|
||||
(fx/defn wallet-connect-legacy-send-async
|
||||
[{:keys [db] :as cofx} {:keys [method params id] :as payload} message-id connector]
|
||||
(let [message? (browser/web3-sign-message? method)
|
||||
sessions (get db :wallet-connect-legacy/sessions)
|
||||
session (first (filter #(= (:connector %) connector) sessions))
|
||||
linked-address (get-in session [:params 0 :accounts 0])
|
||||
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 % linked-address))
|
||||
(dissoc :gasPrice))})
|
||||
{:on-result [:wallet-connect-legacy.dapp/transaction-on-result message-id connector]
|
||||
:on-error [:wallet-connect-legacy.dapp/transaction-on-error message-id connector]}))))
|
||||
(when (#{"eth_accounts" "eth_coinbase"} method)
|
||||
(wallet-connect-legacy-complete-transaction cofx message-id connector (if (= method "eth_coinbase") linked-address [linked-address]))))))
|
||||
|
||||
(fx/defn wallet-connect-legacy-send-async-read-only
|
||||
[{:keys [db] :as cofx} payload id connector]
|
||||
(wallet-connect-legacy-send-async cofx payload id connector))
|
||||
|
||||
(fx/defn process-request
|
||||
{:events [:wallet-connect-legacy/request-received]}
|
||||
[{:keys [db] :as cofx} payload connector]
|
||||
(let [{:keys [id]} payload]
|
||||
(wallet-connect-legacy-send-async-read-only cofx payload id connector)))
|
|
@ -1744,6 +1744,7 @@
|
|||
"wallet-connect-app-connected": "is connected",
|
||||
"wallet-connect-go-back": "Go back to your browser or dapp",
|
||||
"wallet-connect-2.0": "Wallet Connect 2.0",
|
||||
"wallet-connect": "Wallet Connect",
|
||||
"reject": "Reject",
|
||||
"manage-connections": "Manage connections from within Application Connections",
|
||||
"wallet-manage-app-connections": "Manage app connections",
|
||||
|
|
93
yarn.lock
93
yarn.lock
|
@ -1564,6 +1564,27 @@
|
|||
dependencies:
|
||||
"@types/yargs-parser" "*"
|
||||
|
||||
"@walletconnect/browser-utils@^1.7.1":
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/browser-utils/-/browser-utils-1.7.1.tgz#2a28846cd4d73166debbbf7d470e78ba25616f5e"
|
||||
integrity sha512-y6KvxPhi52sWzS0/HtA3EhdgmtG8mXcxdc26YURDOVC/BJh3MxV8E16JFrT4InylOqYJs6dcSLWVfcnJaiPtZw==
|
||||
dependencies:
|
||||
"@walletconnect/safe-json" "1.0.0"
|
||||
"@walletconnect/types" "^1.7.1"
|
||||
"@walletconnect/window-getters" "1.0.0"
|
||||
"@walletconnect/window-metadata" "1.0.0"
|
||||
detect-browser "5.2.0"
|
||||
|
||||
"@walletconnect/client-legacy@npm:@walletconnect/client@^1.7.1":
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/client/-/client-1.7.1.tgz#aaa74199bdc0605db9ac2ecdf8a463b271586d3b"
|
||||
integrity sha512-xD8B8s1hL7Z5vJwb3L0u1bCVAk6cRQfIY9ycymf7KkmIhkAONQJNf2Y0C0xIpbPp2fdn9VwnSfLm5Ed/Ht/1IA==
|
||||
dependencies:
|
||||
"@walletconnect/core" "^1.7.1"
|
||||
"@walletconnect/iso-crypto" "^1.7.1"
|
||||
"@walletconnect/types" "^1.7.1"
|
||||
"@walletconnect/utils" "^1.7.1"
|
||||
|
||||
"@walletconnect/client@^2.0.0-beta.23":
|
||||
version "2.0.0-beta.23"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/client/-/client-2.0.0-beta.23.tgz#934f91beb66ec7bb1a79afc1973fcd48481ccbc5"
|
||||
|
@ -1580,6 +1601,15 @@
|
|||
"@walletconnect/utils" "^2.0.0-beta.23"
|
||||
ws "^8.3.0"
|
||||
|
||||
"@walletconnect/core@^1.7.1":
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-1.7.1.tgz#321c14d63af81241658b028022e0e5fa6dc7f374"
|
||||
integrity sha512-qO+4wykyRNiq3HEuaAA2pW2PDnMM4y7pyPAgiCwfHiqF4PpWvtcdB301hI0K5am9ghuqKZMy1HlE9LWNOEBvcw==
|
||||
dependencies:
|
||||
"@walletconnect/socket-transport" "^1.7.1"
|
||||
"@walletconnect/types" "^1.7.1"
|
||||
"@walletconnect/utils" "^1.7.1"
|
||||
|
||||
"@walletconnect/crypto@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/crypto/-/crypto-1.0.1.tgz#d4c1b1cd5dd1be88fe9a82dfc54cadbbb3f9d325"
|
||||
|
@ -1613,6 +1643,15 @@
|
|||
resolved "https://registry.yarnpkg.com/@walletconnect/environment/-/environment-1.0.0.tgz#c4545869fa9c389ec88c364e1a5f8178e8ab5034"
|
||||
integrity sha512-4BwqyWy6KpSvkocSaV7WR3BlZfrxLbJSLkg+j7Gl6pTDE+U55lLhJvQaMuDVazXYxcjBsG09k7UlH7cGiUI5vQ==
|
||||
|
||||
"@walletconnect/iso-crypto@^1.7.1":
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/iso-crypto/-/iso-crypto-1.7.1.tgz#c463bb5874686c2f21344e2c7f3cf4d71c34ca70"
|
||||
integrity sha512-qMiW0kLN6KCjnLMD50ijIj1lQqjNjGszGUwrSVUiS2/Dp4Ecx+4QEtHbmVwGEkfx4kelYPFpDJV3ZJpQ4Kqg/g==
|
||||
dependencies:
|
||||
"@walletconnect/crypto" "^1.0.1"
|
||||
"@walletconnect/types" "^1.7.1"
|
||||
"@walletconnect/utils" "^1.7.1"
|
||||
|
||||
"@walletconnect/jsonrpc-provider@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/jsonrpc-provider/-/jsonrpc-provider-1.0.0.tgz#066ee5a8a8554c55ea68f9ebf6fe8f96cdb66e7e"
|
||||
|
@ -1668,11 +1707,25 @@
|
|||
dependencies:
|
||||
"@walletconnect/jsonrpc-types" "^1.0.0"
|
||||
|
||||
"@walletconnect/safe-json@^1.0.0":
|
||||
"@walletconnect/safe-json@1.0.0", "@walletconnect/safe-json@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/safe-json/-/safe-json-1.0.0.tgz#12eeb11d43795199c045fafde97e3c91646683b2"
|
||||
integrity sha512-QJzp/S/86sUAgWY6eh5MKYmSfZaRpIlmCJdi5uG4DJlKkZrHEF7ye7gA+VtbVzvTtpM/gRwO2plQuiooIeXjfg==
|
||||
|
||||
"@walletconnect/socket-transport@^1.7.1":
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/socket-transport/-/socket-transport-1.7.1.tgz#cc4c8dcf21c40b805812ecb066b2abb156fdb146"
|
||||
integrity sha512-Gu1RPro0eLe+HHtLhq/1T5TNFfO/HW2z3BnWuUYuJ/F8w1U9iK7+4LMHe+LTgwgWy9Ybcb2k0tiO5e3LgjHBHQ==
|
||||
dependencies:
|
||||
"@walletconnect/types" "^1.7.1"
|
||||
"@walletconnect/utils" "^1.7.1"
|
||||
ws "7.5.3"
|
||||
|
||||
"@walletconnect/types@^1.7.1":
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-1.7.1.tgz#86cc3832e02415dc9f518f3dcb5366722afbfc03"
|
||||
integrity sha512-X0NunEUgq46ExDcKo7BnnFpFhuZ89bZ04/1FtohNziBWcP2Mblp2yf+FN7iwmZiuZ3bRTb8J1O4oJH2JGP9I7A==
|
||||
|
||||
"@walletconnect/types@^2.0.0-beta.23":
|
||||
version "2.0.0-beta.23"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.0.0-beta.23.tgz#3adf5c8329b7807d8c8d4aa1419e470eab72445c"
|
||||
|
@ -1683,6 +1736,19 @@
|
|||
pino "^6.7.0"
|
||||
pino-pretty "^4.3.0"
|
||||
|
||||
"@walletconnect/utils@^1.7.1":
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-1.7.1.tgz#f858d5f22425a4c2da2a28ae493bde7f2eecf815"
|
||||
integrity sha512-7Lig9rruqTMaFuwEhBrArq1QgzIf2NuzO6J3sCUYCZh60EQ7uIZjekaDonQjiQJAbfYcgWUBm8qa0PG1TzYN3Q==
|
||||
dependencies:
|
||||
"@walletconnect/browser-utils" "^1.7.1"
|
||||
"@walletconnect/encoding" "^1.0.0"
|
||||
"@walletconnect/jsonrpc-utils" "^1.0.0"
|
||||
"@walletconnect/types" "^1.7.1"
|
||||
bn.js "4.11.8"
|
||||
js-sha3 "0.8.0"
|
||||
query-string "6.13.5"
|
||||
|
||||
"@walletconnect/utils@^2.0.0-beta.23":
|
||||
version "2.0.0-beta.23"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.0.0-beta.23.tgz#005e4409a7014a66dda30389e4b1f31d186ebd0e"
|
||||
|
@ -1700,12 +1766,12 @@
|
|||
lodash.union "^4.6.0"
|
||||
query-string "^6.13.5"
|
||||
|
||||
"@walletconnect/window-getters@^1.0.0":
|
||||
"@walletconnect/window-getters@1.0.0", "@walletconnect/window-getters@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/window-getters/-/window-getters-1.0.0.tgz#1053224f77e725dfd611c83931b5f6c98c32bfc8"
|
||||
integrity sha512-xB0SQsLaleIYIkSsl43vm8EwETpBzJ2gnzk7e0wMF3ktqiTGS6TFHxcprMl5R44KKh4tCcHCJwolMCaDSwtAaA==
|
||||
|
||||
"@walletconnect/window-metadata@^1.0.0":
|
||||
"@walletconnect/window-metadata@1.0.0", "@walletconnect/window-metadata@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/window-metadata/-/window-metadata-1.0.0.tgz#93b1cc685e6b9b202f29c26be550fde97800c4e5"
|
||||
integrity sha512-9eFvmJxIKCC3YWOL97SgRkKhlyGXkrHwamfechmqszbypFspaSk+t2jQXAEU7YClHF6Qjw5eYOmy1//zFi9/GA==
|
||||
|
@ -3280,6 +3346,11 @@ destroy@~1.0.4:
|
|||
resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80"
|
||||
integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=
|
||||
|
||||
detect-browser@5.2.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/detect-browser/-/detect-browser-5.2.0.tgz#c9cd5afa96a6a19fda0bbe9e9be48a6b6e1e9c97"
|
||||
integrity sha512-tr7XntDAu50BVENgQfajMLzacmSe34D+qZc4zjnniz0ZVuw/TZcLcyxHQjYpJTM36sGEkZZlYLnIM1hH7alTMA==
|
||||
|
||||
detect-libc@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
|
||||
|
@ -5258,7 +5329,7 @@ js-levenshtein@^1.1.3:
|
|||
resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d"
|
||||
integrity sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==
|
||||
|
||||
js-sha3@^0.8.0:
|
||||
js-sha3@0.8.0, js-sha3@^0.8.0:
|
||||
version "0.8.0"
|
||||
resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840"
|
||||
integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==
|
||||
|
@ -7134,6 +7205,15 @@ qs@~6.5.2:
|
|||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
||||
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
|
||||
|
||||
query-string@6.13.5:
|
||||
version "6.13.5"
|
||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.5.tgz#99e95e2fb7021db90a6f373f990c0c814b3812d8"
|
||||
integrity sha512-svk3xg9qHR39P3JlHuD7g3nRnyay5mHbrPctEBDUxUkHRifPHXJDhBUycdCC0NBjXoDf44Gb+IsOZL1Uwn8M/Q==
|
||||
dependencies:
|
||||
decode-uri-component "^0.2.0"
|
||||
split-on-first "^1.0.0"
|
||||
strict-uri-encode "^2.0.0"
|
||||
|
||||
query-string@^5.0.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb"
|
||||
|
@ -9208,6 +9288,11 @@ write-file-atomic@^3.0.0:
|
|||
signal-exit "^3.0.2"
|
||||
typedarray-to-buffer "^3.1.5"
|
||||
|
||||
ws@7.5.3:
|
||||
version "7.5.3"
|
||||
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.3.tgz#160835b63c7d97bfab418fc1b8a9fced2ac01a74"
|
||||
integrity sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==
|
||||
|
||||
ws@^1.1.0, ws@^1.1.5:
|
||||
version "1.1.5"
|
||||
resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.5.tgz#cbd9e6e75e09fc5d2c90015f21f0c40875e0dd51"
|
||||
|
|
Loading…
Reference in New Issue