This commit is contained in:
parent
2be78041e2
commit
32ccca0912
|
@ -16,16 +16,19 @@
|
||||||
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
||||||
view-id (:view-id db)
|
view-id (:view-id db)
|
||||||
root-screen? (or (= view-id :wallet-stack) (nil? view-id))
|
root-screen? (or (= view-id :wallet-stack) (nil? view-id))
|
||||||
account (or from-account (swap-utils/wallet-account wallet))
|
available-accounts (utils/get-accounts-with-token-balance (:accounts wallet)
|
||||||
asset-to-pay (if (get-in data [:asset-to-pay :networks])
|
(:asset-to-pay data))
|
||||||
|
account (or from-account
|
||||||
|
(swap-utils/current-viewing-account wallet)
|
||||||
|
(first available-accounts))
|
||||||
|
asset-to-pay (if (and (not from-account) (get-in data [:asset-to-pay :networks]))
|
||||||
(:asset-to-pay data)
|
(:asset-to-pay data)
|
||||||
(swap-utils/select-asset-to-pay-by-symbol
|
(swap-utils/select-asset-to-pay-by-symbol
|
||||||
{:wallet wallet
|
{:wallet wallet
|
||||||
:account account
|
:account account
|
||||||
:test-networks-enabled? test-networks-enabled?
|
:test-networks-enabled? test-networks-enabled?
|
||||||
:token-symbol (get-in data [:asset-to-pay :symbol])}))
|
:token-symbol (get-in data [:asset-to-pay :symbol])}))
|
||||||
multi-account-balance? (-> (utils/get-accounts-with-token-balance (:accounts wallet)
|
multi-account-balance? (-> available-accounts
|
||||||
asset-to-pay)
|
|
||||||
(count)
|
(count)
|
||||||
(> 1))
|
(> 1))
|
||||||
network' (or network
|
network' (or network
|
||||||
|
|
|
@ -30,27 +30,10 @@
|
||||||
:else
|
:else
|
||||||
(i18n/label :t/something-went-wrong-please-try-again-later)))
|
(i18n/label :t/something-went-wrong-please-try-again-later)))
|
||||||
|
|
||||||
(defn- first-operable-account
|
(defn current-viewing-account
|
||||||
[accounts]
|
|
||||||
(->> accounts
|
|
||||||
vals
|
|
||||||
(remove :watch-only?)
|
|
||||||
(filter :operable?)
|
|
||||||
(sort-by :position)
|
|
||||||
first))
|
|
||||||
|
|
||||||
(defn wallet-account
|
|
||||||
"Picks the account that's gonna be used for the swap operation.
|
|
||||||
It's gonna be either the preselected account defined by
|
|
||||||
`[:wallet :current-viewing-account-address]` in `db`
|
|
||||||
or the first operable account."
|
|
||||||
[wallet]
|
[wallet]
|
||||||
(if-let [wallet-address (get wallet :current-viewing-account-address)]
|
(when-let [wallet-address (get wallet :current-viewing-account-address)]
|
||||||
(-> wallet
|
(get-in wallet [:accounts wallet-address])))
|
||||||
:accounts
|
|
||||||
vals
|
|
||||||
(utils/get-account-by-address wallet-address))
|
|
||||||
(-> wallet :accounts first-operable-account)))
|
|
||||||
|
|
||||||
(defn select-asset-to-pay-by-symbol
|
(defn select-asset-to-pay-by-symbol
|
||||||
"Selects an asset to pay by token symbol.
|
"Selects an asset to pay by token symbol.
|
||||||
|
|
Loading…
Reference in New Issue