rename to wallet-legacy (#17673)

This commit is contained in:
flexsurfer 2023-10-19 13:50:55 +02:00 committed by GitHub
parent e71c167e8a
commit 4a8a23a4c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 693 additions and 777 deletions

View File

@ -9,7 +9,7 @@
(get-in db [:profile/profile :currency] :usd))
(rf/defn set-currency
{:events [:wallet.settings.ui/currency-selected]}
{:events [:wallet-legacy.settings.ui/currency-selected]}
[{:keys [db] :as cofx} currency]
(rf/merge cofx
(multiaccounts.update/multiaccount-update

View File

@ -42,7 +42,7 @@
(update :address eip55/address->checksum)
(update :networks/networks rpc->networks)
(update :networks/current-network #(if (seq %) % config/default-network))
(update :wallet/visible-tokens rpc->visible-tokens)
(update :wallet-legacy/visible-tokens rpc->visible-tokens)
(update :pinned-mailservers rpc->pinned-mailservers)
(update :link-previews-enabled-sites set)
(update :custom-bootnodes rpc->custom-bootnodes)

View File

@ -19,11 +19,11 @@
(log/debug "[wallet-subs] recent-history-fetching-started"
"accounts"
accounts)
(let [event (get db :wallet/on-recent-history-fetching)]
(let [event (get db :wallet-legacy/on-recent-history-fetching)]
(cond-> {:db (-> db
(transactions/update-fetching-status accounts :recent? true)
(assoc :wallet/recent-history-fetching-started? true)
(dissoc :wallet/on-recent-history-fetching))}
(assoc :wallet-legacy/recent-history-fetching-started? true)
(dissoc :wallet-legacy/on-recent-history-fetching))}
event
(assoc :dispatch event))))
@ -34,16 +34,16 @@
"block" blockNumber)
{:db (-> db
(assoc :ethereum/current-block blockNumber)
(update-in [:wallet :accounts]
(update-in [:wallet-legacy :accounts]
wallet/remove-transactions-since-block
blockNumber)
(transactions/update-fetching-status accounts :recent? false)
(dissoc :wallet/waiting-for-recent-history?
:wallet/refreshing-history?
:wallet/fetching-error
:wallet/recent-history-fetching-started?))
(dissoc :wallet-legacy/waiting-for-recent-history?
:wallet-legacy/refreshing-history?
:wallet-legacy/fetching-error
:wallet-legacy/recent-history-fetching-started?))
:transactions/get-transfers
{:chain-tokens (:wallet/all-tokens db)
{:chain-tokens (:wallet-legacy/all-tokens db)
:addresses (reduce
(fn [v address]
(let [normalized-address
@ -60,12 +60,12 @@
[{:keys [db] :as cofx} {:keys [message]}]
(rf/merge
cofx
{:db (assoc db :wallet/fetching-error message)}
{:db (assoc db :wallet-legacy/fetching-error message)}
(wallet.core/after-checking-history)))
(rf/defn non-archival-node-detected
[{:keys [db]} _]
{:db (assoc db :wallet/non-archival-node true)})
{:db (assoc db :wallet-legacy/non-archival-node true)})
(rf/defn new-wallet-event
[cofx {:keys [type blockNumber accounts] :as event}]

View File

@ -142,7 +142,7 @@
(select-keys transactions
(keys (get db :ethereum/watched-transactions)))))
{}
(get-in db [:wallet :accounts]))]
(get-in db [:wallet-legacy :accounts]))]
(apply rf/merge
cofx
(map (fn [[_ transaction]]
@ -154,7 +154,7 @@
transaction can contain multiple transfers and they would overwrite each other
in the transfer map if identified by hash"
[{:keys [db] :as cofx} {:keys [hash id address] :as transfer}]
(let [transfer-by-hash (get-in db [:wallet :accounts address :transactions hash])]
(let [transfer-by-hash (get-in db [:wallet-legacy :accounts address :transactions hash])]
(when-let [unique-id (when-not (= transfer transfer-by-hash)
(if (and transfer-by-hash
(not (= :pending
@ -163,22 +163,22 @@
hash))]
(rf/merge cofx
{:db (assoc-in db
[:wallet :accounts address :transactions unique-id]
[:wallet-legacy :accounts address :transactions unique-id]
(assoc transfer :hash unique-id))}
(check-transaction transfer)))))
(defn get-min-known-block
[db address]
(get-in db [:wallet :accounts (eip55/address->checksum address) :min-block]))
(get-in db [:wallet-legacy :accounts (eip55/address->checksum address) :min-block]))
(defn get-max-block-with-transfers
[db address]
(get-in db [:wallet :accounts (eip55/address->checksum address) :max-block]))
(get-in db [:wallet-legacy :accounts (eip55/address->checksum address) :max-block]))
(defn min-block-transfers-count
[db address]
(get-in db
[:wallet :accounts
[:wallet-legacy :accounts
(eip55/address->checksum address)
:min-block-transfers-count]))
@ -195,7 +195,7 @@
:min-block-transfers-count 1}
(and (= min-block block)
(nil? (get-in db [:wallet :accounts checksum :transactions hash])))
(nil? (get-in db [:wallet-legacy :accounts checksum :transactions hash])))
(update acc :min-block-transfers-count inc)
:else acc))
@ -211,7 +211,7 @@
"min-block" min-block
"min-block-transfers-count" min-block-transfers-count)
{:db (update-in db
[:wallet :accounts checksum]
[:wallet-legacy :accounts checksum]
assoc
:min-block min-block
:min-block-transfers-count min-block-transfers-count)}))
@ -220,7 +220,7 @@
[db addresses fetching-type state]
(update-in
db
[:wallet :fetching]
[:wallet-legacy :fetching]
(fn [accounts]
(reduce
(fn [accounts address]
@ -242,7 +242,7 @@
[{:keys [db] :as cofx} address]
(let [syncing-allowed? (utils.mobile-sync/syncing-allowed? cofx)]
{:db (assoc-in db
[:wallet :fetching address :all-fetched?]
[:wallet-legacy :fetching address :all-fetched?]
(if syncing-allowed?
:all
:all-preloaded))}))
@ -326,7 +326,7 @@
(defn some-transactions-loaded?
[db address]
(not-empty (get-in db [:wallet :accounts address :transactions])))
(not-empty (get-in db [:wallet-legacy :accounts address :transactions])))
(rf/defn fetch-more-tx
{:events [:transactions/fetch-more]}
@ -337,7 +337,7 @@
(rf/merge
cofx
{:transactions/get-transfers
{:chain-tokens (:wallet/all-tokens db)
{:chain-tokens (:wallet-legacy/all-tokens db)
:addresses [address]
:before-block min-known-block
:fetch-more? (utils.mobile-sync/syncing-allowed? cofx)
@ -353,6 +353,6 @@
{:events [:transaction/get-fetched-transfers]}
[{:keys [db]}]
{:transactions/get-transfers
{:chain-tokens (:wallet/all-tokens db)
{:chain-tokens (:wallet-legacy/all-tokens db)
:addresses (map :address (get db :profile/wallet-accounts))
:fetch-more? false}})

View File

@ -206,7 +206,7 @@
:add-new-account-pin (keycard/enter-pin-screen-did-load %)
:keycard-authentication-method (keycard/authentication-method-screen-did-load %)
:multiaccounts (keycard/multiaccounts-screen-did-load %)
:wallet (wallet/wallet-will-focus %)
:wallet-legacy (wallet/wallet-will-focus %)
nil)))
;;TODO :replace by named events
@ -252,5 +252,5 @@
(re-frame/reg-event-fx :buy-crypto.ui/open-screen
(fn []
{:fx [[:dispatch [:wallet/keep-watching]]
{:fx [[:dispatch [:wallet-legacy/keep-watching]]
[:dispatch [:open-modal :buy-crypto nil]]]}))

View File

@ -52,9 +52,9 @@
(defn create-new-account!
[]
(rf/dispatch-sync [:wallet.accounts/start-adding-new-account {:type :generate}])
(rf/dispatch-sync [:wallet-legacy.accounts/start-adding-new-account {:type :generate}])
(rf/dispatch-sync [:set-in [:add-account :account :name] account-name])
(rf/dispatch [:wallet.accounts/add-new-account (native-module/sha3 password)]))
(rf/dispatch [:wallet-legacy.accounts/add-new-account (native-module/sha3 password)]))
(defn assert-new-account-created
[]
@ -120,7 +120,7 @@
(assert-messenger-started)
(create-new-account!) ; create a new account
(rf-test/wait-for
[:wallet.accounts/account-stored]
[:wallet-legacy.accounts/account-stored]
(assert-new-account-created) ; assert account was created
(logout!)
(rf-test/wait-for [::logout/logout-method]))))))

View File

@ -227,7 +227,7 @@
;; now for simplicity do not hide bottom sheet when generating key
;; and exporting key but should be refactored.
(when-not (contains? #{:keycard/generate-and-load-key
:wallet.accounts/generate-new-keycard-account
:wallet-legacy.accounts/generate-new-keycard-account
:keycard/remove-key-with-unpair
:keycard/unpair-and-delete}
on-verified)
@ -236,7 +236,7 @@
:keycard/generate-and-load-key
:keycard/remove-key-with-unpair
:keycard/unpair-and-delete
:wallet.accounts/generate-new-keycard-account}
:wallet-legacy.accounts/generate-new-keycard-account}
on-verified)
(common/get-application-info nil))
(when on-verified

View File

@ -15,7 +15,7 @@
tag-was-lost?
(rf/merge cofx
{:db (assoc-in db [:keycard :pin :status] nil)}
(common/set-on-card-connected :wallet.accounts/generate-new-keycard-account))
(common/set-on-card-connected :wallet-legacy.accounts/generate-new-keycard-account))
(not (nil? pin-retries))
(rf/merge cofx

View File

@ -25,7 +25,7 @@
{:utils/dispatch-later
;; We need to give previous sheet some time to be fully hidden
[{:ms 200
:dispatch [:wallet.accounts/verify-pin]}]})
:dispatch [:wallet-legacy.accounts/verify-pin]}]})
(rf/defn hide-pin-sheet
{:events [:keycard/new-account-pin-sheet-hide]}
@ -44,7 +44,7 @@
(subs (native-module/sha3 normalized-key) 26))))
(rf/defn generate-new-keycard-account
{:events [:wallet.accounts/generate-new-keycard-account]}
{:events [:wallet-legacy.accounts/generate-new-keycard-account]}
[{:keys [db]}]
(let [path-num (inc (get-in db [:profile/profile :latest-derived-path]))
path (str constants/path-wallet-root "/" path-num)
@ -53,7 +53,7 @@
(assoc-in
db
[:keycard :on-export-success]
#(vector :wallet.accounts/account-stored
#(vector :wallet-legacy.accounts/account-stored
(let [public-key (utils.hex/normalize-hex %)]
{;; Strip leading 04 prefix denoting uncompressed key format
:address (eip55/address->checksum
@ -66,11 +66,11 @@
:keycard/export-key {:pin pin :path path}}))
(rf/defn verify-pin
{:events [:wallet.accounts/verify-pin]}
{:events [:wallet-legacy.accounts/verify-pin]}
[cofx]
(common/verify-pin
cofx
{:pin-step :export-key
:on-card-connected :wallet.accounts/verify-pin
:on-success :wallet.accounts/generate-new-keycard-account
:on-card-connected :wallet-legacy.accounts/verify-pin
:on-success :wallet-legacy.accounts/generate-new-keycard-account
:on-failure :keycard/new-account-pin-sheet}))

View File

@ -13,7 +13,7 @@
(rf/merge cofx
{:db (assoc db :network-status (if is-connected? :online :offline))}
(when (and is-connected?
(or (not= (count (get-in db [:wallet :accounts]))
(or (not= (count (get-in db [:wallet-legacy :accounts]))
(count (get db :profile/wallet-accounts)))
(wallet/has-empty-balances? db)))
(wallet/update-balances nil nil))))

View File

@ -48,7 +48,7 @@
:as notification}]
(let [token (if erc20
(get-in db
[:wallet/all-tokens (string/lower-case contract)]
[:wallet-legacy/all-tokens (string/lower-case contract)]
default-erc20-token)
(tokens/native-currency network))
amount (money/wei->ether (decode/uint value))

View File

@ -79,7 +79,7 @@
(rf/defn handle-eip681
[cofx data]
(rf/merge cofx
{:dispatch [:wallet/parse-eip681-uri-and-resolve-ens data]}
{:dispatch [:wallet-legacy/parse-eip681-uri-and-resolve-ens data]}
(navigation/change-tab :wallet-stack)
(navigation/pop-to-root :shell-stack)))

View File

@ -8,11 +8,11 @@
{:db (assoc-in (:db cofx) [:ui/search :currency-filter] search-filter)})
(rf/defn token-filter-changed
{:events [:search/token-filter-changed]}
{:events [:wallet-legacy/search-token-filter-changed]}
[cofx search-filter]
{:db (assoc-in (:db cofx) [:ui/search :token-filter] search-filter)})
(rf/defn recipient-filter-changed
{:events [:search/recipient-filter-changed]}
{:events [:wallet-legacy/search-recipient-filter-changed]}
[cofx search-filter]
{:db (assoc-in (:db cofx) [:ui/search :recipient-filter] search-filter)})

View File

@ -184,7 +184,7 @@
(rf/defn prepare-unconfirmed-transaction
[{:keys [db now]} new-tx-hash
{:keys [value gasPrice maxFeePerGas maxPriorityFeePerGas gas data to from hash]} symbol amount]
(let [token (tokens/symbol->token (:wallet/all-tokens db) symbol)
(let [token (tokens/symbol->token (:wallet-legacy/all-tokens db) symbol)
from (eip55/address->checksum from)
;;if there is a hash in the tx object that means we resending transaction
old-tx-hash hash
@ -208,8 +208,8 @@
(log/info "[signing] prepare-unconfirmed-transaction" tx)
{:db (-> db
;;remove old transaction, because we replace it with the new one
(update-in [:wallet :accounts from :transactions] dissoc old-tx-hash)
(assoc-in [:wallet :accounts from :transactions new-tx-hash] tx))}))
(update-in [:wallet-legacy :accounts from :transactions] dissoc old-tx-hash)
(assoc-in [:wallet-legacy :accounts from :transactions new-tx-hash] tx))}))
(defn get-method-type
[data]
@ -223,7 +223,7 @@
(defn get-transfer-token
[db to data]
(let [{:keys [decimals] :as token} (tokens/address->token (:wallet/all-tokens db) to)]
(let [{:keys [decimals] :as token} (tokens/address->token (:wallet-legacy/all-tokens db) to)]
(when (and token data (string? data))
(when-let [type (get-method-type data)]
(let [[address value _] (native-module/decode-parameters
@ -258,7 +258,7 @@
:symbol :ETH
:value value
:amount (str eth-amount)
:token (tokens/asset-for (:wallet/all-tokens db)
:token (tokens/asset-for (:wallet-legacy/all-tokens db)
(chain/get-current-network db)
:ETH)}
(not (nil? token))
@ -352,7 +352,7 @@
{:db (assoc-in (:db cofx) [:signing/edit-fee :gas-price-loading?] true)
:signing/update-gas-price
{:success-callback #(re-frame/dispatch
[:wallet.send/update-gas-price-success :signing/tx % tx-obj])
[:wallet-legacy.send/update-gas-price-success :signing/tx % tx-obj])
:error-callback #(re-frame/dispatch [:signing/update-gas-price-error %])
:network-id (get-in (chain/current-network db)
[:config :NetworkId])}})))))
@ -528,14 +528,14 @@
(check-queue)))
(rf/defn sign-transaction-button-clicked-from-chat
{:events [:wallet.ui/sign-transaction-button-clicked-from-chat]}
{:events [:wallet-legacy.ui/sign-transaction-button-clicked-from-chat]}
[{:keys [db] :as cofx} {:keys [to amount from token]}]
(let [{:keys [symbol address]} token
amount-hex (str "0x" (native-module/number-to-hex amount))
to-norm (address/normalized-hex (if (string? to) to (:address to)))
from-address (:address from)
identity (:current-chat-id db)
db (dissoc db :wallet/prepare-transaction :signing/edit-fee)]
db (dissoc db :wallet-legacy/prepare-transaction :signing/edit-fee)]
(if to-norm
(rf/merge
cofx
@ -563,15 +563,15 @@
:on-success #(re-frame/dispatch [:transport/message-sent %])}]})))
(rf/defn sign-transaction-button-clicked-from-request
{:events [:wallet.ui/sign-transaction-button-clicked-from-request]}
{:events [:wallet-legacy.ui/sign-transaction-button-clicked-from-request]}
[{:keys [db] :as cofx} {:keys [amount from token]}]
(let [{:keys [request-parameters chat-id]} (:wallet/prepare-transaction db)
(let [{:keys [request-parameters chat-id]} (:wallet-legacy/prepare-transaction db)
{:keys [symbol address]} token
amount-hex (str "0x" (native-module/number-to-hex amount))
to-norm (:address request-parameters)
from-address (:address from)]
(rf/merge cofx
{:db (dissoc db :wallet/prepare-transaction :signing/edit-fee)}
{:db (dissoc db :wallet-legacy/prepare-transaction :signing/edit-fee)}
(fn [cofx]
(sign
cofx
@ -590,14 +590,14 @@
:data (native-module/encode-transfer to-norm amount-hex)})})))))
(rf/defn sign-transaction-button-clicked
{:events [:wallet.ui/sign-transaction-button-clicked]}
{:events [:wallet-legacy.ui/sign-transaction-button-clicked]}
[{:keys [db] :as cofx} {:keys [to amount from token gas gasPrice maxFeePerGas maxPriorityFeePerGas]}]
(let [{:keys [symbol address]} token
amount-hex (str "0x" (native-module/number-to-hex amount))
to-norm (address/normalized-hex (if (string? to) to (:address to)))
from-address (:address from)]
(rf/merge cofx
{:db (dissoc db :wallet/prepare-transaction :signing/edit-fee)}
{:db (dissoc db :wallet-legacy/prepare-transaction :signing/edit-fee)}
(sign
{:tx-obj (merge (if (eip1559/sync-enabled?)
{:from from-address

View File

@ -102,7 +102,7 @@
(let [{:keys [maxFeePerGas maxPriorityFeePerGas]} (get db :signing/edit-fee)
latest-base-fee (money/wei->gwei
(money/bignumber
(get db :wallet/current-base-fee)))
(get db :wallet-legacy/current-base-fee)))
fee-error (cond
(or (:error maxFeePerGas)
(:error maxPriorityFeePerGas))
@ -119,7 +119,7 @@
(defn validate-max-priority-fee
[db]
(let [{:keys [maxPriorityFeePerGas]} (get db :signing/edit-fee)
latest-priority-fee (get db :wallet/current-priority-fee)
latest-priority-fee (get db :wallet-legacy/current-priority-fee)
fee-error (cond
(:error maxPriorityFeePerGas)
nil
@ -182,10 +182,10 @@
(rf/defn set-fee-option
{:events [:signing.edit-fee.ui/set-option]}
[{:keys [db] :as cofx} option]
(let [tip (get db :wallet/current-priority-fee)
slow (get db :wallet/slow-base-fee)
normal (get db :wallet/normal-base-fee)
fast (get db :wallet/fast-base-fee)
(let [tip (get db :wallet-legacy/current-priority-fee)
slow (get db :wallet-legacy/slow-base-fee)
normal (get db :wallet-legacy/normal-base-fee)
fast (get db :wallet-legacy/fast-base-fee)
{:keys [fee tip]} (get (get-fee-options tip slow normal fast) option)]
{:db (-> db
(assoc-in [:signing/edit-fee :selected-fee-option] option)
@ -201,7 +201,7 @@
[{:keys [db]} value]
(let [{:keys [maxFeePerGas maxPriorityFeePerGas]}
(get db :signing/edit-fee)
latest-base-fee (get db :wallet/current-base-fee)
latest-base-fee (get db :wallet-legacy/current-base-fee)
max-fee-value (:value-number maxFeePerGas)
max-priority-fee-value (:value-number maxPriorityFeePerGas)
new-value (money/bignumber value)

View File

@ -36,7 +36,7 @@
:<- [:multiaccount/default-account]
:<- [:multiaccount/public-key]
:<- [:chain-id]
:<- [:wallet]
:<- [:wallet-legacy]
(fn [[{:keys [custom-domain? username address]}
chain default-account public-key chain-id wallet]]
(let [address (or address (address/normalized-hex (:address default-account)))

View File

@ -67,38 +67,40 @@
(reg-root-key-sub :contacts/search-query :contacts/search-query)
;;wallet
(reg-root-key-sub :wallet :wallet)
(reg-root-key-sub :prices :prices)
(reg-root-key-sub :prices-loading? :prices-loading?)
(reg-root-key-sub :wallet.transactions :wallet.transactions)
(reg-root-key-sub :wallet/custom-token-screen :wallet/custom-token-screen)
(reg-root-key-sub :wallet/prepare-transaction :wallet/prepare-transaction)
(reg-root-key-sub :wallet-service/manual-setting :wallet-service/manual-setting)
(reg-root-key-sub :wallet/recipient :wallet/recipient)
(reg-root-key-sub :wallet/favourites :wallet/favourites)
(reg-root-key-sub :wallet/refreshing-history? :wallet/refreshing-history?)
(reg-root-key-sub :wallet/fetching-error :wallet/fetching-error)
(reg-root-key-sub :wallet/non-archival-node :wallet/non-archival-node)
(reg-root-key-sub :wallet/current-base-fee :wallet/current-base-fee)
(reg-root-key-sub :wallet/slow-base-fee :wallet/slow-base-fee)
(reg-root-key-sub :wallet/normal-base-fee :wallet/normal-base-fee)
(reg-root-key-sub :wallet/fast-base-fee :wallet/fast-base-fee)
(reg-root-key-sub :wallet/current-priority-fee :wallet/current-priority-fee)
(reg-root-key-sub :wallet/transactions-management-enabled? :wallet/transactions-management-enabled?)
(reg-root-key-sub :wallet/all-tokens :wallet/all-tokens)
(reg-root-key-sub :wallet/collectible-collections :wallet/collectible-collections)
(reg-root-key-sub :wallet/fetching-collection-assets :wallet/fetching-collection-assets)
(reg-root-key-sub :wallet/collectible-assets :wallet/collectible-assets)
(reg-root-key-sub :wallet/selected-collectible :wallet/selected-collectible)
(reg-root-key-sub :wallet/modal-selecting-source-token? :wallet/modal-selecting-source-token?)
(reg-root-key-sub :wallet/swap-from-token :wallet/swap-from-token)
(reg-root-key-sub :wallet/swap-to-token :wallet/swap-to-token)
(reg-root-key-sub :wallet/swap-from-token-amount :wallet/swap-from-token-amount)
(reg-root-key-sub :wallet/swap-to-token-amount :wallet/swap-to-token-amount)
(reg-root-key-sub :wallet/swap-advanced-mode? :wallet/swap-advanced-mode?)
(reg-root-key-sub :add-account :add-account)
(reg-root-key-sub :buy-crypto/on-ramps :buy-crypto/on-ramps)
(reg-root-key-sub :wallet-legacy :wallet-legacy)
(reg-root-key-sub :wallet-legacy.transactions :wallet-legacy.transactions)
(reg-root-key-sub :wallet-legacy/custom-token-screen :wallet-legacy/custom-token-screen)
(reg-root-key-sub :wallet-legacy/prepare-transaction :wallet-legacy/prepare-transaction)
(reg-root-key-sub :wallet-legacy/recipient :wallet-legacy/recipient)
(reg-root-key-sub :wallet-legacy/favourites :wallet-legacy/favourites)
(reg-root-key-sub :wallet-legacy/refreshing-history? :wallet-legacy/refreshing-history?)
(reg-root-key-sub :wallet-legacy/fetching-error :wallet-legacy/fetching-error)
(reg-root-key-sub :wallet-legacy/non-archival-node :wallet-legacy/non-archival-node)
(reg-root-key-sub :wallet-legacy/current-base-fee :wallet-legacy/current-base-fee)
(reg-root-key-sub :wallet-legacy/slow-base-fee :wallet-legacy/slow-base-fee)
(reg-root-key-sub :wallet-legacy/normal-base-fee :wallet-legacy/normal-base-fee)
(reg-root-key-sub :wallet-legacy/fast-base-fee :wallet-legacy/fast-base-fee)
(reg-root-key-sub :wallet-legacy/current-priority-fee :wallet-legacy/current-priority-fee)
(reg-root-key-sub :wallet-legacy/transactions-management-enabled?
:wallet-legacy/transactions-management-enabled?)
(reg-root-key-sub :wallet-legacy/all-tokens :wallet-legacy/all-tokens)
(reg-root-key-sub :wallet-legacy/collectible-collections :wallet-legacy/collectible-collections)
(reg-root-key-sub :wallet-legacy/fetching-collection-assets :wallet-legacy/fetching-collection-assets)
(reg-root-key-sub :wallet-legacy/collectible-assets :wallet-legacy/collectible-assets)
(reg-root-key-sub :wallet-legacy/selected-collectible :wallet-legacy/selected-collectible)
(reg-root-key-sub :wallet-legacy/modal-selecting-source-token?
:wallet-legacy/modal-selecting-source-token?)
(reg-root-key-sub :wallet-legacy/swap-from-token :wallet-legacy/swap-from-token)
(reg-root-key-sub :wallet-legacy/swap-to-token :wallet-legacy/swap-to-token)
(reg-root-key-sub :wallet-legacy/swap-from-token-amount :wallet-legacy/swap-from-token-amount)
(reg-root-key-sub :wallet-legacy/swap-to-token-amount :wallet-legacy/swap-to-token-amount)
(reg-root-key-sub :wallet-legacy/swap-advanced-mode? :wallet-legacy/swap-advanced-mode?)
;;; Link previews
(reg-root-key-sub :link-previews-whitelist :link-previews-whitelist)
(reg-root-key-sub :chat/link-previews :chat/link-previews)

View File

@ -41,7 +41,7 @@
[code display-name]))
(re-frame/reg-sub
:search/filtered-currencies
:wallet-legacy/search-filtered-currencies
:<- [:search/currency-filter]
(fn [search-currency-filter]
{:search-filter search-currency-filter
@ -55,9 +55,15 @@
[(:symbol token) (:name token)])
(re-frame/reg-sub
:wallet/filtered-grouped-chain-tokens
:<- [:wallet/grouped-chain-tokens]
:<- [:search/token-filter]
:wallet-legacy/search-token-filter
:<- [:ui/search]
(fn [search]
(get search :token-filter)))
(re-frame/reg-sub
:wallet-legacy/filtered-grouped-chain-tokens
:<- [:wallet-legacy/grouped-chain-tokens]
:<- [:wallet-legacy/search-token-filter]
(fn [[{custom-tokens true default-tokens nil} search-token-filter]]
{:search-filter search-token-filter
:tokens {true (apply-filter search-token-filter custom-tokens extract-token-attributes false)

View File

@ -11,35 +11,35 @@
(re-frame/reg-sub
::send-transaction
:<- [:wallet]
:<- [:wallet-legacy]
(fn [wallet]
(:send-transaction wallet)))
(re-frame/reg-sub
:wallet.send/symbol
:wallet-legacy.send/symbol
:<- [::send-transaction]
(fn [send-transaction]
(:symbol send-transaction)))
(re-frame/reg-sub
:wallet.send/camera-flashlight
:wallet-legacy.send/camera-flashlight
:<- [::send-transaction]
(fn [send-transaction]
(:camera-flashlight send-transaction)))
(re-frame/reg-sub
:wallet/settings
:<- [:wallet]
:wallet-legacy/settings
:<- [:wallet-legacy]
(fn [{:keys [settings]}]
(reduce-kv #(conj %1 %3) [] settings)))
(re-frame/reg-sub
:wallet.request/transaction
:<- [:wallet]
:wallet-legacy.request/transaction
:<- [:wallet-legacy]
:request-transaction)
(re-frame/reg-sub
:wallet/binance-chain?
:wallet-legacy/binance-chain?
:<- [:current-network]
(fn [network]
(chain/binance-chain-id? (get-in network [:config :NetworkId]))))
@ -53,7 +53,7 @@
(re-frame/reg-sub
:signing/currencies
:<- [:prices]
:<- [:wallet/currency]
:<- [:wallet-legacy/currency]
:<- [:ethereum/native-currency]
(fn [[prices {:keys [code]} {sym :symbol}]]
[(name sym)
@ -62,10 +62,10 @@
(re-frame/reg-sub
:signing/priority-fee-suggestions-range
:<- [:wallet/current-priority-fee]
:<- [:wallet/slow-base-fee]
:<- [:wallet/normal-base-fee]
:<- [:wallet/fast-base-fee]
:<- [:wallet-legacy/current-priority-fee]
:<- [:wallet-legacy/slow-base-fee]
:<- [:wallet-legacy/normal-base-fee]
:<- [:wallet-legacy/fast-base-fee]
(fn [[latest-tip slow normal fast]]
(reduce
(fn [acc [k fees]]
@ -181,11 +181,11 @@
(get-sufficient-gas-error gas-error-message balance nil nil gas gas-price)))))
(re-frame/reg-sub
:wallet.send/prepare-transaction-with-balance
:<- [:wallet/prepare-transaction]
:<- [:wallet]
:wallet-legacy.send/prepare-transaction-with-balance
:<- [:wallet-legacy/prepare-transaction]
:<- [:wallet-legacy]
:<- [:offline?]
:<- [:wallet/all-tokens]
:<- [:wallet-legacy/all-tokens]
:<- [:current-network]
(fn [[{:keys [from to amount-text] :as transaction}
wallet offline? all-tokens current-network]]
@ -209,11 +209,11 @@
(not offline?))))))
(re-frame/reg-sub
:wallet.request/prepare-transaction-with-balance
:<- [:wallet/prepare-transaction]
:<- [:wallet]
:wallet-legacy.request/prepare-transaction-with-balance
:<- [:wallet-legacy/prepare-transaction]
:<- [:wallet-legacy]
:<- [:offline?]
:<- [:wallet/all-tokens]
:<- [:wallet-legacy/all-tokens]
:<- [:current-network]
(fn [[{:keys [from to amount-text] :as transaction}
wallet offline? all-tokens current-network]]

View File

@ -10,14 +10,14 @@
[utils.money :as money]))
(re-frame/reg-sub
:wallet/accounts
:<- [:wallet]
:wallet-legacy/accounts
:<- [:wallet-legacy]
(fn [wallet]
(get wallet :accounts)))
(re-frame/reg-sub
:wallet/account-by-transaction-hash
:<- [:wallet/accounts]
:wallet-legacy/account-by-transaction-hash
:<- [:wallet-legacy/accounts]
(fn [accounts [_ tx-hash]]
(some (fn [[address account]]
(when-let [transaction (get-in account [:transactions tx-hash])]
@ -25,14 +25,14 @@
accounts)))
(re-frame/reg-sub
:wallet/transactions
:<- [:wallet]
:wallet-legacy/transactions
:<- [:wallet-legacy]
(fn [wallet [_ address]]
(get-in wallet [:accounts address :transactions])))
(re-frame/reg-sub
:wallet/filters
:<- [:wallet]
:wallet-legacy/filters
:<- [:wallet-legacy]
(fn [wallet]
(get wallet :filters)))
@ -61,9 +61,9 @@
:currency-text currency-text))))
(re-frame/reg-sub
:wallet.transactions/transactions
:wallet-legacy.transactions/transactions
(fn [[_ address] _]
[(re-frame/subscribe [:wallet/transactions address])
[(re-frame/subscribe [:wallet-legacy/transactions address])
(re-frame/subscribe [:contacts/contacts-by-address])
(re-frame/subscribe [:ethereum/native-currency])])
(fn [[transactions contacts native-currency]]
@ -76,8 +76,8 @@
transactions)))
(re-frame/reg-sub
:wallet.transactions/all-filters?
:<- [:wallet/filters]
:wallet-legacy.transactions/all-filters?
:<- [:wallet-legacy/filters]
(fn [filters]
(= wallet.db/default-wallet-filters
filters)))
@ -89,8 +89,8 @@
:failed (i18n/label :t/failed)})
(re-frame/reg-sub
:wallet.transactions/filters
:<- [:wallet/filters]
:wallet-legacy.transactions/filters
:<- [:wallet-legacy/filters]
(fn [filters]
(map (fn [id]
(let [checked? (filters id)]
@ -98,20 +98,20 @@
:label (filters-labels id)
:checked? checked?
:on-touch #(if checked?
(re-frame/dispatch [:wallet.transactions/remove-filter id])
(re-frame/dispatch [:wallet.transactions/add-filter id]))}))
(re-frame/dispatch [:wallet-legacy.transactions/remove-filter id])
(re-frame/dispatch [:wallet-legacy.transactions/add-filter id]))}))
wallet.db/default-wallet-filters)))
(re-frame/reg-sub
:wallet.transactions.filters/screen
:<- [:wallet.transactions/filters]
:<- [:wallet.transactions/all-filters?]
:wallet-legacy.transactions.filters/screen
:<- [:wallet-legacy.transactions/filters]
:<- [:wallet-legacy.transactions/all-filters?]
(fn [[filters all-filters?]]
{:all-filters? all-filters?
:filters filters
:on-touch-select-all (when-not all-filters?
#(re-frame/dispatch
[:wallet.transactions/add-all-filters]))}))
[:wallet-legacy.transactions/add-all-filters]))}))
(defn- enrich-transaction-for-list
[filters
@ -134,7 +134,7 @@
:contact to-contact
:address to))
:time-formatted (datetime/timestamp->time timestamp)
:on-touch-fn #(re-frame/dispatch [:wallet.ui/show-transaction-details
:on-touch-fn #(re-frame/dispatch [:wallet-legacy.ui/show-transaction-details
(:hash transaction)
address]))))
@ -149,11 +149,11 @@
:data (sort-by :timestamp > transactions)}))))
(re-frame/reg-sub
:wallet.transactions.history/screen
:wallet-legacy.transactions.history/screen
(fn [[_ address] _]
[(re-frame/subscribe [:wallet.transactions/transactions address])
(re-frame/subscribe [:wallet/filters])
(re-frame/subscribe [:wallet.transactions/all-filters?])])
[(re-frame/subscribe [:wallet-legacy.transactions/transactions address])
(re-frame/subscribe [:wallet-legacy/filters])
(re-frame/subscribe [:wallet-legacy.transactions/all-filters?])])
(fn [[transactions filters all-filters?] [_ address]]
{:all-filters? all-filters?
:total (count transactions)
@ -164,9 +164,9 @@
(group-transactions-by-date))}))
(re-frame/reg-sub
:wallet/recipient-recent-txs
:wallet-legacy/recipient-recent-txs
(fn [[_ address] _]
[(re-frame/subscribe [:wallet.transactions/transactions address])])
[(re-frame/subscribe [:wallet-legacy.transactions/transactions address])])
(fn [[transactions] _]
(->> transactions
vals
@ -175,9 +175,9 @@
(take 3))))
(re-frame/reg-sub
:wallet.transactions.details/current-transaction
:wallet-legacy.transactions.details/current-transaction
(fn [[_ _ address] _]
[(re-frame/subscribe [:wallet.transactions/transactions address])
[(re-frame/subscribe [:wallet-legacy.transactions/transactions address])
(re-frame/subscribe [:ethereum/native-currency])
(re-frame/subscribe [:chain-id])])
(fn [[transactions native-currency chain-id] [_ tx-hash _]]
@ -222,9 +222,9 @@
(:hash transaction))}))))))
(re-frame/reg-sub
:wallet.transactions.details/screen
:wallet-legacy.transactions.details/screen
(fn [[_ tx-hash address] _]
[(re-frame/subscribe [:wallet.transactions.details/current-transaction tx-hash address])
[(re-frame/subscribe [:wallet-legacy.transactions.details/current-transaction tx-hash address])
(re-frame/subscribe [:ethereum/current-block])])
(fn [[transaction current-block]]
(let [confirmations (wallet.db/get-confirmations transaction

View File

@ -11,20 +11,20 @@
(re-frame/reg-sub
:balance
:<- [:wallet]
:<- [:wallet-legacy]
(fn [wallet [_ address]]
(get-in wallet [:accounts address :balance])))
(re-frame/reg-sub
:balance-default
:<- [:wallet]
:<- [:wallet-legacy]
:<- [:profile/wallet-accounts]
(fn [[wallet accounts]]
(get-in wallet [:accounts (:address (wallet.utils/get-default-account accounts)) :balance])))
(re-frame/reg-sub
:balances
:<- [:wallet]
:<- [:wallet-legacy]
:<- [:multiaccount/visible-accounts]
(fn [[wallet accounts]]
(let [accounts (map :address accounts)]
@ -55,7 +55,7 @@
(get-in prices [fsym tsym :last-day])))
(re-frame/reg-sub
:wallet.settings/currency
:wallet-legacy/settings-currency
:<- [:profile/profile]
(fn [settings]
(or (get settings :currency) :usd)))
@ -74,8 +74,8 @@
balance))
(re-frame/reg-sub
:wallet/token->decimals
:<- [:wallet/all-tokens]
:wallet-legacy/token->decimals
:<- [:wallet-legacy/all-tokens]
(fn [all-tokens]
(into {} (map #(vector (:symbol %) (:decimals %)) (vals all-tokens)))))
@ -83,8 +83,8 @@
:portfolio-value
:<- [:balances]
:<- [:prices]
:<- [:wallet/currency]
:<- [:wallet/token->decimals]
:<- [:wallet-legacy/currency]
:<- [:wallet-legacy/token->decimals]
(fn [[balances prices currency token->decimals]]
(if (and balances prices)
(let [currency-key (-> currency :code keyword)
@ -105,8 +105,8 @@
(fn [[_ address] _]
[(re-frame/subscribe [:balance address])
(re-frame/subscribe [:prices])
(re-frame/subscribe [:wallet/currency])
(re-frame/subscribe [:wallet/token->decimals])])
(re-frame/subscribe [:wallet-legacy/currency])
(re-frame/subscribe [:wallet-legacy/token->decimals])])
(fn [[balance prices currency token->decimals]]
(if (and balance prices)
(let [currency-key (-> currency :code keyword)
@ -120,40 +120,40 @@
"...")))
(re-frame/reg-sub
:wallet/sorted-tokens
:<- [:wallet/all-tokens]
:wallet-legacy/sorted-tokens
:<- [:wallet-legacy/all-tokens]
(fn [all-tokens]
(tokens/sorted-tokens-for all-tokens)))
(re-frame/reg-sub
:wallet/grouped-chain-tokens
:<- [:wallet/sorted-tokens]
:<- [:wallet/visible-tokens-symbols]
:wallet-legacy/grouped-chain-tokens
:<- [:wallet-legacy/sorted-tokens]
:<- [:wallet-legacy/visible-tokens-symbols]
(fn [[all-tokens visible-tokens]]
(let [vt-set (set visible-tokens)]
(group-by :custom?
(map #(assoc % :checked? (boolean (get vt-set (keyword (:symbol %))))) all-tokens)))))
(re-frame/reg-sub
:wallet/fetching-tx-history?
:<- [:wallet]
:wallet-legacy/fetching-tx-history?
:<- [:wallet-legacy]
(fn [wallet [_ address]]
(get-in wallet [:fetching address :history?])))
(re-frame/reg-sub
:wallet/fetching-recent-tx-history?
:<- [:wallet]
:wallet-legacy/fetching-recent-tx-history?
:<- [:wallet-legacy]
(fn [wallet [_ address]]
(get-in wallet [:fetching address :recent?])))
(re-frame/reg-sub
:wallet/tx-history-fetched?
:<- [:wallet]
:wallet-legacy/tx-history-fetched?
:<- [:wallet-legacy]
(fn [wallet [_ address]]
(get-in wallet [:fetching address :all-fetched?])))
(re-frame/reg-sub
:wallet/chain-explorer-link
:wallet-legacy/chain-explorer-link
(fn [db [_ address]]
(let [network (:networks/current-network db)
link (get-in config/default-networks-by-id
@ -162,33 +162,33 @@
(str link address)))))
(re-frame/reg-sub
:wallet/error-message
:<- [:wallet]
:wallet-legacy/error-message
:<- [:wallet-legacy]
(fn [wallet]
(or (get-in wallet [:errors :balance-update])
(get-in wallet [:errors :prices-update]))))
(re-frame/reg-sub
:wallet/visible-tokens-symbols
:wallet-legacy/visible-tokens-symbols
:<- [:ethereum/chain-keyword]
:<- [:profile/profile]
(fn [[chain current-multiaccount]]
(get-in current-multiaccount [:wallet/visible-tokens chain])))
(get-in current-multiaccount [:wallet-legacy/visible-tokens chain])))
(re-frame/reg-sub
:wallet/visible-assets
:wallet-legacy/visible-assets
:<- [:current-network]
:<- [:wallet/visible-tokens-symbols]
:<- [:wallet/sorted-tokens]
:<- [:wallet-legacy/visible-tokens-symbols]
:<- [:wallet-legacy/sorted-tokens]
(fn [[network visible-tokens-symbols all-tokens-sorted]]
(conj (filter #(contains? visible-tokens-symbols (:symbol %)) all-tokens-sorted)
(tokens/native-currency network))))
(re-frame/reg-sub
:wallet/visible-assets-with-amount
:wallet-legacy/visible-assets-with-amount
(fn [[_ address] _]
[(re-frame/subscribe [:balance address])
(re-frame/subscribe [:wallet/visible-assets])])
(re-frame/subscribe [:wallet-legacy/visible-assets])])
(fn [[balance visible-assets]]
(map #(assoc % :amount (get balance (:symbol %))) visible-assets)))
@ -208,11 +208,11 @@
(i18n/format-currency (:code currency))))))))
(re-frame/reg-sub
:wallet/visible-assets-with-values
:wallet-legacy/visible-assets-with-values
(fn [[_ address] _]
[(re-frame/subscribe [:wallet/visible-assets-with-amount address])
[(re-frame/subscribe [:wallet-legacy/visible-assets-with-amount address])
(re-frame/subscribe [:prices])
(re-frame/subscribe [:wallet/currency])])
(re-frame/subscribe [:wallet-legacy/currency])])
(fn [[assets prices currency]]
(let [{:keys [tokens nfts]} (group-by #(if (:nft? %) :nfts :tokens) assets)
tokens-with-values (map (update-value prices currency) tokens)]
@ -228,17 +228,17 @@
balances))
(re-frame/reg-sub
:wallet/all-visible-assets-with-amount
:wallet-legacy/all-visible-assets-with-amount
:<- [:balances]
:<- [:wallet/visible-assets]
:<- [:wallet-legacy/visible-assets]
(fn [[balances visible-assets]]
(map #(assoc % :amount (get-asset-amount balances (:symbol %))) visible-assets)))
(re-frame/reg-sub
:wallet/all-visible-assets-with-values
:<- [:wallet/all-visible-assets-with-amount]
:wallet-legacy/all-visible-assets-with-values
:<- [:wallet-legacy/all-visible-assets-with-amount]
:<- [:prices]
:<- [:wallet/currency]
:<- [:wallet-legacy/currency]
(fn [[assets prices currency]]
(let [{:keys [tokens nfts]} (group-by #(if (:nft? %) :nfts :tokens) assets)
tokens-with-values (map (update-value prices currency) tokens)]
@ -246,15 +246,15 @@
:nfts nfts})))
(re-frame/reg-sub
:wallet/transferrable-assets-with-amount
:wallet-legacy/transferrable-assets-with-amount
(fn [[_ address]]
(re-frame/subscribe [:wallet/visible-assets-with-amount address]))
(re-frame/subscribe [:wallet-legacy/visible-assets-with-amount address]))
(fn [all-assets]
(filter #(not (:nft? %)) all-assets)))
(re-frame/reg-sub
:wallet/currency
:<- [:wallet.settings/currency]
:wallet-legacy/currency
:<- [:wallet-legacy/settings-currency]
(fn [currency-id]
(get currency/currencies currency-id (get currency/currencies :usd))))
@ -263,9 +263,9 @@
(string/includes? (string/lower-case (str name)) search-filter))
(re-frame/reg-sub
:wallet/favourites-filtered
:<- [:wallet/favourites]
:<- [:search/recipient-filter]
:wallet-legacy/favourites-filtered
:<- [:wallet-legacy/favourites]
:<- [:wallet-legacy/search-recipient-filter]
(fn [[favs search-filter]]
(let [favs (vals favs)]
(if (string/blank? search-filter)
@ -275,21 +275,21 @@
favs)))))
(re-frame/reg-sub
:wallet/collectible-collection
:<- [:wallet/collectible-collections]
:wallet-legacy/collectible-collection
:<- [:wallet-legacy/collectible-collections]
(fn [all-collections [_ address]]
(when address
(let [all-collections (get all-collections (string/lower-case address) [])]
(sort-by :name all-collections)))))
(re-frame/reg-sub
:wallet/collectible-assets-by-collection-and-address
:<- [:wallet/collectible-assets]
:wallet-legacy/collectible-assets-by-collection-and-address
:<- [:wallet-legacy/collectible-assets]
(fn [all-assets [_ address collectible-slug]]
(get-in all-assets [address collectible-slug] [])))
(re-frame/reg-sub
:wallet/fetching-assets-by-collectible-slug
:<- [:wallet/fetching-collection-assets]
:wallet-legacy/fetching-assets-by-collectible-slug
:<- [:wallet-legacy/fetching-collection-assets]
(fn [fetching-collection-assets [_ collectible-slug]]
(get fetching-collection-assets collectible-slug false)))

View File

@ -55,16 +55,16 @@
[sub-name]
(swap! rf-db/app-db assoc
:profile/wallet-accounts accounts
:wallet wallet)
:wallet-legacy wallet)
(is (= [{:ETH money-eth
:SNT money-snt}
{:ETH money-eth
:SNT money-snt}]
(rf/sub [sub-name]))))
(h/deftest-sub :wallet/token->decimals
(h/deftest-sub :wallet-legacy/token->decimals
[sub-name]
(swap! rf-db/app-db assoc :wallet/all-tokens tokens)
(swap! rf-db/app-db assoc :wallet-legacy/all-tokens tokens)
(is (= {:SNT 18 :ETH 18}
(rf/sub [sub-name]))))
@ -94,16 +94,16 @@
(swap! rf-db/app-db assoc
:profile/wallet-accounts accounts
:prices prices
:wallet empty-wallet
:wallet/all-tokens tokens)
:wallet-legacy empty-wallet
:wallet-legacy/all-tokens tokens)
(is (= "0" (rf/sub [sub-name])))))
(testing "returns formatted value in the default USD currency"
(swap! rf-db/app-db assoc
:profile/wallet-accounts accounts
:prices prices
:wallet wallet
:wallet/all-tokens tokens)
:wallet-legacy wallet
:wallet-legacy/all-tokens tokens)
(is (= "20,550.76" (rf/sub [sub-name])))))
(h/deftest-sub :account-portfolio-value
@ -118,16 +118,16 @@
(swap! rf-db/app-db assoc
:profile/wallet-accounts accounts
:prices prices
:wallet empty-wallet
:wallet/all-tokens tokens)
:wallet-legacy empty-wallet
:wallet-legacy/all-tokens tokens)
(is (= "0" (rf/sub [sub-name main-account-id])))))
(testing "returns formatted value in the default USD currency"
(swap! rf-db/app-db assoc
:profile/wallet-accounts accounts
:prices prices
:wallet wallet
:wallet/all-tokens tokens)
:wallet-legacy wallet
:wallet-legacy/all-tokens tokens)
(is (= "10,275.38" (rf/sub [sub-name main-account-id])))))
(def transactions

View File

@ -121,7 +121,7 @@
network-name [:network-name]
waku-bloom-filter-mode [:waku/bloom-filter-mode]
wakuv2-flag [:waku/v2-flag]
transactions-management-enabled? [:wallet/transactions-management-enabled?]
transactions-management-enabled? [:wallet-legacy/transactions-management-enabled?]
current-log-level [:log-level/current-log-level]
current-fleet [:fleets/current-fleet]]
[list/flat-list

View File

@ -15,7 +15,7 @@
[{:keys [id code display-name]} _ _ current-currency-id]
(let [selected? (= id current-currency-id)]
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:wallet.settings.ui/currency-selected id])
{:on-press #(re-frame/dispatch [:wallet-legacy.settings.ui/currency-selected id])
:accessibility-label :currency-item}
[react/view styles/currency-item
[react/text {:style styles/currency-name-text}
@ -25,8 +25,8 @@
(views/defview currency-settings
[]
(views/letsubs [currency-id [:wallet.settings/currency]
{:keys [currencies search-filter]} [:search/filtered-currencies]]
(views/letsubs [currency-id [:wallet-legacy/settings-currency]
{:keys [currencies search-filter]} [:wallet-legacy/search-filtered-currencies]]
{:component-will-unmount #(do
(re-frame/dispatch [:search/currency-filter-changed nil])
(reset! search-active? false))}

View File

@ -89,7 +89,7 @@
[]
(letsubs [read-once? (atom false)
{:keys [height width]} [:dimensions/window]
camera-flashlight [:wallet.send/camera-flashlight]
camera-flashlight [:wallet-legacy.send/camera-flashlight]
opts [:get-screen-params]
camera-ref (atom nil)]
[react/view

View File

@ -141,8 +141,8 @@
;;WALLET
{:name :wallet
:on-focus [:wallet/tab-opened]
{:name :wallet-legacy
:on-focus [:wallet-legacy/tab-opened]
;;TODO wallet redesign
;;:options {:statusBar {:backgroundColor quo.colors/neutral-5}}
:component wallet.accounts/accounts-overview-old}
@ -171,7 +171,7 @@
:options {:insets {:top? true}}
:component wallet-settings/manage-assets}
{:name :wallet-add-custom-token
:on-focus [:wallet/wallet-add-custom-token]
:on-focus [:wallet-legacy/wallet-add-custom-token]
:options {:topBar {:title {:text (i18n/label :t/add-custom-token)}}
:insets {:top? true}}
:component custom-tokens/add-custom-token}
@ -473,7 +473,7 @@
;[Wallet] Prepare Transaction
{:name :prepare-send-transaction
:on-dissmiss [:wallet/cancel-transaction-command]
:on-dissmiss [:wallet-legacy/cancel-transaction-command]
:options {:topBar {:title {:text (i18n/label :t/send-transaction)}}
:swipeToDismiss false
:hardwareBackButton {:dismissModalOnPress false}
@ -483,7 +483,7 @@
;[Wallet] Request Transaction
{:name :request-transaction
:on-dissmiss [:wallet/cancel-transaction-command]
:on-dissmiss [:wallet-legacy/cancel-transaction-command]
:options {:topBar {:title {:text (i18n/label :t/request-transaction)}}
:swipeToDismiss false
:hardwareBackButton {:dismissModalOnPress false}

View File

@ -88,7 +88,7 @@
[gas-edit
max-fee-per-gas-edit
max-priority-fee-per-gas-edit])
base-fee @(re-frame/subscribe [:wallet/current-base-fee])
base-fee @(re-frame/subscribe [:wallet-legacy/current-base-fee])
[fee-currency fiat-currency price]
@(re-frame/subscribe [:signing/currencies])
fee-eth
@ -306,9 +306,9 @@
(defn fees-warning
[]
(let [base-fee @(re-frame/subscribe [:wallet/current-base-fee])
(let [base-fee @(re-frame/subscribe [:wallet-legacy/current-base-fee])
base-fee-gwei (money/wei-> :gwei (money/bignumber base-fee))
priority-fee @(re-frame/subscribe [:wallet/current-priority-fee])
priority-fee @(re-frame/subscribe [:wallet-legacy/current-priority-fee])
priority-fee-gwei (money/wei-> :gwei (money/bignumber priority-fee))
{priority-fee-edit :maxPriorityFeePerGas
fee-edit :maxFeePerGas}

View File

@ -481,10 +481,10 @@
[:signing/amount-errors (:address from)]
keycard-multiaccount? [:keycard-multiaccount?]
prices [:prices]
wallet-currency [:wallet/currency]
wallet-currency [:wallet-legacy/currency]
mainnet? [:mainnet?]
prices-loading? [:prices-loading?]
management-enabled? [:wallet/transactions-management-enabled?]]
management-enabled? [:wallet-legacy/transactions-management-enabled?]]
(let [display-symbol (wallet.utils/display-symbol token)
fee-display-symbol (wallet.utils/display-symbol (tokens/native-currency chain))]
[react/view (styles/sheet)

View File

@ -40,7 +40,7 @@
(views/defview account-card
[{:keys [address color type] :as account}]
(views/letsubs [currency [:wallet/currency]
(views/letsubs [currency [:wallet-legacy/currency]
portfolio-value [:account-portfolio-value address]
window-width [:dimensions/window-width]
prices-loading? [:prices-loading?]]
@ -63,7 +63,7 @@
:color colors/white-transparent-70-persist}}
(address/normalized-hex address)]]
[react/view {:position :absolute :top 12 :right 12}
[react/touchable-highlight {:on-press #(re-frame/dispatch [:wallet/share-popover address])}
[react/touchable-highlight {:on-press #(re-frame/dispatch [:wallet-legacy/share-popover address])}
[icons/icon :main-icons/share
{:color colors/white-persist
:accessibility-label :share-wallet-address-icon}]]]
@ -81,17 +81,17 @@
(i18n/label :t/wallet-send)
:main-icons/send
colors/white-persist
#(re-frame/dispatch [:wallet/prepare-transaction-from-wallet account])])
#(re-frame/dispatch [:wallet-legacy/prepare-transaction-from-wallet account])])
[react/view {:style (styles/divider)}]
[button
(i18n/label :t/receive)
:main-icons/receive
colors/white-persist
#(re-frame/dispatch [:wallet/share-popover address])]]]))
#(re-frame/dispatch [:wallet-legacy/share-popover address])]]]))
(views/defview transactions
[address]
(views/letsubs [data [:wallet.transactions.history/screen address]]
(views/letsubs [data [:wallet-legacy.transactions.history/screen address]]
[history/history-list data address]))
(defn opensea-link
@ -115,10 +115,10 @@
(views/defview assets-and-collections-new
[address]
(views/letsubs [{:keys [tokens]} [:wallet/visible-assets-with-values address]
currency [:wallet/currency]
(views/letsubs [{:keys [tokens]} [:wallet-legacy/visible-assets-with-values address]
currency [:wallet-legacy/currency]
opensea-enabled? [:opensea-enabled?]
collectible-collection [:wallet/collectible-collection address]]
collectible-collection [:wallet-legacy/collectible-collection address]]
;ethereum-network? [:ethereum-network?]]
(let [tab @selected-tab]
[react/view {:flex 1}
@ -176,12 +176,12 @@
(i18n/label :t/wallet-send)
:main-icons/send
colors/blue-persist
#(re-frame/dispatch [:wallet/prepare-transaction-from-wallet account])])
#(re-frame/dispatch [:wallet-legacy/prepare-transaction-from-wallet account])])
[button
(i18n/label :t/receive)
:main-icons/receive
colors/blue-persist
#(re-frame/dispatch [:wallet/share-popover address])]])
#(re-frame/dispatch [:wallet-legacy/share-popover address])]])
(defn anim-listener
[anim-y scroll-y]
@ -231,10 +231,10 @@
(views/defview assets-and-collections
[address]
(views/letsubs [{:keys [tokens]} [:wallet/visible-assets-with-values address]
currency [:wallet/currency]
(views/letsubs [{:keys [tokens]} [:wallet-legacy/visible-assets-with-values address]
currency [:wallet-legacy/currency]
opensea-enabled? [:opensea-enabled?]
collectible-collection [:wallet/collectible-collection address]
collectible-collection [:wallet-legacy/collectible-collection address]
ethereum-network? [:ethereum-network?]]
(let [{:keys [tab]} @state]
[react/view {:flex 1}
@ -272,11 +272,11 @@
(defn account-new
[selected-account]
(let [;{:keys [name address] :as account} (rf/sub [:account-by-address selected-account])
currency (rf/sub [:wallet/currency])
currency (rf/sub [:wallet-legacy/currency])
portfolio-value (rf/sub [:account-portfolio-value selected-account])
width (rf/sub [:dimensions/window-width])
button-width (/ (- width 40 (* 2 12)) 3)]
;fetching-error (rf/sub [:wallet/fetching-error])]
;fetching-error (rf/sub [:wallet-legacy/fetching-error])]
[react/view
{:flex 1
:background-color (quo.colors/theme-colors quo.colors/white quo.colors/neutral-90)
@ -306,7 +306,7 @@
(views/defview account
[]
(views/letsubs [{:keys [name address] :as current-account} [:multiaccount/current-account]
fetching-error [:wallet/fetching-error]]
fetching-error [:wallet-legacy/fetching-error]]
(let [anim-y (animation/create-value button-group-height)
scroll-y (animation/create-value 0)]
(anim-listener anim-y scroll-y)
@ -327,7 +327,7 @@
:refreshControl (common/refresh-control
(and
@common/updates-counter
@(re-frame/subscribe [:wallet/refreshing-history?])))}
@(re-frame/subscribe [:wallet-legacy/refreshing-history?])))}
(when fetching-error
[react/view
{:style {:flex 1

View File

@ -43,7 +43,7 @@
(str @error)))}]
[quo/button
{:on-press (fn []
(re-frame/dispatch [:wallet.accounts/delete-key
(re-frame/dispatch [:wallet-legacy.accounts/delete-key
account
@password
#(reset! error :wrong-password)])
@ -109,7 +109,7 @@
[{:label (i18n/label :t/apply)
:on-press
#(do
(re-frame/dispatch [:wallet.accounts/save-account
(re-frame/dispatch [:wallet-legacy.accounts/save-account
account
@new-account])
(reset! new-account nil))}]))]
@ -172,5 +172,6 @@
{:theme :negative
:title (i18n/label :t/delete-account)
:on-press #(if (= :watch type)
(re-frame/dispatch [:wallet.settings/show-delete-account-confirmation account])
(re-frame/dispatch [:wallet-legacy.settings/show-delete-account-confirmation
account])
(re-frame/dispatch [:show-popover {:view [delete-account account]}]))}]])]]]))

View File

@ -22,14 +22,14 @@
(utils.utils/set-timeout
(fn []
(swap! updates-counter inc)
(when @(re-frame/subscribe [:wallet/refreshing-history?])
(when @(re-frame/subscribe [:wallet-legacy/refreshing-history?])
(schedule-counter-reset)))
1000))
(defn refresh-action
[]
(schedule-counter-reset)
(re-frame/dispatch [:wallet.ui/pull-to-refresh-history]))
(re-frame/dispatch [:wallet-legacy.ui/pull-to-refresh-history]))
(defn refresh-control
[refreshing?]

View File

@ -41,7 +41,7 @@
:icon :main-icons/refresh
:accessibility-label :wallet-scan-token
:on-press #(hide-sheet-and-dispatch
[:wallet/update-balances nil true])}]
[:wallet-legacy/update-balances nil true])}]
[list.item/list-item
{:theme :accent
:title (i18n/label :t/set-currency)
@ -74,14 +74,14 @@
:icon :main-icons/send
:accessibility-label :send-transaction-button
:on-press #(hide-sheet-and-dispatch
[:wallet/prepare-transaction-from-wallet account])}])
[:wallet-legacy/prepare-transaction-from-wallet account])}])
[list.item/list-item
{:theme :accent
:title (i18n/label :t/share)
:icon :main-icons/share
:accessibility-label :share-account-button
:on-press #(hide-sheet-and-dispatch
[:wallet/share-popover (:address account)])}]
[:wallet-legacy/share-popover (:address account)])}]
(when-not wallet
[list.item/list-item
{:theme :accent
@ -89,7 +89,7 @@
:icon :main-icons/hide
:accessibility-label :hide-account-button
:on-press #(hide-sheet-and-dispatch
[:wallet.accounts/save-account account {:hidden true}])}])])
[:wallet-legacy.accounts/save-account account {:hidden true}])}])])
(defn add-account
[]
@ -101,7 +101,7 @@
:icon :main-icons/add
:accessibility-label :add-account-sheet-generate
:on-press #(hide-sheet-and-dispatch
[:wallet.accounts/start-adding-new-account
[:wallet-legacy.accounts/start-adding-new-account
{:type :generate}])}]
[list.item/list-item
{:theme :accent
@ -109,7 +109,7 @@
:icon :main-icons/show
:accessibility-label :add-account-sheet-watch
:on-press #(hide-sheet-and-dispatch
[:wallet.accounts/start-adding-new-account
[:wallet-legacy.accounts/start-adding-new-account
{:type :watch}])}]
(when-not keycard?
[list.item/list-item
@ -118,7 +118,7 @@
:icon :main-icons/text
:accessibility-label :add-account-sheet-seed
:on-press #(hide-sheet-and-dispatch
[:wallet.accounts/start-adding-new-account
[:wallet-legacy.accounts/start-adding-new-account
{:type :seed}])}])
(when-not keycard?
[list.item/list-item
@ -127,7 +127,7 @@
:icon :main-icons/address
:accessibility-label :add-account-sheet-private-key
:on-press #(hide-sheet-and-dispatch
[:wallet.accounts/start-adding-new-account
[:wallet-legacy.accounts/start-adding-new-account
{:type :key}])}])]))
(defn account-settings

View File

@ -23,7 +23,7 @@
(views/defview account-card
[{:keys [name color address type wallet] :as account} keycard? card-width]
(views/letsubs [currency [:wallet/currency]
(views/letsubs [currency [:wallet-legacy/currency]
portfolio-value [:account-portfolio-value address]
prices-loading? [:prices-loading?]]
[react/touchable-highlight
@ -73,8 +73,8 @@
(views/defview assets
[]
(views/letsubs [{:keys [tokens]} [:wallet/all-visible-assets-with-values]
currency [:wallet/currency]]
(views/letsubs [{:keys [tokens]} [:wallet-legacy/all-visible-assets-with-values]
currency [:wallet-legacy/currency]]
[:<>
(for [item tokens]
^{:key (:name item)}
@ -87,7 +87,8 @@
[components.core/button
{:accessibility-label :send-transaction-button
:type :scale
:on-press #(re-frame/dispatch [:wallet/prepare-transaction-from-wallet account])}
:on-press #(re-frame/dispatch [:wallet-legacy/prepare-transaction-from-wallet
account])}
[react/view (styles/send-button)
[icons/icon :main-icons/send {:color colors/white-persist}]]]]))
@ -142,7 +143,7 @@
;;TOTAL VALUE OLD
(views/defview total-value-old
[{:keys [animation minimized]}]
(views/letsubs [currency [:wallet/currency]
(views/letsubs [currency [:wallet-legacy/currency]
portfolio-value [:portfolio-value]
empty-balances? [:empty-balances?]
frozen-card? [:keycard/frozen-card?]
@ -203,7 +204,7 @@
(views/defview total-value
[]
(views/letsubs [currency [:wallet/currency]
(views/letsubs [currency [:wallet-legacy/currency]
portfolio-value [:portfolio-value]]
[react/view {:padding-vertical 12}
[quo.text/text (i18n/label :t/wallet-total-value)]
@ -257,7 +258,7 @@
:accessibility-label :accounts-qr-code
:on-press #(re-frame/dispatch
[::qr-scanner/scan-code
{:handler :wallet.send/qr-scanner-result}])}
{:handler :wallet-legacy.send/qr-scanner-result}])}
:i/placeholder]
[react/view {:width 12}]
[quo/button
@ -281,12 +282,12 @@
[components.core/animated-header
{:extended-header total-value-old
:refresh-control common/refresh-control
:refreshing-sub (re-frame/subscribe [:wallet/refreshing-history?])
:refreshing-sub (re-frame/subscribe [:wallet-legacy/refreshing-history?])
:refreshing-counter common/updates-counter
:use-insets true
:right-accessories [{:on-press #(re-frame/dispatch
[::qr-scanner/scan-code
{:handler :wallet.send/qr-scanner-result}])
{:handler :wallet-legacy.send/qr-scanner-result}])
:icon :main-icons/qr
:accessibility-label :accounts-qr-code}
{:on-press #(re-frame/dispatch [:bottom-sheet/show-sheet-old

View File

@ -26,7 +26,7 @@
:disabled wallet
:title name
:subtitle (utils/get-shortened-checksum-address address)
:on-press #(rf/dispatch [:wallet.accounts/save-account account
:on-press #(rf/dispatch [:wallet-legacy.accounts/save-account account
{:hidden (not hidden)}])}])}))
(defn manage

View File

@ -31,8 +31,9 @@
(when (= type :watch)
{:right-accessories
[{:icon :qr
:on-press #(re-frame/dispatch [:wallet.add-new/qr-scanner
{:handler :wallet.add-new/qr-scanner-result}])}]}))]))
:on-press #(re-frame/dispatch [:wallet-legacy.add-new/qr-scanner
{:handler
:wallet-legacy.add-new/qr-scanner-result}])}]}))]))
(defn common-settings
[account]
@ -77,7 +78,7 @@
:monospace true
:placeholder (i18n/label :t/enter-address)
:accessibility-label :add-account-enter-watch-address
:on-change-text #(re-frame/dispatch [:wallet.accounts/set-account-to-watch %])}]
:on-change-text #(re-frame/dispatch [:wallet-legacy.accounts/set-account-to-watch %])}]
[quo/text-input
{:label (i18n/label :t/password)
:show-cancel false
@ -179,7 +180,7 @@
#(re-frame/dispatch [:keycard/new-account-pin-sheet
{:view {:content pin
:height 256}}])
#(re-frame/dispatch [:wallet.accounts/add-new-account
#(re-frame/dispatch [:wallet-legacy.accounts/add-new-account
(native-module/sha3 @entered-password)]))
:disabled
(or add-account-disabled?

View File

@ -16,7 +16,7 @@
[status-im.ui.components.toastable-highlight :refer [toastable-highlight-view]]
[status-im.ui.components.topbar :as topbar]
[status-im.ui.screens.wallet.components.views :as wallet.components]
[status-im.wallet.core :as wallet]
[status-im.wallet.core :as wallet-legacy]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
@ -120,7 +120,7 @@
{:width width
:border-radius 16
:margin-bottom 16}
:on-press (when clickable? #(re-frame/dispatch [::wallet/show-nft-details asset]))
:on-press (when clickable? #(re-frame/dispatch [::wallet-legacy/show-nft-details asset]))
:accessibility-label
:nft-asset}
(cond
@ -152,9 +152,9 @@
(defn nft-assets
[{:keys [num-assets address collectible-slug]}]
(let [assets (rf/sub [:wallet/collectible-assets-by-collection-and-address address
(let [assets (rf/sub [:wallet-legacy/collectible-assets-by-collection-and-address address
collectible-slug])
fetching? (rf/sub [:wallet/fetching-assets-by-collectible-slug collectible-slug])]
fetching? (rf/sub [:wallet-legacy/fetching-assets-by-collectible-slug collectible-slug])]
[react/view
{:flex 1
:flex-wrap :wrap
@ -179,7 +179,7 @@
(defn nft-collections
[address]
(let [collection (rf/sub [:wallet/collectible-collection address])]
(let [collection (rf/sub [:wallet-legacy/collectible-collection address])]
[:<>
(for [[index collectible] (map-indexed vector collection)]
^{:key (:slug collectible)}
@ -207,7 +207,7 @@
:border-bottom-width 8
:border-color colors/gray-lighter}
:on-open #(re-frame/dispatch
[::wallet/fetch-collectible-assets-by-owner-and-collection
[::wallet-legacy/fetch-collectible-assets-by-owner-and-collection
address
(:slug collectible)
(:owned_asset_count collectible)])
@ -251,7 +251,7 @@
(defn nft-details-modal
[]
(let [nft (rf/sub [:wallet/selected-collectible])]
(let [nft (rf/sub [:wallet-legacy/selected-collectible])]
[react/scroll-view
[topbar/topbar
{:navigation {:icon :main-icons/close}

View File

@ -20,14 +20,15 @@
(swap! debounce-timers assoc
field-key
(js/setTimeout
#(re-frame/dispatch [:wallet.custom-token.ui/field-is-edited field-key (string/trim value)])
#(re-frame/dispatch [:wallet-legacy.custom-token.ui/field-is-edited field-key
(string/trim value)])
500))))
(defview add-custom-token
[]
(letsubs [{:keys [contract name decimals in-progress? error error-name error-symbol]
:as m}
[:wallet/custom-token-screen]]
[:wallet-legacy/custom-token-screen]]
(let [sym (:symbol m)]
[react/keyboard-avoiding-view {:flex 1 :background-color colors/white}
[react/scroll-view
@ -50,7 +51,7 @@
;;tooltip covers button
[react/view {:position :absolute :z-index 1000 :right 0 :top 10}
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:wallet.custom-token.ui/contract-address-paste])}
{:on-press #(re-frame/dispatch [:wallet-legacy.custom-token.ui/contract-address-paste])}
[react/text {:style {:color colors/blue}}
(i18n/label :t/paste)]]])
[quo/text-input
@ -117,7 +118,7 @@
(string/blank? name)
(string/blank? sym)
(string/blank? decimals)))
:on-press #(re-frame/dispatch [:wallet.custom-token.ui/add-pressed])}
:on-press #(re-frame/dispatch [:wallet-legacy.custom-token.ui/add-pressed])}
(i18n/label :t/add)]}]])))
(defview custom-token-details
@ -166,4 +167,5 @@
{:theme :negative
:title (i18n/label :t/remove-token)
:icon :main-icons/delete
:on-press #(re-frame/dispatch [:wallet.custom-token.ui/remove-pressed token true])}])]]))
:on-press #(re-frame/dispatch [:wallet-legacy.custom-token.ui/remove-pressed token
true])}])]]))

View File

@ -27,8 +27,8 @@
[topbar/topbar
{:navigation {:on-press
#(do
(re-frame/dispatch [:wallet/recipient-modal-closed])
(re-frame/dispatch [:search/recipient-filter-changed nil])
(re-frame/dispatch [:wallet-legacy/recipient-modal-closed])
(re-frame/dispatch [:wallet-legacy/search-recipient-filter-changed nil])
(re-frame/dispatch [:navigate-back]))}
:modal? true
:border-bottom false
@ -36,24 +36,24 @@
:right-accessories
[{:icon :qr
:accessibility-label :scan-contact-code-button
:on-press #(re-frame/dispatch [:wallet.send/qr-scanner
:on-press #(re-frame/dispatch [:wallet-legacy.send/qr-scanner
{:ignore-url true
:handler :wallet.send/qr-scanner-result}])}]}])
:handler :wallet-legacy.send/qr-scanner-result}])}]}])
(defonce search-active? (reagent/atom false))
(defn search-input-wrapper
[]
(let [search-filter @(re-frame/subscribe [:search/recipient-filter])]
(let [search-filter @(re-frame/subscribe [:wallet-legacy/search-recipient-filter])]
[react/view
{:padding-horizontal 16
:padding-vertical 10}
[search-input/search-input-old
{:search-active? search-active?
:search-filter search-filter
:on-cancel #(re-frame/dispatch [:search/recipient-filter-changed nil])
:on-cancel #(re-frame/dispatch [:wallet-legacy/search-recipient-filter-changed nil])
:on-change (fn [text]
(re-frame/dispatch [:search/recipient-filter-changed text])
(re-frame/dispatch [:wallet-legacy/search-recipient-filter-changed text])
(re-frame/dispatch [:set-in [:contacts/new-identity :state] :searching])
(debounce/debounce-and-dispatch [:contacts/set-new-identity text] 300))}]]))
@ -83,7 +83,7 @@
[list.item/list-item
{:icon [chat-icon/custom-icon-view-list (:name account) (:color account)]
:title (:name account)
:on-press #(re-frame/dispatch [:wallet.send/set-recipient (:address account)])
:on-press #(re-frame/dispatch [:wallet-legacy.send/set-recipient (:address account)])
:subtitle [quo/text
{:monospace true
:color :secondary}
@ -99,7 +99,7 @@
:on-press #(do
(some-> ^js @scroll-view-ref
(.scrollTo #js {:x 0 :animated true}))
(re-frame/dispatch [:wallet.recipient/address-changed name]))
(re-frame/dispatch [:wallet-legacy.recipient/address-changed name]))
:icon [chat-icon/contact-icon-contacts-tab contact]}])
(defn empty-items
@ -130,7 +130,7 @@
[list.item/list-item
{:title [quo/text {:monospace true}
(utils/get-shortened-checksum-address address)]
:on-press #(re-frame/dispatch [:wallet.recipient/address-changed address])
:on-press #(re-frame/dispatch [:wallet-legacy.recipient/address-changed address])
:size :small
:accessory [react/text
{:style {:flex-shrink 1
@ -139,8 +139,8 @@
(defn recent-section
[]
(let [{:keys [from]} @(re-frame/subscribe [:wallet/prepare-transaction])
txs @(re-frame/subscribe [:wallet/recipient-recent-txs (:address from)])
(let [{:keys [from]} @(re-frame/subscribe [:wallet-legacy/prepare-transaction])
txs @(re-frame/subscribe [:wallet-legacy/recipient-recent-txs (:address from)])
cnt (count txs)]
[section
(i18n/label :t/recent)
@ -168,12 +168,12 @@
{:monospace true
:color :secondary}
short-address])
:on-press #(re-frame/dispatch [:wallet.send/set-recipient address])
:on-press #(re-frame/dispatch [:wallet-legacy.send/set-recipient address])
:size (when noname? :small)}]))
(views/defview fav-section
[]
(views/letsubs [favourites [:wallet/favourites-filtered]]
(views/letsubs [favourites [:wallet-legacy/favourites-filtered]]
(let [cnt (count favourites)]
[section
(i18n/label :t/favourites)
@ -206,7 +206,7 @@
(views/defview search-results
[]
(views/letsubs [contacts [:contacts/active-with-ens-names]
favourites [:wallet/favourites-filtered]
favourites [:wallet-legacy/favourites-filtered]
accounts [:accounts-for-recipient]]
[react/view
(for [account accounts]
@ -233,7 +233,7 @@
(views/defview new-favourite
[]
(views/letsubs [{:keys [resolved-address]} [:wallet/recipient]
(views/letsubs [{:keys [resolved-address]} [:wallet-legacy/recipient]
fav-name (atom "")]
[kb-presentation/keyboard-avoiding-view {:style {:flex 1}}
[react/view {:flex 1}
@ -265,13 +265,14 @@
[quo/button
{:accessibility-label :add-fav
:type :secondary
:on-press #(re-frame/dispatch [:wallet/add-favourite resolved-address @fav-name])}
:on-press #(re-frame/dispatch [:wallet-legacy/add-favourite resolved-address
@fav-name])}
(i18n/label :t/add)]}]]]))
(views/defview recipient
[]
(views/letsubs [{:keys [address resolved-address searching]} [:wallet/recipient]
search-filter [:search/recipient-filter]]
(views/letsubs [{:keys [address resolved-address searching]} [:wallet-legacy/recipient]
search-filter [:wallet-legacy/search-recipient-filter]]
(let [disabled? (or searching (not resolved-address))]
[kb-presentation/keyboard-avoiding-view
{:style {:flex 1}
@ -295,7 +296,7 @@
[quo/text (i18n/label :t/address-or-ens-name)]
[quo/button
{:type :secondary
:on-press #(re-frame/dispatch [:wallet.recipient/address-paste-pressed])}
:on-press #(re-frame/dispatch [:wallet-legacy.recipient/address-paste-pressed])}
(i18n/label :t/paste)]]
[quo/text-input
{:multiline true
@ -304,9 +305,10 @@
:placeholder (i18n/label :t/recipient-code-placeholder)
:text-align-vertical :top
:on-change-text #(do
(re-frame/dispatch [:set-in [:wallet/recipient :searching]
(re-frame/dispatch [:set-in [:wallet-legacy/recipient :searching]
:searching])
(debounce/debounce-and-dispatch [:wallet.recipient/address-changed
(debounce/debounce-and-dispatch
[:wallet-legacy.recipient/address-changed
(utils.string/safe-trim %)]
600))
:accessibility-label :recipient-address-input}]]
@ -342,5 +344,6 @@
:type :secondary
:after :main-icons/next
:disabled disabled?
:on-press #(re-frame/dispatch [:wallet.send/set-recipient resolved-address])}
:on-press #(re-frame/dispatch [:wallet-legacy.send/set-recipient
resolved-address])}
(i18n/label :t/done)]}]]])))

View File

@ -37,6 +37,6 @@
:padding-horizontal 16
:padding-bottom 16}
[quo/button
{:on-press #(re-frame/dispatch [:wallet.accounts/share address])
{:on-press #(re-frame/dispatch [:wallet-legacy.accounts/share address])
:accessibility-label :share-address-button}
(i18n/label :t/share-address)]]]))

View File

@ -11,13 +11,13 @@
(defn asset
[currency token]
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:wallet.send/set-symbol (:symbol token)])}
{:on-press #(re-frame/dispatch [:wallet-legacy.send/set-symbol (:symbol token)])}
[common/render-asset token nil nil (:code currency)]])
(views/defview assets
[address]
(views/letsubs [{:keys [tokens]} [:wallet/visible-assets-with-values address]
currency [:wallet/currency]]
(views/letsubs [{:keys [tokens]} [:wallet-legacy/visible-assets-with-values address]
currency [:wallet-legacy/currency]]
[react/view
{:style {:height 300}}
[list/flat-list
@ -47,6 +47,7 @@
[]
(re-frame/dispatch [:bottom-sheet/hide-old])
(js/setTimeout #(re-frame/dispatch [:bottom-sheet/show-sheet-old
{:content (fn [] [accounts-list :to :wallet.send/set-field])
{:content (fn [] [accounts-list :to
:wallet-legacy.send/set-field])
:content-height 300}])
400))

View File

@ -98,7 +98,8 @@
:accessibility-label :choose-recipient-button
:on-press #(do
(re-frame/dispatch [:dismiss-keyboard])
(re-frame/dispatch [:wallet.send/navigate-to-recipient-code]))
(re-frame/dispatch
[:wallet-legacy.send/navigate-to-recipient-code]))
:chevron true}
(when-not contact
{:icon :main-icons/add
@ -109,7 +110,7 @@
[react/touchable-highlight
{:on-press
#(when token
(re-frame/dispatch [:wallet.send/set-max-amount token]))}
(re-frame/dispatch [:wallet-legacy.send/set-max-amount token]))}
[react/view {:style (styles/set-max-button)}
[react/text {:style {:color colors/blue}} (i18n/label :t/set-max)]]])
@ -172,10 +173,10 @@
(views/defview request-transaction
[_]
(views/letsubs [{:keys [amount-error amount-text from token sign-enabled?] :as tx}
[:wallet.request/prepare-transaction-with-balance]
[:wallet-legacy.request/prepare-transaction-with-balance]
window-width [:dimensions/window-width]
prices [:prices]
wallet-currency [:wallet/currency]]
wallet-currency [:wallet-legacy/currency]]
[kb-presentation/keyboard-avoiding-view {:style {:flex 1}}
[:<>
[react/scroll-view
@ -196,7 +197,7 @@
:accessibility-label :amount-input
:default-value amount-text
:auto-focus true
:on-change-text #(re-frame/dispatch [:wallet.request/set-amount-text %])
:on-change-text #(re-frame/dispatch [:wallet-legacy.request/set-amount-text %])
:placeholder "0.0 "}]
[asset-selector tx window-width]
(when amount-error
@ -209,7 +210,7 @@
(i18n/label :t/to-capitalized)]
[react/view {:flex-direction :row :flex 1 :align-items :center}
[react/view {:flex 1}
[render-account from token :wallet.request/set-field]]]]]
[render-account from token :wallet-legacy.request/set-field]]]]]
[toolbar/toolbar
{:show-border? true
:right
@ -220,7 +221,7 @@
:disabled (not sign-enabled?)
:on-press #(do
(re-frame/dispatch
[:wallet.ui/request-transaction-button-clicked tx])
[:wallet-legacy.ui/request-transaction-button-clicked tx])
(re-frame/dispatch [:navigate-back]))}
(i18n/label :t/wallet-request)]}]]]))
@ -230,9 +231,9 @@
request?
from token to sign-enabled? from-chat?]
:as tx}
[:wallet.send/prepare-transaction-with-balance]
[:wallet-legacy.send/prepare-transaction-with-balance]
prices [:prices]
wallet-currency [:wallet/currency]
wallet-currency [:wallet-legacy/currency]
window-width [:dimensions/window-width]]
(let [to-norm (address/normalized-hex (if (string? to) to (:address to)))]
[kb-presentation/keyboard-avoiding-view {:style {:flex 1}}
@ -244,7 +245,7 @@
:icon-name :i/arrow-left
:on-press (fn []
(re-frame/dispatch [:navigate-back])
(re-frame/dispatch [:wallet/cancel-transaction-command]))
(re-frame/dispatch [:wallet-legacy/cancel-transaction-command]))
:accessibility-label :back-button}]
[react/scroll-view
{:style {:flex 1}
@ -266,7 +267,7 @@
:default-value amount-text
:editable (not request?)
:auto-focus true
:on-change-text #(re-frame/dispatch [:wallet.send/set-amount-text %])
:on-change-text #(re-frame/dispatch [:wallet-legacy.send/set-amount-text %])
:placeholder "0.0 "}]
[asset-selector tx window-width]
(when amount-error
@ -283,7 +284,7 @@
[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 token :wallet.send/set-field]]]
[render-account from token :wallet-legacy.send/set-field]]]
[components.core/list-header
(i18n/label :t/to-capitalized)]
[react/view {:flex-direction :row :flex 1 :align-items :center}
@ -302,11 +303,11 @@
(re-frame/dispatch
[(cond
request?
:wallet.ui/sign-transaction-button-clicked-from-request
:wallet-legacy.ui/sign-transaction-button-clicked-from-request
from-chat?
:wallet.ui/sign-transaction-button-clicked-from-chat
:wallet-legacy.ui/sign-transaction-button-clicked-from-chat
:else
:wallet.ui/sign-transaction-button-clicked) tx]))}
:wallet-legacy.ui/sign-transaction-button-clicked) tx]))}
(if (and (not request?) from-chat? (not to-norm))
(i18n/label :t/wallet-send)

View File

@ -21,7 +21,7 @@
[topbar/topbar
{:title (i18n/label :t/wallet-assets)
:navigation
{:on-press #(re-frame/dispatch [:wallet.settings.ui/navigate-back-pressed])}}])
{:on-press #(re-frame/dispatch [:wallet-legacy.settings.ui/navigate-back-pressed])}}])
(defn hide-sheet-and-dispatch
[event]
@ -44,7 +44,7 @@
:title (i18n/label :t/remove-token)
:icon :main-icons/delete
:on-press #(hide-sheet-and-dispatch
[:wallet.custom-token.ui/remove-pressed token])}])]))
[:wallet-legacy.custom-token.ui/remove-pressed token])}])]))
(defn render-token
[_]
@ -69,7 +69,8 @@
[chat-icon/custom-icon-view-list title color])
:title title
:subtitle (name sym)
:on-press #(re-frame/dispatch [:wallet.settings/toggle-visible-token (keyword sym)
:on-press #(re-frame/dispatch [:wallet-legacy.settings/toggle-visible-token
(keyword sym)
(not checked?)])
:on-long-press #(re-frame/dispatch [:bottom-sheet/show-sheet-old
{:content (custom-token-actions-view token)}])}])}))
@ -82,9 +83,9 @@
[]
(letsubs [{search-filter :search-filter
{custom-tokens true default-tokens nil} :tokens}
[:wallet/filtered-grouped-chain-tokens]]
[:wallet-legacy/filtered-grouped-chain-tokens]]
{:component-will-unmount #(do
(re-frame/dispatch [:search/token-filter-changed nil])
(re-frame/dispatch [:wallet-legacy/search-token-filter-changed nil])
(reset! search-active? false))}
[react/view {:flex 1 :background-color colors/white}
[toolbar]
@ -95,12 +96,12 @@
[search-input/search-input-old
{:search-active? search-active?
:search-filter search-filter
:on-cancel #(re-frame/dispatch [:search/token-filter-changed nil])
:on-cancel #(re-frame/dispatch [:wallet-legacy/search-token-filter-changed nil])
:on-focus (fn [search-filter]
(when-not search-filter
(re-frame/dispatch [:search/token-filter-changed ""])))
(re-frame/dispatch [:wallet-legacy/search-token-filter-changed ""])))
:on-change (fn [text]
(re-frame/dispatch [:search/token-filter-changed text]))}]]
(re-frame/dispatch [:wallet-legacy/search-token-filter-changed text]))}]]
[list/section-list
{:header
[react/view {:margin-top 16}

View File

@ -15,7 +15,7 @@
[status-im.ui.components.toolbar :as toolbar]
[status-im.ui.components.topbar :as topbar]
[status-im.ui.screens.wallet.components.views :as wallet.components]
[status-im.wallet.swap.core :as wallet.swap]
[status-im.wallet.swap.core :as wallet-legacy.swap]
[status-im.wallet.utils :as wallet.utils]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
@ -49,9 +49,9 @@
(defn asset-selector
[]
(let [{:keys [address]} (rf/sub [:multiaccount/current-account])
{:keys [tokens]} (rf/sub [:wallet/visible-assets-with-values address])
source? (rf/sub [:wallet/modal-selecting-source-token?])
currency (rf/sub [:wallet/currency])]
{:keys [tokens]} (rf/sub [:wallet-legacy/visible-assets-with-values address])
source? (rf/sub [:wallet-legacy/modal-selecting-source-token?])
currency (rf/sub [:wallet-legacy/currency])]
[:<>
[topbar/topbar
{:title (if source?
@ -69,8 +69,8 @@
{:token token
:on-press #(re-frame/dispatch
[(if source?
::wallet.swap/set-from-token
::wallet.swap/set-to-token)
::wallet-legacy.swap/set-from-token
::wallet-legacy.swap/set-to-token)
(:symbol token)])
:currency (:code currency)}])]]))
@ -92,7 +92,7 @@
[{:keys [token source?]}]
(let [token-icon-source (-> token :icon :source)]
[react/touchable-highlight
{:on-press #(re-frame/dispatch [::wallet.swap/open-asset-selector-modal source?])}
{:on-press #(re-frame/dispatch [::wallet-legacy.swap/open-asset-selector-modal source?])}
[react/view
{:style {:flex-direction :row
:align-items :center
@ -139,7 +139,7 @@
:editable true
:auto-focus true
:on-change-text #(re-frame/dispatch [(when source?
::wallet.swap/set-from-token-amount)
::wallet-legacy.swap/set-from-token-amount)
%])
:placeholder "0.0"}]]
[token-display
@ -152,7 +152,7 @@
{:margin-vertical 8}
[quo/separator]
[react/touchable-opacity
{:on-press #(re-frame/dispatch [::wallet.swap/switch-from-token-with-to])}
{:on-press #(re-frame/dispatch [::wallet-legacy.swap/switch-from-token-with-to])}
[react/view
{:style {:background-color colors/gray-lighter
:width 40
@ -412,7 +412,7 @@
[pill-button
{:label (i18n/label :t/switch-to-simple-interface)
:margin-left 0
:on-press #(re-frame/dispatch [::wallet.swap/set-advanced-mode false])}]]
:on-press #(re-frame/dispatch [::wallet-legacy.swap/set-advanced-mode false])}]]
[transaction-fee-card
{:gas-amount 21000
:price-limit 74
@ -432,10 +432,10 @@
[]
(let [{:keys [name]}
(rf/sub [:multiaccount/current-account])
all-tokens (rf/sub [:wallet/all-tokens])
from-symbol (rf/sub [:wallet/swap-from-token])
to-symbol (rf/sub [:wallet/swap-to-token])
advanced-mode? (rf/sub [:wallet/swap-advanced-mode?])
all-tokens (rf/sub [:wallet-legacy/all-tokens])
from-symbol (rf/sub [:wallet-legacy/swap-from-token])
to-symbol (rf/sub [:wallet-legacy/swap-to-token])
advanced-mode? (rf/sub [:wallet-legacy/swap-advanced-mode?])
amount "0.02"
from-token (tokens/symbol->token all-tokens (or from-symbol :DGX))
to-token (tokens/symbol->token all-tokens (or to-symbol :SNT))]
@ -481,12 +481,12 @@
[quo/text {} (i18n/label :t/priority)]
[pill-button
{:label (i18n/label :t/advanced)
:on-press #(re-frame/dispatch [::wallet.swap/set-advanced-mode true])}]]
:on-press #(re-frame/dispatch [::wallet-legacy.swap/set-advanced-mode true])}]]
[quo/text {:color :secondary} "0.0034 ETH/ $ 8.09"]])
(comment
(re-frame/dispatch [::wallet.swap/set-advanced-mode false]))
(re-frame/dispatch [::wallet-legacy.swap/set-advanced-mode false]))
(when-not advanced-mode?
[react/view {:style {:padding-horizontal 16}}

View File

@ -80,7 +80,7 @@
(defn chain-explorer-link
[address]
(let [link @(re-frame/subscribe [:wallet/chain-explorer-link address])]
(let [link @(re-frame/subscribe [:wallet-legacy/chain-explorer-link address])]
[react/touchable-highlight
{:on-press #(when link
(.openURL ^js react/linking link))}
@ -127,13 +127,14 @@
(defn history-list
[{:keys [transaction-history-sections total]} address]
(let [fetching-recent-history? @(re-frame/subscribe [:wallet/fetching-recent-tx-history? address])
fetching-more-history? @(re-frame/subscribe [:wallet/fetching-tx-history? address])
(let [fetching-recent-history? @(re-frame/subscribe [:wallet-legacy/fetching-recent-tx-history?
address])
fetching-more-history? @(re-frame/subscribe [:wallet-legacy/fetching-tx-history? address])
keycard-account? @(re-frame/subscribe [:multiaccounts/keycard-account?])
custom-rpc-node? @(re-frame/subscribe [:custom-rpc-node])
non-archival-rpc-node? @(re-frame/subscribe [:wallet/non-archival-node])
binance-chain? @(re-frame/subscribe [:wallet/binance-chain?])
all-fetched? @(re-frame/subscribe [:wallet/tx-history-fetched? address])
non-archival-rpc-node? @(re-frame/subscribe [:wallet-legacy/non-archival-node])
binance-chain? @(re-frame/subscribe [:wallet-legacy/binance-chain?])
all-fetched? @(re-frame/subscribe [:wallet-legacy/tx-history-fetched? address])
syncing-allowed? @(re-frame/subscribe [:mobile-network/syncing-allowed?])]
[react/view {:flex 1}
[chain-explorer-link address]
@ -280,7 +281,7 @@
(letsubs [{:keys [url type confirmations confirmations-progress
date amount-text currency-text]
:as transaction}
[:wallet.transactions.details/screen tx-hash address]]
[:wallet-legacy.transactions.details/screen tx-hash address]]
[react/view {:flex 1}
;;TODO options should be replaced by bottom sheet ,and topbar should be used here
[topbar/topbar

View File

@ -115,7 +115,7 @@
[cofx data]
(rf/merge cofx
(choose-recipient/parse-eip681-uri-and-resolve-ens data true)
(navigation/navigate-to :wallet nil)))
(navigation/navigate-to :wallet-legacy nil)))
(defn existing-account?
[{:keys [db]} address]

View File

@ -14,7 +14,7 @@
[status-im.utils.deprecated-types :as types]
[status-im.utils.hex :as hex]
[status-im.utils.mobile-sync :as utils.mobile-sync]
[status-im.wallet.core :as wallet]
[status-im.wallet.core :as wallet-legacy]
[status-im.wallet.prices :as prices]
[status-im2.constants :as constants]
[status-im2.navigation.events :as navigation]
@ -27,7 +27,7 @@
[utils.security.core :as security]))
(rf/defn start-adding-new-account
{:events [:wallet.accounts/start-adding-new-account]}
{:events [:wallet-legacy.accounts/start-adding-new-account]}
[{:keys [db] :as cofx} {:keys [type] :as add-account}]
(let [{:keys [latest-derived-path]} (:profile/profile db)
path-num (inc latest-derived-path)
@ -54,7 +54,7 @@
(let [{:keys [error publicKey address]} (types/json->clj result)]
(if error
(re-frame/dispatch [::new-account-error :account-error error])
(re-frame/dispatch [:wallet.accounts/account-stored
(re-frame/dispatch [:wallet-legacy.accounts/account-stored
{:address address
:public-key publicKey
:type type
@ -93,7 +93,7 @@
(if error
(re-frame/dispatch [::new-account-error :account-error error])
(re-frame/dispatch
[:wallet.accounts/account-stored
[:wallet-legacy.accounts/account-stored
{:address address
:public-key publicKey
:key-uid keyUid
@ -123,7 +123,8 @@
(native-module/verify
address
hashed-password
#(re-frame/dispatch [:wallet.accounts/add-new-account-password-verifyied % hashed-password]))))
#(re-frame/dispatch [:wallet-legacy.accounts/add-new-account-password-verifyied %
hashed-password]))))
(re-frame/reg-fx
::generate-account
@ -166,11 +167,11 @@
[{:keys [db]} passphrase hashed-password]
{:db (assoc-in db [:add-account :step] :generating)
::multiaccounts/validate-mnemonic [(security/safe-unmask-data passphrase)
#(re-frame/dispatch [:wallet.accounts/seed-validated
#(re-frame/dispatch [:wallet-legacy.accounts/seed-validated
% passphrase hashed-password])]})
(rf/defn new-account-seed-validated
{:events [:wallet.accounts/seed-validated]}
{:events [:wallet-legacy.accounts/seed-validated]}
[{:keys [db] :as cofx} phrase-warnings passphrase hashed-password]
(let [error (:error (types/json->clj phrase-warnings))
{:keys [key-uid]} (:profile/profile db)]
@ -220,7 +221,7 @@
(rf/merge cofx
{:json-rpc/call [{:method method
:params params
:on-success #(re-frame/dispatch [::wallet/restart])}]
:on-success #(re-frame/dispatch [::wallet-legacy/restart])}]
:db (-> db
(assoc :profile/wallet-accounts new-accounts)
(dissoc :add-account))}
@ -231,7 +232,7 @@
{}))))))
(rf/defn account-generated
{:events [:wallet.accounts/account-stored]}
{:events [:wallet-legacy.accounts/account-stored]}
[{:keys [db] :as cofx} {:keys [address] :as account}]
(let [accounts (:profile/wallet-accounts db)]
(if (some #(when (= (:address %) address) %) accounts)
@ -240,9 +241,9 @@
{:db (update-in db [:add-account :account] merge account)}
(save-new-account)
(if (utils.mobile-sync/syncing-allowed? cofx)
(wallet/set-max-block address 0)
(wallet/update-balances nil true))
(wallet/fetch-collectibles-collection)
(wallet-legacy/set-max-block address 0)
(wallet-legacy/update-balances nil true))
(wallet-legacy/fetch-collectibles-collection)
(prices/update-prices)
(navigation/navigate-back)))))
@ -254,7 +255,7 @@
:type :watch})))
(rf/defn add-new-account-password-verifyied
{:events [:wallet.accounts/add-new-account-password-verifyied]}
{:events [:wallet-legacy.accounts/add-new-account-password-verifyied]}
[{:keys [db] :as cofx} result hashed-password]
(let [{:keys [error]} (types/json->clj result)]
(if (not (string/blank? error))
@ -274,7 +275,7 @@
:hashed-password hashed-password}})
(rf/defn set-account-to-watch
{:events [:wallet.accounts/set-account-to-watch]}
{:events [:wallet-legacy.accounts/set-account-to-watch]}
[{:keys [db]} account]
(let [name? (and (>= (count account) 3)
(not (hex/valid-hex? account)))]
@ -286,10 +287,10 @@
[(chain/chain-id db)
(stateofus/ens-name-parse account)
#(re-frame/dispatch
[:wallet.accounts/set-account-to-watch %])]))))
[:wallet-legacy.accounts/set-account-to-watch %])]))))
(rf/defn add-new-account
{:events [:wallet.accounts/add-new-account]}
{:events [:wallet-legacy.accounts/add-new-account]}
[{:keys [db] :as cofx} hashed-password]
(let [{:keys [type step]} (:add-account db)]
(log/debug "[wallet] add-new-account"
@ -306,7 +307,7 @@
nil))))
(rf/defn save-account
{:events [:wallet.accounts/save-account]}
{:events [:wallet-legacy.accounts/save-account]}
[{:keys [db]} account {:keys [name color hidden]}]
(let [accounts (:profile/wallet-accounts db)
new-account (cond-> account
@ -320,7 +321,7 @@
:db (assoc db :profile/wallet-accounts new-accounts)}))
(rf/defn delete-account
{:events [:wallet.accounts/delete-account]}
{:events [:wallet-legacy.accounts/delete-account]}
[{:keys [db] :as cofx} account]
(let [accounts (:profile/wallet-accounts db)
new-accounts (vec (remove #(= account %) accounts))
@ -331,7 +332,7 @@
:on-success #()}]
:db (-> db
(assoc :profile/wallet-accounts new-accounts)
(update-in [:wallet :accounts] dissoc deleted-address))}
(update-in [:wallet-legacy :accounts] dissoc deleted-address))}
(navigation/pop-to-root :shell-stack))))
(re-frame/reg-fx
@ -349,7 +350,7 @@
(on-success))))))))
(rf/defn delete-account-key
{:events [:wallet.accounts/delete-key]}
{:events [:wallet-legacy.accounts/delete-key]}
[{:keys [db] :as cofx} account password on-error]
(let [deleted-address (:address account)
dapps-address (get-in cofx [:db :profile/profile :dapps-address])]
@ -362,11 +363,11 @@
:password password
:on-success #(do
(re-frame/dispatch [:hide-popover])
(re-frame/dispatch [:wallet.accounts/delete-account account]))
(re-frame/dispatch [:wallet-legacy.accounts/delete-account account]))
:on-error on-error}})))
(rf/defn view-only-qr-scanner-result
{:events [:wallet.add-new/qr-scanner-result]}
{:events [:wallet-legacy.add-new/qr-scanner-result]}
[{db :db :as cofx} data _]
(let [address (:address (eip681/parse-uri data))]
(rf/merge cofx
@ -384,7 +385,7 @@
(list-selection/open-share obj)))
(rf/defn wallet-accounts-share
{:events [:wallet.accounts/share]}
{:events [:wallet-legacy.accounts/share]}
[_ address]
{:list.selection/open-share {:message (eip55/address->checksum address)}})

View File

@ -19,23 +19,23 @@
;; FIXME(Ferossgp): Should be part of QR scanner not wallet
(rf/defn toggle-flashlight
{:events [:wallet/toggle-flashlight]}
{:events [:wallet-legacy/toggle-flashlight]}
[{:keys [db]}]
(let [flashlight-state (get-in db [:wallet :send-transaction :camera-flashlight])
(let [flashlight-state (get-in db [:wallet-legacy :send-transaction :camera-flashlight])
toggled-state (if (= :on flashlight-state) :off :on)]
{:db (assoc-in db [:wallet :send-transaction :camera-flashlight] toggled-state)}))
{:db (assoc-in db [:wallet-legacy :send-transaction :camera-flashlight] toggled-state)}))
(defn- find-address-name
[db address]
(:name (contact.db/find-contact-by-address (:contacts/contacts db) address)))
(rf/defn set-recipient
{:events [:wallet.send/set-recipient]}
{:events [:wallet-legacy.send/set-recipient]}
[{:keys [db]} address]
{:db (-> db
(dissoc :wallet/recipient)
(dissoc :wallet-legacy/recipient)
(assoc-in [:ui/search :recipient-filter] nil)
(assoc-in [:wallet/prepare-transaction :to] address))
(assoc-in [:wallet-legacy/prepare-transaction :to] address))
:dispatch [:navigate-back]})
(re-frame/reg-fx
@ -65,7 +65,7 @@
:or {sym :ETH}}
all-tokens]
(assoc db
:wallet/prepare-transaction
:wallet-legacy/prepare-transaction
(cond-> {:to address
:to-name (or name (find-address-name db address))
:from (wallet.utils/get-default-account
@ -80,9 +80,9 @@
sym (assoc :symbol sym))))
(rf/defn request-uri-parsed
{:events [:wallet/request-uri-parsed]}
{:events [:wallet-legacy/request-uri-parsed]}
[{{:networks/keys [networks current-network]
:wallet/keys [all-tokens]
:wallet-legacy/keys [all-tokens]
:as db}
:db}
{:keys [chain-id] :as data}
@ -90,14 +90,14 @@
(let [{:keys [address gasPrice] :as details}
(eip681/extract-request-details data all-tokens)]
(if address
(if (:wallet/recipient db)
(if (:wallet-legacy/recipient db)
{:db (update db
:wallet/recipient assoc
:wallet-legacy/recipient assoc
:resolved-address address
:address address)}
(if (:wallet/prepare-transaction db)
(if (:wallet-legacy/prepare-transaction db)
{:db (update db
:wallet/prepare-transaction assoc
:wallet-legacy/prepare-transaction assoc
:to address
:to-name (find-address-name db address))}
(let [current-chain-id (get-in networks [current-network :config :NetworkId])]
@ -107,7 +107,8 @@
{:signing/update-gas-price
{:success-callback
#(re-frame/dispatch
[:wallet.send/update-gas-price-success :wallet/prepare-transaction %])
[:wallet-legacy.send/update-gas-price-success :wallet-legacy/prepare-transaction
%])
:network-id (get-in (chain/current-network db)
[:config :NetworkId])}})
(when (and chain-id (not= current-chain-id chain-id))
@ -116,14 +117,14 @@
{:ui/show-error (i18n/label :t/wallet-invalid-address {:data uri})})))
(rf/defn qr-scanner-allowed
{:events [:wallet.send/qr-scanner]}
{:events [:wallet-legacy.send/qr-scanner]}
[{:keys [db] :as cofx} options]
(rf/merge cofx
(bottom-sheet/hide-bottom-sheet-old)
(qr-scaner/scan-qr-code options)))
(rf/defn parse-eip681-uri-and-resolve-ens
{:events [:wallet/parse-eip681-uri-and-resolve-ens]}
{:events [:wallet-legacy/parse-eip681-uri-and-resolve-ens]}
[{db :db :as cofx} {:keys [message uri paths ens-names error]} ignore-url]
(if-not error
;; first we get a vector of ens-names to resolve and a vector of paths of these names
@ -136,7 +137,7 @@
:callback
(fn [addresses]
(re-frame/dispatch
[:wallet/request-uri-parsed
[:wallet-legacy/request-uri-parsed
;; we replace ens-names at their path in the message by their actual address
(reduce (fn [message [path address]]
(assoc-in message path address))
@ -153,7 +154,7 @@
{:ui/show-error (i18n/label :t/wallet-invalid-address {:data uri})}))))
(rf/defn qr-scanner-result
{:events [:wallet.send/qr-scanner-result]}
{:events [:wallet-legacy.send/qr-scanner-result]}
[cofx data {:keys [ignore-url]}]
(rf/merge cofx
(navigation/navigate-back)

View File

@ -43,7 +43,7 @@
:on-error on-error}))
(re-frame/reg-fx
:wallet/get-balances
:wallet-legacy/get-balances
(fn [addresses]
(doseq [address addresses]
(get-balance
@ -53,10 +53,10 @@
(defn assoc-error-message
[db error-type err]
(assoc-in db [:wallet :errors error-type] (or err :unknown-error)))
(assoc-in db [:wallet-legacy :errors error-type] (or err :unknown-error)))
(re-frame/reg-fx
:wallet/get-cached-balances
:wallet-legacy/get-cached-balances
(fn [{:keys [addresses on-success on-error]}]
(json-rpc/call
{:method "wallet_getCachedBalances"
@ -68,7 +68,7 @@
[{:keys [db]} scan-all-tokens?]
(let [addresses (map (comp string/lower-case :address)
(get db :profile/wallet-accounts))]
{:wallet/get-cached-balances
{:wallet-legacy/get-cached-balances
{:addresses addresses
:on-success #(re-frame/dispatch [::set-cached-balances addresses % scan-all-tokens?])
:on-error #(re-frame/dispatch [::on-get-cached-balance-fail % scan-all-tokens?])}}))
@ -86,7 +86,7 @@
{:db (assoc-error-message db :balance-update :error-unable-to-get-token-balance)})
(rf/defn open-transaction-details
{:events [:wallet.ui/show-transaction-details]}
{:events [:wallet-legacy.ui/show-transaction-details]}
[cofx hash address]
(navigation/navigate-to cofx :wallet-transaction-details {:hash hash :address address}))
@ -144,13 +144,13 @@
#(re-frame/dispatch [::update-token-balance-fail %])}))
(re-frame/reg-fx
:wallet/get-tokens-balances
:wallet-legacy/get-tokens-balances
get-token-balances)
(rf/defn collectibles-collection-fetch-success
{:events [::collectibles-collection-fetch-success]}
[{:keys [db]} address collection]
{:db (assoc-in db [:wallet/collectible-collections address] collection)})
{:db (assoc-in db [:wallet-legacy/collectible-collections address] collection)})
(rf/defn fetch-collectibles-collection
{:events [::fetch-collectibles-collection]}
@ -175,19 +175,19 @@
{:events [::collectible-assets-fetch-success]}
[{:keys [db]} address collectible-slug assets]
{:db (-> db
(assoc-in [:wallet/fetching-collection-assets collectible-slug] false)
(assoc-in [:wallet/collectible-assets address collectible-slug] assets))})
(assoc-in [:wallet-legacy/fetching-collection-assets collectible-slug] false)
(assoc-in [:wallet-legacy/collectible-assets address collectible-slug] assets))})
(rf/defn collectibles-assets-fetch-error
{:events [::collectibles-assets-fetch-error]}
[{:keys [db]} collectible-slug]
{:db (assoc-in db [:wallet/fetching-collection-assets collectible-slug] false)})
{:db (assoc-in db [:wallet-legacy/fetching-collection-assets collectible-slug] false)})
(rf/defn fetch-collectible-assets-by-owner-and-collection
{:events [::fetch-collectible-assets-by-owner-and-collection]}
[{:keys [db]} address collectible-slug limit]
(let [chain-id (chain/network->chain-id (chain/current-network db))]
{:db (assoc-in db [:wallet/fetching-collection-assets collectible-slug] true)
{:db (assoc-in db [:wallet-legacy/fetching-collection-assets collectible-slug] true)
:json-rpc/call [{:method "wallet_getOpenseaAssetsByOwnerAndCollection"
:params [chain-id address collectible-slug limit]
:on-error (fn [error]
@ -199,7 +199,7 @@
(re-frame/reg-event-fx ::show-nft-details
(fn [{:keys [db]} [asset]]
{:db (assoc db :wallet/selected-collectible asset)
{:db (assoc db :wallet-legacy/selected-collectible asset)
:fx [[:dispatch [:open-modal :nft-details {}]]]}))
(defn rpc->token
@ -216,21 +216,21 @@
(let [default-tokens (utils.core/index-by :address tokens)
;;we want to override custom-tokens by default
all-tokens (merge (rpc->token custom-tokens) default-tokens)]
{:db (assoc db :wallet/all-tokens all-tokens)}))
{:db (assoc db :wallet-legacy/all-tokens all-tokens)}))
(rf/defn initialize-favourites
[{:keys [db]} favourites]
{:db (assoc db
:wallet/favourites
:wallet-legacy/favourites
(reduce (fn [acc {:keys [address] :as favourit}]
(assoc acc address favourit))
{}
favourites))})
(rf/defn update-balances
{:events [:wallet/update-balances]}
{:events [:wallet-legacy/update-balances]}
[{{:keys [network-status]
:wallet/keys [all-tokens]
:wallet-legacy/keys [all-tokens]
:profile/keys [profile wallet-accounts]
:as db}
:db
@ -239,8 +239,9 @@
"accounts" addresses
"scan-all-tokens?" scan-all-tokens?)
(let [addresses (or addresses
(map (comp string/lower-case :address) wallet-accounts))
{:keys [:wallet/visible-tokens]} profile
(map (comp string/lower-case :address)
wallet-accounts))
{:keys [:wallet-legacy/visible-tokens]} profile
chain (chain/chain-keyword db)
assets (get visible-tokens chain)
tokens (->> (vals all-tokens)
@ -256,15 +257,15 @@
(not= network-status :offline))
(rf/merge
cofx
{:wallet/get-balances addresses
:wallet/get-tokens-balances {:addresses addresses
{:wallet-legacy/get-balances addresses
:wallet-legacy/get-tokens-balances {:addresses addresses
:tokens tokens
:assets assets
:scan-all-tokens? scan-all-tokens?}
:db (prices/clear-error-message db :balance-update)}
(when-not assets
(multiaccounts.update/multiaccount-update
:wallet/visible-tokens
:wallet-legacy/visible-tokens
(assoc visible-tokens
chain
(or (config/default-visible-tokens chain)
@ -288,7 +289,7 @@
{:events [::update-balance-success]}
[{:keys [db]} address balance]
{:db (assoc-in db
[:wallet :accounts (eip55/address->checksum address) :balance :ETH]
[:wallet-legacy :accounts (eip55/address->checksum address) :balance :ETH]
(money/bignumber balance))})
(rf/defn set-cached-balances
@ -304,15 +305,15 @@
(defn has-empty-balances?
[db]
(some #(nil? (get-in % [:balance :ETH]))
(get-in db [:wallet :accounts])))
(get-in db [:wallet-legacy :accounts])))
(rf/defn update-toggle-in-settings
[{{:profile/keys [profile] :as db} :db :as cofx} symbol checked?]
(let [chain (chain/chain-keyword db)
visible-tokens (get profile :wallet/visible-tokens)]
visible-tokens (get profile :wallet-legacy/visible-tokens)]
(rf/merge cofx
(multiaccounts.update/multiaccount-update
:wallet/visible-tokens
:wallet-legacy/visible-tokens
(update visible-tokens
chain
#(set-checked % symbol checked?))
@ -321,16 +322,16 @@
(update-balances % nil nil)))))
(rf/defn toggle-visible-token
{:events [:wallet.settings/toggle-visible-token]}
{:events [:wallet-legacy.settings/toggle-visible-token]}
[cofx symbol checked?]
(update-toggle-in-settings cofx symbol checked?))
(rf/defn update-tokens-balances
{:events [::update-tokens-balances-success]}
[{:keys [db]} balances]
(let [accounts (get-in db [:wallet :accounts])]
(let [accounts (get-in db [:wallet-legacy :accounts])]
{:db (assoc-in db
[:wallet :accounts]
[:wallet-legacy :accounts]
(reduce (fn [acc [address balances]]
(assoc-in acc
[address :balance]
@ -354,13 +355,13 @@
{:events [::tokens-found]}
[{:keys [db] :as cofx} balances]
(let [chain (chain/chain-keyword db)
visible-tokens (get-in db [:profile/profile :wallet/visible-tokens])
visible-tokens (get-in db [:profile/profile :wallet-legacy/visible-tokens])
chain-visible-tokens (into (or (config/default-visible-tokens chain)
#{})
(flatten (map keys (vals balances))))]
(rf/merge cofx
(multiaccounts.update/multiaccount-update
:wallet/visible-tokens
:wallet-legacy/visible-tokens
(update visible-tokens chain set/union chain-visible-tokens)
{})
(update-tokens-balances balances)
@ -375,12 +376,12 @@
(update-toggle-in-settings cofx symbol false))
(rf/defn set-and-validate-amount
{:events [:wallet.send/set-amount-text]}
{:events [:wallet-legacy.send/set-amount-text]}
[{:keys [db]} amount]
{:db (assoc-in db [:wallet/prepare-transaction :amount-text] amount)})
{:db (assoc-in db [:wallet-legacy/prepare-transaction :amount-text] amount)})
(rf/defn wallet-send-gas-price-success
{:events [:wallet.send/update-gas-price-success]}
{:events [:wallet-legacy.send/update-gas-price-success]}
[{db :db} tx-entry price {:keys [maxFeePerGas maxPriorityFeePerGas gasPrice]}]
(when (contains? db tx-entry)
(if (eip1559/sync-enabled?)
@ -398,23 +399,23 @@
assoc
:maxFeePerGas (or maxFeePerGas fee-cap)
:maxPriorityFeePerGas (or maxPriorityFeePerGas tip-cap))
(assoc :wallet/current-base-fee current-base-fee
:wallet/normal-base-fee normal-base-fee
:wallet/slow-base-fee slow-base-fee
:wallet/fast-base-fee fast-base-fee
:wallet/current-priority-fee max-priority-fee)
(assoc :wallet-legacy/current-base-fee current-base-fee
:wallet-legacy/normal-base-fee normal-base-fee
:wallet-legacy/slow-base-fee slow-base-fee
:wallet-legacy/fast-base-fee fast-base-fee
:wallet-legacy/current-priority-fee max-priority-fee)
(assoc-in [:signing/edit-fee :gas-price-loading?] false))})
{:db (-> db
(assoc-in [:wallet/prepare-transaction :gasPrice] (or gasPrice price))
(assoc-in [:wallet-legacy/prepare-transaction :gasPrice] (or gasPrice price))
(assoc-in [:signing/edit-fee :gas-price-loading?] false))})))
(rf/defn set-max-amount
{:events [:wallet.send/set-max-amount]}
{:events [:wallet-legacy.send/set-max-amount]}
[{:keys [db]} {:keys [amount decimals symbol]}]
(let [^js gas (money/bignumber 21000)
^js gasPrice (or
(get-in db [:wallet/prepare-transaction :maxFeePerGas])
(get-in db [:wallet/prepare-transaction :gasPrice]))
(get-in db [:wallet-legacy/prepare-transaction :maxFeePerGas])
(get-in db [:wallet-legacy/prepare-transaction :gasPrice]))
^js fee (when gasPrice (.times gas gasPrice))
amount-text (if (= :ETH symbol)
(when (and fee (money/sufficient-funds? fee amount))
@ -423,23 +424,23 @@
(when amount-text
{:db (cond-> db
:always
(assoc-in [:wallet/prepare-transaction :amount-text] amount-text)
(assoc-in [:wallet-legacy/prepare-transaction :amount-text] amount-text)
(= :ETH symbol)
(assoc-in [:wallet/prepare-transaction :gas] gas))})))
(assoc-in [:wallet-legacy/prepare-transaction :gas] gas))})))
(rf/defn set-and-validate-request-amount
{:events [:wallet.request/set-amount-text]}
{:events [:wallet-legacy.request/set-amount-text]}
[{:keys [db]} amount]
{:db (assoc-in db [:wallet/prepare-transaction :amount-text] amount)})
{:db (assoc-in db [:wallet-legacy/prepare-transaction :amount-text] amount)})
(rf/defn request-transaction-button-clicked-from-chat
{:events [:wallet.ui/request-transaction-button-clicked]}
{:events [:wallet-legacy.ui/request-transaction-button-clicked]}
[{:keys [db] :as cofx} {:keys [to amount from token]}]
(let [{:keys [symbol address]} token
from-address (:address from)
identity (:current-chat-id db)]
(rf/merge cofx
{:db (dissoc db :wallet/prepare-transaction)
{:db (dissoc db :wallet-legacy/prepare-transaction)
:json-rpc/call [{:method "wakuext_requestTransaction"
:params [(:public-key to)
amount
@ -450,17 +451,17 @@
:on-success #(re-frame/dispatch [:transport/message-sent %])}]})))
(rf/defn accept-request-transaction-button-clicked-from-command
{:events [:wallet.ui/accept-request-transaction-button-clicked-from-command]}
{:events [:wallet-legacy.ui/accept-request-transaction-button-clicked-from-command]}
[{:keys [db]} chat-id {:keys [value contract] :as request-parameters}]
(let [identity (:current-chat-id db)
all-tokens (:wallet/all-tokens db)
all-tokens (:wallet-legacy/all-tokens db)
{:keys [symbol decimals]}
(if (seq contract)
(get all-tokens contract)
(tokens/native-currency (chain/get-current-network db)))
amount-text (str (money/internal->formatted value symbol decimals))]
{:db (assoc db
:wallet/prepare-transaction
:wallet-legacy/prepare-transaction
{:from (wallet.utils/get-default-account (:profile/wallet-accounts
db))
:to (or (get-in db [:contacts/contacts identity])
@ -476,19 +477,19 @@
:dispatch [:open-modal :prepare-send-transaction]}))
(rf/defn set-and-validate-amount-request
{:events [:wallet.request/set-and-validate-amount]}
{:events [:wallet-legacy.request/set-and-validate-amount]}
[{:keys [db]} amount symbol decimals]
(let [{:keys [value error]} (wallet.db/parse-amount amount decimals)]
{:db (-> db
(assoc-in [:wallet :request-transaction :amount]
(assoc-in [:wallet-legacy :request-transaction :amount]
(money/formatted->internal value symbol decimals))
(assoc-in [:wallet :request-transaction :amount-text] amount)
(assoc-in [:wallet :request-transaction :amount-error] error))}))
(assoc-in [:wallet-legacy :request-transaction :amount-text] amount)
(assoc-in [:wallet-legacy :request-transaction :amount-error] error))}))
(rf/defn set-symbol-request
{:events [:wallet.request/set-symbol]}
{:events [:wallet-legacy.request/set-symbol]}
[{:keys [db]} symbol]
{:db (assoc-in db [:wallet :request-transaction :symbol] symbol)})
{:db (assoc-in db [:wallet-legacy :request-transaction :symbol] symbol)})
(re-frame/reg-fx
::resolve-address
@ -498,15 +499,16 @@
(rf/defn on-recipient-address-resolved
{:events [::recipient-address-resolved]}
[{:keys [db]} address]
{:db (assoc-in db [:wallet/prepare-transaction :to :address] address)
{:db (assoc-in db [:wallet-legacy/prepare-transaction :to :address] address)
:signing/update-gas-price {:success-callback
#(re-frame/dispatch
[:wallet.send/update-gas-price-success :wallet/prepare-transaction %])
[:wallet-legacy.send/update-gas-price-success
:wallet-legacy/prepare-transaction %])
:network-id (get-in (chain/current-network db)
[:config :NetworkId])}})
(rf/defn prepare-transaction-from-chat
{:events [:wallet/prepare-transaction-from-chat]}
{:events [:wallet-legacy/prepare-transaction-from-chat]}
[{:keys [db]}]
(let [identity (:current-chat-id db)
{:keys [ens-verified name] :as contact}
@ -515,7 +517,7 @@
contact.db/public-key->new-contact
contact.db/enrich-contact))]
(cond-> {:db (assoc db
:wallet/prepare-transaction
:wallet-legacy/prepare-transaction
{:from (wallet.utils/get-default-account
(:profile/wallet-accounts db))
:to contact
@ -532,11 +534,11 @@
:cb #(re-frame/dispatch [::recipient-address-resolved %])}))))
(rf/defn prepare-request-transaction-from-chat
{:events [:wallet/prepare-request-transaction-from-chat]}
{:events [:wallet-legacy/prepare-request-transaction-from-chat]}
[{:keys [db]}]
(let [identity (:current-chat-id db)]
{:db (assoc db
:wallet/prepare-transaction
:wallet-legacy/prepare-transaction
{:from (wallet.utils/get-default-account (:profile/wallet-accounts db))
:to (or (get-in db [:contacts/contacts identity])
(-> identity
@ -548,10 +550,10 @@
:dispatch [:open-modal :request-transaction]}))
(rf/defn prepare-transaction-from-wallet
{:events [:wallet/prepare-transaction-from-wallet]}
{:events [:wallet-legacy/prepare-transaction-from-wallet]}
[{:keys [db]} account]
{:db (assoc db
:wallet/prepare-transaction
:wallet-legacy/prepare-transaction
{:from account
:to nil
:symbol :ETH
@ -559,21 +561,22 @@
:dispatch [:open-modal :prepare-send-transaction]
:signing/update-gas-price {:success-callback
#(re-frame/dispatch
[:wallet.send/update-gas-price-success :wallet/prepare-transaction %])
[:wallet-legacy.send/update-gas-price-success
:wallet-legacy/prepare-transaction %])
:network-id (get-in (chain/current-network db)
[:config :NetworkId])}})
(rf/defn cancel-transaction-command
{:events [:wallet/cancel-transaction-command]}
{:events [:wallet-legacy/cancel-transaction-command]}
[{:keys [db]}]
(let [identity (:current-chat-id db)]
{:db (dissoc db :wallet/prepare-transaction)}))
{:db (dissoc db :wallet-legacy/prepare-transaction)}))
(rf/defn finalize-transaction-from-command
{:events [:wallet/finalize-transaction-from-command]}
{:events [:wallet-legacy/finalize-transaction-from-command]}
[{:keys [db]} account to symbol amount]
{:db (assoc db
:wallet/prepare-transaction
:wallet-legacy/prepare-transaction
{:from account
:to to
:symbol symbol
@ -581,46 +584,47 @@
:from-command? true})})
(rf/defn view-only-qr-scanner-allowed
{:events [:wallet.add-new/qr-scanner]}
{:events [:wallet-legacy.add-new/qr-scanner]}
[{:keys [db] :as cofx} options]
(rf/merge cofx
{:db (update-in db [:add-account] dissoc :address)}
(qr-scaner/scan-qr-code options)))
(rf/defn wallet-send-set-symbol
{:events [:wallet.send/set-symbol]}
{:events [:wallet-legacy.send/set-symbol]}
[{:keys [db] :as cofx} symbol]
(rf/merge cofx
{:db (assoc-in db [:wallet/prepare-transaction :symbol] symbol)}
{:db (assoc-in db [:wallet-legacy/prepare-transaction :symbol] symbol)}
(bottom-sheet/hide-bottom-sheet-old)))
(rf/defn wallet-send-set-field
{:events [:wallet.send/set-field]}
{:events [:wallet-legacy.send/set-field]}
[{:keys [db] :as cofx} field value]
(rf/merge cofx
{:db (assoc-in db [:wallet/prepare-transaction field] value)}
{:db (assoc-in db [:wallet-legacy/prepare-transaction field] value)}
(bottom-sheet/hide-bottom-sheet-old)))
(rf/defn wallet-request-set-field
{:events [:wallet.request/set-field]}
{:events [:wallet-legacy.request/set-field]}
[{:keys [db] :as cofx} field value]
(rf/merge cofx
{:db (assoc-in db [:wallet/prepare-transaction field] value)}
{:db (assoc-in db [:wallet-legacy/prepare-transaction field] value)}
(bottom-sheet/hide-bottom-sheet-old)))
(re-frame/reg-event-fx :wallet.send/navigate-to-recipient-code
(re-frame/reg-event-fx :wallet-legacy.send/navigate-to-recipient-code
(fn [{:keys [db]}]
{:db (-> db (assoc :wallet/recipient {}))
{:db (-> db (assoc :wallet-legacy/recipient {}))
:fx [[:dispatch [:bottom-sheet/hide-old]]
[:dispatch [:open-modal :recipient nil]]]}))
(rf/defn show-delete-account-confirmation
{:events [:wallet.settings/show-delete-account-confirmation]}
{:events [:wallet-legacy.settings/show-delete-account-confirmation]}
[_ account]
{:ui/show-confirmation {:title (i18n/label :t/are-you-sure?)
:confirm-button-text (i18n/label :t/yes)
:cancel-button-text (i18n/label :t/no)
:on-accept #(re-frame/dispatch [:wallet.accounts/delete-account
:on-accept #(re-frame/dispatch
[:wallet-legacy.accounts/delete-account
account])
:on-cancel #()}})
@ -665,7 +669,7 @@
max-block
block))
nil
(get-in db [:wallet :accounts])))
(get-in db [:wallet-legacy :accounts])))
(defn custom-rpc-node? [{:keys [id]}] (= 45 (count id)))
@ -680,7 +684,7 @@
(and max-block
(zero? max-block)
(nil? (get db :wallet/keep-watching-until-ms)))
(nil? (get db :wallet-legacy/keep-watching-until-ms)))
(log/info "[wallet] No transactions found")
:else
@ -697,8 +701,8 @@
[{:keys [db] :as cofx}]
(log/info "[wallet] after-checking-history")
{:db (dissoc db
:wallet/recent-history-fetching-started?
:wallet/refreshing-history?)})
:wallet-legacy/recent-history-fetching-started?
:wallet-legacy/refreshing-history?)})
(defn set-timeout
[db]
@ -719,8 +723,8 @@
(assoc :wallet-service/restart-timeout timeout
:wallet-service/custom-interval (get-next-custom-interval
db)
:wallet/was-started? true
:wallet/on-recent-history-fetching
:wallet-legacy/was-started? true
:wallet-legacy/on-recent-history-fetching
on-recent-history-fetching))
::check-recent-history addresses
::utils.utils/clear-timeouts
@ -747,7 +751,7 @@
(rf/defn restart-wallet-service-after-background
[{:keys [now db] :as cofx} background-time]
(when (and (get db :wallet/was-started?)
(when (and (get db :wallet-legacy/was-started?)
(> (- now background-time)
background-cooldown-time))
(restart-wallet-service cofx nil)))
@ -783,17 +787,17 @@
(def pull-to-refresh-cooldown-period (* 1 60 1000))
(rf/defn restart-on-pull
{:events [:wallet.ui/pull-to-refresh-history]}
{:events [:wallet-legacy.ui/pull-to-refresh-history]}
[{:keys [db now] :as cofx}]
(let [last-pull (get db :wallet/last-pull-time)
fetching-history? (get db :wallet/recent-history-fetching-started?)]
(let [last-pull (get db :wallet-legacy/last-pull-time)
fetching-history? (get db :wallet-legacy/recent-history-fetching-started?)]
(when (and (not fetching-history?)
(or (not last-pull)
(> (- now last-pull) pull-to-refresh-cooldown-period)))
(rf/merge
{:db (assoc db
:wallet/last-pull-time now
:wallet/refreshing-history? true)}
:wallet-legacy/last-pull-time now
:wallet-legacy/refreshing-history? true)}
(restart-wallet-service
{:force-restart? true})))))
@ -831,53 +835,53 @@
{:events [::wallet-stack]}
[{:keys [db]}]
(let [wallet-set-up-passed? (get-in db [:profile/profile :wallet-set-up-passed?])
sign-phrase-showed? (get db :wallet/sign-phrase-showed?)]
{:dispatch-n [[:wallet.ui/pull-to-refresh]] ;TODO temporary simple fix for v1
sign-phrase-showed? (get db :wallet-legacy/sign-phrase-showed?)]
{:dispatch-n [[:wallet-legacy.ui/pull-to-refresh]] ;TODO temporary simple fix for v1
;;[:show-popover {:view [signing-phrase/signing-phrase]}]]
:db (if (or wallet-set-up-passed? sign-phrase-showed?)
db
(assoc db :wallet/sign-phrase-showed? true))}))
(assoc db :wallet-legacy/sign-phrase-showed? true))}))
(rf/defn wallet-wallet-add-custom-token
{:events [:wallet/wallet-add-custom-token]}
{:events [:wallet-legacy/wallet-add-custom-token]}
[{:keys [db]}]
{:db (dissoc db :wallet/custom-token-screen)})
{:db (dissoc db :wallet-legacy/custom-token-screen)})
(rf/defn hide-buy-crypto
{:events [::hide-buy-crypto]}
[{:keys [db]}]
{:db (assoc db :wallet/buy-crypto-hidden true)
{:db (assoc db :wallet-legacy/buy-crypto-hidden true)
:async-storage-set {:buy-crypto-hidden true}})
(rf/defn store-buy-crypto
{:events [::store-buy-crypto-preference]}
[{:keys [db]} {:keys [buy-crypto-hidden]}]
{:db (assoc db :wallet/buy-crypto-hidden buy-crypto-hidden)})
{:db (assoc db :wallet-legacy/buy-crypto-hidden buy-crypto-hidden)})
(rf/defn contract-address-paste
{:events [:wallet.custom-token.ui/contract-address-paste]}
{:events [:wallet-legacy.custom-token.ui/contract-address-paste]}
[_]
{:wallet.custom-token/contract-address-paste nil})
{:wallet-legacy.custom-token/contract-address-paste nil})
(rf/defn transactions-add-filter
{:events [:wallet.transactions/add-filter]}
{:events [:wallet-legacy.transactions/add-filter]}
[{:keys [db]} id]
{:db (update-in db [:wallet :filters] conj id)})
{:db (update-in db [:wallet-legacy :filters] conj id)})
(rf/defn transactions-remove-filter
{:events [:wallet.transactions/remove-filter]}
{:events [:wallet-legacy.transactions/remove-filter]}
[{:keys [db]} id]
{:db (update-in db [:wallet :filters] disj id)})
{:db (update-in db [:wallet-legacy :filters] disj id)})
(rf/defn transactions-add-all-filters
{:events [:wallet.transactions/add-all-filters]}
{:events [:wallet-legacy.transactions/add-all-filters]}
[{:keys [db]}]
{:db (assoc-in db
[:wallet :filters]
[:wallet-legacy :filters]
wallet.db/default-wallet-filters)})
(rf/defn settings-navigate-back-pressed
{:events [:wallet.settings.ui/navigate-back-pressed]}
{:events [:wallet-legacy.settings.ui/navigate-back-pressed]}
[cofx on-close]
(rf/merge cofx
(when on-close
@ -886,32 +890,34 @@
(rf/defn stop-fetching-on-empty-tx-history
[{:keys [db now] :as cofx} transfers]
(let [non-empty-history? (get db :wallet/non-empty-tx-history?)
(let [non-empty-history? (get db :wallet-legacy/non-empty-tx-history?)
custom-node? (custom-rpc-node?
(chain/current-network db))
until-ms (get db :wallet/keep-watching-until-ms)]
until-ms (get db :wallet-legacy/keep-watching-until-ms)]
(when-not (and until-ms (> until-ms now))
(rf/merge
cofx
{:db (dissoc db :wallet/keep-watching-until-ms)}
{:db (dissoc db :wallet-legacy/keep-watching-until-ms)}
(if (and (not non-empty-history?)
(empty? transfers)
(not custom-node?))
(clear-timeouts)
(fn [{:keys [db]}]
{:db (assoc db :wallet/non-empty-tx-history? true)}))))))
{:db (assoc db :wallet-legacy/non-empty-tx-history? true)}))))))
(rf/defn keep-watching-history
{:events [:wallet/keep-watching]}
{:events [:wallet-legacy/keep-watching]}
[{:keys [db now] :as cofx}]
(let [non-empty-history? (get db :wallet/non-empty-tx-history?)
(let [non-empty-history? (get db :wallet-legacy/non-empty-tx-history?)
old-timeout (get db :wallet-service/restart-timeout)
db (assoc db :wallet-service/custom-interval :ms-2-min)
timeout (set-timeout db)]
{:db (assoc db
:wallet/keep-watching-until-ms (+ now (datetime/minutes 30))
:wallet-legacy/keep-watching-until-ms (+ now
(datetime/minutes 30))
:wallet-service/restart-timeout timeout
:wallet-service/custom-interval (get-next-custom-interval db))
:wallet-service/custom-interval (get-next-custom-interval
db))
::utils.utils/clear-timeouts [old-timeout]}))
(re-frame/reg-fx
@ -925,15 +931,15 @@
:on-error #(log/info "Initial blocks range was not set")})))
(rf/defn set-initial-blocks-range
{:events [:wallet/set-initial-blocks-range]}
{:events [:wallet-legacy/set-initial-blocks-range]}
[{:keys [db]}]
{:db (assoc db :wallet/new-account true)
{:db (assoc db :wallet-legacy/new-account true)
::set-inital-range nil})
(rf/defn tab-opened
{:events [:wallet/tab-opened]}
{:events [:wallet-legacy/tab-opened]}
[{:keys [db] :as cofx}]
(when-not (get db :wallet/was-started?)
(when-not (get db :wallet-legacy/was-started?)
(restart-wallet-service cofx nil)))
(rf/defn set-max-block
@ -941,7 +947,7 @@
(log/debug "set-max-block"
"address" address
"block" block)
{:db (assoc-in db [:wallet :accounts address :max-block] block)})
{:db (assoc-in db [:wallet-legacy :accounts address :max-block] block)})
(rf/defn set-max-block-with-transfers
[{:keys [db] :as cofx} address transfers]
@ -950,15 +956,15 @@
(if (> block max-block)
block
max-block))
(get-in db [:wallet :accounts address :max-block] 0)
(get-in db [:wallet-legacy :accounts address :max-block] 0)
transfers)]
(set-max-block cofx address max-block)))
(rf/defn share
{:events [:wallet/share-popover]}
{:events [:wallet-legacy/share-popover]}
[{:keys [db] :as cofx} address]
(let [non-empty-history? (get db :wallet/non-empty-tx-history?)
restart? (and (not (get db :wallet/non-empty-tx-history?))
(let [non-empty-history? (get db :wallet-legacy/non-empty-tx-history?)
restart? (and (not (get db :wallet-legacy/non-empty-tx-history?))
(not (get db :wallet-service/restart-timeout)))]
(rf/merge
cofx
@ -973,10 +979,10 @@
(json-rpc/call
{:method "wallet_getPendingTransactions"
:params []
:on-success #(re-frame/dispatch [:wallet/on-retreiving-pending-transactions %])})))
:on-success #(re-frame/dispatch [:wallet-legacy/on-retreiving-pending-transactions %])})))
(rf/defn get-pending-transactions
{:events [:wallet/get-pending-transactions]}
{:events [:wallet-legacy/get-pending-transactions]}
[_]
(log/info "[wallet] get pending transactions")
{::get-pending-transactions nil})
@ -984,7 +990,7 @@
(defn normalize-transaction
[db {:keys [gasPrice gasLimit value from to] :as transaction}]
(let [sym (-> transaction :symbol keyword)
token (tokens/symbol->token (:wallet/all-tokens db) sym)]
token (tokens/symbol->token (:wallet-legacy/all-tokens db) sym)]
(-> transaction
(select-keys [:timestamp :hash :data])
(assoc :from (eip55/address->checksum from)
@ -997,12 +1003,12 @@
:gas-limit (money/bignumber gasLimit)))))
(rf/defn on-retriving-pending-transactions
{:events [:wallet/on-retreiving-pending-transactions]}
{:events [:wallet-legacy/on-retreiving-pending-transactions]}
[{:keys [db]} raw-transactions]
(log/info "[wallet] pending transactions")
{:db
(reduce (fn [db {:keys [from] :as transaction}]
(let [path [:wallet :accounts from :transactions (:hash transaction)]]
(let [path [:wallet-legacy :accounts from :transactions (:hash transaction)]]
(if-not (get-in db path)
(assoc-in db path transaction)
db)))
@ -1011,7 +1017,7 @@
::start-watching (map (juxt :from :hash :network_id) raw-transactions)})
(re-frame/reg-fx
:wallet/delete-pending-transactions
:wallet-legacy/delete-pending-transactions
(fn [hashes]
(log/info "[wallet] delete pending transactions")
(doseq [tx-hash hashes]
@ -1024,10 +1030,10 @@
{:events [:multiaccounts.ui/switch-transactions-management-enabled]}
[{:keys [db]} enabled?]
{:async-storage-set {:transactions-management-enabled? enabled?}
:db (assoc db :wallet/transactions-management-enabled? enabled?)})
:db (assoc db :wallet-legacy/transactions-management-enabled? enabled?)})
(re-frame/reg-fx
:wallet/initialize-transactions-management-enabled
:wallet-legacy/initialize-transactions-management-enabled
(fn []
(let [callback #(re-frame/dispatch [:multiaccounts.ui/switch-transactions-management-enabled %])]
(async-storage/get-item :transactions-management-enabled? callback))))
@ -1058,13 +1064,13 @@
tokens))
(re-frame/reg-fx
:wallet/get-tokens
:wallet-legacy/get-tokens
(fn [[network-id accounts recovered-account?]]
(utils.utils/set-timeout
(fn []
(json-rpc/call {:method "wallet_getTokens"
:params [(int network-id)]
:on-success #(re-frame/dispatch [:wallet/initialize-wallet
:on-success #(re-frame/dispatch [:wallet-legacy/initialize-wallet
accounts
(normalize-tokens network-id %)
nil nil
@ -1074,7 +1080,7 @@
(re-frame/reg-fx
;;TODO: this could be replaced by a single API call on status-go side
:wallet/initialize-wallet
:wallet-legacy/initialize-wallet
(fn [[network-id network callback]]
(-> (js/Promise.all
(clj->js
@ -1178,7 +1184,7 @@
(native-module/start-local-notifications)))
(rf/defn initialize-wallet
{:events [:wallet/initialize-wallet]}
{:events [:wallet-legacy/initialize-wallet]}
[{:keys [db] :as cofx} accounts tokens custom-tokens
favourites scan-all-tokens? new-account?]
(rf/merge
@ -1208,7 +1214,7 @@
:else
(get-cached-balances scan-all-tokens?))
(when-not (get db :wallet/new-account)
(when-not (get db :wallet-legacy/new-account)
(restart-wallet-service nil))
(when (chain/binance-chain? db)
(request-current-block-update))

View File

@ -13,46 +13,47 @@
[utils.re-frame :as rf]))
(re-frame/reg-fx
:wallet.custom-token/contract-address-paste
:wallet-legacy.custom-token/contract-address-paste
(fn []
(react/get-from-clipboard
#(re-frame/dispatch [:wallet.custom-token/contract-address-is-pasted (string/trim %)]))))
#(re-frame/dispatch [:wallet-legacy.custom-token/contract-address-is-pasted (string/trim %)]))))
(defn field-exists?
[{:wallet/keys [all-tokens]} field-key field-value]
[{:wallet-legacy/keys [all-tokens]} field-key field-value]
(some #(= field-value (get % field-key))
(vals all-tokens)))
(defn token-in-list?
[{:wallet/keys [all-tokens]} contract]
[{:wallet-legacy/keys [all-tokens]} contract]
(not (nil? (get all-tokens (string/lower-case contract)))))
(rf/defn contract-address-is-changed
{:events [:wallet.custom-token/contract-address-is-pasted]}
{:events [:wallet-legacy.custom-token/contract-address-is-pasted]}
[{:keys [db]} contract]
(if (address/address? contract)
(if (token-in-list? db contract)
{:db (assoc db
:wallet/custom-token-screen
:wallet-legacy/custom-token-screen
{:contract contract :error (i18n/label :t/already-have-asset)})}
{:db (assoc db
:wallet/custom-token-screen
:wallet-legacy/custom-token-screen
{:contract contract :in-progress? true})
:json-rpc/call [{:method "wallet_discoverToken"
:params [(chain/chain-id db) contract]
:on-success #(re-frame/dispatch [:wallet.custom-token/token-discover-result %])
:on-error #(re-frame/dispatch [:wallet.custom-token/not-supported])}]})
:on-success #(re-frame/dispatch
[:wallet-legacy.custom-token/token-discover-result %])
:on-error #(re-frame/dispatch [:wallet-legacy.custom-token/not-supported])}]})
{:db (assoc db
:wallet/custom-token-screen
:wallet-legacy/custom-token-screen
{:contract contract
:error (i18n/label :t/wrong-address)})}))
(rf/defn token-discover-result
{:events [:wallet.custom-token/token-discover-result]}
{:events [:wallet-legacy.custom-token/token-discover-result]}
[{:keys [db]} {:keys [name symbol decimals]}]
(let [symbol-exists? (field-exists? db :symbol (keyword symbol))]
{:db (update db
:wallet/custom-token-screen
:wallet-legacy/custom-token-screen
merge
{:name name
:symbol symbol
@ -62,15 +63,15 @@
:in-progress? nil})}))
(rf/defn not-supported
{:events [:wallet.custom-token/not-supported]}
{:events [:wallet-legacy.custom-token/not-supported]}
[{:keys [db]}]
{:db (assoc-in db [:wallet/custom-token-screen :in-progress?] nil)
{:db (assoc-in db [:wallet-legacy/custom-token-screen :in-progress?] nil)
:utils/show-popup {:content (i18n/label :t/contract-isnt-supported)}})
(rf/defn add-custom-token
{:events [:wallet.custom-token.ui/add-pressed]}
{:events [:wallet-legacy.custom-token.ui/add-pressed]}
[{:keys [db] :as cofx}]
(let [{:keys [contract name symbol decimals]} (get db :wallet/custom-token-screen)
(let [{:keys [contract name symbol decimals]} (get db :wallet-legacy/custom-token-screen)
symbol (keyword symbol)
new-token {:address contract
:name name
@ -79,7 +80,7 @@
:color (rand-nth colors/chat-colors)}]
(rf/merge cofx
{:db (assoc-in db
[:wallet/all-tokens contract]
[:wallet-legacy/all-tokens contract]
(assoc new-token :custom? true))
:json-rpc/call [{:method "wallet_addCustomToken"
:params [new-token]
@ -89,10 +90,10 @@
(navigation/navigate-back))))
(rf/defn remove-custom-token
{:events [:wallet.custom-token.ui/remove-pressed]}
{:events [:wallet-legacy.custom-token.ui/remove-pressed]}
[{:keys [db] :as cofx} {:keys [address] :as token} navigate-back?]
(rf/merge cofx
{:db (update db :wallet/all-tokens dissoc address)
{:db (update db :wallet-legacy/all-tokens dissoc address)
:json-rpc/call [{:method "wallet_deleteCustomToken"
:params [address]
:on-success #()}]}
@ -101,12 +102,12 @@
(navigation/navigate-back))))
(rf/defn field-is-edited
{:events [:wallet.custom-token.ui/field-is-edited]}
{:events [:wallet-legacy.custom-token.ui/field-is-edited]}
[{:keys [db] :as cofx} field-key value]
(case field-key
:contract (contract-address-is-changed cofx value)
:name {:db (update db
:wallet/custom-token-screen
:wallet-legacy/custom-token-screen
merge
{field-key
value
@ -115,7 +116,7 @@
(i18n/label :t/you-already-have-an-asset
{:value value}))})}
:symbol {:db (update db
:wallet/custom-token-screen
:wallet-legacy/custom-token-screen
merge
{field-key
value
@ -123,5 +124,5 @@
(when (field-exists? db field-key (keyword value))
(i18n/label :t/you-already-have-an-asset {:value value}))})}
:decimals {:db (assoc-in db
[:wallet/custom-token-screen :decimals]
[:wallet-legacy/custom-token-screen :decimals]
value)}))

View File

@ -12,11 +12,11 @@
(defn assoc-error-message
[db error-type err]
(assoc-in db [:wallet :errors error-type] (or err :unknown-error)))
(assoc-in db [:wallet-legacy :errors error-type] (or err :unknown-error)))
(defn clear-error-message
[db error-type]
(update-in db [:wallet :errors] dissoc error-type))
(update-in db [:wallet-legacy :errors] dissoc error-type))
(defn tokens-symbols
[visible-token-symbols all-tokens]
@ -24,7 +24,7 @@
(set (map :symbol (tokens/nfts-for all-tokens)))))
(re-frame/reg-fx
:wallet/get-prices
:wallet-legacy/get-prices
(fn [{:keys [from to mainnet? success-event error-event]}]
(prices/get-prices from
to
@ -48,9 +48,9 @@
(assoc :prices-loading? false))})
(rf/defn update-prices
{:events [:wallet.ui/pull-to-refresh]}
[{{:keys [network-status :wallet/all-tokens]
{:keys [currency :wallet/visible-tokens]
{:events [:wallet-legacy.ui/pull-to-refresh]}
[{{:keys [network-status :wallet-legacy/all-tokens]
{:keys [currency :wallet-legacy/visible-tokens]
:or {currency :usd}}
:profile/profile
:as db}
@ -61,7 +61,7 @@
tokens (tokens-symbols assets all-tokens)
currency (get currency/currencies currency)]
(when (not= network-status :offline)
{:wallet/get-prices
{:wallet-legacy/get-prices
{:from (if mainnet?
(conj tokens "ETH")
[(-> (tokens/native-currency (chain/get-current-network db))

View File

@ -25,15 +25,15 @@
(ens/address chain-id ens-name cb)))
(re-frame/reg-fx
:wallet.recipient/address-paste
:wallet-legacy.recipient/address-paste
(fn []
(react/get-from-clipboard
#(re-frame/dispatch [:wallet.recipient/address-changed (string/trim %)]))))
#(re-frame/dispatch [:wallet-legacy.recipient/address-changed (string/trim %)]))))
(rf/defn address-paste-pressed
{:events [:wallet.recipient/address-paste-pressed]}
{:events [:wallet-legacy.recipient/address-paste-pressed]}
[_]
{:wallet.recipient/address-paste nil})
{:wallet-legacy.recipient/address-paste nil})
(rf/defn set-recipient
{:events [::recipient-address-resolved]}
@ -47,8 +47,8 @@
(if (eip55/valid-address-checksum? checksum)
(rf/merge cofx
{:db (-> db
(assoc-in [:wallet/recipient :searching] false)
(assoc-in [:wallet/recipient :resolved-address] checksum))}
(assoc-in [:wallet-legacy/recipient :searching] false)
(assoc-in [:wallet-legacy/recipient :resolved-address] checksum))}
(json-rpc/call
{:method "eth_getCode"
:params [checksum "latest"]
@ -58,7 +58,7 @@
:t/warning-sending-to-contract-descr)))
:number-of-retries 3}))
{:ui/show-error (i18n/label :t/wallet-invalid-address-checksum {:data recipient})
:db (assoc-in db [:wallet/recipient :searching] false)}))
:db (assoc-in db [:wallet-legacy/recipient :searching] false)}))
(and (not (string/blank? recipient))
(not (string/starts-with? recipient "0x"))
(ens/valid-eth-name-prefix? recipient))
@ -72,34 +72,34 @@
{:chain-id (chain/chain-id db)
:ens-name ens-name
:cb #(re-frame/dispatch [::recipient-address-resolved % @resolve-last-id])}})
{:db (assoc-in db [:wallet/recipient :searching] false)}))
{:db (assoc-in db [:wallet-legacy/recipient :searching] false)}))
:else
{:db (assoc-in db [:wallet/recipient :searching] false)}))))
{:db (assoc-in db [:wallet-legacy/recipient :searching] false)}))))
(rf/defn address-changed
{:events [:wallet.recipient/address-changed]}
{:events [:wallet-legacy.recipient/address-changed]}
[{:keys [db] :as cofx} new-identity]
(rf/merge cofx
{:db (update db
:wallet/recipient assoc
:wallet-legacy/recipient assoc
:address new-identity
:resolved-address nil
:searching true)}
(set-recipient new-identity nil)))
(rf/defn recipient-modal-closed
{:events [:wallet/recipient-modal-closed]}
{:events [:wallet-legacy/recipient-modal-closed]}
[{:keys [db]}]
{:db (dissoc db :wallet/recipient)})
{:db (dissoc db :wallet-legacy/recipient)})
(rf/defn add-favourite
{:events [:wallet/add-favourite]}
{:events [:wallet-legacy/add-favourite]}
[{:keys [db] :as cofx} address name]
(let [new-favourite {:address address
:name (or name "")
:favourite true}]
(rf/merge cofx
{:db (assoc-in db [:wallet/favourites address] new-favourite)
{:db (assoc-in db [:wallet-legacy/favourites address] new-favourite)
:json-rpc/call [{:method "wallet_addSavedAddress"
:params [new-favourite]
:on-success #()}]}

View File

@ -9,44 +9,44 @@
;; selection of sink asset."
(re-frame/reg-event-fx ::open-asset-selector-modal
(fn [{:keys [db]} [source?]]
{:db (assoc db :wallet/modal-selecting-source-token? source?)
{:db (assoc db :wallet-legacy/modal-selecting-source-token? source?)
:fx [[:dispatch [:open-modal :swap-asset-selector {}]]]}))
(rf/defn set-from-token
{:events [::set-from-token]}
[{:keys [db]} from-symbol]
(rf/merge {:db (assoc db :wallet/swap-from-token from-symbol)}
(rf/merge {:db (assoc db :wallet-legacy/swap-from-token from-symbol)}
(navigation/navigate-back)))
(rf/defn set-to-token
{:events [::set-to-token]}
[{:keys [db]} to-symbol]
(rf/merge {:db (assoc db :wallet/swap-to-token to-symbol)}
(rf/merge {:db (assoc db :wallet-legacy/swap-to-token to-symbol)}
(navigation/navigate-back)))
(rf/defn set-from-token-amount
[{:keys [db]} from-amount]
{:db (assoc db :wallet/swap-from-token-amount from-amount)})
{:db (assoc db :wallet-legacy/swap-from-token-amount from-amount)})
(rf/defn set-max-from-token-amount
[{:keys [db]} _]
{:db (assoc db :wallet/swap-from-token-amount 0)})
{:db (assoc db :wallet-legacy/swap-from-token-amount 0)})
(rf/defn switch-from-token-with-to
{:events [::switch-from-token-with-to]}
[{:keys [db]}]
{:db (assoc db
:wallet/swap-from-token (:wallet/swap-to-token db)
:wallet/swap-to-token (:wallet/swap-from-token db))})
:wallet-legacy/swap-from-token (:wallet-legacy/swap-to-token db)
:wallet-legacy/swap-to-token (:wallet-legacy/swap-from-token db))})
(rf/defn set-advanced-mode
{:events [::set-advanced-mode]}
[{:keys [db]} mode]
{:db (assoc db :wallet/swap-advanced-mode? mode)})
{:db (assoc db :wallet-legacy/swap-advanced-mode? mode)})
(comment
(->> re-frame.db/app-db
deref
:wallet/all-tokens
:wallet-legacy/all-tokens
vals
(map #(str (:name %) "-" (:symbol %)))))

View File

@ -74,7 +74,7 @@
(def default-multiaccount
{:preview-privacy? blank-preview?
:wallet/visible-tokens {:mainnet #{:SNT}}
:wallet-legacy/visible-tokens {:mainnet #{:SNT}}
:currency :usd
:appearance 0
:profile-pictures-show-to 2
@ -87,7 +87,7 @@
(defn default-visible-tokens
[chain]
(get-in default-multiaccount [:wallet/visible-tokens chain]))
(get-in default-multiaccount [:wallet-legacy/visible-tokens chain]))
(def mainnet-networks
[{:id "mainnet_rpc"

View File

@ -103,12 +103,12 @@
network-id (str (get-in networks
[current-network :config :NetworkId]))]
(rf/merge cofx
(cond-> {:wallet/initialize-transactions-management-enabled nil
:wallet/initialize-wallet
(cond-> {:wallet-legacy/initialize-transactions-management-enabled nil
:wallet-legacy/initialize-wallet
[network-id
current-network-config
(fn [accounts tokens custom-tokens favourites]
(re-frame/dispatch [:wallet/initialize-wallet
(re-frame/dispatch [:wallet-legacy/initialize-wallet
accounts tokens custom-tokens favourites]))]
:check-eip1559-activation {:network-id network-id}
:chat/open-last-chat (get-in db [:profile/profile :key-uid])}
@ -135,7 +135,7 @@
{:db (dissoc db :profile/login)
:dispatch-n [[:logging/initialize-web3-client-version]
(when (and new-account? (not recovered-account?))
[:wallet/set-initial-blocks-range])
[:wallet-legacy/set-initial-blocks-range])
[:ens/update-usernames ensUsernames]]}
(login-existing-profile settings account))))

View File

@ -2,11 +2,11 @@
(:require [utils.re-frame :as rf]))
(rf/defn scan-address-success
{:events [:wallet-2/scan-address-success]}
{:events [:wallet/scan-address-success]}
[{:keys [db]} address]
{:db (assoc db :wallet-2/scanned-address address)})
{:db (assoc db :wallet/scanned-address address)})
(rf/defn clean-scanned-address
{:events [:wallet-2/clean-scanned-address]}
{:events [:wallet/clean-scanned-address]}
[{:keys [db]}]
{:db (dissoc db :wallet-2/scanned-address)})
{:db (dissoc db :wallet/scanned-address)})

View File

@ -8,13 +8,13 @@
(deftest scan-address-success
(let [db {}]
(testing "scan-address-success"
(let [expected-db {:wallet-2/scanned-address address}
(let [expected-db {:wallet/scanned-address address}
effects (events/scan-address-success {:db db} address)
result-db (:db effects)]
(is (= result-db expected-db))))))
(deftest clean-scanned-address
(let [db {:wallet-2/scanned-address address}]
(let [db {:wallet/scanned-address address}]
(testing "clean-scanned-address"
(let [expected-db {}
effects (events/clean-scanned-address {:db db})

View File

@ -19,6 +19,6 @@
:subtitle (i18n/label :t/scan-an-account-qr-code)
:error-message (i18n/label :t/oops-this-qr-does-not-contain-an-address)
:validate-fn #(contains-address? %)
:on-success-scan #(debounce/debounce-and-dispatch [:wallet-2/scan-address-success
:on-success-scan #(debounce/debounce-and-dispatch [:wallet/scan-address-success
(extract-address %)]
300)}])

View File

@ -51,7 +51,7 @@
(reset! timer (js/setTimeout #(reset! valid-ens-or-address? true)
2000)))]
(fn []
(let [scanned-address (rf/sub [:wallet-2/scanned-address])]
(let [scanned-address (rf/sub [:wallet/scanned-address])]
[quo/address-input
{:on-scan #(rf/dispatch [:open-modal :scan-address])
:ens-regex constants/regx-ens
@ -61,9 +61,9 @@
:on-detect-address on-detect-address-or-ens
:on-change-text (fn [text]
(when-not (= scanned-address text)
(rf/dispatch [:wallet-2/clean-scanned-address]))
(rf/dispatch [:wallet/clean-scanned-address]))
(reset! input-value text))
:on-clear #(rf/dispatch [:wallet-2/clean-scanned-address])
:on-clear #(rf/dispatch [:wallet/clean-scanned-address])
:valid-ens-or-address? @valid-ens-or-address?}]))))
(defn- f-view-internal
@ -73,7 +73,7 @@
on-close #(rf/dispatch [:dismiss-modal :wallet-select-address])
on-change-tab #(reset! selected-tab %)]
(fn []
(rn/use-effect (fn [] #(rf/dispatch [:wallet-2/clean-scanned-address])))
(rn/use-effect (fn [] #(rf/dispatch [:wallet/clean-scanned-address])))
[rn/scroll-view
{:content-container-style (style/container margin-top)
:keyboard-should-persist-taps :never

View File

@ -19,8 +19,8 @@
:sync-state :done
:link-previews-whitelist []
:app-state "active"
:wallet wallet.db/default-wallet
:wallet/all-tokens {}
:wallet-legacy wallet.db/default-wallet
:wallet-legacy/all-tokens {}
:peers-count 0
:node-info {}
:peers-summary []

View File

@ -181,7 +181,7 @@
(re-frame/reg-sub
:contacts/active-with-ens-names
:<- [:contacts/active]
:<- [:search/recipient-filter]
:<- [:wallet-legacy/search-recipient-filter]
(fn [[contacts search-filter]]
(let [contacts (filter :ens-verified contacts)]
(if (string/blank? search-filter)

View File

@ -147,7 +147,7 @@
(get-in animations [type item-id :delete-swiped])))
(re-frame/reg-sub
:search/recipient-filter
:wallet-legacy/search-recipient-filter
:<- [:ui/search]
(fn [search]
(get search :recipient-filter)))
@ -158,12 +158,6 @@
(fn [search]
(get search :currency-filter)))
(re-frame/reg-sub
:search/token-filter
:<- [:ui/search]
(fn [search]
(get search :token-filter)))
(defn- node-version
[web3-node-version]
(or web3-node-version "N/A"))

View File

@ -190,8 +190,8 @@
(re-frame/reg-sub
:accounts-for-recipient
:<- [:multiaccount/visible-accounts]
:<- [:wallet/prepare-transaction]
:<- [:search/recipient-filter]
:<- [:wallet-legacy/prepare-transaction]
:<- [:wallet-legacy/search-recipient-filter]
(fn [[accounts {:keys [from]} search-filter]]
(let [accounts (remove #(= (:address %) (:address from)) accounts)]
(if (string/blank? search-filter)

View File

@ -24,10 +24,10 @@
;;bottom sheet
(reg-root-key-sub :bottom-sheet :bottom-sheet)
; media-server
;;media-server
(reg-root-key-sub :mediaserver/port :mediaserver/port)
;; push notifications
;;push notifications
(reg-root-key-sub :push-notifications/preferences :push-notifications/preferences)
;;general
@ -78,7 +78,7 @@
(reg-root-key-sub :multiaccount/reset-password-form-vals :multiaccount/reset-password-form-vals)
(reg-root-key-sub :multiaccount/reset-password-errors :multiaccount/reset-password-errors)
(reg-root-key-sub :multiaccount/resetting-password? :multiaccount/resetting-password?)
;; delete profile
;;delete profile
(reg-root-key-sub :delete-profile/error :delete-profile/error)
(reg-root-key-sub :delete-profile/keep-keys-on-keycard? :delete-profile/keep-keys-on-keycard?)
@ -127,119 +127,9 @@
(reg-root-key-sub :messages/pin-messages :pin-messages)
(reg-root-key-sub :messages/pin-modal :pin-modal)
; Messages home view -> tabs
(reg-root-key-sub :messages-home/selected-tab :messages-home/selected-tab)
;;browser
(reg-root-key-sub :browsers :browser/browsers)
(reg-root-key-sub :browser/options :browser/options)
(reg-root-key-sub :dapps/permissions :dapps/permissions)
(reg-root-key-sub :bookmarks :bookmarks/bookmarks)
(reg-root-key-sub :browser/screen-id :browser/screen-id)
;;stickers
(reg-root-key-sub :stickers/selected-pack :stickers/selected-pack)
(reg-root-key-sub :stickers/packs :stickers/packs)
(reg-root-key-sub :stickers/recent-stickers :stickers/recent-stickers)
;;mailserver
(reg-root-key-sub :mailserver/current-id :mailserver/current-id)
(reg-root-key-sub :mailserver/mailservers :mailserver/mailservers)
(reg-root-key-sub :mailserver.edit/mailserver :mailserver.edit/mailserver)
(reg-root-key-sub :mailserver/state :mailserver/state)
(reg-root-key-sub :mailserver/pending-requests :mailserver/pending-requests)
(reg-root-key-sub :mailserver/request-error? :mailserver/request-error)
(reg-root-key-sub :mailserver/fetching-gaps-in-progress :mailserver/fetching-gaps-in-progress)
;;contacts
(reg-root-key-sub :contacts/contacts-raw :contacts/contacts)
(reg-root-key-sub :contacts/current-contact-identity :contacts/identity)
(reg-root-key-sub :contacts/current-contact-ens-name :contacts/ens-name)
(reg-root-key-sub :contacts/new-identity :contacts/new-identity)
(reg-root-key-sub :group/selected-contacts :group/selected-contacts)
(reg-root-key-sub :contacts/search-query :contacts/search-query)
;;wallet
(reg-root-key-sub :wallet :wallet)
(reg-root-key-sub :prices :prices)
(reg-root-key-sub :prices-loading? :prices-loading?)
(reg-root-key-sub :wallet.transactions :wallet.transactions)
(reg-root-key-sub :wallet/custom-token-screen :wallet/custom-token-screen)
(reg-root-key-sub :wallet/prepare-transaction :wallet/prepare-transaction)
(reg-root-key-sub :wallet-service/manual-setting :wallet-service/manual-setting)
(reg-root-key-sub :wallet/recipient :wallet/recipient)
(reg-root-key-sub :wallet/favourites :wallet/favourites)
(reg-root-key-sub :wallet/refreshing-history? :wallet/refreshing-history?)
(reg-root-key-sub :wallet/fetching-error :wallet/fetching-error)
(reg-root-key-sub :wallet/non-archival-node :wallet/non-archival-node)
(reg-root-key-sub :wallet/current-base-fee :wallet/current-base-fee)
(reg-root-key-sub :wallet/slow-base-fee :wallet/slow-base-fee)
(reg-root-key-sub :wallet/normal-base-fee :wallet/normal-base-fee)
(reg-root-key-sub :wallet/fast-base-fee :wallet/fast-base-fee)
(reg-root-key-sub :wallet/current-priority-fee :wallet/current-priority-fee)
(reg-root-key-sub :wallet/transactions-management-enabled? :wallet/transactions-management-enabled?)
(reg-root-key-sub :wallet/all-tokens :wallet/all-tokens)
(reg-root-key-sub :wallet/collectible-collections :wallet/collectible-collections)
(reg-root-key-sub :wallet/fetching-collection-assets :wallet/fetching-collection-assets)
(reg-root-key-sub :wallet/collectible-assets :wallet/collectible-assets)
(reg-root-key-sub :wallet/selected-collectible :wallet/selected-collectible)
(reg-root-key-sub :wallet/modal-selecting-source-token? :wallet/modal-selecting-source-token?)
(reg-root-key-sub :wallet/swap-from-token :wallet/swap-from-token)
(reg-root-key-sub :wallet/swap-to-token :wallet/swap-to-token)
(reg-root-key-sub :wallet/swap-from-token-amount :wallet/swap-from-token-amount)
(reg-root-key-sub :wallet/swap-to-token-amount :wallet/swap-to-token-amount)
(reg-root-key-sub :wallet/swap-advanced-mode? :wallet/swap-advanced-mode?)
;; Wallet 2
(reg-root-key-sub :wallet-2/scanned-address :wallet-2/scanned-address)
;;; Link previews
(reg-root-key-sub :link-previews-whitelist :link-previews-whitelist)
(reg-root-key-sub :chat/link-previews :chat/link-previews)
;;commands
(reg-root-key-sub :commands/select-account :commands/select-account)
;;ethereum
(reg-root-key-sub :ethereum/current-block :ethereum/current-block)
;;ens
(reg-root-key-sub :ens/registration :ens/registration)
(reg-root-key-sub :ens/registrations :ens/registrations)
(reg-root-key-sub :ens/names :ens/names)
;;signing
(reg-root-key-sub :signing/sign :signing/sign)
(reg-root-key-sub :signing/tx :signing/tx)
(reg-root-key-sub :signing/edit-fee :signing/edit-fee)
;;intro-wizard
(reg-root-key-sub :intro-wizard-state :intro-wizard)
(reg-root-key-sub :toasts :toasts)
(reg-root-key-sub :popover/popover :popover/popover)
(reg-root-key-sub :visibility-status-popover/popover :visibility-status-popover/popover)
(reg-root-key-sub :add-account :add-account)
(reg-root-key-sub :keycard :keycard)
(reg-root-key-sub :auth-method :auth-method)
;; keycard
(reg-root-key-sub :keycard/banner-hidden :keycard/banner-hidden)
;; delete profile
(reg-root-key-sub :delete-profile/error :delete-profile/error)
(reg-root-key-sub :delete-profile/keep-keys-on-keycard? :delete-profile/keep-keys-on-keycard?)
;; push notifications
(reg-root-key-sub :push-notifications/servers :push-notifications/servers)
(reg-root-key-sub :push-notifications/preferences :push-notifications/preferences)
(reg-root-key-sub :buy-crypto/on-ramps :buy-crypto/on-ramps)
;; communities
;;communities
(reg-root-key-sub :communities :communities)
(reg-root-key-sub :communities/create :communities/create)
(reg-root-key-sub :communities/create-channel :communities/create-channel)
@ -251,5 +141,8 @@
(reg-root-key-sub :communities/selected-tab :communities/selected-tab)
(reg-root-key-sub :contract-communities :contract-communities)
;; activity center
;;activity center
(reg-root-key-sub :activity-center :activity-center)
;;wallet
(reg-root-key-sub :wallet/scanned-address :wallet/scanned-address)

View File

@ -37,7 +37,7 @@
```clojure
(require '[test-helpers.unit :as h])
(h/deftest-sub :wallet/sorted-tokens
(h/deftest-sub :wallet-legacy/sorted-tokens
[sub-name]
(testing \"sorts tokens by name, lowercased\"
;; Arrange