Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fbf140da0 | ||
|
|
e9b8118c0d | ||
|
|
80c15bd8d0 | ||
|
|
4aef76281c | ||
|
|
c62d7d501e |
@@ -32,9 +32,7 @@ showXcrunLogs() {
|
||||
}
|
||||
|
||||
# find the first connected iPhone's UUID
|
||||
#DEVICE_UUID=$(idevice_id -l)
|
||||
# hardcoding Sid's iPhone
|
||||
DEVICE_UUID="00008120-0002681E0E04201E"
|
||||
DEVICE_UUID=$(idevice_id -l)
|
||||
|
||||
# Check if any device is connected
|
||||
if [ -z "${DEVICE_UUID}" ]; then
|
||||
|
||||
@@ -88,6 +88,15 @@
|
||||
{:chainId :chain-id
|
||||
:removed :removed?})
|
||||
name-details)]
|
||||
(let [new-db (reduce (fn [db {:keys [username removed? chain-id] :as name-detail}]
|
||||
(if removed?
|
||||
(update-in db [:ens/names chain-id] dissoc username)
|
||||
(let [old (get-in db [:ens/names chain-id username])]
|
||||
(assoc-in db [:ens/names chain-id username] (merge old name-detail)))))
|
||||
db
|
||||
name-details)]
|
||||
(prn "new db" new-db)
|
||||
)
|
||||
{:db (reduce (fn [db {:keys [username removed? chain-id] :as name-detail}]
|
||||
(if removed?
|
||||
(update-in db [:ens/names chain-id] dissoc username)
|
||||
|
||||
+64
-24
@@ -4,6 +4,8 @@
|
||||
[clojure.string :as string]
|
||||
[native-module.utils :as native-utils]
|
||||
[react-native.platform :as platform]
|
||||
[status-backend.core :as status-backend]
|
||||
[status-backend.config :as status-backend.config]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.transforms :as types]))
|
||||
|
||||
@@ -14,18 +16,24 @@
|
||||
|
||||
(defn account-manager
|
||||
[]
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-AccountManager ^js (.-NativeModules react-native))))
|
||||
(if false
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-AccountManager ^js (.-NativeModules react-native)))
|
||||
status-backend/fetch-js-obj))
|
||||
|
||||
(defn encryption
|
||||
[]
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-EncryptionUtils ^js (.-NativeModules react-native))))
|
||||
(if false
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-EncryptionUtils ^js (.-NativeModules react-native)))
|
||||
status-backend/fetch-js-obj))
|
||||
|
||||
(defn database
|
||||
[]
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-DatabaseManager ^js (.-NativeModules react-native))))
|
||||
(if false
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-DatabaseManager ^js (.-NativeModules react-native)))
|
||||
status-backend/fetch-js-obj))
|
||||
|
||||
(defn ui-helper
|
||||
[]
|
||||
@@ -34,23 +42,31 @@
|
||||
|
||||
(defn log-manager
|
||||
[]
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-LogManager ^js (.-NativeModules react-native))))
|
||||
(if false
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-LogManager ^js (.-NativeModules react-native)))
|
||||
status-backend/fetch-js-obj))
|
||||
|
||||
(defn utils
|
||||
[]
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-Utils ^js (.-NativeModules react-native))))
|
||||
(if false
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-Utils ^js (.-NativeModules react-native)))
|
||||
status-backend/fetch-js-obj))
|
||||
|
||||
(defn network
|
||||
[]
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-NetworkManager ^js (.-NativeModules react-native))))
|
||||
(if false
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-NetworkManager ^js (.-NativeModules react-native)))
|
||||
status-backend/fetch-js-obj))
|
||||
|
||||
(defn mail-manager
|
||||
[]
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-MailManager ^js (.-NativeModules react-native))))
|
||||
(if false
|
||||
(when (exists? (.-NativeModules react-native))
|
||||
(.-MailManager ^js (.-NativeModules react-native)))
|
||||
status-backend/fetch-js-obj))
|
||||
|
||||
(defn mail
|
||||
[opts callback]
|
||||
@@ -58,7 +74,9 @@
|
||||
|
||||
(defn init
|
||||
[handler]
|
||||
(.addListener ^js (.-DeviceEventEmitter ^js react-native) "gethEvent" #(handler (.-jsonEvent ^js %))))
|
||||
(if false
|
||||
(.addListener ^js (.-DeviceEventEmitter ^js react-native) "gethEvent" #(handler (.-jsonEvent ^js %)))
|
||||
(status-backend/init-web-socket handler)))
|
||||
|
||||
(defn clear-web-data
|
||||
[]
|
||||
@@ -340,7 +358,9 @@
|
||||
(log/debug "[native-module] set-blank-preview-flag")
|
||||
;; Sometimes the app crashes during logout because `flag` is nil.
|
||||
(when-not (nil? flag)
|
||||
(.setBlankPreviewFlag ^js (encryption) flag)))
|
||||
(.setBlankPreviewFlag ^js (when (exists? (.-NativeModules react-native))
|
||||
(.-EncryptionUtils ^js (.-NativeModules react-native)))
|
||||
flag)))
|
||||
|
||||
(defn get-device-model-info
|
||||
[]
|
||||
@@ -419,8 +439,11 @@
|
||||
(defn sha3
|
||||
[s]
|
||||
(log/debug "[native-module] sha3")
|
||||
(when s
|
||||
(.sha3 ^js (encryption) (str s))))
|
||||
(time
|
||||
(let [temp-encryption (when (exists? (.-NativeModules react-native))
|
||||
(.-EncryptionUtils ^js (.-NativeModules react-native)))]
|
||||
(when s
|
||||
(.sha3 ^js temp-encryption (str s))))))
|
||||
|
||||
(defn utf8-to-hex
|
||||
[s]
|
||||
@@ -444,7 +467,8 @@
|
||||
|
||||
(defn add-centralized-metric
|
||||
[metric]
|
||||
(.addCentralizedMetric ^js (status) (types/clj->json metric) #(log/debug "pushed metric" % metric)))
|
||||
(.addCentralizedMetric ^js (status) (types/clj->json metric)
|
||||
(fn []) #_(log/debug "pushed metric" % metric)))
|
||||
|
||||
(defn address?
|
||||
[address]
|
||||
@@ -456,7 +480,9 @@
|
||||
(defn to-checksum-address
|
||||
[address]
|
||||
(log/debug "[native-module] to-checksum-address")
|
||||
(.toChecksumAddress ^js (utils) address))
|
||||
(.toChecksumAddress ^js (when (exists? (.-NativeModules react-native))
|
||||
(.-Utils ^js (.-NativeModules react-native)))
|
||||
address))
|
||||
|
||||
(defn validate-mnemonic
|
||||
"Validate that a mnemonic conforms to BIP39 dictionary/checksum standards"
|
||||
@@ -522,7 +548,9 @@
|
||||
|
||||
(defn backup-disabled-data-dir
|
||||
[]
|
||||
(.backupDisabledDataDir ^js (utils)))
|
||||
(if false ;; Check for not use of status-backend
|
||||
(.backupDisabledDataDir ^js (utils))
|
||||
status-backend.config/data-dir-path))
|
||||
|
||||
(defn fleets
|
||||
[]
|
||||
@@ -530,15 +558,27 @@
|
||||
|
||||
(defn keystore-dir
|
||||
[]
|
||||
(.keystoreDir ^js (utils)))
|
||||
(if false
|
||||
(.keystoreDir ^js (utils))
|
||||
status-backend.config/keystore-dir-path))
|
||||
|
||||
(defn log-file-directory
|
||||
[]
|
||||
(.logFileDirectory ^js (log-manager)))
|
||||
(if false
|
||||
(.logFileDirectory ^js (log-manager))
|
||||
status-backend.config/log-dir-path))
|
||||
|
||||
(defn init-status-go-logging
|
||||
[{:keys [enable? mobile-system? log-level log-request-go? callback]}]
|
||||
(.initLogging ^js (log-manager) enable? mobile-system? log-level log-request-go? callback))
|
||||
(if false
|
||||
(.initLogging ^js (log-manager) enable? mobile-system? log-level log-request-go? callback)
|
||||
(.initLogging ^js (log-manager)
|
||||
{:Enabled enable?
|
||||
:MobileSystem mobile-system?
|
||||
:Level log-level
|
||||
:LogRequestGo log-request-go?
|
||||
:LogRequestFile status-backend.config/log-request-file-path}
|
||||
callback)))
|
||||
|
||||
(defn get-random-mnemonic
|
||||
[callback]
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
:seed :i/seed
|
||||
:key :i/password
|
||||
nil)
|
||||
:color :neutral
|
||||
:blur? true
|
||||
:border? true}]
|
||||
[rn/view
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
(ns status-backend.config)
|
||||
|
||||
;; Before run:
|
||||
;; adb reverse tcp:9050 tcp:9050
|
||||
|
||||
;; TODO: these should be read from env vars
|
||||
(def ^:private address "localhost")
|
||||
(def ^:private port 9050)
|
||||
(def ^:private url (str "http://" address ":" port))
|
||||
|
||||
(def status-go-url (str url "/statusgo/"))
|
||||
(def signals-url (str url "/signals"))
|
||||
|
||||
(def fetch-default-params
|
||||
{:method :POST
|
||||
:headers {"Accept" "application/json"
|
||||
"Content-Type" "application/json"}})
|
||||
|
||||
;; This dir musts exist before running the app
|
||||
(def data-dir-path "/home/ulises/p/status-go/1_test-db")
|
||||
|
||||
(def keystore-dir-path "/home/ulises/p/status-go/1_test-db/1_keystore")
|
||||
(def log-dir-path "/home/ulises/p/status-go/requests.log")
|
||||
(def log-request-file-path (str data-dir-path "/requests.log"))
|
||||
@@ -0,0 +1,86 @@
|
||||
(ns status-backend.core
|
||||
(:require
|
||||
[status-backend.config :as config]
|
||||
[utils.network.core :as network]
|
||||
[clojure.string :as string]
|
||||
[oops.core :as oops]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn fetch
|
||||
([endpoint]
|
||||
(println (str ".......................... 1-----: " endpoint))
|
||||
(fetch endpoint nil (fn [])))
|
||||
([endpoint body-params]
|
||||
(println (str ".......................... 2-----: " endpoint))
|
||||
(fetch endpoint body-params (fn [])))
|
||||
([endpoint body-params callback]
|
||||
(println (str "========================== > INVOKE: " endpoint "::" (prn-str body-params)))
|
||||
(let [url (str config/status-go-url endpoint)
|
||||
params (assoc config/fetch-default-params :body body-params)]
|
||||
(network/fetch url params callback))))
|
||||
|
||||
(defn- method-name->endpoint [s]
|
||||
(let [first-letter-capitalized (string/capitalize (first s))]
|
||||
(str first-letter-capitalized (subs s 1))))
|
||||
|
||||
(def fetch-js-obj
|
||||
"Performs a request to the status-backend (by using `status-backend.core/fetch`) using
|
||||
the method invoked as endpoint name. E.g
|
||||
This call: (.myMethod fetch-js-obj params)
|
||||
Is the same as: (fetch \"MyMethod\" params)
|
||||
"
|
||||
(js/Proxy. #js{}
|
||||
#js{:get (fn [_target native-module-method-name]
|
||||
(let [endpoint (method-name->endpoint native-module-method-name)]
|
||||
(partial fetch endpoint)))}))
|
||||
|
||||
(declare web-socket)
|
||||
|
||||
(defn init-web-socket [on-message]
|
||||
(defonce web-socket (js/WebSocket. config/signals-url))
|
||||
(oops/oset! web-socket "onopen" #(log/debug "[backend] Web Socket connected"))
|
||||
(oops/oset! web-socket "onmessage" (fn [e]
|
||||
(println " NEW WEBSOCKET MESSAGE! -- START")
|
||||
(-> e (oops/oget "data") (on-message))
|
||||
(println " NEW WEBSOCKET MESSAGE! -- END")))
|
||||
(oops/oset! web-socket "onerror" #(log/error "[backend] Web Socket error" %))
|
||||
(oops/oset! web-socket "onclose" #(log/error "[backend] Web Socket closed" %)))
|
||||
|
||||
|
||||
;(defn call-private-rpc [payload callback]
|
||||
; ;; NOTE: according to the status-backend readme, we call RPCs using the `CallRPC`
|
||||
; ;; endpoint, instead of using `CallPrivateRPC` as in mobile.
|
||||
; (fetch "CallRPC" payload callback))
|
||||
|
||||
|
||||
(comment ;; Useful REPL commands (will be removed)
|
||||
;; STEP 1: Initialize the app
|
||||
;; Option 1: Method call
|
||||
(.initializeApplication ^js fetch-js-obj
|
||||
(utils.transforms/clj->json {:dataDir "/home/ulises/p/status-go/test-db" ;; Put your dir
|
||||
:mixpanelAppId status-im.config/mixpanel-app-id
|
||||
:mixpanelToken status-im.config/mixpanel-token})
|
||||
(fn [raw-response]
|
||||
(let [result (utils.transforms/json->clj raw-response)]
|
||||
(js/alert (prn-str result)))))
|
||||
|
||||
;; Option 2: calling fetch
|
||||
(fetch "InitializeApplication"
|
||||
{:dataDir "/home/ulises/p/status-go/test-db"
|
||||
:mixpanelAppId status-im.config/mixpanel-app-id
|
||||
:mixpanelToken status-im.config/mixpanel-token}
|
||||
(fn [response]
|
||||
(js/alert (prn-str response))))
|
||||
|
||||
|
||||
;; STEP 2 "Create a Profile and Log in
|
||||
(let [body (-> (status-im.contexts.profile.config/create)
|
||||
(assoc :displayName "Sonic"
|
||||
:password (native-module.core/sha3 "Hola1234.,")
|
||||
:imagePath nil
|
||||
:customizationColor :army))]
|
||||
(fetch "CreateAccountAndLogin"
|
||||
body
|
||||
(fn [response]
|
||||
(def --r response)
|
||||
(js/alert (str "HTTP-RESPONSE:\n" (js/JSON.stringify response)))))))
|
||||
@@ -25,6 +25,7 @@
|
||||
(rf/defn process
|
||||
{:events [:signals/signal-received]}
|
||||
[{:keys [db] :as cofx} event-str]
|
||||
(println (str "<<<<<<<<<<<<<<<<<<<<<<<<<< SIGNAL: " (prn-str event-str)))
|
||||
;; We only convert to clojure when strictly necessary or we know it
|
||||
;; won't impact performance, as it is a fairly costly operation on large-ish
|
||||
;; data structures
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
[context]
|
||||
(when (push-event? (interceptor/get-coeffect context :db))
|
||||
(when-let [event (tracking/metrics-event (interceptor/get-coeffect context :event))]
|
||||
(log/debug "tracking event" event)
|
||||
#_(log/debug "tracking event" event)
|
||||
(if (or (seq? event) (vector? event))
|
||||
(doseq [e event]
|
||||
(native-module/add-centralized-metric e))
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
:screen/onboarding.new-to-status)]]]
|
||||
(when-not syncing-account-recovered?
|
||||
[:dispatch [:syncing/clear-syncing-installation-id]])]
|
||||
:dispatch-later [{:ms constants/onboarding-generating-keys-animation-duration-ms
|
||||
:dispatch-later [#_{:ms constants/onboarding-generating-keys-animation-duration-ms
|
||||
:dispatch [:navigate-to-within-stack
|
||||
[:screen/onboarding.enable-notifications
|
||||
loading-screen]]}]
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
(defn title
|
||||
[]
|
||||
(let [generate-keys-opacity (reanimated/use-shared-value 1)
|
||||
#_(let [generate-keys-opacity (reanimated/use-shared-value 1)
|
||||
saving-keys-opacity (reanimated/use-shared-value 0)
|
||||
keys-saved-opacity (reanimated/use-shared-value 0)]
|
||||
(sequence-animation generate-keys-opacity saving-keys-opacity keys-saved-opacity)
|
||||
@@ -86,7 +86,8 @@
|
||||
{:style (reanimated/apply-animations-to-style
|
||||
{:opacity keys-saved-opacity}
|
||||
style/title-style)}
|
||||
[keys-saved-title]]]))
|
||||
[keys-saved-title]]])
|
||||
)
|
||||
|
||||
(defn content
|
||||
[]
|
||||
|
||||
@@ -156,7 +156,9 @@
|
||||
{:db (update db :profile/login #(-> % (dissoc :processing) (assoc :error error)))}
|
||||
{:db (dissoc db :profile/login)
|
||||
:fx [(when (and new-account? (not recovered-account?))
|
||||
[:dispatch-later [{:ms 1000 :dispatch [:wallet-legacy/set-initial-blocks-range]}]])
|
||||
;; INVALID EVENT:
|
||||
;[:dispatch-later [{:ms 1000 :dispatch [:wallet-legacy/set-initial-blocks-range]}]]
|
||||
)
|
||||
[:dispatch-later [{:ms 2000 :dispatch [:ens/update-usernames ensUsernames]}]]
|
||||
[:dispatch [:profile.login/login-existing-profile settings account]]]})))
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
(defn- bridge-token-component
|
||||
[]
|
||||
(fn [{:keys [chain-id network-name]} {:keys [networks] :as token}]
|
||||
(fn [{:keys [chain-id network-name]} {:keys [supported-networks] :as token}]
|
||||
(let [network (rf/sub [:wallet/network-details-by-chain-id chain-id])
|
||||
currency (rf/sub [:profile/currency])
|
||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||
@@ -28,7 +28,8 @@
|
||||
fiat-formatted (utils/get-standard-fiat-format crypto-value
|
||||
currency-symbol
|
||||
fiat-value)
|
||||
token-available-on-network? (network-utils/token-available-on-network? networks chain-id)]
|
||||
token-available-on-network? (network-utils/token-available-on-network? supported-networks
|
||||
chain-id)]
|
||||
[quo/network-list
|
||||
{:label (name network-name)
|
||||
:network-image (quo.resources/get-network (:network-name network))
|
||||
@@ -49,7 +50,10 @@
|
||||
mainnet (first network-details)
|
||||
layer-2-networks (rest network-details)
|
||||
account-token (some #(when (= token-symbol (:symbol %)) %) tokens)
|
||||
account-token (when account-token (assoc account-token :networks (:networks token)))
|
||||
account-token (when account-token
|
||||
(assoc account-token
|
||||
:networks (:networks token)
|
||||
:supported-networks (:supported-networks token)))
|
||||
bridge-to-title (i18n/label :t/bridge-to
|
||||
{:name (string/upper-case (str token-symbol))})]
|
||||
|
||||
|
||||
@@ -522,9 +522,10 @@
|
||||
[tokens networks chain-ids]
|
||||
(map (fn [token]
|
||||
(assoc token
|
||||
:networks (network-utils/network-list token networks)
|
||||
:available-balance (calculate-total-token-balance token)
|
||||
:total-balance (calculate-total-token-balance token chain-ids)))
|
||||
:networks (network-utils/network-list-with-positive-balance token networks)
|
||||
:supported-networks (network-utils/network-list token networks)
|
||||
:available-balance (calculate-total-token-balance token)
|
||||
:total-balance (calculate-total-token-balance token chain-ids)))
|
||||
tokens))
|
||||
|
||||
(defn estimated-time-format
|
||||
|
||||
@@ -72,11 +72,32 @@
|
||||
(update :testPreferredChainIds chain-ids-set->string)
|
||||
(dissoc :watch-only? :default-account? :operable? :tokens :collectibles)))
|
||||
|
||||
(defn add-missing-balance-per-chain-values
|
||||
"Adds any missing chain balance (0) to the balance-per-chain map based on token supported chains as
|
||||
status-go returns balance for that chain only if the balance is positive."
|
||||
[balances-per-chain supported-chains]
|
||||
(let [zero-balance-per-chain (fn [chain-id]
|
||||
{:chain-id chain-id
|
||||
:raw-balance (money/->bignumber 0)
|
||||
:balance "0"})]
|
||||
(reduce
|
||||
(fn [result chain-id]
|
||||
(if (contains? result chain-id)
|
||||
result
|
||||
(assoc result chain-id (zero-balance-per-chain chain-id))))
|
||||
balances-per-chain
|
||||
supported-chains)))
|
||||
|
||||
(defn- rpc->balances-per-chain
|
||||
[token]
|
||||
[token supported-chains]
|
||||
(-> token
|
||||
(update :balances-per-chain update-vals #(update % :raw-balance money/bignumber))
|
||||
(update :balances-per-chain update-keys (comp utils.number/parse-int name))))
|
||||
(update :balances-per-chain update-keys (comp utils.number/parse-int name))
|
||||
(update :balances-per-chain #(add-missing-balance-per-chain-values % supported-chains))))
|
||||
|
||||
(defn- update-balances-per-chain
|
||||
[tokens supported-chains-by-token-symbol]
|
||||
(mapv #(rpc->balances-per-chain % (get supported-chains-by-token-symbol (:symbol %))) tokens))
|
||||
|
||||
(defn- remove-tokens-with-empty-values
|
||||
[tokens]
|
||||
@@ -85,12 +106,12 @@
|
||||
tokens))
|
||||
|
||||
(defn rpc->tokens
|
||||
[tokens]
|
||||
[tokens supported-chains-by-token-symbol]
|
||||
(-> tokens
|
||||
(update-keys name)
|
||||
(update-vals #(cske/transform-keys transforms/->kebab-case-keyword %))
|
||||
(update-vals remove-tokens-with-empty-values)
|
||||
(update-vals #(mapv rpc->balances-per-chain %))))
|
||||
(update-vals #(update-balances-per-chain % supported-chains-by-token-symbol))))
|
||||
|
||||
(defn rpc->network
|
||||
[network]
|
||||
|
||||
@@ -229,14 +229,17 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet/store-wallet-token
|
||||
(fn [{:keys [db]} [address raw-tokens-data]]
|
||||
(let [tokens (data-store/rpc->tokens raw-tokens-data)
|
||||
add-tokens (fn [stored-accounts tokens-per-account]
|
||||
(reduce-kv (fn [accounts address tokens-data]
|
||||
(if (contains? accounts address)
|
||||
(update accounts address assoc :tokens tokens-data)
|
||||
accounts))
|
||||
stored-accounts
|
||||
tokens-per-account))]
|
||||
(let [supported-chains-by-token-symbol (get-in db [:wallet :tokens :supported-chains-by-symbol])
|
||||
tokens (data-store/rpc->tokens raw-tokens-data
|
||||
supported-chains-by-token-symbol)
|
||||
add-tokens (fn [stored-accounts tokens-per-account]
|
||||
(reduce-kv
|
||||
(fn [accounts address tokens-data]
|
||||
(if (contains? accounts address)
|
||||
(update accounts address assoc :tokens tokens-data)
|
||||
accounts))
|
||||
stored-accounts
|
||||
tokens-per-account))]
|
||||
{:db (-> db
|
||||
(update-in [:wallet :accounts] add-tokens tokens)
|
||||
(assoc-in [:wallet :ui :tokens-loading address] false))})))
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
token-decimals (if collectible 0 (:decimals token))
|
||||
native-token? (and token (= token-display-name "ETH"))
|
||||
routes-available? (pos? (count chosen-route))
|
||||
token-networks (:networks token)
|
||||
token-networks (:supported-networks token)
|
||||
token-networks-ids (when token-networks
|
||||
(map #(:chain-id %) token-networks))
|
||||
from-network-amounts-by-chain (send-utils/network-amounts-by-chain
|
||||
@@ -190,17 +190,21 @@
|
||||
;; `token` is a map extracted from the sender, but in the wallet home page we don't know the
|
||||
;; sender yet, so we only provide the `token-symbol`, later in
|
||||
;; `:wallet/select-from-account` the `token` key will be set.
|
||||
(let [{:keys [networks]} token
|
||||
receiver-networks (get-in db [:wallet :ui :send :receiver-networks])
|
||||
token-networks-ids (map :chain-id networks)
|
||||
unsupported-token? (not-any? (set receiver-networks) token-networks-ids)
|
||||
unique-owner (when (= (count owners) 1)
|
||||
(first owners))
|
||||
unique-owner-tokens (get-in db [:wallet :accounts unique-owner :tokens])
|
||||
token-data (or token
|
||||
(when (and token-symbol unique-owner)
|
||||
(some #(when (= (:symbol %) token-symbol) %)
|
||||
unique-owner-tokens)))]
|
||||
(let [{:keys [networks]} token
|
||||
receiver-networks (get-in db [:wallet :ui :send :receiver-networks])
|
||||
token-networks-ids (map :chain-id networks)
|
||||
unsupported-token? (not-any? (set receiver-networks) token-networks-ids)
|
||||
unique-owner (when (= (count owners) 1)
|
||||
(first owners))
|
||||
unique-owner-tokens (get-in db [:wallet :accounts unique-owner :tokens])
|
||||
token-data (or token
|
||||
(when (and token-symbol unique-owner)
|
||||
(some #(when (= (:symbol %) token-symbol) %)
|
||||
unique-owner-tokens)))
|
||||
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
||||
network-details (-> (get-in db
|
||||
[:wallet :networks (if test-networks-enabled? :test :prod)])
|
||||
(network-utils/sorted-networks-with-details))]
|
||||
(when (or token-data token-symbol)
|
||||
{:db (cond-> db
|
||||
:always (update-in [:wallet :ui :send]
|
||||
@@ -211,7 +215,11 @@
|
||||
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol)
|
||||
token-data (update-in [:wallet :ui :send]
|
||||
#(assoc %
|
||||
:token token-data
|
||||
:token (assoc token-data
|
||||
:supported-networks
|
||||
(network-utils/network-list
|
||||
token-data
|
||||
network-details))
|
||||
:token-display-name (:symbol token-data)))
|
||||
unique-owner (assoc-in [:wallet :current-viewing-account-address] unique-owner)
|
||||
entry-point (assoc-in [:wallet :ui :send :entry-point] entry-point))
|
||||
@@ -230,7 +238,7 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet/edit-token-to-send
|
||||
(fn [{:keys [db]} [token]]
|
||||
(let [{token-networks :networks
|
||||
(let [{token-networks :supported-networks
|
||||
token-symbol :symbol} token
|
||||
receiver-networks (get-in db [:wallet :ui :send :receiver-networks])
|
||||
token-networks-ids (map :chain-id token-networks)
|
||||
@@ -426,7 +434,7 @@
|
||||
{:balances-per-chain balances-per-chain
|
||||
:disabled-chain-ids disabled-from-chain-ids
|
||||
:only-with-balance? false}))
|
||||
token-networks-ids (when token (map #(:chain-id %) (:networks token)))
|
||||
token-networks-ids (when token (map #(:chain-id %) (:supported-networks token)))
|
||||
sender-network-values (when sender-token-available-networks-for-suggested-routes
|
||||
(send-utils/loading-network-amounts
|
||||
{:valid-networks
|
||||
@@ -708,7 +716,11 @@
|
||||
;; account, so we extract the token data from the picked account.
|
||||
(let [token (utils/get-token-from-account db token-symbol address)]
|
||||
(assoc token
|
||||
:networks (network-utils/network-list token network-details)
|
||||
:networks (network-utils/network-list-with-positive-balance
|
||||
token
|
||||
network-details)
|
||||
:supported-networks (network-utils/network-list token
|
||||
network-details)
|
||||
:total-balance (utils/calculate-total-token-balance token))))
|
||||
bridge-tx? (= tx-type :tx/bridge)
|
||||
flow-id (if bridge-tx?
|
||||
|
||||
@@ -79,11 +79,14 @@
|
||||
(h/deftest-event :wallet/edit-token-to-send
|
||||
[event-id dispatch]
|
||||
(let [token-symbol "ETH"
|
||||
token {:symbol "ETH"
|
||||
:name "Ether"
|
||||
:networks #{{:chain-id 421614}
|
||||
{:chain-id 11155420}
|
||||
{:chain-id 11155111}}}
|
||||
token {:symbol "ETH"
|
||||
:name "Ether"
|
||||
:networks #{{:chain-id 421614}
|
||||
{:chain-id 11155420}
|
||||
{:chain-id 11155111}}
|
||||
:supported-networks #{{:chain-id 421614}
|
||||
{:chain-id 11155420}
|
||||
{:chain-id 11155111}}}
|
||||
receiver-networks [421614 11155420]]
|
||||
(testing "can be called with :token"
|
||||
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
receiver-preferred-networks (rf/sub
|
||||
[:wallet/wallet-send-receiver-preferred-networks])
|
||||
{token-symbol :symbol
|
||||
token-networks :networks} (rf/sub [:wallet/wallet-send-token])
|
||||
token-networks :supported-networks} (rf/sub [:wallet/wallet-send-token])
|
||||
token-chain-ids-set (set (mapv #(:chain-id %) token-networks))
|
||||
[selected-receiver-networks
|
||||
set-selected-receiver-networks] (rn/use-state receiver-networks)
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
;; RN to dispatch the network status update, otherwise when going
|
||||
;; offline the user will immediately see a toast saying "provider
|
||||
;; X is down".
|
||||
[{:ms 500
|
||||
[{:ms 50000
|
||||
:dispatch [:wallet/blockchain-status-changed
|
||||
(transforms/js->clj event-js)]}]]]}
|
||||
|
||||
|
||||
@@ -65,7 +65,11 @@
|
||||
:tokens
|
||||
(filter #(= token-symbol (:symbol %)))
|
||||
first)]
|
||||
(assoc token :networks (network-utils/network-list token networks))))
|
||||
(assoc token
|
||||
:networks
|
||||
(network-utils/network-list-with-positive-balance
|
||||
token
|
||||
networks))))
|
||||
|
||||
(defn select-default-asset-to-receive
|
||||
"Selects an asset to receive if it was not provided explicitly.
|
||||
|
||||
@@ -20,40 +20,50 @@
|
||||
|
||||
(defn store-token-list
|
||||
[{:keys [db]} [{:keys [data]}]]
|
||||
(let [chain-ids (chain/chain-ids db)
|
||||
tokens (reduce (fn [{:keys [by-address by-symbol] :as data}
|
||||
{:keys [name source version tokens]}]
|
||||
(-> data
|
||||
(update :sources
|
||||
conj
|
||||
{:name name
|
||||
:source source
|
||||
:version version
|
||||
:tokens-count (count tokens)})
|
||||
(update :by-address
|
||||
merge
|
||||
(tokens-data/tokens-by-address
|
||||
{:added-tokens by-address
|
||||
:source-name name
|
||||
:tokens tokens
|
||||
:chain-ids chain-ids}))
|
||||
(update :by-symbol
|
||||
merge
|
||||
(tokens-data/tokens-by-symbol
|
||||
{:added-tokens by-symbol
|
||||
:source-name name
|
||||
:tokens tokens
|
||||
:chain-ids chain-ids}))))
|
||||
{:sources []
|
||||
:by-address {}
|
||||
:by-symbol {}}
|
||||
data)
|
||||
symbols (->> tokens
|
||||
:by-symbol
|
||||
vals
|
||||
(map :symbol)
|
||||
set
|
||||
vec)]
|
||||
(let [chain-ids (chain/chain-ids db)
|
||||
tokens (reduce (fn [{:keys [by-address by-symbol] :as data}
|
||||
{:keys [name source version tokens]}]
|
||||
(-> data
|
||||
(update :sources
|
||||
conj
|
||||
{:name name
|
||||
:source source
|
||||
:version version
|
||||
:tokens-count (count tokens)})
|
||||
(update :by-address
|
||||
merge
|
||||
(tokens-data/tokens-by-address
|
||||
{:added-tokens by-address
|
||||
:source-name name
|
||||
:tokens tokens
|
||||
:chain-ids chain-ids}))
|
||||
(update :by-symbol
|
||||
merge
|
||||
(tokens-data/tokens-by-symbol
|
||||
{:added-tokens by-symbol
|
||||
:source-name name
|
||||
:tokens tokens
|
||||
:chain-ids chain-ids}))))
|
||||
{:sources []
|
||||
:by-address {}
|
||||
:by-symbol {}}
|
||||
data)
|
||||
symbols (->> tokens
|
||||
:by-symbol
|
||||
vals
|
||||
(map :symbol)
|
||||
set
|
||||
vec)
|
||||
by-symbol-vals (-> tokens :by-symbol vals)
|
||||
supported-chains-by-symbol (reduce
|
||||
(fn [result
|
||||
{token-symbol :symbol
|
||||
:keys [chain-id]}]
|
||||
(if (contains? result token-symbol)
|
||||
(update result token-symbol conj chain-id)
|
||||
(assoc result token-symbol #{chain-id})))
|
||||
{}
|
||||
by-symbol-vals)]
|
||||
{:fx [[:effects.wallet.tokens/fetch-market-values
|
||||
{:symbols symbols
|
||||
:currency constants/profile-default-currency
|
||||
@@ -70,9 +80,10 @@
|
||||
:on-error [:wallet.tokens/fetch-prices-failed]}]]
|
||||
:db (-> db
|
||||
(assoc-in [:wallet :tokens]
|
||||
{:sources (:sources tokens)
|
||||
:by-address (-> tokens :by-address vals)
|
||||
:by-symbol (-> tokens :by-symbol vals)})
|
||||
{:sources (:sources tokens)
|
||||
:supported-chains-by-symbol supported-chains-by-symbol
|
||||
:by-address (-> tokens :by-address vals)
|
||||
:by-symbol by-symbol-vals})
|
||||
(assoc-in [:wallet :ui :loading]
|
||||
{:token-list false
|
||||
:market-values true
|
||||
|
||||
@@ -47,10 +47,10 @@
|
||||
(match?
|
||||
(:db (tokens.events/store-token-list cofx [{:data data}]))
|
||||
{:wallet {:networks {:prod [{:chain-id 1}]}
|
||||
:tokens {:sources [{:name "native"
|
||||
:source "native"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}]
|
||||
:tokens {:sources [{:name "native"
|
||||
:source "native"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}]
|
||||
:by-address '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000000"
|
||||
@@ -73,28 +73,29 @@
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil})
|
||||
:by-symbol '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-ETH"
|
||||
:community-id nil
|
||||
:symbol "ETH"
|
||||
:sources ["native"]
|
||||
:name "Ether"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000001"
|
||||
:decimals 18
|
||||
:key "1-SNT"
|
||||
:community-id nil
|
||||
:symbol "SNT"
|
||||
:sources ["native"]
|
||||
:name "Status Network Token"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil})}
|
||||
:by-symbol '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-ETH"
|
||||
:community-id nil
|
||||
:symbol "ETH"
|
||||
:sources ["native"]
|
||||
:name "Ether"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000001"
|
||||
:decimals 18
|
||||
:key "1-SNT"
|
||||
:community-id nil
|
||||
:symbol "SNT"
|
||||
:sources ["native"]
|
||||
:name "Status Network Token"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil})
|
||||
:supported-chains-by-symbol {"ETH" #{1} "SNT" #{1}}}
|
||||
:ui {:loading {:token-list false
|
||||
:market-values true
|
||||
:details true
|
||||
@@ -109,12 +110,13 @@
|
||||
:db
|
||||
:wallet
|
||||
:tokens)
|
||||
{:sources [{:name "native"
|
||||
:source "native"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}]
|
||||
:by-address nil
|
||||
:by-symbol nil}))))
|
||||
{:sources [{:name "native"
|
||||
:source "native"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}]
|
||||
:by-address nil
|
||||
:by-symbol nil
|
||||
:supported-chains-by-symbol {}}))))
|
||||
(testing "response contains two lists"
|
||||
(let [cofx {:db {:wallet {:networks {:prod [{:chain-id 1}]}}}}
|
||||
data [{:name "native"
|
||||
@@ -131,80 +133,81 @@
|
||||
:db
|
||||
:wallet
|
||||
:tokens)
|
||||
{:sources [{:name "native"
|
||||
:source "native"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}
|
||||
{:name "second"
|
||||
:source "second"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}]
|
||||
:by-address '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000000"
|
||||
:community-id nil
|
||||
:symbol "ETH"
|
||||
:sources ["native"]
|
||||
:name "Ether"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000001"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000001"
|
||||
:community-id nil
|
||||
:symbol "SNT"
|
||||
:sources ["native" "second"]
|
||||
:name "Status Network Token"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000002"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000002"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["second"]
|
||||
:name "Another Token 1"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil})
|
||||
:by-symbol '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-ETH"
|
||||
:community-id nil
|
||||
:symbol "ETH"
|
||||
:sources ["native"]
|
||||
:name "Ether"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000001"
|
||||
:decimals 18
|
||||
:key "1-SNT"
|
||||
:community-id nil
|
||||
:symbol "SNT"
|
||||
:sources ["native" "second"]
|
||||
:name "Status Network Token"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000002"
|
||||
:decimals 18
|
||||
:key "1-ANOTHER1"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["second"]
|
||||
:name "Another Token 1"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil})}))))
|
||||
{:sources [{:name "native"
|
||||
:source "native"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}
|
||||
{:name "second"
|
||||
:source "second"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}]
|
||||
:by-address '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000000"
|
||||
:community-id nil
|
||||
:symbol "ETH"
|
||||
:sources ["native"]
|
||||
:name "Ether"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000001"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000001"
|
||||
:community-id nil
|
||||
:symbol "SNT"
|
||||
:sources ["native" "second"]
|
||||
:name "Status Network Token"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000002"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000002"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["second"]
|
||||
:name "Another Token 1"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil})
|
||||
:by-symbol '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-ETH"
|
||||
:community-id nil
|
||||
:symbol "ETH"
|
||||
:sources ["native"]
|
||||
:name "Ether"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000001"
|
||||
:decimals 18
|
||||
:key "1-SNT"
|
||||
:community-id nil
|
||||
:symbol "SNT"
|
||||
:sources ["native" "second"]
|
||||
:name "Status Network Token"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000002"
|
||||
:decimals 18
|
||||
:key "1-ANOTHER1"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["second"]
|
||||
:name "Another Token 1"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil})
|
||||
:supported-chains-by-symbol {"ETH" #{1} "SNT" #{1} "ANOTHER1" #{1}}}))))
|
||||
(testing "second list contains a token that replaces the one that was added before"
|
||||
(let [cofx {:db {:wallet {:networks {:prod [{:chain-id 1}]}}}}
|
||||
data [{:name "native"
|
||||
@@ -221,55 +224,56 @@
|
||||
:db
|
||||
:wallet
|
||||
:tokens)
|
||||
{:sources [{:name "native"
|
||||
:source "native"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}
|
||||
{:name "second"
|
||||
:source "second"
|
||||
:version "1.0.0"
|
||||
:tokens-count 1}]
|
||||
:by-address '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000000"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["native" "second"]
|
||||
:name "Another Token 2"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000002"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000002"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["native"]
|
||||
:name "Another Token 1"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil})
|
||||
:by-symbol '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-ETH"
|
||||
:community-id nil
|
||||
:symbol "ETH"
|
||||
:sources ["native"]
|
||||
:name "Ether"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-ANOTHER1"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["native" "second"]
|
||||
:name "Another Token 2"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil})})))))
|
||||
{:sources [{:name "native"
|
||||
:source "native"
|
||||
:version "1.0.0"
|
||||
:tokens-count 2}
|
||||
{:name "second"
|
||||
:source "second"
|
||||
:version "1.0.0"
|
||||
:tokens-count 1}]
|
||||
:by-address '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000000"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["native" "second"]
|
||||
:name "Another Token 2"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000002"
|
||||
:decimals 18
|
||||
:key "1-0x0000000000000000000000000000000000000002"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["native"]
|
||||
:name "Another Token 1"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil})
|
||||
:by-symbol '({:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-ETH"
|
||||
:community-id nil
|
||||
:symbol "ETH"
|
||||
:sources ["native"]
|
||||
:name "Ether"
|
||||
:type :erc20
|
||||
:verified? true
|
||||
:chain-id 1
|
||||
:image nil}
|
||||
{:address "0x0000000000000000000000000000000000000000"
|
||||
:decimals 18
|
||||
:key "1-ANOTHER1"
|
||||
:community-id nil
|
||||
:symbol "ANOTHER1"
|
||||
:sources ["native" "second"]
|
||||
:name "Another Token 2"
|
||||
:type :erc20
|
||||
:verified? false
|
||||
:chain-id 1
|
||||
:image nil})
|
||||
:supported-chains-by-symbol {"ETH" #{1} "ANOTHER1" #{1}}})))))
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
(def adjust-resize 16)
|
||||
|
||||
(defn is-hermes
|
||||
(defn hermes?
|
||||
[]
|
||||
(boolean (.-HermesInternal js/global)))
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
(ff/load-flags))
|
||||
|
||||
(dev/setup)
|
||||
(log/info "hermesEnabled ->" (is-hermes))
|
||||
(log/info "hermesEnabled ->" (hermes?))
|
||||
|
||||
(re-frame/dispatch-sync [:app-started])
|
||||
|
||||
|
||||
@@ -144,11 +144,12 @@
|
||||
(remove disabled-from-chain-ids?)
|
||||
set)]
|
||||
(some-> token
|
||||
(assoc :networks (network-utils/network-list token networks)
|
||||
:available-balance (utils/calculate-total-token-balance token)
|
||||
:total-balance (utils/calculate-total-token-balance
|
||||
token
|
||||
enabled-from-chain-ids))))))
|
||||
(assoc :networks (network-utils/network-list-with-positive-balance token networks)
|
||||
:supported-networks (network-utils/network-list token networks)
|
||||
:available-balance (utils/calculate-total-token-balance token)
|
||||
:total-balance (utils/calculate-total-token-balance
|
||||
token
|
||||
enabled-from-chain-ids))))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/wallet-send-token-symbol
|
||||
@@ -459,6 +460,7 @@
|
||||
networks)
|
||||
chain-ids
|
||||
(filter #(some #{(:chain-id %)} chain-ids)))
|
||||
:supported-networks (network-utils/network-list token networks)
|
||||
:available-balance (utils/calculate-total-token-balance token)
|
||||
:total-balance (utils/calculate-total-token-balance
|
||||
token
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns utils.network.core
|
||||
(:require
|
||||
[clojure.string :as string]))
|
||||
(:require [clojure.string :as string]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def url-regex
|
||||
#"https?://(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}(\.[a-z]{2,6})?\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)")
|
||||
@@ -41,7 +41,12 @@
|
||||
(map :error)
|
||||
(not-any? identity)))
|
||||
|
||||
(defn chain-id-available?
|
||||
[current-networks network]
|
||||
(let [chain-id (get-in network [:config :NetworkId])]
|
||||
(every? #(not= chain-id (get-in % [1 :config :NetworkId])) current-networks)))
|
||||
(defn fetch [url {:keys [body] :as params} callback]
|
||||
(let [js-params (cond-> params
|
||||
(map? body) (update :body (comp js/JSON.stringify clj->js))
|
||||
:always clj->js)]
|
||||
(-> (js/fetch url js-params)
|
||||
(.then (fn [response]
|
||||
(.text response)))
|
||||
(.then callback)
|
||||
(.catch #(log/error (str "Error while fetching: " url) %)))))
|
||||
|
||||
@@ -21,8 +21,10 @@
|
||||
(when js/goog.DEBUG
|
||||
(reset! handler-nesting-level 0))
|
||||
(when rf.interop/debug-enabled?
|
||||
(log/debug "Handling re-frame event: "
|
||||
(first (interceptor/get-coeffect context :event))))
|
||||
(do
|
||||
(log/debug "Handling re-frame event: "
|
||||
(first (interceptor/get-coeffect context :event)))
|
||||
nil))
|
||||
context)))
|
||||
|
||||
(defn- update-db
|
||||
|
||||
Reference in New Issue
Block a user