Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21ebd4d930 | ||
|
|
40c36c30e6 |
+15
-12
@@ -23,15 +23,18 @@ PODS:
|
|||||||
- secp256k1
|
- secp256k1
|
||||||
- SSZipArchive
|
- SSZipArchive
|
||||||
- libevent (2.1.12)
|
- libevent (2.1.12)
|
||||||
- libwebp (1.2.4):
|
- libwebp (1.3.2):
|
||||||
- libwebp/demux (= 1.2.4)
|
- libwebp/demux (= 1.3.2)
|
||||||
- libwebp/mux (= 1.2.4)
|
- libwebp/mux (= 1.3.2)
|
||||||
- libwebp/webp (= 1.2.4)
|
- libwebp/sharpyuv (= 1.3.2)
|
||||||
- libwebp/demux (1.2.4):
|
- libwebp/webp (= 1.3.2)
|
||||||
|
- libwebp/demux (1.3.2):
|
||||||
- libwebp/webp
|
- libwebp/webp
|
||||||
- libwebp/mux (1.2.4):
|
- libwebp/mux (1.3.2):
|
||||||
- libwebp/demux
|
- libwebp/demux
|
||||||
- libwebp/webp (1.2.4)
|
- libwebp/sharpyuv (1.3.2)
|
||||||
|
- libwebp/webp (1.3.2):
|
||||||
|
- libwebp/sharpyuv
|
||||||
- RCT-Folly (2022.05.16.00):
|
- RCT-Folly (2022.05.16.00):
|
||||||
- boost
|
- boost
|
||||||
- DoubleConversion
|
- DoubleConversion
|
||||||
@@ -1189,7 +1192,7 @@ PODS:
|
|||||||
- secp256k1 (0.1.6)
|
- secp256k1 (0.1.6)
|
||||||
- SocketRocket (0.6.1)
|
- SocketRocket (0.6.1)
|
||||||
- SSZipArchive (2.4.3)
|
- SSZipArchive (2.4.3)
|
||||||
- TOCropViewController (2.6.1)
|
- TOCropViewController (2.7.4)
|
||||||
- Yoga (1.14.0)
|
- Yoga (1.14.0)
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
@@ -1489,7 +1492,7 @@ CHECKOUT OPTIONS:
|
|||||||
:git: https://github.com/status-im/Keycard.swift.git
|
:git: https://github.com/status-im/Keycard.swift.git
|
||||||
:tag: 3.1.1
|
:tag: 3.1.1
|
||||||
secp256k1:
|
secp256k1:
|
||||||
:commit: 46a1fa30d9b8babeae85ff519050f42394ab5fcc
|
:commit: 4ab977cc2b2d7319be858bcb30a5d189bb149884
|
||||||
:git: https://github.com/status-im/secp256k1.swift.git
|
:git: https://github.com/status-im/secp256k1.swift.git
|
||||||
:submodules: true
|
:submodules: true
|
||||||
|
|
||||||
@@ -1506,7 +1509,7 @@ SPEC CHECKSUMS:
|
|||||||
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
|
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
|
||||||
Keycard: 3bd24405b9a875b3b3cf1ab1be69b5c30c5f28bc
|
Keycard: 3bd24405b9a875b3b3cf1ab1be69b5c30c5f28bc
|
||||||
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
|
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
|
||||||
libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef
|
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
|
||||||
RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0
|
RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0
|
||||||
RCTRequired: 2544c0f1081a5fa12e108bb8cb40e5f4581ccd87
|
RCTRequired: 2544c0f1081a5fa12e108bb8cb40e5f4581ccd87
|
||||||
RCTTypeSafety: 50efabe2b115c11ed03fbf3fd79e2f163ddb5d7c
|
RCTTypeSafety: 50efabe2b115c11ed03fbf3fd79e2f163ddb5d7c
|
||||||
@@ -1590,9 +1593,9 @@ SPEC CHECKSUMS:
|
|||||||
secp256k1: f61d67e6fdcb85fd727acf1bf35ace6036db540c
|
secp256k1: f61d67e6fdcb85fd727acf1bf35ace6036db540c
|
||||||
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
|
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
|
||||||
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
|
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
|
||||||
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
|
TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654
|
||||||
Yoga: a716eea57d0d3430219c0a5a233e1e93ee931eb7
|
Yoga: a716eea57d0d3430219c0a5a233e1e93ee931eb7
|
||||||
|
|
||||||
PODFILE CHECKSUM: 81a66b45adddb083171ade882c343deb4faf2a8b
|
PODFILE CHECKSUM: 56d9f695324306d6db368d1172d211dfab55b7cb
|
||||||
|
|
||||||
COCOAPODS: 1.15.2
|
COCOAPODS: 1.15.2
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ in {
|
|||||||
yarn = super.yarn.override { nodejs = super.nodejs_20; };
|
yarn = super.yarn.override { nodejs = super.nodejs_20; };
|
||||||
openjdk = super.openjdk17_headless;
|
openjdk = super.openjdk17_headless;
|
||||||
xcodeWrapper = callPackage ./pkgs/xcodeenv/compose-xcodewrapper.nix { } {
|
xcodeWrapper = callPackage ./pkgs/xcodeenv/compose-xcodewrapper.nix { } {
|
||||||
versions = ["15.1" "15.2" "15.3" "15.4"];
|
versions = ["15.1" "15.2" "15.3" "15.4" "16.0" "16.1"];
|
||||||
};
|
};
|
||||||
go = super.go_1_21;
|
go = super.go_1_21;
|
||||||
clang = super.clang_15;
|
clang = super.clang_15;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
(ns status-im.contexts.wallet.bridge.bridge-to.view
|
(ns status-im.contexts.wallet.bridge.bridge-to.view
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[quo.foundations.resources :as quo.resources]
|
[quo.foundations.resources :as quo.resources]
|
||||||
[quo.theme]
|
[quo.theme]
|
||||||
@@ -15,28 +14,34 @@
|
|||||||
|
|
||||||
(defn- bridge-token-component
|
(defn- bridge-token-component
|
||||||
[]
|
[]
|
||||||
(fn [{:keys [chain-id network-name]} {:keys [supported-networks] :as token}]
|
(fn [{:keys [chain-id network-name]} {:keys [supported-networks] :as token} selected-network]
|
||||||
(let [network (rf/sub [:wallet/network-details-by-chain-id chain-id])
|
(let [network (rf/sub [:wallet/network-details-by-chain-id chain-id])
|
||||||
currency (rf/sub [:profile/currency])
|
currency (rf/sub [:profile/currency])
|
||||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||||
prices-per-token (rf/sub [:wallet/prices-per-token])
|
prices-per-token (rf/sub [:wallet/prices-per-token])
|
||||||
balance (utils/calculate-total-token-balance token [chain-id])
|
{selected-network-chain-id :chain-id} selected-network
|
||||||
crypto-value (utils/get-standard-crypto-format token balance prices-per-token)
|
balance (utils/calculate-total-token-balance token [chain-id])
|
||||||
fiat-value (utils/calculate-token-fiat-value
|
crypto-value (utils/get-standard-crypto-format token
|
||||||
{:currency currency
|
balance
|
||||||
:balance balance
|
prices-per-token)
|
||||||
:token token
|
fiat-value (utils/calculate-token-fiat-value
|
||||||
:prices-per-token prices-per-token})
|
{:currency currency
|
||||||
fiat-formatted (utils/fiat-formatted-for-ui currency-symbol
|
:balance balance
|
||||||
fiat-value)
|
:token token
|
||||||
token-available-on-network? (network-utils/token-available-on-network? supported-networks
|
:prices-per-token prices-per-token})
|
||||||
chain-id)]
|
fiat-formatted (utils/fiat-formatted-for-ui currency-symbol
|
||||||
|
fiat-value)
|
||||||
|
token-available-on-network? (network-utils/token-available-on-network?
|
||||||
|
supported-networks
|
||||||
|
chain-id)]
|
||||||
[quo/network-list
|
[quo/network-list
|
||||||
{:label (name network-name)
|
{:label (name network-name)
|
||||||
:network-image (quo.resources/get-network (:network-name network))
|
:network-image (quo.resources/get-network (:network-name network))
|
||||||
:token-value (str crypto-value " " (:symbol token))
|
:token-value (str crypto-value " " (:symbol token))
|
||||||
:fiat-value fiat-formatted
|
:fiat-value fiat-formatted
|
||||||
:state (if token-available-on-network? :default :disabled)
|
:state (if (and token-available-on-network? (not= chain-id selected-network-chain-id))
|
||||||
|
:default
|
||||||
|
:disabled)
|
||||||
:on-press #(rf/dispatch [:wallet/select-bridge-network
|
:on-press #(rf/dispatch [:wallet/select-bridge-network
|
||||||
{:network-chain-id chain-id
|
{:network-chain-id chain-id
|
||||||
:stack-id :screen/wallet.bridge-to}])}])))
|
:stack-id :screen/wallet.bridge-to}])}])))
|
||||||
@@ -46,6 +51,7 @@
|
|||||||
(let [network-details (rf/sub [:wallet/network-details])
|
(let [network-details (rf/sub [:wallet/network-details])
|
||||||
account (rf/sub [:wallet/current-viewing-account])
|
account (rf/sub [:wallet/current-viewing-account])
|
||||||
token (rf/sub [:wallet/wallet-send-token])
|
token (rf/sub [:wallet/wallet-send-token])
|
||||||
|
selected-network (rf/sub [:wallet/send-network])
|
||||||
token-symbol (:symbol token)
|
token-symbol (:symbol token)
|
||||||
tokens (:tokens account)
|
tokens (:tokens account)
|
||||||
mainnet (first network-details)
|
mainnet (first network-details)
|
||||||
@@ -55,8 +61,7 @@
|
|||||||
(assoc account-token
|
(assoc account-token
|
||||||
:networks (:networks token)
|
:networks (:networks token)
|
||||||
:supported-networks (:supported-networks token)))
|
:supported-networks (:supported-networks token)))
|
||||||
bridge-to-title (i18n/label :t/bridge-to
|
bridge-to-title (i18n/label :t/select-network-to-receive)]
|
||||||
{:name (string/upper-case (str token-symbol))})]
|
|
||||||
|
|
||||||
(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clean-bridge-to-selection]))
|
(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clean-bridge-to-selection]))
|
||||||
|
|
||||||
@@ -68,11 +73,11 @@
|
|||||||
:switcher-type :select-account}]
|
:switcher-type :select-account}]
|
||||||
[quo/page-top {:title bridge-to-title}]
|
[quo/page-top {:title bridge-to-title}]
|
||||||
[rn/view style/content-container
|
[rn/view style/content-container
|
||||||
[bridge-token-component (assoc mainnet :network-name :t/mainnet) account-token]]
|
[bridge-token-component (assoc mainnet :network-name :t/mainnet) account-token selected-network]]
|
||||||
|
|
||||||
[quo/divider-label (i18n/label :t/layer-2)]
|
[quo/divider-label (i18n/label :t/layer-2)]
|
||||||
[rn/flat-list
|
[rn/flat-list
|
||||||
{:data layer-2-networks
|
{:data layer-2-networks
|
||||||
:render-fn (fn [network]
|
:render-fn (fn [network]
|
||||||
[bridge-token-component network account-token])
|
[bridge-token-component network account-token selected-network])
|
||||||
:content-container-style style/content-container}]]))
|
:content-container-style style/content-container}]]))
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
(ns status-im.contexts.wallet.bridge.flow-config)
|
(ns status-im.contexts.wallet.bridge.flow-config)
|
||||||
|
|
||||||
(def steps
|
(def steps
|
||||||
[{:screen-id :screen/wallet.select-from
|
[{:screen-id :screen/wallet.bridge-select-asset
|
||||||
:skip-step? (fn [db] (some? (get-in db [:wallet :current-viewing-account-address])))}
|
|
||||||
{:screen-id :screen/wallet.bridge-select-asset
|
|
||||||
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :token])))}
|
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :token])))}
|
||||||
{:screen-id :screen/wallet.bridge-to
|
{:screen-id :screen/wallet.bridge-to
|
||||||
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :bridge-to-chain-id])))}
|
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :bridge-to-chain-id])))}
|
||||||
|
|||||||
@@ -82,13 +82,13 @@
|
|||||||
token-owners (rf/sub [:wallet/operable-addresses-with-token-symbol token-symbol])
|
token-owners (rf/sub [:wallet/operable-addresses-with-token-symbol token-symbol])
|
||||||
testnet-mode? (rf/sub [:profile/test-networks-enabled?])
|
testnet-mode? (rf/sub [:profile/test-networks-enabled?])
|
||||||
account-owns-token? (rf/sub [:wallet/current-account-owns-token token-symbol])
|
account-owns-token? (rf/sub [:wallet/current-account-owns-token token-symbol])
|
||||||
|
network-details (rf/sub [:wallet/network-details])
|
||||||
receive-token-symbol (if (= token-symbol "SNT") "ETH" "SNT")
|
receive-token-symbol (if (= token-symbol "SNT") "ETH" "SNT")
|
||||||
token-owned? (if selected-account account-owns-token? (seq token-owners))
|
token-owned? (if selected-account account-owns-token? (seq token-owners))
|
||||||
asset-to-receive (rf/sub [:wallet/token-by-symbol receive-token-symbol])
|
asset-to-receive (rf/sub [:wallet/token-by-symbol receive-token-symbol])
|
||||||
params (cond-> {:start-flow? true
|
params (cond-> {:start-flow? true
|
||||||
:owners token-owners
|
:owners token-owners
|
||||||
:testnet-mode? testnet-mode?
|
:testnet-mode? testnet-mode?}
|
||||||
:asset-to-receive asset-to-receive}
|
|
||||||
selected-account
|
selected-account
|
||||||
(assoc :token token-data
|
(assoc :token token-data
|
||||||
:stack-id :screen/wallet.accounts
|
:stack-id :screen/wallet.accounts
|
||||||
@@ -108,9 +108,13 @@
|
|||||||
(action-send params entry-point))
|
(action-send params entry-point))
|
||||||
(action-receive selected-account)
|
(action-receive selected-account)
|
||||||
(when token-owned?
|
(when token-owned?
|
||||||
(action-swap params))
|
(action-swap (assoc params
|
||||||
|
:asset-to-receive
|
||||||
|
asset-to-receive)))
|
||||||
(when token-owned?
|
(when token-owned?
|
||||||
(action-bridge (assoc params
|
(action-bridge (assoc params
|
||||||
|
:network-details
|
||||||
|
network-details
|
||||||
:bridge-disabled?
|
:bridge-disabled?
|
||||||
(send-utils/bridge-disabled? token-symbol))))]))]]))
|
(send-utils/bridge-disabled? token-symbol))))]))]]))
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,11 @@
|
|||||||
(ns status-im.contexts.wallet.common.wizard.events
|
(ns status-im.contexts.wallet.common.wizard.events
|
||||||
(:require [status-im.contexts.wallet.bridge.flow-config :as wallet-bridge-flow]
|
(:require [status-im.contexts.wallet.common.wizard.utils :as wizard-utils]
|
||||||
[status-im.contexts.wallet.send.flow-config :as wallet-send-flow]
|
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn- wizard-find-next-screen
|
|
||||||
[db flow-id current-screen]
|
|
||||||
(let [flow-config (case flow-id
|
|
||||||
:wallet-send-flow wallet-send-flow/steps
|
|
||||||
:wallet-bridge-flow wallet-bridge-flow/steps
|
|
||||||
nil)]
|
|
||||||
(first (filter (fn [{:keys [skip-step? screen-id]}]
|
|
||||||
(and (not= screen-id current-screen)
|
|
||||||
(not (and (fn? skip-step?) (skip-step? db)))))
|
|
||||||
flow-config))))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/wizard-navigate-forward
|
:wallet/wizard-navigate-forward
|
||||||
(fn [{:keys [db]} [{:keys [current-screen flow-id start-flow?]}]]
|
(fn [{:keys [db]} [{:keys [current-screen flow-id start-flow?]}]]
|
||||||
(let [next-screen (wizard-find-next-screen db flow-id current-screen)]
|
(let [next-screen (wizard-utils/wizard-find-next-screen db flow-id current-screen)]
|
||||||
{:fx [[:dispatch
|
{:fx [[:dispatch
|
||||||
(if start-flow?
|
(if start-flow?
|
||||||
[:open-modal (:screen-id next-screen)]
|
[:open-modal (:screen-id next-screen)]
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
(ns status-im.contexts.wallet.common.wizard.utils
|
||||||
|
(:require [status-im.contexts.wallet.bridge.flow-config :as wallet-bridge-flow]
|
||||||
|
[status-im.contexts.wallet.send.flow-config :as wallet-send-flow]))
|
||||||
|
|
||||||
|
(defn wizard-find-next-screen
|
||||||
|
[db flow-id current-screen]
|
||||||
|
(let [flow-config (case flow-id
|
||||||
|
:wallet-send-flow wallet-send-flow/steps
|
||||||
|
:wallet-bridge-flow wallet-bridge-flow/steps
|
||||||
|
nil)]
|
||||||
|
(first (filter (fn [{:keys [skip-step? screen-id]}]
|
||||||
|
(and (not= screen-id current-screen)
|
||||||
|
(not (and (fn? skip-step?) (skip-step? db)))))
|
||||||
|
flow-config))))
|
||||||
@@ -10,11 +10,13 @@
|
|||||||
[status-im.contexts.settings.wallet.effects]
|
[status-im.contexts.settings.wallet.effects]
|
||||||
[status-im.contexts.settings.wallet.events]
|
[status-im.contexts.settings.wallet.events]
|
||||||
[status-im.contexts.wallet.common.activity-tab.events]
|
[status-im.contexts.wallet.common.activity-tab.events]
|
||||||
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
[status-im.contexts.wallet.common.utils.external-links :as external-links]
|
[status-im.contexts.wallet.common.utils.external-links :as external-links]
|
||||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||||
[status-im.contexts.wallet.data-store :as data-store]
|
[status-im.contexts.wallet.data-store :as data-store]
|
||||||
[status-im.contexts.wallet.db :as db]
|
[status-im.contexts.wallet.db :as db]
|
||||||
[status-im.contexts.wallet.item-types :as item-types]
|
[status-im.contexts.wallet.item-types :as item-types]
|
||||||
|
[status-im.contexts.wallet.sheets.network-selection.view :as network-selection]
|
||||||
[status-im.contexts.wallet.tokens.events]
|
[status-im.contexts.wallet.tokens.events]
|
||||||
[status-im.feature-flags :as ff]
|
[status-im.feature-flags :as ff]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
@@ -343,19 +345,61 @@
|
|||||||
(rf/reg-event-fx :wallet/get-keypairs get-keypairs)
|
(rf/reg-event-fx :wallet/get-keypairs get-keypairs)
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/bridge-select-token
|
(rf/reg-event-fx :wallet/bridge-select-token
|
||||||
(fn [{:keys [db]} [{:keys [token token-symbol stack-id start-flow?]}]]
|
(fn [{:keys [db]}
|
||||||
(let [missing-recipient? (-> db :wallet :ui :send :to-address nil?)
|
[{:keys [token token-symbol stack-id network owners network-details start-flow?] :as params}]]
|
||||||
to-address (-> db :wallet :current-viewing-account-address)]
|
(let [{:keys [wallet]} db
|
||||||
|
unique-owner (when (= (count owners) 1)
|
||||||
|
(first owners))
|
||||||
|
token (if (and unique-owner (nil? token))
|
||||||
|
(let [token (utils/get-token-from-account db
|
||||||
|
token-symbol
|
||||||
|
unique-owner)]
|
||||||
|
(assoc token
|
||||||
|
:networks (network-utils/network-list-with-positive-balance
|
||||||
|
token
|
||||||
|
network-details)
|
||||||
|
:supported-networks (network-utils/network-list
|
||||||
|
token
|
||||||
|
network-details)
|
||||||
|
:total-balance (utils/calculate-total-token-balance token)))
|
||||||
|
token)
|
||||||
|
missing-recipient? (-> db :wallet :ui :send :to-address nil?)
|
||||||
|
to-address (or unique-owner
|
||||||
|
(-> db :wallet :current-viewing-account-address)
|
||||||
|
(utils/get-default-account (-> db :wallet :accounts)))
|
||||||
|
view-id (:view-id db)
|
||||||
|
root-screen? (or (= view-id :wallet-stack) (nil? view-id))
|
||||||
|
multi-account-balance? (-> (utils/get-accounts-with-token-balance (:accounts wallet)
|
||||||
|
token)
|
||||||
|
(count)
|
||||||
|
(> 1))]
|
||||||
{:db (cond-> db
|
{:db (cond-> db
|
||||||
:always (assoc-in [:wallet :ui :send :tx-type] :tx/bridge)
|
:always (assoc-in [:wallet :ui :send :tx-type] :tx/bridge)
|
||||||
token (assoc-in [:wallet :ui :send :token] token)
|
token (assoc-in [:wallet :ui :send :token] token)
|
||||||
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol)
|
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol)
|
||||||
|
network (assoc-in [:wallet :ui :send :network] network)
|
||||||
missing-recipient? (assoc-in [:wallet :ui :send :to-address] to-address))
|
missing-recipient? (assoc-in [:wallet :ui :send :to-address] to-address))
|
||||||
:fx [[:dispatch
|
:fx (if (and (not unique-owner) multi-account-balance? root-screen?)
|
||||||
[:wallet/wizard-navigate-forward
|
[[:dispatch [:open-modal :screen/wallet.select-from]]]
|
||||||
{:current-screen stack-id
|
(if (some? network)
|
||||||
:start-flow? start-flow?
|
[[:dispatch
|
||||||
:flow-id :wallet-bridge-flow}]]]})))
|
[:wallet/wizard-navigate-forward
|
||||||
|
{:current-screen stack-id
|
||||||
|
:start-flow? start-flow?
|
||||||
|
:flow-id :wallet-bridge-flow}]]]
|
||||||
|
[[:dispatch [:wallet/switch-current-viewing-account to-address]]
|
||||||
|
[:dispatch
|
||||||
|
[:show-bottom-sheet
|
||||||
|
{:content (fn []
|
||||||
|
[network-selection/view
|
||||||
|
{:title (i18n/label :t/select-network-to-bridge-from)
|
||||||
|
:token-symbol (or token-symbol (:symbol token))
|
||||||
|
:source :bridge
|
||||||
|
:on-select-network (fn [network]
|
||||||
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
|
(rf/dispatch
|
||||||
|
[:wallet/bridge-select-token
|
||||||
|
(assoc params :network network)]))}])}]]]))})))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/start-bridge
|
(rf/reg-event-fx :wallet/start-bridge
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
[status-im.contexts.wallet.collectible.utils :as collectible.utils]
|
[status-im.contexts.wallet.collectible.utils :as collectible.utils]
|
||||||
[status-im.contexts.wallet.common.utils :as utils]
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||||
|
[status-im.contexts.wallet.common.wizard.utils :as wizard-utils]
|
||||||
[status-im.contexts.wallet.data-store :as data-store]
|
[status-im.contexts.wallet.data-store :as data-store]
|
||||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||||
|
[status-im.contexts.wallet.sheets.network-selection.view :as network-selection]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.money :as utils.money]
|
[utils.money :as utils.money]
|
||||||
[utils.number]
|
[utils.number]
|
||||||
@@ -148,23 +150,16 @@
|
|||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/select-send-address
|
:wallet/select-send-address
|
||||||
(fn [{:keys [db]} [{:keys [address recipient stack-id start-flow?]}]]
|
(fn [{:keys [db]} [{:keys [address recipient stack-id start-flow?]}]]
|
||||||
(let [[prefix to-address] (utils/split-prefix-and-address address)
|
(let [[_ to-address] (utils/split-prefix-and-address address)
|
||||||
testnet-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
collectible-tx? (send-utils/tx-type-collectible?
|
||||||
receiver-networks (network-utils/resolve-receiver-networks
|
(-> db :wallet :ui :send :tx-type))
|
||||||
{:prefix prefix
|
collectible (when collectible-tx?
|
||||||
:testnet-enabled? testnet-enabled?})
|
(-> db :wallet :ui :send :collectible))
|
||||||
collectible-tx? (send-utils/tx-type-collectible?
|
one-collectible? (when collectible-tx?
|
||||||
(-> db :wallet :ui :send :tx-type))
|
(= (collectible.utils/collectible-balance collectible) 1))]
|
||||||
collectible (when collectible-tx?
|
|
||||||
(-> db :wallet :ui :send :collectible))
|
|
||||||
one-collectible? (when collectible-tx?
|
|
||||||
(= (collectible.utils/collectible-balance collectible) 1))]
|
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc-in [:wallet :ui :send :recipient] (or recipient address))
|
(assoc-in [:wallet :ui :send :recipient] (or recipient address))
|
||||||
(assoc-in [:wallet :ui :send :to-address] to-address)
|
(assoc-in [:wallet :ui :send :to-address] to-address))
|
||||||
(assoc-in [:wallet :ui :send :address-prefix] prefix)
|
|
||||||
(assoc-in [:wallet :ui :send :receiver-preferred-networks] receiver-networks)
|
|
||||||
(assoc-in [:wallet :ui :send :receiver-networks] receiver-networks))
|
|
||||||
:fx [(when (and collectible-tx? one-collectible?)
|
:fx [(when (and collectible-tx? one-collectible?)
|
||||||
[:dispatch [:wallet/start-get-suggested-routes {:amount 1}]])
|
[:dispatch [:wallet/start-get-suggested-routes {:amount 1}]])
|
||||||
[:dispatch
|
[:dispatch
|
||||||
@@ -182,14 +177,12 @@
|
|||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/set-token-to-send
|
:wallet/set-token-to-send
|
||||||
(fn [{:keys [db]} [{:keys [token-symbol token stack-id start-flow? owners]} entry-point]]
|
(fn [{:keys [db]}
|
||||||
|
[{:keys [token-symbol token network stack-id start-flow? owners] :as params} entry-point]]
|
||||||
;; `token` is a map extracted from the sender, but in the wallet home page we don't know the
|
;; `token` is a map extracted from the sender, but in the wallet home page we don't know the
|
||||||
;; sender yet, so we only provide the `token-symbol`, later in
|
;; sender yet, so we only provide the `token-symbol`, later in
|
||||||
;; `:wallet/select-from-account` the `token` key will be set.
|
;; `:wallet/select-from-account` the `token` key will be set.
|
||||||
(let [{:keys [networks]} token
|
(let [{:keys [wallet]} db
|
||||||
receiver-networks (get-in db [:wallet :ui :send :receiver-networks])
|
|
||||||
token-networks-ids (map :chain-id networks)
|
|
||||||
unsupported-token? (not-any? (set receiver-networks) token-networks-ids)
|
|
||||||
unique-owner (when (= (count owners) 1)
|
unique-owner (when (= (count owners) 1)
|
||||||
(first owners))
|
(first owners))
|
||||||
unique-owner-tokens (get-in db [:wallet :accounts unique-owner :tokens])
|
unique-owner-tokens (get-in db [:wallet :accounts unique-owner :tokens])
|
||||||
@@ -197,17 +190,25 @@
|
|||||||
(when (and token-symbol unique-owner)
|
(when (and token-symbol unique-owner)
|
||||||
(some #(when (= (:symbol %) token-symbol) %)
|
(some #(when (= (:symbol %) token-symbol) %)
|
||||||
unique-owner-tokens)))
|
unique-owner-tokens)))
|
||||||
|
view-id (:view-id db)
|
||||||
|
root-screen? (or (= view-id :wallet-stack) (nil? view-id))
|
||||||
|
multi-account-balance? (-> (utils/get-accounts-with-token-balance (:accounts wallet)
|
||||||
|
token)
|
||||||
|
(count)
|
||||||
|
(> 1))
|
||||||
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
||||||
network-details (-> (get-in db
|
network-details (-> (get-in db
|
||||||
[:wallet :networks (if test-networks-enabled? :test :prod)])
|
[:wallet :networks (if test-networks-enabled? :test :prod)])
|
||||||
(network-utils/sorted-networks-with-details))]
|
(network-utils/sorted-networks-with-details))
|
||||||
|
next-screen (:screen-id (wizard-utils/wizard-find-next-screen db
|
||||||
|
:wallet-send-flow
|
||||||
|
stack-id))]
|
||||||
(when (or token-data token-symbol)
|
(when (or token-data token-symbol)
|
||||||
{:db (cond-> db
|
{:db (cond-> db
|
||||||
:always (update-in [:wallet :ui :send]
|
network (update-in [:wallet :ui :send]
|
||||||
#(-> %
|
#(-> %
|
||||||
(dissoc :collectible :tx-type)
|
(dissoc :collectible :tx-type)
|
||||||
(assoc :token-not-supported-in-receiver-networks?
|
(assoc :network network)))
|
||||||
unsupported-token?)))
|
|
||||||
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol)
|
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol)
|
||||||
token-data (update-in [:wallet :ui :send]
|
token-data (update-in [:wallet :ui :send]
|
||||||
#(assoc %
|
#(assoc %
|
||||||
@@ -216,20 +217,35 @@
|
|||||||
(network-utils/network-list
|
(network-utils/network-list
|
||||||
token-data
|
token-data
|
||||||
network-details))
|
network-details))
|
||||||
:token-display-name (:symbol token-data)))
|
:token-display-name (:symbol token-data)
|
||||||
|
:token-symbol (:symbol token-data)))
|
||||||
unique-owner (assoc-in [:wallet :current-viewing-account-address] unique-owner)
|
unique-owner (assoc-in [:wallet :current-viewing-account-address] unique-owner)
|
||||||
entry-point (assoc-in [:wallet :ui :send :entry-point] entry-point))
|
entry-point (assoc-in [:wallet :ui :send :entry-point] entry-point))
|
||||||
:fx [[:dispatch [:wallet/stop-and-clean-suggested-routes]]
|
:fx (if (and (not unique-owner) multi-account-balance? root-screen?)
|
||||||
[:dispatch
|
[[:dispatch [:open-modal :screen/wallet.select-from]]]
|
||||||
;; ^:flush-dom allows us to make sure the re-frame DB state is always synced
|
(if (or (= next-screen :screen/wallet.select-from) (some? network))
|
||||||
;; before the navigation occurs, so the new screen is always rendered with
|
[[:dispatch [:wallet/stop-and-clean-suggested-routes]]
|
||||||
;; the DB state set by this event. By adding the metadata we are omitting
|
[:dispatch
|
||||||
;; a 1-frame blink when the screen is mounted.
|
;; ^:flush-dom allows us to make sure the re-frame DB state is always synced
|
||||||
^:flush-dom
|
;; before the navigation occurs, so the new screen is always rendered with
|
||||||
[:wallet/wizard-navigate-forward
|
;; the DB state set by this event. By adding the metadata we are omitting
|
||||||
{:current-screen stack-id
|
;; a 1-frame blink when the screen is mounted.
|
||||||
:start-flow? start-flow?
|
^:flush-dom
|
||||||
:flow-id :wallet-send-flow}]]]}))))
|
[:wallet/wizard-navigate-forward
|
||||||
|
{:current-screen stack-id
|
||||||
|
:start-flow? start-flow?
|
||||||
|
:flow-id :wallet-send-flow}]]]
|
||||||
|
[[:dispatch
|
||||||
|
[:show-bottom-sheet
|
||||||
|
{:content (fn []
|
||||||
|
[network-selection/view
|
||||||
|
{:token-symbol (or token-symbol (:symbol token-data))
|
||||||
|
:source :send
|
||||||
|
:on-select-network (fn [network]
|
||||||
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
|
(rf/dispatch
|
||||||
|
[:wallet/set-token-to-send
|
||||||
|
(assoc params :network network)]))}])}]]]))}))))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/edit-token-to-send
|
:wallet/edit-token-to-send
|
||||||
@@ -288,7 +304,7 @@
|
|||||||
|
|
||||||
collectible
|
collectible
|
||||||
(str (:name collection-data) " #" collectible-id))
|
(str (:name collection-data) " #" collectible-id))
|
||||||
owner-address (-> db :wallet :current-viewing-account-address)
|
owner-address (-> collectible :ownership first :address)
|
||||||
collectible-tx (-> db
|
collectible-tx (-> db
|
||||||
(update-in [:wallet :ui :send] dissoc :token)
|
(update-in [:wallet :ui :send] dissoc :token)
|
||||||
(assoc-in [:wallet :ui :send :collectible] collectible)
|
(assoc-in [:wallet :ui :send :collectible] collectible)
|
||||||
@@ -404,89 +420,62 @@
|
|||||||
|
|
||||||
(rf/reg-event-fx :wallet/start-get-suggested-routes
|
(rf/reg-event-fx :wallet/start-get-suggested-routes
|
||||||
(fn [{:keys [db]} [{:keys [amount amount-out updated-token] :as args :or {amount-out "0"}}]]
|
(fn [{:keys [db]} [{:keys [amount amount-out updated-token] :as args :or {amount-out "0"}}]]
|
||||||
(let [wallet-address (get-in db [:wallet :current-viewing-account-address])
|
(let [wallet-address (get-in db [:wallet :current-viewing-account-address])
|
||||||
{:keys [token tx-type collectible to-address
|
{:keys [token tx-type collectible to-address
|
||||||
receiver-networks disabled-from-chain-ids
|
network bridge-to-chain-id]
|
||||||
from-locked-amounts bridge-to-chain-id]
|
|
||||||
:or {token updated-token}} (get-in db [:wallet :ui :send])
|
:or {token updated-token}} (get-in db [:wallet :ui :send])
|
||||||
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
||||||
networks (get-in db [:wallet :networks (if test-networks-enabled? :test :prod)])
|
networks (get-in db
|
||||||
network-chain-ids (map :chain-id networks)
|
[:wallet :networks
|
||||||
token-decimal (when token (:decimals token))
|
(if test-networks-enabled? :test :prod)])
|
||||||
token-id (utils/format-token-id token collectible)
|
network-chain-ids (map :chain-id networks)
|
||||||
to-token-id ""
|
token-decimal (when token (:decimals token))
|
||||||
gas-rates constants/gas-rate-medium
|
token-id (utils/format-token-id token collectible)
|
||||||
to-hex (fn [v] (send-utils/amount-in-hex v (if token token-decimal 0)))
|
to-token-id ""
|
||||||
amount-in (to-hex amount)
|
gas-rates constants/gas-rate-medium
|
||||||
amount-out (to-hex amount-out)
|
to-hex (fn [v] (send-utils/amount-in-hex v (if token token-decimal 0)))
|
||||||
from-address wallet-address
|
amount-in (to-hex amount)
|
||||||
disabled-to-chain-ids (if (= tx-type :tx/bridge)
|
amount-out (to-hex amount-out)
|
||||||
(filter #(not= % bridge-to-chain-id) network-chain-ids)
|
from-address wallet-address
|
||||||
(filter (fn [chain-id]
|
network-chain-id (if collectible
|
||||||
(not (some #(= chain-id %)
|
(get-in collectible [:id :contract-id :chain-id])
|
||||||
receiver-networks)))
|
(:chain-id network))
|
||||||
network-chain-ids))
|
disabled-from-chain-ids (filter #(not= % network-chain-id) network-chain-ids)
|
||||||
from-locked-amount (update-vals from-locked-amounts to-hex)
|
disabled-to-chain-ids (filter #(not= %
|
||||||
send-type (case tx-type
|
(if (= tx-type :tx/bridge)
|
||||||
:tx/collectible-erc-721 constants/send-type-erc-721-transfer
|
bridge-to-chain-id
|
||||||
:tx/collectible-erc-1155 constants/send-type-erc-1155-transfer
|
network-chain-id))
|
||||||
:tx/bridge constants/send-type-bridge
|
network-chain-ids)
|
||||||
constants/send-type-transfer)
|
send-type (case tx-type
|
||||||
balances-per-chain (when token (:balances-per-chain token))
|
:tx/collectible-erc-721 constants/send-type-erc-721-transfer
|
||||||
sender-token-available-networks-for-suggested-routes
|
:tx/collectible-erc-1155 constants/send-type-erc-1155-transfer
|
||||||
(when token
|
:tx/bridge constants/send-type-bridge
|
||||||
(send-utils/token-available-networks-for-suggested-routes
|
constants/send-type-transfer)
|
||||||
{:balances-per-chain balances-per-chain
|
sender-network-values (when (= tx-type :tx/bridge)
|
||||||
:disabled-chain-ids disabled-from-chain-ids
|
(send-utils/loading-network-amounts
|
||||||
:only-with-balance? true}))
|
{:networks [network-chain-id]
|
||||||
receiver-token-available-networks-for-suggested-routes
|
:values {network-chain-id amount}
|
||||||
(when token
|
:receiver? false}))
|
||||||
(send-utils/token-available-networks-for-suggested-routes
|
receiver-network-values (when (= tx-type :tx/bridge)
|
||||||
{:balances-per-chain balances-per-chain
|
(send-utils/loading-network-amounts
|
||||||
:disabled-chain-ids disabled-from-chain-ids
|
{:networks [bridge-to-chain-id]
|
||||||
:only-with-balance? false}))
|
:receiver? true}))
|
||||||
token-networks-ids (when token (map #(:chain-id %) (:supported-networks token)))
|
request-uuid (str (random-uuid))
|
||||||
sender-network-values (when sender-token-available-networks-for-suggested-routes
|
params [{:uuid request-uuid
|
||||||
(send-utils/loading-network-amounts
|
:sendType send-type
|
||||||
{:valid-networks
|
:addrFrom from-address
|
||||||
(if (= tx-type :tx/bridge)
|
:addrTo to-address
|
||||||
(remove #(= bridge-to-chain-id %)
|
:amountIn amount-in
|
||||||
sender-token-available-networks-for-suggested-routes)
|
:amountOut amount-out
|
||||||
sender-token-available-networks-for-suggested-routes)
|
:tokenID token-id
|
||||||
:disabled-chain-ids disabled-from-chain-ids
|
:toTokenID to-token-id
|
||||||
:receiver-networks receiver-networks
|
:disabledFromChainIDs disabled-from-chain-ids
|
||||||
:token-networks-ids token-networks-ids
|
:disabledToChainIDs disabled-to-chain-ids
|
||||||
:tx-type tx-type
|
:gasFeeMode gas-rates
|
||||||
:receiver? false}))
|
:fromLockedAmount {}
|
||||||
receiver-network-values (when receiver-token-available-networks-for-suggested-routes
|
:username (:username args)
|
||||||
(send-utils/loading-network-amounts
|
:publicKey (:publicKey args)
|
||||||
{:valid-networks
|
:packID (:packID args)}]]
|
||||||
(if (= tx-type :tx/bridge)
|
|
||||||
(filter
|
|
||||||
#(= bridge-to-chain-id %)
|
|
||||||
receiver-token-available-networks-for-suggested-routes)
|
|
||||||
receiver-token-available-networks-for-suggested-routes)
|
|
||||||
:disabled-chain-ids disabled-from-chain-ids
|
|
||||||
:receiver-networks receiver-networks
|
|
||||||
:token-networks-ids token-networks-ids
|
|
||||||
:tx-type tx-type
|
|
||||||
:receiver? true}))
|
|
||||||
request-uuid (str (random-uuid))
|
|
||||||
params [{:uuid request-uuid
|
|
||||||
:sendType send-type
|
|
||||||
:addrFrom from-address
|
|
||||||
:addrTo to-address
|
|
||||||
:amountIn amount-in
|
|
||||||
:amountOut amount-out
|
|
||||||
:tokenID token-id
|
|
||||||
:toTokenID to-token-id
|
|
||||||
:disabledFromChainIDs disabled-from-chain-ids
|
|
||||||
:disabledToChainIDs disabled-to-chain-ids
|
|
||||||
:gasFeeMode gas-rates
|
|
||||||
:fromLockedAmount from-locked-amount
|
|
||||||
:username (:username args)
|
|
||||||
:publicKey (:publicKey args)
|
|
||||||
:packID (:packID args)}]]
|
|
||||||
(when (and to-address from-address amount-in token-id)
|
(when (and to-address from-address amount-in token-id)
|
||||||
{:db (update-in db
|
{:db (update-in db
|
||||||
[:wallet :ui :send]
|
[:wallet :ui :send]
|
||||||
@@ -712,7 +701,7 @@
|
|||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/select-from-account
|
:wallet/select-from-account
|
||||||
(fn [{db :db} [{:keys [address stack-id network-details start-flow?]}]]
|
(fn [{db :db} [{:keys [address stack-id network-details network start-flow?] :as params}]]
|
||||||
(let [{:keys [token-symbol
|
(let [{:keys [token-symbol
|
||||||
tx-type]} (-> db :wallet :ui :send)
|
tx-type]} (-> db :wallet :ui :send)
|
||||||
token (when token-symbol
|
token (when token-symbol
|
||||||
@@ -724,22 +713,38 @@
|
|||||||
:networks (network-utils/network-list-with-positive-balance
|
:networks (network-utils/network-list-with-positive-balance
|
||||||
token
|
token
|
||||||
network-details)
|
network-details)
|
||||||
:supported-networks (network-utils/network-list token
|
:supported-networks (network-utils/network-list
|
||||||
network-details)
|
token
|
||||||
|
network-details)
|
||||||
:total-balance (utils/calculate-total-token-balance token))))
|
:total-balance (utils/calculate-total-token-balance token))))
|
||||||
bridge-tx? (= tx-type :tx/bridge)
|
bridge-tx? (= tx-type :tx/bridge)
|
||||||
flow-id (if bridge-tx?
|
flow-id (if bridge-tx?
|
||||||
:wallet-bridge-flow
|
:wallet-bridge-flow
|
||||||
:wallet-send-flow)]
|
:wallet-send-flow)]
|
||||||
{:db (cond-> db
|
{:db (cond-> db
|
||||||
|
network (assoc-in [:wallet :ui :send :network] network)
|
||||||
token-symbol (assoc-in [:wallet :ui :send :token] token)
|
token-symbol (assoc-in [:wallet :ui :send :token] token)
|
||||||
bridge-tx? (assoc-in [:wallet :ui :send :to-address] address))
|
bridge-tx? (assoc-in [:wallet :ui :send :to-address] address))
|
||||||
:fx [[:dispatch [:wallet/switch-current-viewing-account address]]
|
:fx (if (some? network)
|
||||||
[:dispatch
|
[[:dispatch [:wallet/switch-current-viewing-account address]]
|
||||||
[:wallet/wizard-navigate-forward
|
[:dispatch
|
||||||
{:current-screen stack-id
|
[:wallet/wizard-navigate-forward
|
||||||
:start-flow? start-flow?
|
{:current-screen stack-id
|
||||||
:flow-id flow-id}]]]})))
|
:start-flow? start-flow?
|
||||||
|
:flow-id flow-id}]]]
|
||||||
|
[[:dispatch [:dismiss-modal :screen/wallet.select-from]]
|
||||||
|
[:dispatch [:wallet/switch-current-viewing-account address]]
|
||||||
|
[:dispatch
|
||||||
|
[:show-bottom-sheet
|
||||||
|
{:content (fn []
|
||||||
|
[network-selection/view
|
||||||
|
{:token-symbol (or token-symbol (:symbol token))
|
||||||
|
:source :send
|
||||||
|
:on-select-network (fn [network]
|
||||||
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
|
(rf/dispatch
|
||||||
|
[:wallet/select-from-account
|
||||||
|
(assoc params :network network)]))}])}]]])})))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/transaction-confirmation-navigate-back
|
:wallet/transaction-confirmation-navigate-back
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
(ns status-im.contexts.wallet.send.events-test
|
(ns status-im.contexts.wallet.send.events-test
|
||||||
(:require
|
(:require
|
||||||
[cljs.test :refer-macros [is testing]]
|
[cljs.test :refer-macros [is testing]]
|
||||||
|
[matcher-combinators.matchers :as m]
|
||||||
matcher-combinators.test
|
matcher-combinators.test
|
||||||
[re-frame.db :as rf-db]
|
[re-frame.db :as rf-db]
|
||||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||||
@@ -579,8 +580,23 @@
|
|||||||
[event-id dispatch]
|
[event-id dispatch]
|
||||||
(let [stack-id :screen/stack
|
(let [stack-id :screen/stack
|
||||||
start-flow? false
|
start-flow? false
|
||||||
address "0x01"]
|
address "0x01"
|
||||||
|
network {:chain-id 1}]
|
||||||
(testing "when tx-type is :tx/bridge and token-symbol is nil"
|
(testing "when tx-type is :tx/bridge and token-symbol is nil"
|
||||||
|
(let [flow-id :wallet-bridge-flow
|
||||||
|
tx-type :tx/bridge
|
||||||
|
expected-result {:db {:wallet {:ui {:send {:to-address address
|
||||||
|
:tx-type tx-type}}}}
|
||||||
|
:fx [[:dispatch [:dismiss-modal :screen/wallet.select-from]]
|
||||||
|
[:dispatch [:wallet/switch-current-viewing-account address]]
|
||||||
|
[:dispatch [:show-bottom-sheet {:content (m/pred fn?)}]]]}]
|
||||||
|
(reset! rf-db/app-db {:wallet {:ui {:send {:tx-type tx-type}}}})
|
||||||
|
(is (match? expected-result
|
||||||
|
(dispatch [event-id
|
||||||
|
{:address address
|
||||||
|
:stack-id stack-id
|
||||||
|
:start-flow? start-flow?}])))))
|
||||||
|
(testing "when tx-type is :tx/bridge, network is selected and token-symbol is nil"
|
||||||
(let [flow-id :wallet-bridge-flow
|
(let [flow-id :wallet-bridge-flow
|
||||||
tx-type :tx/bridge
|
tx-type :tx/bridge
|
||||||
expected-result {:db {:wallet {:ui {:send {:to-address address
|
expected-result {:db {:wallet {:ui {:send {:to-address address
|
||||||
@@ -596,6 +612,7 @@
|
|||||||
(dispatch [event-id
|
(dispatch [event-id
|
||||||
{:address address
|
{:address address
|
||||||
:stack-id stack-id
|
:stack-id stack-id
|
||||||
|
:network network
|
||||||
:start-flow? start-flow?}])))))
|
:start-flow? start-flow?}])))))
|
||||||
(testing "when tx-type is not :tx/bridge and token-symbol is nil"
|
(testing "when tx-type is not :tx/bridge and token-symbol is nil"
|
||||||
(let [flow-id :wallet-send-flow
|
(let [flow-id :wallet-send-flow
|
||||||
@@ -612,6 +629,7 @@
|
|||||||
(dispatch [event-id
|
(dispatch [event-id
|
||||||
{:address address
|
{:address address
|
||||||
:stack-id stack-id
|
:stack-id stack-id
|
||||||
|
:network network
|
||||||
:start-flow? start-flow?}])))))
|
:start-flow? start-flow?}])))))
|
||||||
(testing "when tx-type is :tx/bridge and token-symbol is not nil"
|
(testing "when tx-type is :tx/bridge and token-symbol is not nil"
|
||||||
(let [flow-id :wallet-bridge-flow
|
(let [flow-id :wallet-bridge-flow
|
||||||
@@ -680,5 +698,6 @@
|
|||||||
(dispatch [event-id
|
(dispatch [event-id
|
||||||
{:address address
|
{:address address
|
||||||
:stack-id stack-id
|
:stack-id stack-id
|
||||||
|
:network network
|
||||||
:start-flow? start-flow?
|
:start-flow? start-flow?
|
||||||
:netork-details network-details}])))))))
|
:netork-details network-details}])))))))
|
||||||
|
|||||||
@@ -14,9 +14,7 @@
|
|||||||
(-> db :wallet :ui :send :token some?))
|
(-> db :wallet :ui :send :token some?))
|
||||||
|
|
||||||
(def steps
|
(def steps
|
||||||
[{:screen-id :screen/wallet.select-from
|
[{:screen-id :screen/wallet.select-address
|
||||||
:skip-step? (fn [db] (some? (get-in db [:wallet :current-viewing-account-address])))}
|
|
||||||
{:screen-id :screen/wallet.select-address
|
|
||||||
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :recipient])))}
|
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :recipient])))}
|
||||||
{:screen-id :screen/wallet.select-asset
|
{:screen-id :screen/wallet.select-asset
|
||||||
:skip-step? (fn [db] (or (token-selected? db) (collectible-selected? db)))}
|
:skip-step? (fn [db] (or (token-selected? db) (collectible-selected? db)))}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||||
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
||||||
[status-im.contexts.wallet.send.from.style :as style]
|
[status-im.contexts.wallet.send.from.style :as style]
|
||||||
[status-im.setup.hot-reload :as hot-reload]
|
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
|
[utils.money :as money]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn- on-account-press
|
(defn- on-account-press
|
||||||
@@ -15,27 +15,28 @@
|
|||||||
(rf/dispatch [:wallet/select-from-account
|
(rf/dispatch [:wallet/select-from-account
|
||||||
{:address address
|
{:address address
|
||||||
:network-details network-details
|
:network-details network-details
|
||||||
:stack-id :screen/wallet.select-from}]))
|
:stack-id :screen/wallet.select-from
|
||||||
|
:start-flow? true}]))
|
||||||
(defn- on-close
|
|
||||||
[]
|
|
||||||
(rf/dispatch [:wallet/clean-current-viewing-account]))
|
|
||||||
|
|
||||||
(defn- render-fn
|
(defn- render-fn
|
||||||
[item _ _ {:keys [network-details]}]
|
[item _ _ {:keys [network-details]}]
|
||||||
(let [transformed-address (rf/sub [:wallet/account-address (:address item)
|
(let [has-balance (money/above-zero? (:asset-pay-balance item))]
|
||||||
(:network-preferences-names item)])]
|
|
||||||
[quo/account-item
|
[quo/account-item
|
||||||
{:on-press #(on-account-press (:address item) network-details)
|
{:type (if has-balance :tag :default)
|
||||||
|
:on-press #(on-account-press (:address item) network-details)
|
||||||
|
:state (if has-balance :default :disabled)
|
||||||
|
:token-props {:symbol (:asset-pay-symbol item)
|
||||||
|
:value (:asset-pay-balance item)}
|
||||||
:account-props (assoc item
|
:account-props (assoc item
|
||||||
:address transformed-address
|
:address (:formatted-address item)
|
||||||
:full-address? true)}]))
|
:full-address? true)}]))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [accounts (rf/sub [:wallet/accounts-with-current-asset])
|
(let [token-symbol (rf/sub [:wallet/send-token-symbol])
|
||||||
|
token (rf/sub [:wallet/token-by-symbol token-symbol])
|
||||||
|
accounts (rf/sub [:wallet/accounts-with-balances token])
|
||||||
network-details (rf/sub [:wallet/network-details])]
|
network-details (rf/sub [:wallet/network-details])]
|
||||||
(hot-reload/use-safe-unmount on-close)
|
|
||||||
[floating-button-page/view
|
[floating-button-page/view
|
||||||
{:footer-container-padding 0
|
{:footer-container-padding 0
|
||||||
:header [account-switcher/view
|
:header [account-switcher/view
|
||||||
|
|||||||
@@ -30,19 +30,16 @@
|
|||||||
(let [amount (rf/sub [:wallet/send-total-amount-formatted])
|
(let [amount (rf/sub [:wallet/send-total-amount-formatted])
|
||||||
tx-type (rf/sub [:wallet/wallet-send-tx-type])
|
tx-type (rf/sub [:wallet/wallet-send-tx-type])
|
||||||
{:keys [full-name]} (rf/sub [:wallet/bridge-to-network-details])]
|
{:keys [full-name]} (rf/sub [:wallet/bridge-to-network-details])]
|
||||||
[quo/data-item
|
(when (= tx-type :tx/bridge)
|
||||||
(cond-> {:container-style style/amount-data-item
|
[quo/data-item
|
||||||
:status (if loading-routes? :loading :default)
|
{:container-style style/amount-data-item
|
||||||
:size :small
|
:status (if loading-routes? :loading :default)
|
||||||
:title (i18n/label :t/recipient-gets)
|
:size :small
|
||||||
:subtitle amount}
|
:title-icon :i/info
|
||||||
|
:title (i18n/label :t/bridged-to
|
||||||
(= tx-type :tx/bridge)
|
{:network full-name})
|
||||||
(assoc
|
:subtitle amount
|
||||||
:title-icon :i/info
|
:on-press show-bonder-fee-info}])))
|
||||||
:title (i18n/label :t/bridged-to
|
|
||||||
{:network full-name})
|
|
||||||
:on-press show-bonder-fee-info))]))
|
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [loading-routes? fees]}]
|
[{:keys [loading-routes? fees]}]
|
||||||
@@ -62,6 +59,6 @@
|
|||||||
{:container-style style/fees-data-item
|
{:container-style style/fees-data-item
|
||||||
:status (if loading-routes? :loading :default)
|
:status (if loading-routes? :loading :default)
|
||||||
:size :small
|
:size :small
|
||||||
:title (i18n/label :t/fees)
|
:title (i18n/label :t/max-fees)
|
||||||
:subtitle fees}]
|
:subtitle fees}]
|
||||||
[received-amount {:loading-routes? loading-routes?}]])
|
[received-amount {:loading-routes? loading-routes?}]])
|
||||||
|
|||||||
@@ -25,10 +25,9 @@
|
|||||||
:height 40})
|
:height 40})
|
||||||
|
|
||||||
(def fees-data-item
|
(def fees-data-item
|
||||||
{:flex 1
|
{:flex 1
|
||||||
:height 40
|
:height 40
|
||||||
:margin-horizontal 16
|
:background-color :transparent})
|
||||||
:background-color :transparent})
|
|
||||||
|
|
||||||
(def amount-data-item
|
(def amount-data-item
|
||||||
{:flex 1
|
{:flex 1
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[quo.foundations.colors :as colors]
|
|
||||||
[quo.theme]
|
[quo.theme]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[react-native.safe-area :as safe-area]
|
[react-native.safe-area :as safe-area]
|
||||||
@@ -15,29 +14,18 @@
|
|||||||
[status-im.contexts.wallet.send.input-amount.style :as style]
|
[status-im.contexts.wallet.send.input-amount.style :as style]
|
||||||
[status-im.contexts.wallet.send.routes.view :as routes]
|
[status-im.contexts.wallet.send.routes.view :as routes]
|
||||||
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
|
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
|
||||||
[status-im.contexts.wallet.sheets.unpreferred-networks-alert.view :as unpreferred-networks-alert]
|
|
||||||
[status-im.setup.hot-reload :as hot-reload]
|
[status-im.setup.hot-reload :as hot-reload]
|
||||||
[utils.debounce :as debounce]
|
[utils.debounce :as debounce]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.money :as money]
|
[utils.money :as money]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn- every-network-value-is-zero?
|
|
||||||
[sender-network-values]
|
|
||||||
(every? (fn [{:keys [total-amount]}]
|
|
||||||
(and
|
|
||||||
total-amount
|
|
||||||
(money/bignumber? total-amount)
|
|
||||||
(money/equal-to total-amount
|
|
||||||
(money/bignumber "0"))))
|
|
||||||
sender-network-values))
|
|
||||||
|
|
||||||
(defn select-asset-bottom-sheet
|
(defn select-asset-bottom-sheet
|
||||||
[clear-input!]
|
[clear-input!]
|
||||||
(let [{preselected-token-symbol :symbol} (rf/sub [:wallet/wallet-send-token])]
|
(let [{preselected-token-symbol :symbol} (rf/sub [:wallet/wallet-send-token])]
|
||||||
[:<> ;; Need to be a `:<>` to keep `asset-list` scrollable.
|
[:<> ;; Need to be a `:<>` to keep `asset-list` scrollable.
|
||||||
[quo/drawer-top
|
[quo/drawer-top
|
||||||
{:title (i18n/label :t/select-asset)
|
{:title (i18n/label :t/select-token)
|
||||||
:container-style {:padding-bottom 8}}]
|
:container-style {:padding-bottom 8}}]
|
||||||
[asset-list/view
|
[asset-list/view
|
||||||
{:content-container-style {:padding-horizontal 8
|
{:content-container-style {:padding-horizontal 8
|
||||||
@@ -47,37 +35,6 @@
|
|||||||
(rf/dispatch [:wallet/edit-token-to-send token])
|
(rf/dispatch [:wallet/edit-token-to-send token])
|
||||||
(clear-input!))}]]))
|
(clear-input!))}]]))
|
||||||
|
|
||||||
(defn- token-not-available
|
|
||||||
[token-symbol receiver-networks token-networks]
|
|
||||||
(let [theme (quo.theme/use-theme)
|
|
||||||
add-token-networks (fn []
|
|
||||||
(let [chain-ids (concat receiver-networks
|
|
||||||
(mapv #(:chain-id %) token-networks))]
|
|
||||||
(rf/dispatch [:wallet/update-receiver-networks chain-ids])))]
|
|
||||||
[rn/view {:style (style/token-not-available-container theme)}
|
|
||||||
[rn/view
|
|
||||||
[quo/icon :i/alert
|
|
||||||
{:size 16
|
|
||||||
:color (colors/resolve-color :danger theme)}]]
|
|
||||||
[rn/view {:style style/token-not-available-content-container}
|
|
||||||
[quo/text
|
|
||||||
{:style (style/token-not-available-text theme)
|
|
||||||
:size :paragraph-2}
|
|
||||||
(i18n/label :t/token-not-available-on-receiver-networks {:token-symbol token-symbol})]
|
|
||||||
[quo/button
|
|
||||||
{:size 24
|
|
||||||
:customization-color (colors/resolve-color :danger theme)
|
|
||||||
:on-press add-token-networks}
|
|
||||||
(i18n/label :t/add-networks-token-can-be-sent-to {:token-symbol token-symbol})]]]))
|
|
||||||
|
|
||||||
(defn- show-unpreferred-networks-alert
|
|
||||||
[on-confirm]
|
|
||||||
(rf/dispatch
|
|
||||||
[:show-bottom-sheet
|
|
||||||
{:content (fn []
|
|
||||||
[unpreferred-networks-alert/view
|
|
||||||
{:on-confirm on-confirm}])}]))
|
|
||||||
|
|
||||||
(defn- no-routes-found
|
(defn- no-routes-found
|
||||||
[]
|
[]
|
||||||
[rn/view {:style style/no-routes-found-container}
|
[rn/view {:style style/no-routes-found-container}
|
||||||
@@ -119,7 +76,7 @@
|
|||||||
|
|
||||||
(defn- insufficient-asset-amount?
|
(defn- insufficient-asset-amount?
|
||||||
[{:keys [token-symbol owned-eth-token input-state no-routes-found? limit-exceeded?
|
[{:keys [token-symbol owned-eth-token input-state no-routes-found? limit-exceeded?
|
||||||
sender-network-values enough-assets?]}]
|
enough-assets?]}]
|
||||||
(let [eth-selected? (= token-symbol (string/upper-case constants/mainnet-short-name))
|
(let [eth-selected? (= token-symbol (string/upper-case constants/mainnet-short-name))
|
||||||
zero-owned-eth? (money/equal-to (:total-balance owned-eth-token) 0)
|
zero-owned-eth? (money/equal-to (:total-balance owned-eth-token) 0)
|
||||||
input-at-max-owned-amount? (money/equal-to
|
input-at-max-owned-amount? (money/equal-to
|
||||||
@@ -129,7 +86,6 @@
|
|||||||
input-at-max-owned-amount?
|
input-at-max-owned-amount?
|
||||||
zero-owned-eth?)]
|
zero-owned-eth?)]
|
||||||
(and (or no-routes-found? limit-exceeded?)
|
(and (or no-routes-found? limit-exceeded?)
|
||||||
(seq sender-network-values)
|
|
||||||
(or exceeded-input? (not enough-assets?)))))
|
(or exceeded-input? (not enough-assets?)))))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
@@ -142,122 +98,104 @@
|
|||||||
button-one-props :button-one-props
|
button-one-props :button-one-props
|
||||||
current-screen-id :current-screen-id
|
current-screen-id :current-screen-id
|
||||||
initial-crypto-currency? :initial-crypto-currency?
|
initial-crypto-currency? :initial-crypto-currency?
|
||||||
enabled-from-chain-ids :enabled-from-chain-ids
|
|
||||||
from-enabled-networks :from-enabled-networks
|
|
||||||
:or {initial-crypto-currency? true}}]
|
:or {initial-crypto-currency? true}}]
|
||||||
(let [view-id (rf/sub [:view-id])
|
(let [view-id (rf/sub [:view-id])
|
||||||
active-screen? (= view-id current-screen-id)
|
{fiat-currency :currency} (rf/sub [:profile/profile])
|
||||||
bottom (safe-area/get-bottom)
|
currency (rf/sub [:profile/currency])
|
||||||
[crypto-currency?
|
{token-symbol :symbol
|
||||||
set-crypto-currency] (rn/use-state initial-crypto-currency?)
|
:as token} (rf/sub [:wallet/wallet-send-token])
|
||||||
handle-on-confirm (fn [amount]
|
network (rf/sub [:wallet/send-network])
|
||||||
(rf/dispatch [:wallet/set-token-amount-to-send
|
|
||||||
{:amount amount
|
|
||||||
:stack-id current-screen-id}]))
|
|
||||||
{fiat-currency :currency} (rf/sub [:profile/profile])
|
|
||||||
{token-symbol :symbol
|
|
||||||
token-networks :networks
|
|
||||||
:as token} (rf/sub [:wallet/wallet-send-token])
|
|
||||||
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
|
|
||||||
{:keys [total-balance]
|
{:keys [total-balance]
|
||||||
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
|
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
|
||||||
(str token-symbol)
|
(str token-symbol)
|
||||||
enabled-from-chain-ids])
|
[(:chain-id network)]])
|
||||||
token-balance (or default-limit-crypto total-balance)
|
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||||
prices-per-token (rf/sub [:wallet/prices-per-token])
|
loading-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
|
||||||
usd-conversion-rate (utils/token-usd-price token prices-per-token)
|
route (rf/sub [:wallet/wallet-send-route])
|
||||||
currency (rf/sub [:profile/currency])
|
current-address (rf/sub [:wallet/current-viewing-account-address])
|
||||||
token-decimals (rf/sub [:wallet/send-display-token-decimals])
|
current-color (rf/sub [:wallet/current-viewing-account-color])
|
||||||
|
enough-assets? (rf/sub [:wallet/wallet-send-enough-assets?])
|
||||||
conversion-rate (utils/token-price-by-symbol prices-per-token
|
owned-eth-token (rf/sub [:wallet/token-by-symbol
|
||||||
token-symbol
|
(string/upper-case constants/mainnet-short-name)
|
||||||
currency)
|
[(:chain-id network)]])
|
||||||
[input-state set-input-state] (rn/use-state controlled-input/init-state)
|
suggested-routes (rf/sub [:wallet/wallet-send-suggested-routes])
|
||||||
clear-input! #(set-input-state controlled-input/delete-all)
|
tx-type (rf/sub [:wallet/wallet-send-tx-type])
|
||||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
[crypto-currency?
|
||||||
loading-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
|
set-crypto-currency] (rn/use-state initial-crypto-currency?)
|
||||||
route (rf/sub [:wallet/wallet-send-route])
|
[input-state set-input-state] (rn/use-state controlled-input/init-state)
|
||||||
on-confirm (or default-on-confirm handle-on-confirm)
|
active-screen? (= view-id current-screen-id)
|
||||||
max-limit (if crypto-currency?
|
bottom (safe-area/get-bottom)
|
||||||
(utils/cut-crypto-decimals-to-fit-usd-cents
|
token-balance (or default-limit-crypto total-balance)
|
||||||
token-balance
|
prices-per-token (rf/sub [:wallet/prices-per-token])
|
||||||
usd-conversion-rate)
|
usd-conversion-rate (utils/token-usd-price token prices-per-token)
|
||||||
(utils/cut-fiat-balance-to-two-decimals
|
conversion-rate (utils/token-price-by-symbol prices-per-token
|
||||||
(money/crypto->fiat token-balance conversion-rate)))
|
token-symbol
|
||||||
input-value (controlled-input/input-value input-state)
|
currency)
|
||||||
valid-input? (not (or (controlled-input/empty-value? input-state)
|
token-decimals (rf/sub [:wallet/send-display-token-decimals])
|
||||||
(controlled-input/input-error input-state)))
|
clear-input! #(set-input-state controlled-input/delete-all)
|
||||||
amount-in-crypto (if crypto-currency?
|
max-limit (if crypto-currency?
|
||||||
input-value
|
(utils/cut-crypto-decimals-to-fit-usd-cents
|
||||||
(rf/sub [:wallet/send-amount-fixed
|
token-balance
|
||||||
(/ input-value conversion-rate)]))
|
usd-conversion-rate)
|
||||||
show-select-asset-sheet #(rf/dispatch
|
(utils/cut-fiat-balance-to-two-decimals
|
||||||
[:show-bottom-sheet
|
(money/crypto->fiat token-balance conversion-rate)))
|
||||||
{:content (fn []
|
input-value (controlled-input/input-value input-state)
|
||||||
[select-asset-bottom-sheet
|
valid-input? (not (or (controlled-input/empty-value? input-state)
|
||||||
clear-input!])}])
|
(controlled-input/input-error input-state)))
|
||||||
sender-network-values (rf/sub [:wallet/wallet-send-sender-network-values])
|
amount-in-crypto (if crypto-currency?
|
||||||
receiver-network-values (rf/sub [:wallet/wallet-send-receiver-network-values])
|
input-value
|
||||||
tx-type (rf/sub [:wallet/wallet-send-tx-type])
|
(rf/sub [:wallet/send-amount-fixed
|
||||||
unsupported-token-in-receiver? (and (not= tx-type :tx/bridge)
|
(/ input-value conversion-rate)]))
|
||||||
(->> receiver-network-values
|
routes-request-uuid (when suggested-routes
|
||||||
(remove #(= (:type %) :add))
|
(:uuid suggested-routes))
|
||||||
(every? #(= (:type %) :not-available))))
|
no-routes-found? (and
|
||||||
suggested-routes (rf/sub [:wallet/wallet-send-suggested-routes])
|
routes-request-uuid
|
||||||
routes (when suggested-routes
|
(empty? route)
|
||||||
(or (:best suggested-routes) []))
|
(not loading-routes?))
|
||||||
no-routes-found? (and
|
input-error (controlled-input/input-error input-state)
|
||||||
(every-network-value-is-zero? sender-network-values)
|
limit-exceeded? (controlled-input/upper-limit-exceeded? input-state)
|
||||||
(some? routes)
|
not-enough-asset? (insufficient-asset-amount?
|
||||||
(not loading-routes?)
|
{:enough-assets? enough-assets?
|
||||||
(not unsupported-token-in-receiver?))
|
:token-symbol token-symbol
|
||||||
receiver-networks (rf/sub [:wallet/wallet-send-receiver-networks])
|
:owned-eth-token owned-eth-token
|
||||||
receiver-preferred-networks (rf/sub [:wallet/wallet-send-receiver-preferred-networks])
|
:input-state input-state
|
||||||
receiver-preferred-network? (set receiver-preferred-networks)
|
:no-routes-found? no-routes-found?
|
||||||
sending-to-unpreferred-networks? (some (comp not receiver-preferred-network?)
|
:limit-exceeded? limit-exceeded?})
|
||||||
receiver-networks)
|
should-try-again? (and (not limit-exceeded?)
|
||||||
input-error (controlled-input/input-error input-state)
|
no-routes-found?
|
||||||
limit-exceeded? (controlled-input/upper-limit-exceeded? input-state)
|
(not not-enough-asset?))
|
||||||
current-address (rf/sub [:wallet/current-viewing-account-address])
|
show-no-routes? (and (or no-routes-found? limit-exceeded?)
|
||||||
current-color (rf/sub [:wallet/current-viewing-account-color])
|
(not not-enough-asset?))
|
||||||
enough-assets? (rf/sub [:wallet/wallet-send-enough-assets?])
|
confirm-disabled? (or (nil? route)
|
||||||
owned-eth-token (rf/sub [:wallet/token-by-symbol
|
(empty? route)
|
||||||
(string/upper-case constants/mainnet-short-name)
|
(not valid-input?))
|
||||||
enabled-from-chain-ids])
|
fee-formatted (when (or (not confirm-disabled?) not-enough-asset?)
|
||||||
not-enough-asset? (insufficient-asset-amount?
|
(get-fee-formatted route))
|
||||||
{:enough-assets? enough-assets?
|
handle-on-confirm (fn [amount]
|
||||||
:token-symbol token-symbol
|
(rf/dispatch [:wallet/set-token-amount-to-send
|
||||||
:owned-eth-token owned-eth-token
|
{:amount amount
|
||||||
:input-state input-state
|
:stack-id current-screen-id}]))
|
||||||
:no-routes-found? no-routes-found?
|
on-confirm (or default-on-confirm handle-on-confirm)
|
||||||
:limit-exceeded? limit-exceeded?
|
show-select-asset-sheet #(rf/dispatch
|
||||||
:sender-network-values sender-network-values})
|
[:show-bottom-sheet
|
||||||
should-try-again? (and (not limit-exceeded?)
|
{:content (fn []
|
||||||
no-routes-found?
|
[select-asset-bottom-sheet
|
||||||
(not not-enough-asset?))
|
clear-input!])}])
|
||||||
show-no-routes? (and (or no-routes-found? limit-exceeded?)
|
request-fetch-routes (fn [bounce-duration-ms]
|
||||||
(not-empty sender-network-values)
|
(fetch-routes
|
||||||
(not not-enough-asset?))
|
{:amount amount-in-crypto
|
||||||
confirm-disabled? (or (nil? route)
|
:valid-input? valid-input?
|
||||||
(empty? route)
|
:bounce-duration-ms bounce-duration-ms
|
||||||
(not valid-input?))
|
:token token
|
||||||
fee-formatted (when (or (not confirm-disabled?) not-enough-asset?)
|
:reset-amounts-to-zero? (and limit-exceeded?
|
||||||
(get-fee-formatted route))
|
(some? route))}))
|
||||||
request-fetch-routes (fn [bounce-duration-ms]
|
swap-between-fiat-and-crypto (fn []
|
||||||
(fetch-routes
|
(if crypto-currency?
|
||||||
{:amount amount-in-crypto
|
(set-input-state
|
||||||
:valid-input? valid-input?
|
#(controlled-input/->fiat % conversion-rate))
|
||||||
:bounce-duration-ms bounce-duration-ms
|
(set-input-state
|
||||||
:token token
|
#(controlled-input/->crypto % conversion-rate)))
|
||||||
:reset-amounts-to-zero? (and limit-exceeded?
|
(set-crypto-currency (not crypto-currency?)))]
|
||||||
(some? routes))}))
|
|
||||||
swap-between-fiat-and-crypto (fn []
|
|
||||||
(if crypto-currency?
|
|
||||||
(set-input-state
|
|
||||||
#(controlled-input/->fiat % conversion-rate))
|
|
||||||
(set-input-state
|
|
||||||
#(controlled-input/->crypto % conversion-rate)))
|
|
||||||
(set-crypto-currency (not crypto-currency?)))]
|
|
||||||
(rn/use-effect
|
(rn/use-effect
|
||||||
(fn []
|
(fn []
|
||||||
(when active-screen?
|
(when active-screen?
|
||||||
@@ -287,8 +225,9 @@
|
|||||||
[current-address])
|
[current-address])
|
||||||
(rn/use-effect
|
(rn/use-effect
|
||||||
(fn []
|
(fn []
|
||||||
(request-fetch-routes 0))
|
(when active-screen?
|
||||||
[send-from-locked-amounts])
|
(request-fetch-routes 2000)))
|
||||||
|
[amount-in-crypto valid-input?])
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style style/screen
|
{:style style/screen
|
||||||
:accessibility-label (str "container"
|
:accessibility-label (str "container"
|
||||||
@@ -316,7 +255,7 @@
|
|||||||
conversion-rate)
|
conversion-rate)
|
||||||
conversion-rate))
|
conversion-rate))
|
||||||
:hint-component [quo/network-tags
|
:hint-component [quo/network-tags
|
||||||
{:networks (seq from-enabled-networks)
|
{:networks (seq [network])
|
||||||
:title (i18n/label
|
:title (i18n/label
|
||||||
:t/send-limit
|
:t/send-limit
|
||||||
{:limit (if crypto-currency?
|
{:limit (if crypto-currency?
|
||||||
@@ -328,17 +267,9 @@
|
|||||||
(controlled-input/upper-limit-bn
|
(controlled-input/upper-limit-bn
|
||||||
input-state)))})
|
input-state)))})
|
||||||
:status (when (controlled-input/input-error input-state) :error)}]}]
|
:status (when (controlled-input/input-error input-state) :error)}]}]
|
||||||
[routes/view
|
(if (= tx-type :tx/bridge)
|
||||||
{:token token-by-symbol
|
[routes/view {:token token-by-symbol}]
|
||||||
:input-value input-value
|
[rn/view {:style {:flex 1}}])
|
||||||
:valid-input? valid-input?
|
|
||||||
:token-not-supported-in-receiver-networks? unsupported-token-in-receiver?
|
|
||||||
:current-screen-id current-screen-id
|
|
||||||
:request-fetch-routes request-fetch-routes}]
|
|
||||||
(when (and (not loading-routes?)
|
|
||||||
sender-network-values
|
|
||||||
unsupported-token-in-receiver?)
|
|
||||||
[token-not-available token-symbol receiver-networks token-networks])
|
|
||||||
(when not-enough-asset?
|
(when not-enough-asset?
|
||||||
[not-enough-asset])
|
[not-enough-asset])
|
||||||
(when (or (and (not no-routes-found?) (or loading-routes? route))
|
(when (or (and (not no-routes-found?) (or loading-routes? route))
|
||||||
@@ -359,14 +290,10 @@
|
|||||||
loading-routes?
|
loading-routes?
|
||||||
(and (not should-try-again?)
|
(and (not should-try-again?)
|
||||||
confirm-disabled?))
|
confirm-disabled?))
|
||||||
:on-press (cond
|
:on-press (if should-try-again?
|
||||||
should-try-again?
|
|
||||||
#(rf/dispatch [:wallet/start-get-suggested-routes
|
#(rf/dispatch [:wallet/start-get-suggested-routes
|
||||||
{:amount amount-in-crypto
|
{:amount amount-in-crypto
|
||||||
:updated-token token-by-symbol}])
|
:updated-token token-by-symbol}])
|
||||||
sending-to-unpreferred-networks?
|
|
||||||
#(show-unpreferred-networks-alert on-confirm)
|
|
||||||
:else
|
|
||||||
#(on-confirm amount-in-crypto))
|
#(on-confirm amount-in-crypto))
|
||||||
:customization-color current-color}
|
:customization-color current-color}
|
||||||
(when should-try-again?
|
(when should-try-again?
|
||||||
|
|||||||
@@ -34,19 +34,3 @@
|
|||||||
:top margin-top}
|
:top margin-top}
|
||||||
inverted?
|
inverted?
|
||||||
(assoc :transform [{:scaleY -1}])))
|
(assoc :transform [{:scaleY -1}])))
|
||||||
|
|
||||||
(def disclaimer
|
|
||||||
{:margin-horizontal 20
|
|
||||||
:margin-top 20
|
|
||||||
:margin-bottom 8})
|
|
||||||
|
|
||||||
(def input-container
|
|
||||||
{:margin-top 8
|
|
||||||
:margin-bottom 12})
|
|
||||||
|
|
||||||
(defn keyboard-container
|
|
||||||
[bottom]
|
|
||||||
{:padding-bottom bottom})
|
|
||||||
|
|
||||||
(def error-box
|
|
||||||
{:margin-horizontal 20})
|
|
||||||
|
|||||||
@@ -1,87 +1,23 @@
|
|||||||
(ns status-im.contexts.wallet.send.routes.view
|
(ns status-im.contexts.wallet.send.routes.view
|
||||||
(:require
|
(:require
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
|
[quo.theme]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
|
[status-im.constants :as constants]
|
||||||
|
[status-im.contexts.wallet.common.utils :as common-utils]
|
||||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||||
[status-im.contexts.wallet.send.routes.style :as style]
|
[status-im.contexts.wallet.send.routes.style :as style]
|
||||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
|
||||||
[status-im.contexts.wallet.sheets.network-preferences.view :as network-preferences]
|
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
|
||||||
(def row-height 44)
|
(def row-height 44)
|
||||||
(def space-between-rows 11)
|
(def space-between-rows 11)
|
||||||
(def network-link-linear-height 10)
|
(def network-link-linear-height 10)
|
||||||
(def network-link-1x-height 56)
|
(def network-link-1x-height 56)
|
||||||
(def network-link-2x-height 111)
|
(def network-link-2x-height 111)
|
||||||
|
|
||||||
|
|
||||||
(defn- open-preferences
|
|
||||||
[]
|
|
||||||
(rf/dispatch
|
|
||||||
[:show-bottom-sheet
|
|
||||||
{:content
|
|
||||||
(fn []
|
|
||||||
(let [receiver-networks (rf/sub [:wallet/wallet-send-receiver-networks])
|
|
||||||
receiver-preferred-networks (rf/sub
|
|
||||||
[:wallet/wallet-send-receiver-preferred-networks])
|
|
||||||
{token-symbol :symbol
|
|
||||||
token-networks :supported-networks} (rf/sub [:wallet/wallet-send-token])
|
|
||||||
token-chain-ids-set (set (mapv #(:chain-id %) token-networks))
|
|
||||||
[selected-receiver-networks
|
|
||||||
set-selected-receiver-networks] (rn/use-state receiver-networks)
|
|
||||||
receiver-preferred-networks-set (set receiver-preferred-networks)
|
|
||||||
receiver-selected-preferred-networks (filter #(contains?
|
|
||||||
receiver-preferred-networks-set
|
|
||||||
%)
|
|
||||||
selected-receiver-networks)
|
|
||||||
receiver-selected-non-preferred-networks (filter #(not (contains?
|
|
||||||
receiver-preferred-networks-set
|
|
||||||
%))
|
|
||||||
selected-receiver-networks)
|
|
||||||
not-available-preferred-networks (filter (fn [preferred-chain-id]
|
|
||||||
(not (contains? token-chain-ids-set
|
|
||||||
preferred-chain-id)))
|
|
||||||
receiver-selected-preferred-networks)
|
|
||||||
not-available-non-preferred-networks (filter (fn [preferred-chain-id]
|
|
||||||
(not (contains?
|
|
||||||
token-chain-ids-set
|
|
||||||
preferred-chain-id)))
|
|
||||||
receiver-selected-non-preferred-networks)
|
|
||||||
first-section-warning-label (when (not-empty not-available-preferred-networks)
|
|
||||||
(i18n/label
|
|
||||||
:t/token-not-available-on-networks
|
|
||||||
{:token-symbol token-symbol
|
|
||||||
:networks
|
|
||||||
(network-utils/network-ids->formatted-text
|
|
||||||
not-available-preferred-networks)}))
|
|
||||||
second-section-warning-label (when (not-empty
|
|
||||||
not-available-non-preferred-networks)
|
|
||||||
(i18n/label
|
|
||||||
:t/token-not-available-on-networks
|
|
||||||
{:token-symbol token-symbol
|
|
||||||
:networks
|
|
||||||
(network-utils/network-ids->formatted-text
|
|
||||||
not-available-non-preferred-networks)}))]
|
|
||||||
[network-preferences/view
|
|
||||||
{:title (i18n/label :t/edit-receiver-networks)
|
|
||||||
:first-section-label (i18n/label :t/preferred-by-receiver)
|
|
||||||
:second-section-label (i18n/label :t/not-preferred-by-receiver)
|
|
||||||
:selected-networks (set (map network-utils/id->network
|
|
||||||
receiver-networks))
|
|
||||||
:receiver-preferred-networks receiver-preferred-networks
|
|
||||||
:button-label (i18n/label :t/apply-changes)
|
|
||||||
:first-section-warning-label first-section-warning-label
|
|
||||||
:second-section-warning-label second-section-warning-label
|
|
||||||
:on-change #(set-selected-receiver-networks %)
|
|
||||||
:on-save (fn [chain-ids]
|
|
||||||
(rf/dispatch [:hide-bottom-sheet])
|
|
||||||
(rf/dispatch [:wallet/update-receiver-networks
|
|
||||||
chain-ids]))}]))}]))
|
|
||||||
|
|
||||||
(defn render-network-values
|
(defn render-network-values
|
||||||
[{:keys [network-values token-symbol on-press on-long-press receiver? loading-routes?
|
[{:keys [network-values token-symbol receiver? loading-routes?
|
||||||
token-not-supported-in-receiver-networks?]}]
|
token-not-supported-in-receiver-networks?]}]
|
||||||
[rn/view
|
[rn/view
|
||||||
(doall
|
(doall
|
||||||
@@ -96,27 +32,19 @@
|
|||||||
(= network-value-type :not-available)
|
(= network-value-type :not-available)
|
||||||
:disabled
|
:disabled
|
||||||
:else network-value-type)
|
:else network-value-type)
|
||||||
amount-formatted (-> (rf/sub [:wallet/send-amount-fixed total-amount])
|
amount-formatted (-> total-amount
|
||||||
|
(common-utils/sanitized-token-amount-to-display
|
||||||
|
constants/min-token-decimals-to-display)
|
||||||
(str " " token-symbol))]
|
(str " " token-symbol))]
|
||||||
[rn/view
|
[rn/view
|
||||||
{:key (str (if receiver? "to" "from") "-" chain-id)
|
{:key (str (if receiver? "to" "from") "-" chain-id)
|
||||||
:style {:margin-top (if (pos? index) 11 7.5)}}
|
:style {:margin-top (if (pos? index) 11 7.5)}}
|
||||||
[quo/network-bridge
|
[quo/network-bridge
|
||||||
{:amount (if (= network-value-type :not-available)
|
{:amount (if (= network-value-type :not-available)
|
||||||
(i18n/label :t/not-available)
|
(i18n/label :t/not-available)
|
||||||
amount-formatted)
|
amount-formatted)
|
||||||
:network (network-utils/id->network chain-id)
|
:network (network-utils/id->network chain-id)
|
||||||
:status status
|
:status status}]]))
|
||||||
:on-press #(when (not loading-routes?)
|
|
||||||
(cond
|
|
||||||
(= network-value-type :edit)
|
|
||||||
(open-preferences)
|
|
||||||
on-press (on-press chain-id total-amount)))
|
|
||||||
:on-long-press #(when (and (not loading-routes?) (not= status :disabled))
|
|
||||||
(cond
|
|
||||||
(= network-value-type :add)
|
|
||||||
(open-preferences)
|
|
||||||
on-long-press (on-long-press chain-id total-amount)))}]]))
|
|
||||||
network-values))])
|
network-values))])
|
||||||
|
|
||||||
(defn render-network-links
|
(defn render-network-links
|
||||||
@@ -156,59 +84,15 @@
|
|||||||
:destination destination}]]]))
|
:destination destination}]]]))
|
||||||
network-links)])
|
network-links)])
|
||||||
|
|
||||||
(defn disable-chain
|
|
||||||
[chain-id disabled-from-chain-ids token-available-networks-for-suggested-routes]
|
|
||||||
(let [disabled-chain-ids
|
|
||||||
(if (contains? (set
|
|
||||||
disabled-from-chain-ids)
|
|
||||||
chain-id)
|
|
||||||
(vec (remove #(= % chain-id)
|
|
||||||
disabled-from-chain-ids))
|
|
||||||
(conj disabled-from-chain-ids
|
|
||||||
chain-id))
|
|
||||||
re-enabling-chain?
|
|
||||||
(< (count disabled-chain-ids)
|
|
||||||
(count disabled-from-chain-ids))]
|
|
||||||
(if (or re-enabling-chain?
|
|
||||||
(> (count token-available-networks-for-suggested-routes) 1))
|
|
||||||
(rf/dispatch [:wallet/disable-from-networks
|
|
||||||
disabled-chain-ids])
|
|
||||||
(rf/dispatch [:toasts/upsert
|
|
||||||
{:id :disable-chain-error
|
|
||||||
:type :negative
|
|
||||||
:text (i18n/label :t/at-least-one-network-must-be-activated)}]))))
|
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [token theme valid-input? request-fetch-routes on-press-to-network current-screen-id
|
[{:keys [token]}]
|
||||||
token-not-supported-in-receiver-networks? input-value]}]
|
(let [theme (quo.theme/use-theme)
|
||||||
(let [token-symbol (:symbol token)
|
token-symbol (:symbol token)
|
||||||
nav-current-screen-id (rf/sub [:view-id])
|
loading-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
|
||||||
active-screen? (= nav-current-screen-id current-screen-id)
|
sender-network-values (rf/sub [:wallet/wallet-send-sender-network-values])
|
||||||
loading-routes? (rf/sub
|
receiver-network-values (rf/sub [:wallet/wallet-send-receiver-network-values])
|
||||||
[:wallet/wallet-send-loading-suggested-routes?])
|
network-links (rf/sub [:wallet/wallet-send-network-links])
|
||||||
sender-network-values (rf/sub
|
show-routes? (not-empty sender-network-values)]
|
||||||
[:wallet/wallet-send-sender-network-values])
|
|
||||||
receiver-network-values (rf/sub
|
|
||||||
[:wallet/wallet-send-receiver-network-values])
|
|
||||||
network-links (rf/sub [:wallet/wallet-send-network-links])
|
|
||||||
disabled-from-chain-ids (rf/sub
|
|
||||||
[:wallet/wallet-send-disabled-from-chain-ids])
|
|
||||||
{token-balances-per-chain :balances-per-chain} (rf/sub [:wallet/wallet-send-token])
|
|
||||||
token-available-networks-for-suggested-routes
|
|
||||||
(send-utils/token-available-networks-for-suggested-routes
|
|
||||||
{:balances-per-chain token-balances-per-chain
|
|
||||||
:disabled-chain-ids disabled-from-chain-ids})
|
|
||||||
show-routes? (not-empty sender-network-values)]
|
|
||||||
(rn/use-effect
|
|
||||||
(fn []
|
|
||||||
(when (and active-screen?
|
|
||||||
(> (count token-available-networks-for-suggested-routes) 0))
|
|
||||||
(request-fetch-routes 2000)))
|
|
||||||
[input-value valid-input?])
|
|
||||||
(rn/use-effect
|
|
||||||
#(when (and active-screen? (> (count token-available-networks-for-suggested-routes) 0))
|
|
||||||
(request-fetch-routes 0))
|
|
||||||
[disabled-from-chain-ids])
|
|
||||||
[rn/scroll-view {:content-container-style style/routes-container}
|
[rn/scroll-view {:content-container-style style/routes-container}
|
||||||
(when show-routes?
|
(when show-routes?
|
||||||
[rn/view {:style style/routes-header-container}
|
[rn/view {:style style/routes-header-container}
|
||||||
@@ -220,27 +104,18 @@
|
|||||||
:container-style style/section-label-right}]])
|
:container-style style/section-label-right}]])
|
||||||
[rn/view {:style style/routes-inner-container}
|
[rn/view {:style style/routes-inner-container}
|
||||||
[render-network-values
|
[render-network-values
|
||||||
{:token-symbol token-symbol
|
{:token-symbol token-symbol
|
||||||
:network-values sender-network-values
|
:network-values sender-network-values
|
||||||
:on-press (fn [chain-id-to-disable]
|
:receiver? false
|
||||||
(disable-chain
|
:theme theme
|
||||||
chain-id-to-disable
|
:loading-routes? loading-routes?}]
|
||||||
disabled-from-chain-ids
|
|
||||||
token-available-networks-for-suggested-routes))
|
|
||||||
:receiver? false
|
|
||||||
:theme theme
|
|
||||||
:loading-routes? loading-routes?
|
|
||||||
:token-not-supported-in-receiver-networks? false}]
|
|
||||||
[render-network-links
|
[render-network-links
|
||||||
{:network-links network-links
|
{:network-links network-links
|
||||||
:sender-network-values sender-network-values}]
|
:sender-network-values sender-network-values}]
|
||||||
[render-network-values
|
[render-network-values
|
||||||
{:token-symbol token-symbol
|
{:token-symbol token-symbol
|
||||||
:network-values receiver-network-values
|
:network-values receiver-network-values
|
||||||
:on-press on-press-to-network
|
:receiver? true
|
||||||
:receiver? true
|
:loading-routes? loading-routes?
|
||||||
:loading-routes? loading-routes?
|
:theme theme}]]]))
|
||||||
:theme theme
|
|
||||||
:token-not-supported-in-receiver-networks? token-not-supported-in-receiver-networks?
|
|
||||||
:on-save #(request-fetch-routes 0)}]]]))
|
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
:on-press on-close
|
:on-press on-close
|
||||||
:switcher-type :select-account}]
|
:switcher-type :select-account}]
|
||||||
[quo/page-top
|
[quo/page-top
|
||||||
{:title (i18n/label :t/select-asset)
|
{:title (i18n/label :t/select-token)
|
||||||
:title-accessibility-label :title-label}]
|
:title-accessibility-label :title-label}]
|
||||||
[quo/segmented-control
|
[quo/segmented-control
|
||||||
{:size 32
|
{:size 32
|
||||||
|
|||||||
@@ -229,44 +229,17 @@
|
|||||||
safe-add-type-edit)))
|
safe-add-type-edit)))
|
||||||
|
|
||||||
(defn loading-network-amounts
|
(defn loading-network-amounts
|
||||||
[{:keys [valid-networks disabled-chain-ids receiver-networks token-networks-ids tx-type receiver?]}]
|
[{:keys [networks values receiver?]}]
|
||||||
(let [disabled-set (set disabled-chain-ids)
|
(->> networks
|
||||||
receiver-networks-set (set receiver-networks)
|
(map
|
||||||
token-networks-ids-set (set token-networks-ids)
|
(fn [chain-id]
|
||||||
valid-networks-set (set valid-networks)
|
(let [network-value (when values (get values chain-id))]
|
||||||
not-available-networks (if receiver?
|
(cond-> {:chain-id chain-id
|
||||||
(filter #(not (token-networks-ids-set %)) receiver-networks)
|
:type (if network-value :default :loading)}
|
||||||
[])
|
network-value (assoc :total-amount
|
||||||
not-available-networks-set (set not-available-networks)
|
(money/bignumber network-value))
|
||||||
valid-networks (-> (concat valid-networks
|
(and (not network-value) (not receiver?)) (assoc :total-amount (money/bignumber "0"))))))
|
||||||
(when (not (and receiver? (= tx-type :tx/bridge)))
|
(vec)))
|
||||||
disabled-chain-ids)
|
|
||||||
(when receiver?
|
|
||||||
(filter #(not (valid-networks-set %))
|
|
||||||
not-available-networks)))
|
|
||||||
(distinct))]
|
|
||||||
(->> valid-networks
|
|
||||||
(map
|
|
||||||
(fn [chain-id]
|
|
||||||
(cond->
|
|
||||||
{:chain-id chain-id
|
|
||||||
:type (cond
|
|
||||||
(contains? not-available-networks-set chain-id) :not-available
|
|
||||||
(or receiver?
|
|
||||||
(not (contains? disabled-set chain-id))) :loading
|
|
||||||
(and (not receiver?) (contains? disabled-set chain-id)) :disabled)}
|
|
||||||
(and (not receiver?) (contains? disabled-set chain-id))
|
|
||||||
(assoc :total-amount (money/bignumber "0")))))
|
|
||||||
(filter
|
|
||||||
(fn [network-amount]
|
|
||||||
(or (and receiver?
|
|
||||||
(or (= tx-type :tx/bridge)
|
|
||||||
(contains? receiver-networks-set (:chain-id network-amount))))
|
|
||||||
(not receiver?))))
|
|
||||||
(sort-by (fn [network-amount]
|
|
||||||
(get network-priority-score
|
|
||||||
(network-utils/id->network (:chain-id network-amount)))))
|
|
||||||
(vec))))
|
|
||||||
|
|
||||||
(defn network-links
|
(defn network-links
|
||||||
[route from-values-by-chain to-values-by-chain]
|
[route from-values-by-chain to-values-by-chain]
|
||||||
|
|||||||
@@ -8,12 +8,16 @@
|
|||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn- network-item
|
(defn- network-item
|
||||||
[{:keys [network on-select-network]}]
|
[{:keys [network on-select-network source]}]
|
||||||
(let [{:keys [network-name
|
(let [{:keys [network-name
|
||||||
chain-id]} network
|
chain-id]} network
|
||||||
{balance-in-crypto :crypto
|
{balance-in-crypto :crypto
|
||||||
balance-in-fiat :fiat} (rf/sub [:wallet/swap-asset-to-pay-network-balance chain-id])
|
balance-in-fiat :fiat} (case source
|
||||||
mainnet? (= network-name constants/mainnet-network-name)]
|
:swap
|
||||||
|
(rf/sub [:wallet/swap-asset-to-pay-network-balance chain-id])
|
||||||
|
(rf/sub [:wallet/send-token-network-balance chain-id]))
|
||||||
|
mainnet?
|
||||||
|
(= network-name constants/mainnet-network-name)]
|
||||||
[quo/network-list
|
[quo/network-list
|
||||||
{:label (name network-name)
|
{:label (name network-name)
|
||||||
:network-image (quo.resources/get-network network-name)
|
:network-image (quo.resources/get-network network-name)
|
||||||
@@ -23,21 +27,28 @@
|
|||||||
:container-style (style/network-list-container mainnet?)}]))
|
:container-style (style/network-list-container mainnet?)}]))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [on-select-network]}]
|
[{:keys [token-symbol on-select-network source title]
|
||||||
(let [token-symbol (rf/sub [:wallet/swap-asset-to-pay-token-symbol])
|
:or {source :swap
|
||||||
{mainnet-network :mainnet-network
|
title (i18n/label :t/select-network)}}]
|
||||||
layer-2-networks :layer-2-networks} (rf/sub [:wallet/swap-asset-to-pay-networks])
|
(let [{mainnet-network :mainnet-network
|
||||||
|
layer-2-networks :layer-2-networks} (case source
|
||||||
|
:swap
|
||||||
|
(rf/sub [:wallet/swap-asset-to-pay-networks])
|
||||||
|
:send
|
||||||
|
(rf/sub [:wallet/send-token-grouped-networks])
|
||||||
|
:bridge
|
||||||
|
(rf/sub [:wallet/send-token-grouped-networks]))
|
||||||
render-fn (rn/use-callback (fn [network]
|
render-fn (rn/use-callback (fn [network]
|
||||||
[network-item
|
[network-item
|
||||||
{:network network
|
{:network network
|
||||||
:on-select-network
|
:on-select-network on-select-network
|
||||||
on-select-network}]))]
|
:source source}]))]
|
||||||
[:<>
|
[:<>
|
||||||
[rn/view {:style style/header-container}
|
[rn/view {:style style/header-container}
|
||||||
[quo/text
|
[quo/text
|
||||||
{:size :heading-2
|
{:size :heading-2
|
||||||
:weight :semi-bold}
|
:weight :semi-bold}
|
||||||
(i18n/label :t/select-network)]
|
title]
|
||||||
[quo/context-tag
|
[quo/context-tag
|
||||||
{:type :token
|
{:type :token
|
||||||
:size 24
|
:size 24
|
||||||
@@ -46,7 +57,8 @@
|
|||||||
(when mainnet-network
|
(when mainnet-network
|
||||||
[network-item
|
[network-item
|
||||||
{:network mainnet-network
|
{:network mainnet-network
|
||||||
:on-select-network on-select-network}])
|
:on-select-network on-select-network
|
||||||
|
:source source}])
|
||||||
[quo/divider-label {:container-style style/divider-label}
|
[quo/divider-label {:container-style style/divider-label}
|
||||||
(i18n/label :t/layer-2)]
|
(i18n/label :t/layer-2)]
|
||||||
[rn/flat-list
|
[rn/flat-list
|
||||||
|
|||||||
@@ -34,7 +34,8 @@
|
|||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [accounts (rf/sub [:wallet/accounts-with-balances])]
|
(let [asset-to-pay (rf/sub [:wallet/swap-asset-to-pay])
|
||||||
|
accounts (rf/sub [:wallet/accounts-with-balances asset-to-pay])]
|
||||||
[floating-button-page/view
|
[floating-button-page/view
|
||||||
{:footer-container-padding 0
|
{:footer-container-padding 0
|
||||||
:header [quo/page-nav
|
:header [quo/page-nav
|
||||||
|
|||||||
@@ -56,12 +56,12 @@
|
|||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:wallet/network-values
|
:wallet/network-values
|
||||||
:<- [:wallet/wallet-send]
|
:<- [:wallet/wallet-send]
|
||||||
:<- [:wallet/send-display-token-decimals]
|
(fn [{:keys [from-values-by-chain to-values-by-chain token-display-name token] :as send-data}
|
||||||
(fn [[{:keys [from-values-by-chain to-values-by-chain token-display-name] :as send-data} token-decimals]
|
|
||||||
[_ to-values?]]
|
[_ to-values?]]
|
||||||
(let [network-values (if to-values? to-values-by-chain from-values-by-chain)
|
(let [network-values (if to-values? to-values-by-chain from-values-by-chain)
|
||||||
token-symbol (or token-display-name
|
token-symbol (or token-display-name
|
||||||
(-> send-data :token :symbol))]
|
(-> send-data :token :symbol))
|
||||||
|
token-decimals (:decimals token)]
|
||||||
(reduce-kv
|
(reduce-kv
|
||||||
(fn [acc chain-id amount]
|
(fn [acc chain-id amount]
|
||||||
(let [network-name (network-utils/id->network chain-id)
|
(let [network-name (network-utils/id->network chain-id)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
(:require
|
(:require
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.wallet.common.activity-tab.constants :as activity-constants]
|
[status-im.contexts.wallet.common.activity-tab.constants :as activity-tab-constants]
|
||||||
[status-im.contexts.wallet.common.utils :as common-utils]
|
[status-im.contexts.wallet.common.utils :as common-utils]
|
||||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||||
[utils.money :as money]
|
[utils.money :as money]
|
||||||
@@ -34,6 +34,11 @@
|
|||||||
:<- [:wallet/wallet-send]
|
:<- [:wallet/wallet-send]
|
||||||
:-> :token)
|
:-> :token)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/send-token-symbol
|
||||||
|
:<- [:wallet/wallet-send]
|
||||||
|
:-> :token-symbol)
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/send-transaction-ids
|
:wallet/send-transaction-ids
|
||||||
:<- [:wallet/wallet-send]
|
:<- [:wallet/wallet-send]
|
||||||
@@ -54,6 +59,11 @@
|
|||||||
:<- [:wallet/wallet-send]
|
:<- [:wallet/wallet-send]
|
||||||
:-> :tx-type)
|
:-> :tx-type)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/send-network
|
||||||
|
:<- [:wallet/wallet-send]
|
||||||
|
:-> :network)
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/sending-collectible?
|
:wallet/sending-collectible?
|
||||||
:<- [:wallet/send-tx-type]
|
:<- [:wallet/send-tx-type]
|
||||||
@@ -77,7 +87,7 @@
|
|||||||
(->> address-activity
|
(->> address-activity
|
||||||
(sort :timestamp)
|
(sort :timestamp)
|
||||||
(keep (fn [{:keys [activity-type recipient]}]
|
(keep (fn [{:keys [activity-type recipient]}]
|
||||||
(when (= activity-constants/wallet-activity-type-send activity-type)
|
(when (= activity-tab-constants/wallet-activity-type-send activity-type)
|
||||||
recipient)))
|
recipient)))
|
||||||
(distinct)))))
|
(distinct)))))
|
||||||
|
|
||||||
@@ -173,3 +183,39 @@
|
|||||||
(= (:chain-id network) bridge-to-chain-id)
|
(= (:chain-id network) bridge-to-chain-id)
|
||||||
network))
|
network))
|
||||||
networks))))
|
networks))))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/send-token-grouped-networks
|
||||||
|
:<- [:wallet/wallet-send-token]
|
||||||
|
(fn [token]
|
||||||
|
(let [{token-networks :networks} token
|
||||||
|
grouped-networks (group-by :layer
|
||||||
|
token-networks)
|
||||||
|
mainnet-network (first (get grouped-networks constants/layer-1-network))
|
||||||
|
layer-2-networks (get grouped-networks constants/layer-2-network)]
|
||||||
|
{:mainnet-network mainnet-network
|
||||||
|
:layer-2-networks layer-2-networks})))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/send-token-network-balance
|
||||||
|
:<- [:wallet/wallet-send-token]
|
||||||
|
:<- [:profile/currency]
|
||||||
|
:<- [:profile/currency-symbol]
|
||||||
|
:<- [:wallet/prices-per-token]
|
||||||
|
(fn [[token currency currency-symbol prices-per-token] [_ chain-id]]
|
||||||
|
(let [{:keys [balances-per-chain
|
||||||
|
decimals]} token
|
||||||
|
balance-for-chain (get balances-per-chain chain-id)
|
||||||
|
total-balance (money/token->unit (:raw-balance balance-for-chain) decimals)
|
||||||
|
fiat-value (common-utils/calculate-token-fiat-value
|
||||||
|
{:currency currency
|
||||||
|
:balance total-balance
|
||||||
|
:token token
|
||||||
|
:prices-per-token prices-per-token})
|
||||||
|
crypto-formatted (common-utils/get-standard-crypto-format token
|
||||||
|
total-balance
|
||||||
|
prices-per-token)
|
||||||
|
fiat-formatted (common-utils/fiat-formatted-for-ui currency-symbol
|
||||||
|
fiat-value)]
|
||||||
|
{:crypto (str crypto-formatted " " (:symbol token))
|
||||||
|
:fiat fiat-formatted})))
|
||||||
|
|||||||
@@ -334,24 +334,3 @@
|
|||||||
:token token-for-fees
|
:token token-for-fees
|
||||||
:prices-per-token prices-per-token})]
|
:prices-per-token prices-per-token})]
|
||||||
fee-in-fiat)))
|
fee-in-fiat)))
|
||||||
|
|
||||||
(rf/reg-sub
|
|
||||||
:wallet/accounts-with-balances
|
|
||||||
:<- [:wallet/operable-accounts]
|
|
||||||
:<- [:wallet/swap-asset-to-pay]
|
|
||||||
(fn [[accounts asset-to-pay]]
|
|
||||||
(let [token-symbol (:symbol asset-to-pay)]
|
|
||||||
(map
|
|
||||||
(fn [account]
|
|
||||||
(let [tokens (:tokens account)
|
|
||||||
filtered-tokens (filter #(= (:symbol %) token-symbol) tokens)
|
|
||||||
asset-pay-balance (utils/calculate-total-token-balance filtered-tokens)
|
|
||||||
formatted-address (network-utils/format-address (:address account)
|
|
||||||
(:network-preferences-names account))]
|
|
||||||
(assoc account
|
|
||||||
:formatted-address formatted-address
|
|
||||||
:asset-pay-balance (utils/sanitized-token-amount-to-display
|
|
||||||
asset-pay-balance
|
|
||||||
constants/min-token-decimals-to-display)
|
|
||||||
:asset-pay-symbol token-symbol)))
|
|
||||||
accounts))))
|
|
||||||
|
|||||||
@@ -901,3 +901,23 @@
|
|||||||
:<- [:wallet/accounts-without-current-viewing-account]
|
:<- [:wallet/accounts-without-current-viewing-account]
|
||||||
(fn [accounts]
|
(fn [accounts]
|
||||||
(get-emoji-and-colors-from-accounts accounts)))
|
(get-emoji-and-colors-from-accounts accounts)))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/accounts-with-balances
|
||||||
|
:<- [:wallet/operable-accounts]
|
||||||
|
(fn [accounts [_ token]]
|
||||||
|
(let [token-symbol (:symbol token)]
|
||||||
|
(map
|
||||||
|
(fn [account]
|
||||||
|
(let [tokens (:tokens account)
|
||||||
|
filtered-tokens (filter #(= (:symbol %) token-symbol) tokens)
|
||||||
|
asset-pay-balance (utils/calculate-total-token-balance filtered-tokens)
|
||||||
|
formatted-address (network-utils/format-address (:address account)
|
||||||
|
(:network-preferences-names account))]
|
||||||
|
(assoc account
|
||||||
|
:formatted-address formatted-address
|
||||||
|
:asset-pay-balance (utils/sanitized-token-amount-to-display
|
||||||
|
asset-pay-balance
|
||||||
|
constants/min-token-decimals-to-display)
|
||||||
|
:asset-pay-symbol token-symbol)))
|
||||||
|
accounts))))
|
||||||
|
|||||||
@@ -799,7 +799,6 @@
|
|||||||
"do-not-cheat": "Don't try to cheat",
|
"do-not-cheat": "Don't try to cheat",
|
||||||
"do-not-cheat-description": "These 12 words give access to all of your funds so it is important that you write them in the correct order, take it seriously.",
|
"do-not-cheat-description": "These 12 words give access to all of your funds so it is important that you write them in the correct order, take it seriously.",
|
||||||
"do-not-quit": "Do not quit the application or turn off your device. Doing so will lead to data corruption, loss of your Status profile and the inability to use Status.",
|
"do-not-quit": "Do not quit the application or turn off your device. Doing so will lead to data corruption, loss of your Status profile and the inability to use Status.",
|
||||||
|
|
||||||
"do-not-share": "Do not share",
|
"do-not-share": "Do not share",
|
||||||
"done": "Done",
|
"done": "Done",
|
||||||
"dont-ask": "Don't ask me again",
|
"dont-ask": "Don't ask me again",
|
||||||
@@ -1215,7 +1214,10 @@
|
|||||||
"include": "Include",
|
"include": "Include",
|
||||||
"incoming": "Incoming",
|
"incoming": "Incoming",
|
||||||
"incoming-transaction": "Incoming transaction",
|
"incoming-transaction": "Incoming transaction",
|
||||||
"incorrect-code": ["str", "Sorry the code was incorrect, please enter it again"],
|
"incorrect-code": [
|
||||||
|
"str",
|
||||||
|
"Sorry the code was incorrect, please enter it again"
|
||||||
|
],
|
||||||
"incorrect-private-key": "This is not the private key for this key pair",
|
"incorrect-private-key": "This is not the private key for this key pair",
|
||||||
"increase-gas": "Increase Gas",
|
"increase-gas": "Increase Gas",
|
||||||
"information-you-input-and-send": "Information you input and send",
|
"information-you-input-and-send": "Information you input and send",
|
||||||
@@ -2280,8 +2282,11 @@
|
|||||||
"select-chat": "Select chat to start messaging",
|
"select-chat": "Select chat to start messaging",
|
||||||
"select-network": "Select network",
|
"select-network": "Select network",
|
||||||
"select-network-for-buying": "Select network for buying",
|
"select-network-for-buying": "Select network for buying",
|
||||||
|
"select-network-to-bridge-from": "Select network to bridge from",
|
||||||
|
"select-network-to-receive": "Select network to receive",
|
||||||
"select-networks": "Select networks",
|
"select-networks": "Select networks",
|
||||||
"select-new-location-for-keys": "Select a new location to save your private key(s)",
|
"select-new-location-for-keys": "Select a new location to save your private key(s)",
|
||||||
|
"select-token": "Select token",
|
||||||
"select-token-to-receive": "Select token to receive",
|
"select-token-to-receive": "Select token to receive",
|
||||||
"select-token-to-swap": "Select token to Swap",
|
"select-token-to-swap": "Select token to Swap",
|
||||||
"selected": "Selected",
|
"selected": "Selected",
|
||||||
|
|||||||
Reference in New Issue
Block a user