Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a617599b0 | ||
|
|
40f98f8238 | ||
|
|
2161c2e433 | ||
|
|
2983af67d6 | ||
|
|
4a8bb704bf | ||
|
|
e61702c8bb | ||
|
|
5b75e1dca6 | ||
|
|
97d4edcf30 | ||
|
|
1663848b7e | ||
|
|
113f9aaa81 | ||
|
|
6db24a4a6c | ||
|
|
8cac0e46b1 | ||
|
|
b38d2c1836 | ||
|
|
8948904a9b |
@@ -1,8 +1,8 @@
|
||||
---
|
||||
name: MVPBug Report
|
||||
about: MVPBug Report
|
||||
name: Bug Report
|
||||
about: Bug Report
|
||||
title: ''
|
||||
labels: ['E:Mobile Bug MVP', ':1234: low prio']
|
||||
labels: ['bug', ':1234: low prio']
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
/* Options section can't access functions in objects. */
|
||||
def isPRBuild = utils.isPRBuild()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
import groovy.json.JsonBuilder
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
pipeline {
|
||||
agent { label 'linux' }
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
/* Options section can't access functions in objects. */
|
||||
def isPRBuild = utils.isPRBuild()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
/* Options section can't access functions in objects. */
|
||||
def isPRBuild = utils.isPRBuild()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
pipeline {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
pipeline {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
pipeline {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
pipeline {
|
||||
agent { label 'macos' }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
pipeline {
|
||||
agent { label params.AGENT_LABEL }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
pipeline {
|
||||
agent { label 'linux' }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
library 'status-jenkins-lib@v1.9.8'
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
|
||||
+1
-1
@@ -1485,7 +1485,7 @@ SPEC CHECKSUMS:
|
||||
FBLazyVector: 56e0e498dbb513b96c40bac6284729ba4e62672d
|
||||
FBReactNativeSpec: 146c741a3f40361f6bc13a4ba284678cbedb5881
|
||||
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
|
||||
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
|
||||
glog: 36c15c01d70ed395c6e4f3619f98a23ee415b07a
|
||||
hermes-engine: 1d1835b2cc54c381909d94d1b3c8e0a2f1a94a0e
|
||||
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
|
||||
Keycard: ac6df4d91525c3c82635ac24d4ddd9a80aca5fc8
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[legacy.status-im.data-store.visibility-status-updates :as visibility-status-updates]
|
||||
[status-im.contexts.wallet.common.validation :as validation]
|
||||
[utils.ethereum.eip.eip55 :as eip55]))
|
||||
|
||||
(defn rpc->visible-tokens
|
||||
@@ -35,6 +36,7 @@
|
||||
(update :pinned-mailservers rpc->pinned-mailservers)
|
||||
(update :link-previews-enabled-sites set)
|
||||
(update :currency rpc->currency)
|
||||
(assoc :ens-name? (validation/ens-name? (:preferred-name settings)))
|
||||
(visibility-status-updates/<-rpc-settings)
|
||||
(set/rename-keys {:compressedKey :compressed-key
|
||||
:emojiHash :emoji-hash})))
|
||||
|
||||
@@ -85,11 +85,12 @@
|
||||
(rf/defn add-members
|
||||
"Add members to a group chat"
|
||||
{:events [:group-chats.ui/add-members-pressed]}
|
||||
[{{:group-chat/keys [selected-participants]} :db :as cofx} chat-id]
|
||||
{:json-rpc/call [{:method "wakuext_addMembersToGroupChat"
|
||||
:params [nil chat-id selected-participants]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:chat-updated % true])}]})
|
||||
[{{:group-chat/keys [selected-participants]} :db} chat-id]
|
||||
(when (seq selected-participants)
|
||||
{:json-rpc/call [{:method "wakuext_addMembersToGroupChat"
|
||||
:params [nil chat-id selected-participants]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:chat-updated % true])}]}))
|
||||
|
||||
(rf/defn add-members-from-invitation
|
||||
"Add members to a group chat"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
[quo.components.calendar.calendar.view :as calendar]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(def start-date (time/date-time (time/year (time/now)) (time/month (time/now)) 5))
|
||||
(def start-date (time/date-time (time/year (time/now)) (time/month (time/now)) 8))
|
||||
(def end-date (time/date-time (time/plus start-date (time/days 2))))
|
||||
|
||||
(h/describe "calendar component"
|
||||
@@ -23,7 +23,7 @@
|
||||
{:start-date nil
|
||||
:end-date nil
|
||||
:on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day start-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day start-date))))
|
||||
(h/was-called-with on-change {:start-date start-date :end-date nil})))
|
||||
|
||||
(h/test "should call on-change with start and end date on second click"
|
||||
@@ -31,7 +31,7 @@
|
||||
(h/render
|
||||
[calendar/view
|
||||
{:start-date start-date :end-date nil :on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day end-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day end-date))))
|
||||
(h/was-called-with on-change {:start-date start-date :end-date end-date})))
|
||||
|
||||
(h/test "should reset the dates on third click"
|
||||
@@ -41,7 +41,7 @@
|
||||
{:start-date start-date
|
||||
:end-date end-date
|
||||
:on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day start-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day start-date))))
|
||||
(h/was-called-with on-change {:start-date start-date :end-date nil})))
|
||||
|
||||
(h/test "should reset dates when start date is clicked again"
|
||||
@@ -51,7 +51,7 @@
|
||||
{:start-date start-date
|
||||
:end-date nil
|
||||
:on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day start-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day start-date))))
|
||||
(h/was-called-with on-change {:start-date nil :end-date nil})))
|
||||
|
||||
(h/test "should assign start and end date correctly when upper range selected first"
|
||||
@@ -61,5 +61,5 @@
|
||||
{:start-date end-date
|
||||
:end-date nil
|
||||
:on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day start-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day start-date))))
|
||||
(h/was-called-with on-change {:start-date start-date :end-date end-date}))))
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
:color-index gradient-color-index}]])
|
||||
|
||||
(defn- card-details
|
||||
[{:keys [community? avatar-image-src collectible-name theme state set-state]}]
|
||||
[{:keys [community? avatar-image-src collectible-name theme state set-state loading?]}]
|
||||
(let [loader-opacity (reanimated/use-shared-value 1)
|
||||
avatar-opacity (reanimated/use-shared-value 0)
|
||||
[load-time set-load-time] (rn/use-state (datetime/now))
|
||||
@@ -102,7 +102,7 @@
|
||||
:avatar-opacity avatar-opacity}))
|
||||
empty-name? (string/blank? collectible-name)]
|
||||
(rn/use-mount (fn []
|
||||
(when (string/blank? avatar-image-src)
|
||||
(when (and (string/blank? avatar-image-src) (not loading?))
|
||||
(set-avatar-loaded))))
|
||||
[rn/view {:style style/card-details-container}
|
||||
[reanimated/view {:style (style/avatar-container avatar-opacity)}
|
||||
@@ -137,7 +137,7 @@
|
||||
|
||||
(defn- card-view
|
||||
[{:keys [avatar-image-src collectible-name community? counter state set-state
|
||||
gradient-color-index image-src supported-file?]}]
|
||||
gradient-color-index image-src supported-file? loading?]}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
loader-opacity (reanimated/use-shared-value (if supported-file? 1 0))
|
||||
image-opacity (reanimated/use-shared-value (if supported-file? 0 1))
|
||||
@@ -189,6 +189,7 @@
|
||||
:community? community?
|
||||
:avatar-image-src avatar-image-src
|
||||
:collectible-name collectible-name
|
||||
:loading? loading?
|
||||
:theme theme}]]))
|
||||
|
||||
(defn- image-view
|
||||
@@ -276,6 +277,7 @@
|
||||
[:supported-file? {:optional true} [:maybe boolean?]]
|
||||
[:native-ID {:optional true} [:maybe [:or string? keyword?]]]
|
||||
[:community? {:optional true} [:maybe boolean?]]
|
||||
[:loading? {:optional true} [:maybe boolean?]]
|
||||
[:counter {:optional true} [:maybe [:or :string :int]]]
|
||||
[:gradient-color-index {:optional true}
|
||||
[:maybe [:enum :gradient-1 :gradient-2 :gradient-3 :gradient-4 :gradient-5]]]
|
||||
|
||||
@@ -6,16 +6,20 @@
|
||||
(h/describe "Wallet: Token Input"
|
||||
(h/test "Token label renders"
|
||||
(h/render-with-theme-provider [token-input/view
|
||||
{:token :snt
|
||||
:currency :eur
|
||||
:crypto? true
|
||||
:conversion 1}])
|
||||
{:token-symbol :snt
|
||||
:currency-symbol :snt
|
||||
:on-swap nil
|
||||
:error? false
|
||||
:value "1"
|
||||
:converted-value "10"}])
|
||||
(h/is-truthy (h/get-by-text "SNT")))
|
||||
|
||||
(h/test "Amount renders"
|
||||
(h/render-with-theme-provider [token-input/view
|
||||
{:token :snt
|
||||
:currency :eur
|
||||
:converted-value "€0.00"
|
||||
:conversion 1}])
|
||||
{:token-symbol :snt
|
||||
:currency-symbol :snt
|
||||
:on-swap nil
|
||||
:error? false
|
||||
:value "1"
|
||||
:converted-value "€0.00"}])
|
||||
(h/is-truthy (h/get-by-text "€0.00"))))
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
[:=>
|
||||
[:catn
|
||||
[:props
|
||||
[:map
|
||||
[:token {:optional true} [:maybe [:or :string :keyword]]]
|
||||
[:currency {:optional true} [:maybe [:or :string :keyword]]]
|
||||
[:error? {:optional true} [:maybe :boolean]]
|
||||
[:title {:optional true} [:maybe :string]]
|
||||
[:conversion {:optional true} [:maybe :double]]
|
||||
[:show-keyboard? {:optional true} [:maybe :boolean]]
|
||||
[:networks {:optional true}
|
||||
[:maybe [:sequential [:map [:source [:maybe :schema.common/image-source]]]]]]
|
||||
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
|
||||
[:value {:optional true} [:maybe :string]]]]]
|
||||
[:map {:closed true}
|
||||
[:token-symbol [:maybe [:or :string :keyword]]]
|
||||
[:currency-symbol [:maybe [:or :string :keyword]]]
|
||||
[:hint-component {:optional true} [:maybe :schema.common/hiccup]]
|
||||
[:on-token-press {:optional true} [:maybe fn?]]
|
||||
[:on-swap [:maybe fn?]]
|
||||
[:container-style {:optional true} [:maybe :map]]
|
||||
[:error? [:maybe :boolean]]
|
||||
[:value [:maybe :string]]
|
||||
[:converted-value [:maybe :string]]]]]
|
||||
:any])
|
||||
|
||||
@@ -25,9 +25,11 @@
|
||||
|
||||
(defn input-container
|
||||
[window-width]
|
||||
{:width (- window-width 120)
|
||||
:margin-left 8
|
||||
:margin-right 8})
|
||||
{:width (- window-width 120)
|
||||
:margin-left 8
|
||||
:margin-right 8
|
||||
:flex-direction :row
|
||||
:align-items :flex-end})
|
||||
|
||||
(def text-input-dimensions
|
||||
(-> typography/heading-1
|
||||
@@ -65,6 +67,6 @@
|
||||
:justify-content :space-between
|
||||
:align-items :center})
|
||||
|
||||
(defn fiat-amount
|
||||
(defn converted-amount
|
||||
[theme]
|
||||
{:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)})
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
(ns quo.components.wallet.token-input.view
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[oops.core :as oops]
|
||||
[quo.components.buttons.button.view :as button]
|
||||
[quo.components.dividers.divider-line.view :as divider-line]
|
||||
[quo.components.markdown.text :as text]
|
||||
[quo.components.tags.network-tags.view :as network-tag]
|
||||
[quo.components.utilities.token.view :as token]
|
||||
[quo.components.wallet.token-input.schema :as component-schema]
|
||||
[quo.components.wallet.token-input.style :as style]
|
||||
@@ -13,19 +11,6 @@
|
||||
[react-native.core :as rn]
|
||||
[schema.core :as schema]))
|
||||
|
||||
(defn- data-info
|
||||
[{:keys [theme networks title converted-value error?]}]
|
||||
[rn/view {:style style/data-container}
|
||||
[network-tag/view
|
||||
{:networks networks
|
||||
:title title
|
||||
:status (when error? :error)}]
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:weight :medium
|
||||
:style (style/fiat-amount theme)}
|
||||
converted-value]])
|
||||
|
||||
(defn- token-name-text
|
||||
[theme text]
|
||||
[text/text
|
||||
@@ -35,85 +20,63 @@
|
||||
(string/upper-case (or (clj->js text) ""))])
|
||||
|
||||
(defn input-section
|
||||
[{:keys [on-change-text value value-internal set-value-internal on-selection-change
|
||||
on-token-press]}]
|
||||
(let [input-ref (atom nil)
|
||||
set-ref #(reset! input-ref %)
|
||||
focus-input #(when-let [ref ^js @input-ref]
|
||||
(.focus ref))
|
||||
controlled-input? (some? value)
|
||||
handle-on-change-text (fn [v]
|
||||
(when-not controlled-input?
|
||||
(set-value-internal v))
|
||||
(when on-change-text
|
||||
(on-change-text v)))
|
||||
handle-selection-change (fn [^js e]
|
||||
(when on-selection-change
|
||||
(-> e
|
||||
(oops/oget "nativeEvent.selection")
|
||||
(js->clj :keywordize-keys true)
|
||||
(on-selection-change))))]
|
||||
(fn [{:keys [token customization-color show-keyboard? crypto? currency value error? selection
|
||||
handle-on-swap allow-selection?]
|
||||
:or {show-keyboard? true
|
||||
allow-selection? true}}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
window-width (:width (rn/get-window))]
|
||||
[rn/pressable
|
||||
{:style {:width "100%"
|
||||
:flex-direction :row}
|
||||
:on-press on-token-press}
|
||||
[token/view
|
||||
{:token token
|
||||
:size :size-32}]
|
||||
[rn/view {:style (style/input-container window-width)}
|
||||
[rn/pressable
|
||||
{:style style/text-input-container
|
||||
:on-press focus-input}
|
||||
[rn/text-input
|
||||
(cond-> {:style (style/text-input theme error?)
|
||||
:placeholder-text-color (style/placeholder-text theme)
|
||||
:auto-focus true
|
||||
:ref set-ref
|
||||
:placeholder "0"
|
||||
:keyboard-type :numeric
|
||||
:on-change-text handle-on-change-text
|
||||
:selection-color customization-color
|
||||
:show-soft-input-on-focus show-keyboard?
|
||||
:on-selection-change handle-selection-change
|
||||
:selection (clj->js selection)
|
||||
:editable allow-selection?}
|
||||
controlled-input? (assoc :value value)
|
||||
(not controlled-input?) (assoc :default-value value-internal))]
|
||||
[token-name-text theme (if crypto? token currency)]]]
|
||||
[button/button
|
||||
{:icon true
|
||||
:icon-only? true
|
||||
:size 32
|
||||
:on-press handle-on-swap
|
||||
:type :outline
|
||||
:accessibility-label :reorder}
|
||||
:i/reorder]]))))
|
||||
[{:keys [token-symbol on-token-press value error? on-swap currency-symbol]}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
window-width (:width (rn/get-window))]
|
||||
[rn/pressable
|
||||
{:style {:width "100%"
|
||||
:flex-direction :row}
|
||||
:on-press on-token-press}
|
||||
[token/view
|
||||
{:token token-symbol
|
||||
:size :size-32}]
|
||||
[rn/view {:style (style/input-container window-width)}
|
||||
[rn/text-input
|
||||
{:style (style/text-input theme error?)
|
||||
:placeholder-text-color (style/placeholder-text theme)
|
||||
:placeholder "0"
|
||||
:keyboard-type :numeric
|
||||
:editable false
|
||||
:value value}]
|
||||
[token-name-text theme currency-symbol]]
|
||||
[button/button
|
||||
{:icon true
|
||||
:icon-only? true
|
||||
:size 32
|
||||
:on-press #(when on-swap (on-swap))
|
||||
:type :outline
|
||||
:accessibility-label :reorder}
|
||||
:i/reorder]]))
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [container-style on-swap crypto?] :as props}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
width (:width (rn/get-window))
|
||||
[value-internal set-value-internal] (rn/use-state nil)
|
||||
handle-on-swap (rn/use-callback
|
||||
(fn []
|
||||
(when on-swap (on-swap (not crypto?))))
|
||||
[on-swap])]
|
||||
[{:keys [token-symbol
|
||||
value
|
||||
on-token-press
|
||||
error?
|
||||
container-style
|
||||
on-swap
|
||||
converted-value
|
||||
hint-component
|
||||
currency-symbol]}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
width (:width (rn/get-window))]
|
||||
[rn/view {:style (merge (style/main-container width) container-style)}
|
||||
[rn/view {:style style/amount-container}
|
||||
[input-section
|
||||
(assoc props
|
||||
:value-internal value-internal
|
||||
:theme theme
|
||||
:set-value-internal set-value-internal
|
||||
:handle-on-swap handle-on-swap
|
||||
:crypto? crypto?)]]
|
||||
{:theme theme
|
||||
:token-symbol token-symbol
|
||||
:on-token-press on-token-press
|
||||
:value value
|
||||
:error? error?
|
||||
:on-swap on-swap
|
||||
:currency-symbol currency-symbol}]]
|
||||
[divider-line/view {:container-style (style/divider theme)}]
|
||||
[data-info (assoc props :theme theme)]]))
|
||||
[rn/view {:style style/data-container}
|
||||
hint-component
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:weight :medium
|
||||
:style (style/converted-amount theme)}
|
||||
converted-value]]]))
|
||||
|
||||
(def view (schema/instrument #'view-internal component-schema/?schema))
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
(ns status-im.common.controlled-input.utils
|
||||
(:require
|
||||
[clojure.string :as string]))
|
||||
[clojure.string :as string]
|
||||
[status-im.contexts.wallet.common.utils :as wallet-utils]
|
||||
[utils.money :as money]))
|
||||
|
||||
(def init-state
|
||||
{:value ""
|
||||
@@ -14,7 +16,7 @@
|
||||
|
||||
(defn numeric-value
|
||||
[state]
|
||||
(or (parse-double (input-value state)) 0))
|
||||
(money/bignumber (input-value state)))
|
||||
|
||||
(defn input-error
|
||||
[state]
|
||||
@@ -26,23 +28,27 @@
|
||||
|
||||
(defn upper-limit
|
||||
[state]
|
||||
(:upper-limit state))
|
||||
(money/bignumber (:upper-limit state)))
|
||||
|
||||
(defn lower-limit
|
||||
[state]
|
||||
(:lower-limit state))
|
||||
(money/bignumber (:lower-limit state)))
|
||||
|
||||
(defn upper-limit-exceeded?
|
||||
[state]
|
||||
(and
|
||||
(upper-limit state)
|
||||
(> (numeric-value state) (upper-limit state))))
|
||||
(let [num-value (numeric-value state)]
|
||||
(and
|
||||
(upper-limit state)
|
||||
(when (money/bignumber? num-value)
|
||||
(money/greater-than (numeric-value state) (upper-limit state))))))
|
||||
|
||||
(defn lower-limit-exceeded?
|
||||
(defn- lower-limit-exceeded?
|
||||
[state]
|
||||
(and
|
||||
(lower-limit state)
|
||||
(< (numeric-value state) (lower-limit state))))
|
||||
(let [num-value (numeric-value state)]
|
||||
(and
|
||||
(lower-limit state)
|
||||
(when (money/bignumber? num-value)
|
||||
(money/less-than (numeric-value state) (lower-limit state))))))
|
||||
|
||||
(defn- recheck-errorness
|
||||
[state]
|
||||
@@ -75,13 +81,11 @@
|
||||
|
||||
(defn increase
|
||||
[state]
|
||||
(let [new-val (inc (numeric-value state))]
|
||||
(set-input-value state (str new-val))))
|
||||
(set-input-value state (str (money/add (numeric-value state) 1))))
|
||||
|
||||
(defn decrease
|
||||
[state]
|
||||
(let [new-val (dec (numeric-value state))]
|
||||
(set-input-value state (str new-val))))
|
||||
(set-input-value state (str (money/add (numeric-value state) -1))))
|
||||
|
||||
(def ^:private not-digits-or-dot-pattern
|
||||
#"[^0-9+\.]")
|
||||
@@ -130,3 +134,29 @@
|
||||
(defn empty-value?
|
||||
[state]
|
||||
(string/blank? (:value state)))
|
||||
|
||||
(defn- fiat->crypto
|
||||
[value conversion-rate]
|
||||
(-> value
|
||||
(money/fiat->crypto conversion-rate)
|
||||
(wallet-utils/cut-crypto-decimals-to-fit-usd-cents conversion-rate)))
|
||||
|
||||
(defn- crypto->fiat
|
||||
[value conversion-rate]
|
||||
(-> value
|
||||
(money/crypto->fiat conversion-rate)
|
||||
(wallet-utils/cut-fiat-balance-to-two-decimals)))
|
||||
|
||||
(defn ->crypto
|
||||
[state conversion-rate]
|
||||
(-> state
|
||||
(set-input-value (fiat->crypto (input-value state) conversion-rate))
|
||||
(set-upper-limit (fiat->crypto (upper-limit state) conversion-rate))
|
||||
(set-lower-limit (fiat->crypto (lower-limit state) conversion-rate))))
|
||||
|
||||
(defn ->fiat
|
||||
[state conversion-rate]
|
||||
(-> state
|
||||
(set-input-value (crypto->fiat (input-value state) conversion-rate))
|
||||
(set-upper-limit (crypto->fiat (upper-limit state) conversion-rate))
|
||||
(set-lower-limit (crypto->fiat (lower-limit state) conversion-rate))))
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
(let [parsed-time (t.format/parse (t.format/formatters :date-time-no-ms) muted-till-string)
|
||||
hours-and-minutes (str (add-leading-zero (t/hour (t/plus parsed-time time-zone-offset)))
|
||||
":"
|
||||
(add-leading-zero (t/minute parsed-time)))
|
||||
(add-leading-zero (t/minute (t/plus parsed-time time-zone-offset))))
|
||||
when-to-unmute (cond (= go-default-time
|
||||
muted-till-string) (i18n/label :t/until-you-turn-it-back-on)
|
||||
(today? parsed-time) (str hours-and-minutes " today")
|
||||
|
||||
@@ -38,9 +38,12 @@
|
||||
[path]
|
||||
(map #(str % path) status-web-urls))
|
||||
|
||||
|
||||
(def handled-schemes (set (into uri-schemes status-web-urls)))
|
||||
|
||||
(defn wc-normalize-uri
|
||||
[uri]
|
||||
(if (string/includes? uri "//wc:") (string/replace-first uri "/?" "?") uri))
|
||||
|
||||
(def group-chat-extractor
|
||||
{[#"(.*)" :params] {"" :group-chat
|
||||
"/" :group-chat}})
|
||||
@@ -60,7 +63,9 @@
|
||||
["wallet/" :account] :wallet-account
|
||||
[user-with-data-path :user-data] :user
|
||||
"c" :community
|
||||
"u" :user}
|
||||
"u" :user
|
||||
#"wc:([^\?]+)" :wallet-connect
|
||||
"wc" :wallet-connect}
|
||||
ethereum-scheme eip-extractor}])
|
||||
|
||||
(defn parse-query-params
|
||||
@@ -75,6 +80,11 @@
|
||||
(when-not (string/blank? fragment)
|
||||
fragment)))
|
||||
|
||||
(defn remove-scheme
|
||||
[uri]
|
||||
(let [[_ url] (string/split uri #"://")]
|
||||
url))
|
||||
|
||||
(defn match-uri
|
||||
[uri]
|
||||
(let [;; bidi has trouble parse path with `=` in it extract `=` here and add back to parsed
|
||||
@@ -88,13 +98,17 @@
|
||||
uri-without-equal-in-path
|
||||
(if equal-end-of-base64url (string/replace-first uri equal-end-of-base64url "") uri)
|
||||
|
||||
;;bidi has issue to detect wc regex with /?, couldn't fine any other workaround
|
||||
normalize-uri
|
||||
(wc-normalize-uri uri-without-equal-in-path)
|
||||
|
||||
;; fragment is the one after `#`, usually user-id, ens-name, community-id
|
||||
fragment (parse-fragment uri)
|
||||
ens? (utils.ens/is-valid-eth-name? fragment)
|
||||
compressed-key? (validators/valid-compressed-key? fragment)
|
||||
|
||||
{:keys [handler route-params] :as parsed}
|
||||
(assoc (bidi/match-route routes uri-without-equal-in-path)
|
||||
{:keys [handler route-params query-params] :as parsed}
|
||||
(assoc (bidi/match-route routes normalize-uri)
|
||||
:uri uri
|
||||
:query-params (parse-query-params uri))]
|
||||
(cond-> parsed
|
||||
@@ -131,7 +145,13 @@
|
||||
(update-in [:route-params :user-data] #(str % equal-end-of-base64url))
|
||||
|
||||
(and (= handler :user) compressed-key?)
|
||||
(assoc-in [:route-params :user-id] fragment))))
|
||||
(assoc-in [:route-params :user-id] fragment)
|
||||
|
||||
(= handler :wallet-connect)
|
||||
(assoc-in [:route-params :uri]
|
||||
(if (get query-params "uri")
|
||||
(get query-params "uri")
|
||||
(remove-scheme normalize-uri))))))
|
||||
|
||||
(defn match-contact-async
|
||||
[chain {:keys [user-id ens-name]} callback]
|
||||
@@ -328,6 +348,10 @@
|
||||
(= handler :wallet-account)
|
||||
(cb (match-wallet-account route-params))
|
||||
|
||||
(= handler :wallet-connect)
|
||||
(cb {:type :wallet-connect
|
||||
:uri (:uri route-params)})
|
||||
|
||||
(address/address? uri)
|
||||
(cb (address->eip681 uri))
|
||||
|
||||
|
||||
@@ -105,6 +105,12 @@
|
||||
[full-url]
|
||||
(log/info "universal-links: no handler for " full-url))
|
||||
|
||||
(rf/defn handle-wallet-connect
|
||||
[_ uri]
|
||||
(log/info "universal-links: handle-wallet-connect" uri)
|
||||
{:dispatch-later {:ms 1500
|
||||
:dispatch [:wallet-connect/on-scan-connection uri]}})
|
||||
|
||||
(defn dispatch-url
|
||||
"Dispatch url so we can get access to re-frame/db"
|
||||
[url]
|
||||
@@ -117,7 +123,7 @@
|
||||
|
||||
(rf/defn on-handle
|
||||
{:events [:universal-links/match-value]}
|
||||
[cofx url {:keys [type chat-id community-id] :as data}]
|
||||
[cofx url {:keys [type chat-id community-id uri] :as data}]
|
||||
(case type
|
||||
:group-chat (handle-group-chat cofx data)
|
||||
:private-chat (handle-private-chat cofx data)
|
||||
@@ -130,6 +136,7 @@
|
||||
:browser (handle-browse cofx data)
|
||||
:eip681 (handle-eip681 cofx data)
|
||||
:wallet-account (handle-wallet-account cofx data)
|
||||
:wallet-connect (handle-wallet-connect cofx uri)
|
||||
(handle-not-found url)))
|
||||
|
||||
(rf/defn route-url
|
||||
@@ -178,13 +185,10 @@
|
||||
[{:keys [db]} [{:keys [public-key on-success]}]]
|
||||
(let [profile-public-key (get-in db [:profile/profile :public-key])
|
||||
profile? (or (not public-key) (= public-key profile-public-key))
|
||||
ens-name? (if profile?
|
||||
(get-in db [:profile/profile :ens-name?])
|
||||
(get-in db [:contacts/contacts public-key :ens-name]))
|
||||
public-key (if profile? profile-public-key public-key)]
|
||||
(when public-key
|
||||
{:json-rpc/call
|
||||
[{:method (if ens-name? "wakuext_shareUserURLWithENS" "wakuext_shareUserURLWithData")
|
||||
[{:method "wakuext_shareUserURLWithData"
|
||||
:params [public-key]
|
||||
:on-success (fn [url]
|
||||
(rf/dispatch [:universal-links/save-profile-url public-key url])
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
(let [db {:profile/profile {:ens-name? true :public-key pubkey}}
|
||||
rst (links/generate-profile-url {:db db} [])]
|
||||
(are [result expected] (match? result expected)
|
||||
"wakuext_shareUserURLWithENS" (-> rst :json-rpc/call first :method)
|
||||
pubkey (-> rst :json-rpc/call first :params first)))))
|
||||
"wakuext_shareUserURLWithData" (-> rst :json-rpc/call first :method)
|
||||
pubkey (-> rst :json-rpc/call first :params first)))))
|
||||
(testing "user has no ens name"
|
||||
(testing "it calls the ens rpc method with public keyas param"
|
||||
(let [db {:profile/profile {:public-key pubkey}}
|
||||
@@ -60,8 +60,8 @@
|
||||
db {:contacts/contacts {pubkey {:ens-name ens}}}
|
||||
rst (links/generate-profile-url {:db db} [{:public-key pubkey}])]
|
||||
(are [result expected] (match? result expected)
|
||||
"wakuext_shareUserURLWithENS" (-> rst :json-rpc/call first :method)
|
||||
pubkey (-> rst :json-rpc/call first :params first)))))
|
||||
"wakuext_shareUserURLWithData" (-> rst :json-rpc/call first :method)
|
||||
pubkey (-> rst :json-rpc/call first :params first)))))
|
||||
(testing "contact has no ens name"
|
||||
(testing "it calls the ens rpc method with public keyas param"
|
||||
(let [db {:contacts/contacts {pubkey {:public-key pubkey}}}
|
||||
|
||||
@@ -58,6 +58,9 @@
|
||||
{:keys [admins] :as group} (rf/sub [:chats/chat-by-id chat-id])
|
||||
current-pk (rf/sub [:multiaccount/public-key])
|
||||
admin? (get admins current-pk)]
|
||||
(rn/use-mount (fn []
|
||||
(rf/dispatch [:group/clear-added-participants])
|
||||
(rf/dispatch [:group/clear-removed-members])))
|
||||
[rn/view {:flex 1 :margin-top 20}
|
||||
[rn/touchable-opacity
|
||||
{:on-press #(rf/dispatch [:navigate-back])
|
||||
@@ -174,11 +177,8 @@
|
||||
:icon :i/add-user
|
||||
:label (i18n/label (if admin? :t/manage-members :t/add-members))
|
||||
:counter-value (count contacts)
|
||||
:on-press (fn []
|
||||
(rf/dispatch [:group/clear-added-participants])
|
||||
(rf/dispatch [:group/clear-removed-members])
|
||||
(rf/dispatch [:open-modal :group-add-manage-members
|
||||
chat-id]))}]}]
|
||||
:on-press #(rf/dispatch [:open-modal :group-add-manage-members
|
||||
chat-id])}]}]
|
||||
[rn/section-list
|
||||
{:key-fn :title
|
||||
:sticky-section-headers-enabled false
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
(h/render [audio-message/audio-message message context])
|
||||
(h/is-truthy (h/get-by-label-text :audio-message-container)))
|
||||
|
||||
(h/test "press play calls audio/toggle-playpause-player"
|
||||
(h/test-skip "press play calls audio/toggle-playpause-player"
|
||||
(with-redefs [audio/toggle-playpause-player (js/jest.fn)
|
||||
audio/new-player (fn [_ _ _] {})
|
||||
audio/prepare-player (fn [_ on-success _] (on-success))
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
token-permissions-check id last-opened-at]
|
||||
:as community} (data-store.communities/<-rpc community-js)
|
||||
previous-last-opened-at (get-in db [:communities id :last-opened-at])]
|
||||
(when (> clock (get-in db [:communities id :clock]))
|
||||
(when (>= clock (get-in db [:communities id :clock]))
|
||||
{:db (assoc-in db
|
||||
[:communities id]
|
||||
(assoc community :last-opened-at (max last-opened-at previous-last-opened-at)))
|
||||
|
||||
@@ -181,9 +181,4 @@
|
||||
|
||||
(testing "given a community with lower clock"
|
||||
(let [effects (events/handle-community {:db {:communities {community-id {:clock 3}}}} [community])]
|
||||
(is (nil? effects))))
|
||||
|
||||
(testing "given a community without clock"
|
||||
(let [community #js {:id community-id}
|
||||
effects (events/handle-community {} [community])]
|
||||
(is (nil? effects))))))
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
(fn [{:keys [db]} [contact-id]]
|
||||
{:db (update-in db
|
||||
[:contacts/contacts contact-id]
|
||||
#(assoc % :blocked? false :added true :active? true))}))
|
||||
#(assoc % :blocked? false))}))
|
||||
|
||||
(rf/reg-event-fx :contact/unblock-contact
|
||||
(fn [_ [contact-id]]
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
[status-im.common.controlled-input.utils :as controlled-input]
|
||||
[status-im.contexts.preview.quo.preview :as preview]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[utils.money :as money]
|
||||
[utils.number :as number]))
|
||||
[utils.money :as money]))
|
||||
|
||||
(def networks
|
||||
[{:source (resources/get-network :arbitrum)}
|
||||
@@ -17,9 +16,10 @@
|
||||
{:source (resources/get-network :ethereum)}])
|
||||
|
||||
(def title "Max: 200 SNT")
|
||||
(def conversion-rate 3450.28)
|
||||
|
||||
(def descriptor
|
||||
[{:key :token
|
||||
[{:key :token-symbol
|
||||
:type :select
|
||||
:options [{:key :eth}
|
||||
{:key :snt}]}
|
||||
@@ -28,50 +28,38 @@
|
||||
:options [{:key "$"}
|
||||
{:key "€"}]}
|
||||
{:key :error?
|
||||
:type :boolean}
|
||||
{:key :allow-selection?
|
||||
:type :boolean}])
|
||||
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [state (reagent/atom {:token :eth
|
||||
:currency "$"
|
||||
:conversion-rate 3450.28
|
||||
:networks networks
|
||||
:title title
|
||||
:customization-color :blue
|
||||
:show-keyboard? false
|
||||
:allow-selection? true
|
||||
:crypto? true})]
|
||||
(let [state (reagent/atom {:token-symbol :eth
|
||||
:currency "$"
|
||||
:crypto? true
|
||||
:error? false})]
|
||||
(fn []
|
||||
(let [{:keys [currency token conversion-rate
|
||||
crypto?]} @state
|
||||
[input-state set-input-state] (rn/use-state controlled-input/init-state)
|
||||
input-amount (controlled-input/input-value input-state)
|
||||
swap-between-fiat-and-crypto (fn []
|
||||
(set-input-state
|
||||
(fn [input-state]
|
||||
(controlled-input/set-input-value
|
||||
input-state
|
||||
(let [new-value
|
||||
(if-not crypto?
|
||||
(utils/cut-crypto-decimals-to-fit-usd-cents
|
||||
conversion-rate
|
||||
(money/fiat->crypto input-amount
|
||||
conversion-rate))
|
||||
(utils/cut-fiat-balance-to-two-decimals
|
||||
(money/crypto->fiat input-amount
|
||||
conversion-rate)))]
|
||||
(number/remove-trailing-zeroes
|
||||
new-value))))))
|
||||
converted-value (if crypto?
|
||||
(utils/prettify-balance currency
|
||||
(money/crypto->fiat input-amount
|
||||
conversion-rate))
|
||||
(utils/prettify-crypto-balance
|
||||
(or (clj->js token) "")
|
||||
(money/fiat->crypto input-amount conversion-rate)
|
||||
conversion-rate))]
|
||||
(let [{:keys [currency token-symbol crypto? error?]} @state
|
||||
[input-state set-input-state] (rn/use-state controlled-input/init-state)
|
||||
input-amount (controlled-input/input-value input-state)
|
||||
swap-between-fiat-and-crypto (fn []
|
||||
(if crypto?
|
||||
(set-input-state #(controlled-input/->fiat
|
||||
%
|
||||
conversion-rate))
|
||||
(set-input-state
|
||||
#(controlled-input/->crypto
|
||||
%
|
||||
conversion-rate))))
|
||||
converted-value (if crypto?
|
||||
(utils/prettify-balance currency
|
||||
(money/crypto->fiat
|
||||
input-amount
|
||||
conversion-rate))
|
||||
(utils/prettify-crypto-balance
|
||||
(or (clj->js token-symbol) "")
|
||||
(money/fiat->crypto input-amount
|
||||
conversion-rate)
|
||||
conversion-rate))]
|
||||
[preview/preview-container
|
||||
{:state state
|
||||
:descriptor descriptor
|
||||
@@ -79,12 +67,18 @@
|
||||
:component-container-style {:flex 1
|
||||
:justify-content :space-between}}
|
||||
[quo/token-input
|
||||
(merge @state
|
||||
{:value input-amount
|
||||
:converted-value converted-value
|
||||
:on-swap (fn [crypto]
|
||||
(swap! state assoc :crypto? crypto)
|
||||
(swap-between-fiat-and-crypto))})]
|
||||
{:token-symbol token-symbol
|
||||
:currency-symbol (if crypto? token-symbol currency)
|
||||
:error? error?
|
||||
:value input-amount
|
||||
:converted-value converted-value
|
||||
:on-swap (fn []
|
||||
(swap! state assoc :crypto? (not crypto?))
|
||||
(swap-between-fiat-and-crypto))
|
||||
:hint-component [quo/network-tags
|
||||
{:networks networks
|
||||
:title title
|
||||
:status (when (:error? @state) :error)}]}]
|
||||
[quo/numbered-keyboard
|
||||
{:container-style {:padding-bottom (safe-area/get-top)}
|
||||
:left-action :dot
|
||||
|
||||
@@ -11,18 +11,18 @@
|
||||
|
||||
(defn items
|
||||
[theme]
|
||||
(let [profile (rf/sub [:profile/profile-with-image])
|
||||
customization-color (rf/sub [:profile/customization-color])
|
||||
bio (:bio profile)
|
||||
full-name (profile.utils/displayed-name profile)]
|
||||
(let [{:keys [bio ens-name?] :as profile} (rf/sub [:profile/profile-with-image])
|
||||
customization-color (rf/sub [:profile/customization-color])
|
||||
full-name (profile.utils/displayed-name profile)]
|
||||
[{:label (i18n/label :t/profile)
|
||||
:items [{:title (i18n/label :t/name)
|
||||
:on-press #(rf/dispatch [:open-modal :edit-name])
|
||||
:blur? true
|
||||
:label :text
|
||||
:label-props (utils/truncate-str full-name constants/profile-name-max-length)
|
||||
:action :arrow
|
||||
:container-style style/item-container}
|
||||
:items [(cond-> {:title (i18n/label :t/name)
|
||||
:blur? true
|
||||
:label :text
|
||||
:label-props (utils/truncate-str full-name constants/profile-name-max-length)
|
||||
:container-style style/item-container}
|
||||
(not ens-name?)
|
||||
(assoc :on-press #(rf/dispatch [:open-modal :edit-name])
|
||||
:action :arrow))
|
||||
{:title (i18n/label :t/bio)
|
||||
:on-press #(rf/dispatch [:open-modal :edit-bio])
|
||||
:blur? true
|
||||
|
||||
@@ -25,23 +25,29 @@
|
||||
[]
|
||||
(rf/dispatch [:wallet/request-collectibles-for-current-viewing-account]))
|
||||
|
||||
(defn view
|
||||
[{:keys [selected-tab]}]
|
||||
(let [collectible-list (rf/sub
|
||||
(defn- collectibles-tab
|
||||
[]
|
||||
(let [updating? (rf/sub [:wallet/current-viewing-account-collectibles-updating?])
|
||||
collectible-list (rf/sub
|
||||
[:wallet/current-viewing-account-collectibles-in-selected-networks])
|
||||
current-account-address (rf/sub [:wallet/current-viewing-account-address])]
|
||||
[rn/view {:style {:flex 1}}
|
||||
(case selected-tab
|
||||
:assets [assets/view]
|
||||
:collectibles [collectibles/view
|
||||
{:collectibles collectible-list
|
||||
:current-account-address current-account-address
|
||||
:on-end-reached on-end-reached
|
||||
:on-collectible-press on-collectible-press
|
||||
:on-collectible-long-press on-collectible-long-press}]
|
||||
:activity [activity/view]
|
||||
:permissions [empty-tab/view
|
||||
{:title (i18n/label :t/no-permissions)
|
||||
:description (i18n/label :t/no-collectibles-description)
|
||||
:placeholder? true}]
|
||||
[about/view])]))
|
||||
[collectibles/view
|
||||
{:loading? updating?
|
||||
:collectibles collectible-list
|
||||
:current-account-address current-account-address
|
||||
:on-end-reached on-end-reached
|
||||
:on-collectible-press on-collectible-press
|
||||
:on-collectible-long-press on-collectible-long-press}]))
|
||||
|
||||
(defn view
|
||||
[{:keys [selected-tab]}]
|
||||
[rn/view {:style {:flex 1}}
|
||||
(case selected-tab
|
||||
:assets [assets/view]
|
||||
:collectibles [collectibles-tab]
|
||||
:activity [activity/view]
|
||||
:permissions [empty-tab/view
|
||||
{:title (i18n/label :t/no-permissions)
|
||||
:description (i18n/label :t/no-collectibles-description)
|
||||
:placeholder? true}]
|
||||
[about/view])])
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
(ns status-im.contexts.wallet.collectible.events
|
||||
(:require [camel-snake-kebab.extras :as cske]
|
||||
[clojure.set]
|
||||
[clojure.string :as string]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.contexts.network.data-store :as network.data-store]
|
||||
[status-im.contexts.wallet.collectible.utils :as collectible-utils]
|
||||
[status-im.contexts.wallet.data-store :as data-store]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.collection]
|
||||
[utils.ethereum.chain :as chain]
|
||||
[utils.number :as utils.number]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
@@ -24,6 +28,12 @@
|
||||
(def max-cache-age-seconds 3600)
|
||||
(def collectibles-request-batch-size 25)
|
||||
|
||||
(def ownership-state
|
||||
{:idle 1
|
||||
:delayed 2
|
||||
:updating 3
|
||||
:error 4})
|
||||
|
||||
(defn- move-collectibles-to-accounts
|
||||
[accounts new-collectibles-per-account]
|
||||
(reduce-kv (fn [acc account new-collectibles]
|
||||
@@ -84,12 +94,18 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet/request-collectibles-for-all-accounts
|
||||
(fn [{:keys [db]} [{:keys [new-request?]}]]
|
||||
(let [accounts (->> (get-in db [:wallet :accounts])
|
||||
(let [updating-addresses (-> (get-in db [:wallet :ui :collectibles :updating])
|
||||
keys
|
||||
set)
|
||||
accounts (->> (get-in db [:wallet :accounts])
|
||||
(filter (fn [[_ {:keys [has-more-collectibles?]}]]
|
||||
(or (nil? has-more-collectibles?)
|
||||
(true? has-more-collectibles?))))
|
||||
(keys))
|
||||
num-accounts (count accounts)
|
||||
;; filter the addresses which are requested before and the collectibles are updating
|
||||
requestable-addresses (clojure.set/difference (set accounts)
|
||||
updating-addresses)
|
||||
num-accounts (count requestable-addresses)
|
||||
collectibles-per-account (quot collectibles-request-batch-size num-accounts)
|
||||
;; We need to pass unique IDs for simultaneous requests, otherwise they'll fail
|
||||
request-ids (get-unique-collectible-request-id num-accounts)
|
||||
@@ -100,13 +116,13 @@
|
||||
:account account
|
||||
:amount collectibles-per-account}]])
|
||||
request-ids
|
||||
accounts)]
|
||||
requestable-addresses)]
|
||||
{:db (cond-> db
|
||||
:always (assoc-in [:wallet :ui :collectibles :pending-requests] num-accounts)
|
||||
new-request? (update-in [:wallet :accounts] update-vals #(dissoc % :collectibles)))
|
||||
:fx collectible-requests})))
|
||||
|
||||
(defn request-new-collectibles-for-account-from-signal
|
||||
(defn request-collectibles-for-account
|
||||
[{:keys [db]} [address]]
|
||||
(let [pending-requests (get-in db [:wallet :ui :collectibles :pending-requests] 0)
|
||||
[request-id] (get-unique-collectible-request-id 1)]
|
||||
@@ -117,49 +133,138 @@
|
||||
:account address
|
||||
:amount collectibles-request-batch-size}]]]}))
|
||||
|
||||
(rf/reg-event-fx :wallet/request-new-collectibles-for-account-from-signal
|
||||
request-new-collectibles-for-account-from-signal)
|
||||
(rf/reg-event-fx :wallet/request-collectibles-for-account request-collectibles-for-account)
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/request-collectibles-for-current-viewing-account
|
||||
(fn [{:keys [db]} _]
|
||||
(when (network.data-store/online? db)
|
||||
(let [current-viewing-account (-> db :wallet :current-viewing-account-address)
|
||||
[request-id] (get-unique-collectible-request-id 1)]
|
||||
{:db (assoc-in db [:wallet :ui :collectibles :pending-requests] 1)
|
||||
:fx [[:dispatch
|
||||
[:wallet/request-new-collectibles-for-account
|
||||
{:request-id request-id
|
||||
:account current-viewing-account
|
||||
:amount collectibles-request-batch-size}]]]}))))
|
||||
(let [current-viewing-account (-> db :wallet :current-viewing-account-address)]
|
||||
{:fx [[:dispatch [:wallet/request-collectibles-for-account current-viewing-account]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/collectible-ownership-update-finished-with-error
|
||||
(fn [{:keys [db]} [{:keys [accounts message chainId]}]]
|
||||
(let [address (first accounts)
|
||||
pending-chain-ids (get-in db [:wallet :ui :collectibles :updating address])
|
||||
updated-chain-ids (disj pending-chain-ids chainId)
|
||||
all-chain-updated? (and (some? pending-chain-ids) (empty? updated-chain-ids))]
|
||||
{:db (cond-> db
|
||||
(some? pending-chain-ids)
|
||||
(assoc-in [:wallet :ui :collectibles :updating address] updated-chain-ids))
|
||||
:fx [[:dispatch
|
||||
[:wallet/log-rpc-error
|
||||
{:event :wallet/collectible-ownership-update-finished-with-error
|
||||
:params {:address address
|
||||
:chain-id chainId}}
|
||||
message]]
|
||||
(when all-chain-updated?
|
||||
[:dispatch [:wallet/request-collectibles-for-account address]])]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/collectible-ownership-update-finished
|
||||
(fn [{:keys [db]} [{:keys [accounts chainId]}]]
|
||||
(let [address (first accounts)
|
||||
pending-chain-ids (get-in db [:wallet :ui :collectibles :updating address])
|
||||
updated-chain-ids (disj pending-chain-ids chainId)
|
||||
all-chain-updated? (and (some? pending-chain-ids) (empty? updated-chain-ids))]
|
||||
{:db (cond-> db
|
||||
(some? pending-chain-ids)
|
||||
(assoc-in [:wallet :ui :collectibles :updating address] updated-chain-ids))
|
||||
:fx [(when all-chain-updated?
|
||||
[:dispatch [:wallet/request-collectibles-for-account address]])]})))
|
||||
|
||||
(defn- update-collectibles-in-account
|
||||
[existing-collectibles updated-collectibles]
|
||||
(let [indexed-existing (utils.collection/index-by
|
||||
:unique-id
|
||||
existing-collectibles)
|
||||
existing-ids (-> indexed-existing keys vec)
|
||||
;; pick collectibles only in the app-db
|
||||
indexed-updated (-> (utils.collection/index-by
|
||||
:unique-id
|
||||
updated-collectibles)
|
||||
(select-keys existing-ids))]
|
||||
(-> (merge-with
|
||||
merge
|
||||
indexed-existing
|
||||
indexed-updated)
|
||||
vals
|
||||
vec)))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/collectibles-data-updated
|
||||
(fn [{:keys [db]} [{:keys [message]}]]
|
||||
(let [collectibles-by-address (->> message
|
||||
transforms/json->clj
|
||||
data-store/rpc->collectibles
|
||||
(group-by #(-> % :ownership first :address)))]
|
||||
{:db (update-in db
|
||||
[:wallet :accounts]
|
||||
#(reduce-kv
|
||||
(fn [accounts address updated-collectibles]
|
||||
(if (contains? accounts address)
|
||||
(update-in accounts
|
||||
[address :collectibles]
|
||||
update-collectibles-in-account
|
||||
updated-collectibles)
|
||||
accounts))
|
||||
%
|
||||
collectibles-by-address))})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/set-collectibles-updating-status
|
||||
(fn [{:keys [db]} [address chain-ids]]
|
||||
{:db (assoc-in db [:wallet :ui :collectibles :updating address] chain-ids)}))
|
||||
|
||||
(defn- update-fetched-collectibles-progress
|
||||
[db owner-address collectibles offset has-more?]
|
||||
(-> db
|
||||
(update-in [:wallet :ui :collectibles :updating] dissoc owner-address)
|
||||
(assoc-in [:wallet :ui :collectibles :fetched owner-address] collectibles)
|
||||
(assoc-in [:wallet :accounts owner-address :current-collectible-idx]
|
||||
(+ offset (count collectibles)))
|
||||
(assoc-in [:wallet :accounts owner-address :has-more-collectibles?] has-more?)))
|
||||
|
||||
(defn- updating-collectibles?
|
||||
[status]
|
||||
(and (= (:state status) (ownership-state :updating))
|
||||
(= (:timestamp status) -1)))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/owned-collectibles-filtering-done
|
||||
(fn [{:keys [db]} [{:keys [message]}]]
|
||||
(let [{:keys [offset ownershipStatus collectibles
|
||||
hasMore]} (transforms/json->clj message)
|
||||
collectibles (cske/transform-keys transforms/->kebab-case-keyword collectibles)
|
||||
pending-requests (dec (get-in db [:wallet :ui :collectibles :pending-requests]))
|
||||
owner-address (some->> ownershipStatus
|
||||
first
|
||||
key
|
||||
name)]
|
||||
hasMore]} (transforms/json->clj message)
|
||||
ownership-status-by-address (-> ownershipStatus
|
||||
(update-keys name)
|
||||
(update-vals #(update-keys %
|
||||
(comp utils.number/parse-int name))))
|
||||
owner-address (some-> ownership-status-by-address
|
||||
first
|
||||
key)
|
||||
ownership-status (get ownership-status-by-address owner-address)
|
||||
collectibles (data-store/rpc->collectibles collectibles)
|
||||
pending-requests (dec (get-in db [:wallet :ui :collectibles :pending-requests]))
|
||||
;; check if collectibles are updating (never fetched and cached before) for this address
|
||||
updating-chains (-> (select-keys
|
||||
ownership-status
|
||||
(for [[k v] ownership-status
|
||||
:when (updating-collectibles? v)]
|
||||
k))
|
||||
keys
|
||||
set)
|
||||
updating? (-> updating-chains count pos?)]
|
||||
{:db (cond-> db
|
||||
:always (assoc-in [:wallet :ui :collectibles :pending-requests] pending-requests)
|
||||
owner-address (update-fetched-collectibles-progress owner-address
|
||||
collectibles
|
||||
offset
|
||||
hasMore))
|
||||
(when-not updating? hasMore)))
|
||||
:fx [(when (zero? pending-requests)
|
||||
[:dispatch [:wallet/flush-collectibles-fetched]])]})))
|
||||
[:dispatch [:wallet/flush-collectibles-fetched]])
|
||||
(when updating?
|
||||
[:dispatch [:wallet/set-collectibles-updating-status owner-address updating-chains]])]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/navigate-to-collectible-details
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
|
||||
(is (match? result-db expected-db))))))
|
||||
|
||||
(deftest request-new-collectibles-for-account-from-signal-test
|
||||
(testing "request new collectibles for account from signal"
|
||||
(deftest request-collectibles-for-account-test
|
||||
(testing "request collectibles for account"
|
||||
(let [db {:wallet {}}
|
||||
address "0x1"
|
||||
expected {:db {:wallet {:ui {:collectibles {:pending-requests 1}}}}
|
||||
@@ -53,6 +53,6 @@
|
||||
{:request-id 0
|
||||
:account address
|
||||
:amount events/collectibles-request-batch-size}]]]}
|
||||
effects (events/request-new-collectibles-for-account-from-signal {:db db}
|
||||
[address])]
|
||||
effects (events/request-collectibles-for-account {:db db}
|
||||
[address])]
|
||||
(is (match? expected effects)))))
|
||||
|
||||
@@ -70,3 +70,10 @@
|
||||
test-networks-enabled?
|
||||
is-goerli-enabled?)]
|
||||
(str base-link "/assets/" opensea-network-name "/" contract-address "/" token-id)))
|
||||
|
||||
(defn get-collectible-unique-id
|
||||
[{:keys [id]}]
|
||||
(let [chain-id (-> id :contract-id :chain-id)
|
||||
contract-address (-> id :contract-id :address)
|
||||
token-id (-> id :token-id)]
|
||||
(str chain-id contract-address token-id)))
|
||||
|
||||
@@ -10,6 +10,16 @@
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- loading-collectible-item
|
||||
[_ index]
|
||||
(let [gradient-color (keyword (str "gradient-" (inc (mod index 5))))]
|
||||
[quo/collectible-list-item
|
||||
{:type :card
|
||||
:gradient-color-index gradient-color
|
||||
:supported-file? true
|
||||
:loading? true
|
||||
:container-style style/collectible-container}]))
|
||||
|
||||
(defn- collectible-item
|
||||
[{:keys [preview-url collection-data collectible-data total-owned on-press on-long-press]
|
||||
:as collectible}
|
||||
@@ -41,10 +51,18 @@
|
||||
|
||||
(defn view
|
||||
[{:keys [collectibles filtered? on-end-reached on-collectible-press
|
||||
current-account-address on-collectible-long-press]}]
|
||||
current-account-address on-collectible-long-press loading?]}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
no-results-match-query? (and filtered? (empty? collectibles))]
|
||||
(cond
|
||||
loading?
|
||||
[rn/flat-list
|
||||
{:data (repeat 8 {})
|
||||
:style {:flex 1}
|
||||
:content-container-style style/list-container-style
|
||||
:num-columns 2
|
||||
:render-fn loading-collectible-item}]
|
||||
|
||||
no-results-match-query?
|
||||
[rn/view {:style {:flex 1 :justify-content :center}}
|
||||
[quo/empty-state
|
||||
@@ -62,15 +80,14 @@
|
||||
;; TODO: https://github.com/status-im/status-mobile/issues/20137
|
||||
;; 1. If possible, move `collectibles-data` calculation to a subscription
|
||||
;; 2. Optimization: do not recalculate all the collectibles, process only the new ones
|
||||
(let [collectibles-data (map-indexed
|
||||
(fn [index {:keys [ownership] :as collectible}]
|
||||
(let [collectibles-data (map
|
||||
(fn [{:keys [ownership] :as collectible}]
|
||||
(let [total-owned (rf/sub [:wallet/total-owned-collectible ownership
|
||||
current-account-address])]
|
||||
(assoc collectible
|
||||
:total-owned total-owned
|
||||
:on-long-press on-collectible-long-press
|
||||
:on-press on-collectible-press
|
||||
:collectible-index index)))
|
||||
:total-owned total-owned
|
||||
:on-long-press on-collectible-long-press
|
||||
:on-press on-collectible-press)))
|
||||
collectibles)]
|
||||
[rn/flat-list
|
||||
{:data collectibles-data
|
||||
@@ -80,5 +97,5 @@
|
||||
:num-columns 2
|
||||
:render-fn collectible-item
|
||||
:on-end-reached on-end-reached
|
||||
:key-fn :collectible-index
|
||||
:key-fn :unique-id
|
||||
:on-end-reached-threshold 4}]))))
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
(calc-max-crypto-decimals cent-value))})))
|
||||
|
||||
(defn cut-crypto-decimals-to-fit-usd-cents
|
||||
[token-price-in-usd token-units]
|
||||
[token-units token-price-in-usd]
|
||||
(let [{:keys [zero-value? usd-cent-value standardized-decimals-count]}
|
||||
(analyze-token-amount-for-price token-price-in-usd token-units)]
|
||||
(cond
|
||||
@@ -99,7 +99,7 @@
|
||||
|
||||
(defn prettify-crypto-balance
|
||||
[token-symbol crypto-balance conversion-rate]
|
||||
(str (cut-crypto-decimals-to-fit-usd-cents conversion-rate crypto-balance)
|
||||
(str (cut-crypto-decimals-to-fit-usd-cents crypto-balance conversion-rate)
|
||||
" "
|
||||
(string/upper-case token-symbol)))
|
||||
|
||||
@@ -323,18 +323,6 @@
|
||||
(let [counter (count address)]
|
||||
(str (subs address 0 6) "\u2026" (subs address (- counter 3) counter)))))
|
||||
|
||||
(defn make-limit-label-crypto
|
||||
[amount currency]
|
||||
(str amount
|
||||
" "
|
||||
(some-> currency
|
||||
name
|
||||
string/upper-case)))
|
||||
|
||||
(defn make-limit-label-fiat
|
||||
[amount currency-symbol]
|
||||
(str currency-symbol amount))
|
||||
|
||||
(defn get-account-name-error
|
||||
[s existing-account-names]
|
||||
(cond
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
(ns status-im.contexts.wallet.common.validation
|
||||
(:require [status-im.constants :as constants]))
|
||||
(:require [clojure.string :as string]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
(defn ens-name? [s] (boolean (re-find constants/regx-ens s)))
|
||||
(defn ens-name?
|
||||
[s]
|
||||
(and (not (string/blank? s))
|
||||
(boolean (re-find constants/regx-ens s))))
|
||||
(defn private-key?
|
||||
[s]
|
||||
(or (re-find constants/regx-private-key-hex s)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.collectible.utils :as collectible-utils]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||
[utils.collection :as utils.collection]
|
||||
@@ -266,3 +267,10 @@
|
||||
(defn tokens-never-loaded?
|
||||
[db]
|
||||
(nil? (get-in db [:wallet :ui :tokens-loading])))
|
||||
|
||||
(defn rpc->collectibles
|
||||
[collectibles]
|
||||
(->> collectibles
|
||||
(cske/transform-keys transforms/->kebab-case-keyword)
|
||||
(map #(assoc % :unique-id (collectible-utils/get-collectible-unique-id %)))
|
||||
vec))
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
:wallet/fetch-assets-for-address
|
||||
(fn [_ [address]]
|
||||
{:fx [[:dispatch [:wallet/get-wallet-token-for-account address]]
|
||||
[:dispatch [:wallet/request-new-collectibles-for-account-from-signal address]]
|
||||
[:dispatch [:wallet/request-collectibles-for-account address]]
|
||||
[:dispatch [:wallet/check-recent-history-for-account address]]]}))
|
||||
|
||||
(defn- reconcile-accounts
|
||||
@@ -151,11 +151,6 @@
|
||||
:on-success [:wallet/get-accounts-success]
|
||||
:on-error [:wallet/log-rpc-error {:event :wallet/get-accounts}]}]]]}))
|
||||
|
||||
(rf/reg-event-fx :wallet/process-account-from-signal
|
||||
(fn [{:keys [db]} [{:keys [address] :as account}]]
|
||||
{:db (assoc-in db [:wallet :accounts address] (data-store/rpc->account account))
|
||||
:fx [[:dispatch [:wallet/fetch-assets-for-address address]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/save-account
|
||||
(fn [_ [{:keys [account on-success]}]]
|
||||
@@ -584,25 +579,13 @@
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/process-keypair-from-backup
|
||||
(fn [{:keys [db]} [{:keys [backedUpKeypair]}]]
|
||||
(let [{:keys [key-uid accounts]} backedUpKeypair
|
||||
accounts-fx
|
||||
(mapv (fn [{:keys [chat] :as account}]
|
||||
;; We exclude the chat account from the profile keypair for fetching the assets
|
||||
(when-not chat
|
||||
[:dispatch
|
||||
[:wallet/process-account-from-signal
|
||||
account]]))
|
||||
accounts)]
|
||||
{:db (assoc-in db
|
||||
[:wallet :keypairs key-uid]
|
||||
(data-store/rpc->keypair backedUpKeypair))
|
||||
:fx accounts-fx})))
|
||||
(fn [_ [{:keys [backedUpKeypair]}]]
|
||||
{:fx [[:dispatch [:wallet/reconcile-keypairs [backedUpKeypair]]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/process-watch-only-account-from-backup
|
||||
(fn [_ [{:keys [backedUpWatchOnlyAccount]}]]
|
||||
{:fx [[:dispatch [:wallet/process-account-from-signal backedUpWatchOnlyAccount]]]}))
|
||||
{:fx [[:dispatch [:wallet/reconcile-watch-only-accounts [backedUpWatchOnlyAccount]]]]}))
|
||||
|
||||
(defn reconcile-watch-only-accounts
|
||||
[{:keys [db]} [watch-only-accounts]]
|
||||
|
||||
@@ -143,13 +143,6 @@
|
||||
address-2 {:address address-2}}}})
|
||||
(is (match? expected-fx (:fx (dispatch [event-id])))))))
|
||||
|
||||
(h/deftest-event :wallet/process-account-from-signal
|
||||
[event-id dispatch]
|
||||
(let [expected-effects {:db {:wallet {:accounts {address account}}}
|
||||
:fx [[:dispatch [:wallet/fetch-assets-for-address address]]]}]
|
||||
(reset! rf-db/app-db {:wallet {:accounts {}}})
|
||||
(is (match? expected-effects (dispatch [event-id raw-account])))))
|
||||
|
||||
(h/deftest-event :wallet/reconcile-keypairs
|
||||
[event-id dispatch]
|
||||
(let [keypair-key-uid (:key-uid raw-account)]
|
||||
|
||||
@@ -19,17 +19,23 @@
|
||||
|
||||
(def on-collectible-press #(rf/dispatch [:wallet/navigate-to-collectible-details %]))
|
||||
|
||||
(def request-collectibles #(rf/dispatch [:wallet/request-collectibles-for-all-accounts {}]))
|
||||
|
||||
(defn- collectibles-tab
|
||||
[]
|
||||
(let [updating? (rf/sub [:wallet/home-tab-collectibles-updating?])
|
||||
collectible-list (rf/sub [:wallet/owned-collectibles-list-in-selected-networks])]
|
||||
[collectibles/view
|
||||
{:loading? updating?
|
||||
:collectibles collectible-list
|
||||
:on-collectible-long-press on-collectible-long-press
|
||||
:on-end-reached request-collectibles
|
||||
:on-collectible-press on-collectible-press}]))
|
||||
|
||||
(defn view
|
||||
[{:keys [selected-tab]}]
|
||||
(let [collectible-list (rf/sub [:wallet/owned-collectibles-list-in-selected-networks])
|
||||
request-collectibles #(rf/dispatch
|
||||
[:wallet/request-collectibles-for-all-accounts {}])]
|
||||
[rn/view {:style style/container}
|
||||
(case selected-tab
|
||||
:assets [assets/view]
|
||||
:collectibles [collectibles/view
|
||||
{:collectibles collectible-list
|
||||
:on-collectible-long-press on-collectible-long-press
|
||||
:on-end-reached request-collectibles
|
||||
:on-collectible-press on-collectible-press}]
|
||||
[activity/view {:activities []}])]))
|
||||
[rn/view {:style style/container}
|
||||
(case selected-tab
|
||||
:assets [assets/view]
|
||||
:collectibles [collectibles-tab]
|
||||
[activity/view {:activities []}])])
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
(h/setup-subs sub-mocks)
|
||||
(h/render-with-theme-provider [input-amount/view
|
||||
{:crypto-decimals 2
|
||||
:limit-crypto 250
|
||||
:limit-crypto (money/bignumber 250)
|
||||
:initial-crypto-currency? false}])
|
||||
(h/is-truthy (h/get-by-text "0"))
|
||||
(h/is-truthy (h/get-by-text "USD"))
|
||||
@@ -124,7 +124,7 @@
|
||||
(let [on-confirm (h/mock-fn)]
|
||||
(h/render-with-theme-provider [input-amount/view
|
||||
{:crypto-decimals 10
|
||||
:limit-crypto 1000
|
||||
:limit-crypto (money/bignumber 1000)
|
||||
:on-confirm on-confirm
|
||||
:initial-crypto-currency? true}])
|
||||
|
||||
@@ -135,18 +135,19 @@
|
||||
(h/fire-event :press (h/query-by-label-text :keyboard-key-4))
|
||||
(h/fire-event :press (h/query-by-label-text :keyboard-key-5))
|
||||
|
||||
|
||||
(-> (h/wait-for #(h/get-by-text "$1234.50"))
|
||||
(.then (fn []
|
||||
(h/is-truthy (h/get-by-label-text :button-one))
|
||||
(h/is-truthy (h/get-by-label-text :container))
|
||||
(h/fire-event :press (h/get-by-label-text :button-one))
|
||||
(h/was-called on-confirm))))))
|
||||
(let [btn (h/get-by-label-text :button-one)]
|
||||
(h/is-truthy btn)
|
||||
(h/fire-event :press btn)
|
||||
(h/was-called on-confirm)))))))
|
||||
|
||||
(h/test "Try to fill more than limit"
|
||||
(h/setup-subs sub-mocks)
|
||||
(h/render-with-theme-provider [input-amount/view
|
||||
{:crypto-decimals 1
|
||||
:limit-crypto 1}])
|
||||
:limit-crypto (money/bignumber 1)}])
|
||||
|
||||
(h/fire-event :press (h/query-by-label-text :keyboard-key-2))
|
||||
(h/fire-event :press (h/query-by-label-text :keyboard-key-9))
|
||||
@@ -158,13 +159,12 @@
|
||||
(h/setup-subs sub-mocks)
|
||||
(h/render-with-theme-provider [input-amount/view
|
||||
{:crypto-decimals 1
|
||||
:limit-crypto 1
|
||||
:limit-crypto (money/bignumber 10)
|
||||
:on-confirm #()}])
|
||||
|
||||
(h/fire-event :press (h/query-by-label-text :keyboard-key-9))
|
||||
(h/fire-event :press (h/query-by-label-text :keyboard-key-9))
|
||||
(h/is-truthy (h/get-by-label-text :container-error))
|
||||
(h/fire-event :press (h/query-by-label-text :reorder))
|
||||
(h/is-truthy #(h/get-by-text "Max: $100.00"))))
|
||||
|
||||
(-> (h/wait-for #(h/get-by-text "Max: $1000.00"))
|
||||
(.then (fn []
|
||||
(h/wait-for #(h/is-truthy (h/get-by-label-text :container))))))))
|
||||
|
||||
@@ -153,9 +153,8 @@
|
||||
bottom (safe-area/get-bottom)
|
||||
[crypto-currency? set-crypto-currency] (rn/use-state initial-crypto-currency?)
|
||||
on-navigate-back on-navigate-back
|
||||
[input-state set-input-state] (rn/use-state controlled-input/init-state)
|
||||
|
||||
[just-toggled-mode? set-just-toggled-mode?] (rn/use-state false)
|
||||
clear-input! #(set-input-state controlled-input/delete-all)
|
||||
handle-on-confirm (fn [amount]
|
||||
(rf/dispatch [:wallet/set-token-amount-to-send
|
||||
{:amount amount
|
||||
@@ -166,12 +165,10 @@
|
||||
:as
|
||||
token} (rf/sub [:wallet/wallet-send-token])
|
||||
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
|
||||
{token-balance :total-balance
|
||||
available-balance :available-balance
|
||||
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
|
||||
{token-balance :total-balance
|
||||
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
|
||||
(str token-symbol)
|
||||
enabled-from-chain-ids])
|
||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||
currency (rf/sub [:profile/currency])
|
||||
conversion-rate (-> token
|
||||
:market-values-per-currency
|
||||
@@ -181,48 +178,29 @@
|
||||
utils/token-usd-price
|
||||
utils/one-cent-value
|
||||
utils/calc-max-crypto-decimals)
|
||||
[input-state set-input-state] (rn/use-state
|
||||
(-> controlled-input/init-state
|
||||
(controlled-input/set-upper-limit
|
||||
(utils/cut-crypto-decimals-to-fit-usd-cents
|
||||
(or default-limit-crypto token-balance)
|
||||
conversion-rate))))
|
||||
clear-input! #(set-input-state controlled-input/delete-all)
|
||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||
loading-routes? (rf/sub
|
||||
[:wallet/wallet-send-loading-suggested-routes?])
|
||||
route (rf/sub [:wallet/wallet-send-route])
|
||||
on-confirm (or default-on-confirm handle-on-confirm)
|
||||
crypto-decimals (or token-decimals default-crypto-decimals)
|
||||
current-crypto-limit (or default-limit-crypto
|
||||
(utils/get-standard-crypto-format
|
||||
token
|
||||
token-balance))
|
||||
available-crypto-limit (or default-limit-crypto
|
||||
(utils/get-standard-crypto-format
|
||||
token
|
||||
available-balance))
|
||||
current-fiat-limit (.toFixed (* token-balance conversion-rate) 2)
|
||||
available-fiat-limit (.toFixed (* available-balance conversion-rate) 2)
|
||||
current-limit (if crypto-currency?
|
||||
current-crypto-limit
|
||||
current-fiat-limit)
|
||||
available-limit (if crypto-currency?
|
||||
available-crypto-limit
|
||||
available-fiat-limit)
|
||||
valid-input? (not (or (string/blank?
|
||||
(controlled-input/input-value
|
||||
input-state))
|
||||
(<= (controlled-input/numeric-value
|
||||
input-state)
|
||||
0)
|
||||
(> (controlled-input/numeric-value
|
||||
input-state)
|
||||
available-limit)))
|
||||
input-num-value (controlled-input/numeric-value input-state)
|
||||
input-amount (controlled-input/input-value input-state)
|
||||
input-value (controlled-input/input-value input-state)
|
||||
valid-input? (not (or (controlled-input/empty-value? input-state)
|
||||
(controlled-input/input-error input-state)))
|
||||
confirm-disabled? (or (nil? route)
|
||||
(empty? route)
|
||||
(string/blank? (controlled-input/input-value
|
||||
input-state))
|
||||
(<= input-num-value 0)
|
||||
(> input-num-value current-limit))
|
||||
(not valid-input?))
|
||||
amount-in-crypto (if crypto-currency?
|
||||
input-amount
|
||||
input-value
|
||||
(number/remove-trailing-zeroes
|
||||
(.toFixed (/ input-amount conversion-rate)
|
||||
(.toFixed (/ input-value conversion-rate)
|
||||
crypto-decimals)))
|
||||
total-amount-receiver (rf/sub [:wallet/total-amount true])
|
||||
amount-text (str (number/remove-trailing-zeroes
|
||||
@@ -270,8 +248,7 @@
|
||||
receiver-selected-network))
|
||||
receiver-networks))
|
||||
input-error (controlled-input/input-error input-state)
|
||||
limit-insufficient? (> (controlled-input/numeric-value input-state)
|
||||
current-limit)
|
||||
limit-insufficient? (controlled-input/upper-limit-exceeded? input-state)
|
||||
should-try-again? (and (not limit-insufficient?) no-routes-found?)
|
||||
current-address (rf/sub [:wallet/current-viewing-account-address])
|
||||
owned-eth-token (rf/sub [:wallet/token-by-symbol
|
||||
@@ -284,7 +261,9 @@
|
||||
(if (= token-symbol
|
||||
(string/upper-case
|
||||
constants/mainnet-short-name))
|
||||
(= current-limit input-amount)
|
||||
(money/equal-to
|
||||
(controlled-input/numeric-value input-state)
|
||||
(controlled-input/upper-limit input-state))
|
||||
(money/equal-to (:total-balance
|
||||
owned-eth-token)
|
||||
0)))
|
||||
@@ -298,38 +277,20 @@
|
||||
:valid-input? valid-input?
|
||||
:bounce-duration-ms bounce-duration-ms
|
||||
:token token}))
|
||||
swap-currency (fn [to-crypto? value]
|
||||
(if to-crypto?
|
||||
(utils/cut-crypto-decimals-to-fit-usd-cents
|
||||
conversion-rate
|
||||
(money/fiat->crypto value conversion-rate))
|
||||
(utils/cut-fiat-balance-to-two-decimals
|
||||
(money/crypto->fiat value
|
||||
conversion-rate))))
|
||||
swap-between-fiat-and-crypto (fn [swap-to-crypto-currency?]
|
||||
swap-between-fiat-and-crypto (fn []
|
||||
(set-just-toggled-mode? true)
|
||||
(set-crypto-currency swap-to-crypto-currency?)
|
||||
(set-input-state
|
||||
(fn [input-state]
|
||||
(controlled-input/set-input-value
|
||||
input-state
|
||||
(let [value (controlled-input/input-value
|
||||
input-state)
|
||||
new-value (swap-currency
|
||||
swap-to-crypto-currency?
|
||||
value)]
|
||||
(number/remove-trailing-zeroes
|
||||
new-value))))))]
|
||||
(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-mount
|
||||
(fn []
|
||||
(let [dismiss-keyboard-fn #(when (= % "active") (rn/dismiss-keyboard!))
|
||||
app-keyboard-listener (.addEventListener rn/app-state "change" dismiss-keyboard-fn)]
|
||||
#(.remove app-keyboard-listener))))
|
||||
(hot-reload/use-safe-unmount on-navigate-back)
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
|
||||
[current-limit])
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(when input-error (debounce/clear-all))
|
||||
@@ -353,35 +314,36 @@
|
||||
:on-press #(rf/dispatch [:navigate-back])
|
||||
:switcher-type :select-account}]
|
||||
[quo/token-input
|
||||
{:container-style style/input-container
|
||||
:token token-symbol
|
||||
:currency fiat-currency
|
||||
:currency-symbol currency-symbol
|
||||
:crypto-decimals (min token-decimals 6)
|
||||
:error? (controlled-input/input-error input-state)
|
||||
:networks (seq from-enabled-networks)
|
||||
:title (i18n/label
|
||||
:t/send-limit
|
||||
{:limit (if crypto-currency?
|
||||
(utils/make-limit-label-crypto current-limit token-symbol)
|
||||
(utils/make-limit-label-fiat current-limit currency-symbol))})
|
||||
:conversion conversion-rate
|
||||
:show-keyboard? false
|
||||
:value input-amount
|
||||
:on-swap swap-between-fiat-and-crypto
|
||||
:on-token-press show-select-asset-sheet
|
||||
:allow-selection? false
|
||||
:crypto? crypto-currency?
|
||||
:converted-value (if crypto-currency?
|
||||
(utils/prettify-balance
|
||||
currency-symbol
|
||||
(money/crypto->fiat input-amount
|
||||
conversion-rate))
|
||||
(utils/prettify-crypto-balance
|
||||
(or (clj->js token-symbol) "")
|
||||
(money/fiat->crypto input-amount
|
||||
{:container-style style/input-container
|
||||
:token-symbol token-symbol
|
||||
:value input-value
|
||||
:on-swap swap-between-fiat-and-crypto
|
||||
:on-token-press show-select-asset-sheet
|
||||
:error? (controlled-input/input-error input-state)
|
||||
:currency-symbol (if crypto-currency? token-symbol fiat-currency)
|
||||
:converted-value (if crypto-currency?
|
||||
(utils/prettify-balance
|
||||
currency-symbol
|
||||
(money/crypto->fiat input-value
|
||||
conversion-rate))
|
||||
(utils/prettify-crypto-balance
|
||||
(or (clj->js token-symbol) "")
|
||||
(money/fiat->crypto input-value
|
||||
conversion-rate)
|
||||
conversion-rate))
|
||||
:hint-component [quo/network-tags
|
||||
{:networks (seq from-enabled-networks)
|
||||
:title (i18n/label
|
||||
:t/send-limit
|
||||
{:limit (if crypto-currency?
|
||||
(utils/prettify-crypto-balance
|
||||
(or (clj->js token-symbol) "")
|
||||
(controlled-input/upper-limit input-state)
|
||||
conversion-rate)
|
||||
conversion-rate))}]
|
||||
(utils/prettify-balance currency-symbol
|
||||
(controlled-input/upper-limit
|
||||
input-state)))})
|
||||
:status (when (controlled-input/input-error input-state) :error)}]}]
|
||||
[routes/view
|
||||
{:token token-by-symbol
|
||||
:send-amount-in-crypto amount-in-crypto
|
||||
@@ -426,7 +388,7 @@
|
||||
:left-action :dot
|
||||
:delete-key? true
|
||||
:on-press (fn [c]
|
||||
(let [new-text (str input-amount c)
|
||||
(let [new-text (str input-value c)
|
||||
max-decimals (if crypto-currency? crypto-decimals 2)
|
||||
regex-pattern (str "^\\d*\\.?\\d{0," max-decimals "}$")
|
||||
regex (re-pattern regex-pattern)]
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
(ns status-im.contexts.wallet.send.routes.view
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.controlled-input.utils :as controlled-input]
|
||||
[status-im.contexts.wallet.common.utils :as 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.utils :as send-utils]
|
||||
[status-im.contexts.wallet.sheets.network-preferences.view :as network-preferences]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.money :as money]
|
||||
[utils.number :as number]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
||||
@@ -87,160 +80,164 @@
|
||||
(rf/dispatch [:wallet/update-receiver-networks
|
||||
chain-ids]))}]))}]))
|
||||
|
||||
(defn- edit-amount
|
||||
[{:keys [chain-id token-symbol send-amount-in-crypto init-amount]}]
|
||||
(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content
|
||||
(fn []
|
||||
(let [{:keys [network-name] :as network-details} (rf/sub [:wallet/network-details-by-chain-id
|
||||
chain-id])
|
||||
{fiat-currency :currency} (rf/sub [:profile/profile])
|
||||
{token-decimals :decimals
|
||||
:as
|
||||
token} (rf/sub [:wallet/wallet-send-token])
|
||||
currency (rf/sub [:profile/currency])
|
||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||
send-from-locked-amounts (rf/sub
|
||||
[:wallet/wallet-send-from-locked-amounts])
|
||||
{account-color :color} (rf/sub [:wallet/current-viewing-account])
|
||||
locked-amount (get send-from-locked-amounts chain-id)
|
||||
network-name-str (string/capitalize (name network-name))
|
||||
[input-state set-input-state] (rn/use-state (cond-> controlled-input/init-state
|
||||
init-amount
|
||||
(controlled-input/set-input-value
|
||||
(money/to-string init-amount))
|
||||
locked-amount
|
||||
(controlled-input/set-input-value
|
||||
locked-amount)))
|
||||
[crypto-currency? set-crypto-currency] (rn/use-state true)
|
||||
conversion-rate (-> token
|
||||
:market-values-per-currency
|
||||
currency
|
||||
:price)
|
||||
{token-balance :total-balance} (rf/sub [:wallet/token-by-symbol
|
||||
(str token-symbol)
|
||||
[chain-id]])
|
||||
current-crypto-limit (utils/get-standard-crypto-format
|
||||
token
|
||||
token-balance)
|
||||
current-fiat-limit (.toFixed (* token-balance conversion-rate) 2)
|
||||
current-limit (if crypto-currency?
|
||||
current-crypto-limit
|
||||
current-fiat-limit)
|
||||
crypto-decimals token-decimals
|
||||
input-amount (controlled-input/input-value input-state)
|
||||
[is-amount-locked? set-is-amount-locked] (rn/use-state (some? locked-amount))
|
||||
bottom (safe-area/get-bottom)
|
||||
amount-in-crypto (if crypto-currency?
|
||||
input-amount
|
||||
(number/remove-trailing-zeroes
|
||||
(.toFixed (/ input-amount
|
||||
conversion-rate)
|
||||
crypto-decimals)))
|
||||
locked-greater-then-send-amount? (let [amount (money/bignumber
|
||||
amount-in-crypto)
|
||||
send-amount (money/bignumber
|
||||
send-amount-in-crypto)]
|
||||
(and (money/bignumber? amount)
|
||||
(money/bignumber? send-amount)
|
||||
(money/greater-than amount send-amount)))
|
||||
swap-between-fiat-and-crypto (fn [swap-to-crypto-currency?]
|
||||
(set-crypto-currency swap-to-crypto-currency?)
|
||||
(set-input-state
|
||||
(fn [input-state]
|
||||
#_(defn- edit-amount
|
||||
[{:keys [chain-id token-symbol send-amount-in-crypto init-amount]}]
|
||||
(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content
|
||||
(fn []
|
||||
(let [{:keys [network-name] :as network-details} (rf/sub [:wallet/network-details-by-chain-id
|
||||
chain-id])
|
||||
{fiat-currency :currency} (rf/sub [:profile/profile])
|
||||
{token-decimals :decimals
|
||||
:as
|
||||
token} (rf/sub [:wallet/wallet-send-token])
|
||||
currency (rf/sub [:profile/currency])
|
||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||
send-from-locked-amounts (rf/sub
|
||||
[:wallet/wallet-send-from-locked-amounts])
|
||||
{account-color :color} (rf/sub [:wallet/current-viewing-account])
|
||||
locked-amount (get send-from-locked-amounts chain-id)
|
||||
network-name-str (string/capitalize (name network-name))
|
||||
[input-state set-input-state] (rn/use-state
|
||||
(cond-> controlled-input/init-state
|
||||
init-amount
|
||||
(controlled-input/set-input-value
|
||||
input-state
|
||||
(let [value (controlled-input/input-value
|
||||
input-state)
|
||||
new-value (if
|
||||
swap-to-crypto-currency?
|
||||
(.toFixed
|
||||
(/ value
|
||||
conversion-rate)
|
||||
crypto-decimals)
|
||||
(.toFixed
|
||||
(* value
|
||||
conversion-rate)
|
||||
12))]
|
||||
(number/remove-trailing-zeroes
|
||||
new-value))))))
|
||||
lock-or-unlock-amount (fn []
|
||||
(if is-amount-locked?
|
||||
(rf/dispatch [:wallet/lock-from-amount
|
||||
chain-id
|
||||
amount-in-crypto])
|
||||
(rf/dispatch [:wallet/unlock-from-amount
|
||||
chain-id]))
|
||||
(rf/dispatch [:hide-bottom-sheet]))]
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
|
||||
[current-limit])
|
||||
[:<>
|
||||
[quo/drawer-top
|
||||
{:title (i18n/label :t/send-from-network {:network network-name-str})
|
||||
:description (i18n/label :t/define-amount-sent-from-network {:network network-name-str})}]
|
||||
[quo/token-input
|
||||
{:container-style style/input-container
|
||||
:token token-symbol
|
||||
:currency fiat-currency
|
||||
:currency-symbol currency-symbol
|
||||
:crypto-decimals (min token-decimals 6)
|
||||
:error? (controlled-input/input-error input-state)
|
||||
:networks [network-details]
|
||||
:title (i18n/label
|
||||
:t/send-limit
|
||||
{:limit (if crypto-currency?
|
||||
(utils/make-limit-label-crypto current-limit token-symbol)
|
||||
(utils/make-limit-label-fiat current-limit currency-symbol))})
|
||||
:conversion conversion-rate
|
||||
:show-keyboard? false
|
||||
:value (controlled-input/input-value input-state)
|
||||
:on-swap swap-between-fiat-and-crypto
|
||||
:allow-selection? false}]
|
||||
(when locked-greater-then-send-amount?
|
||||
[quo/information-box
|
||||
{:type :error
|
||||
:icon :i/info
|
||||
:style style/error-box}
|
||||
(i18n/label :t/value-higher-than-send-amount)])
|
||||
[quo/disclaimer
|
||||
{:on-change (fn [checked?]
|
||||
(set-is-amount-locked checked?))
|
||||
:checked? is-amount-locked?
|
||||
:container-style style/disclaimer
|
||||
:icon (if is-amount-locked?
|
||||
:i/locked
|
||||
:i/unlocked)
|
||||
:customization-color account-color}
|
||||
(i18n/label :t/dont-auto-recalculate-network {:network network-name-str})]
|
||||
[quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:button-one-label (i18n/label :t/update)
|
||||
:button-one-props {:on-press lock-or-unlock-amount
|
||||
:customization-color account-color
|
||||
:disabled? (or (controlled-input/empty-value? input-state)
|
||||
(controlled-input/input-error input-state)
|
||||
locked-greater-then-send-amount?)}}]
|
||||
[quo/numbered-keyboard
|
||||
{:container-style (style/keyboard-container bottom)
|
||||
:left-action :dot
|
||||
:delete-key? true
|
||||
:on-press (fn [c]
|
||||
(let [new-text (str input-amount c)
|
||||
max-decimals (if crypto-currency? crypto-decimals 2)
|
||||
regex-pattern (str "^\\d*\\.?\\d{0," max-decimals "}$")
|
||||
regex (re-pattern regex-pattern)]
|
||||
(when (re-matches regex new-text)
|
||||
(set-is-amount-locked true)
|
||||
(set-input-state #(controlled-input/add-character % c)))))
|
||||
:on-delete (fn []
|
||||
(set-is-amount-locked true)
|
||||
(set-input-state controlled-input/delete-last))
|
||||
:on-long-press-delete (fn []
|
||||
(set-is-amount-locked true)
|
||||
(set-input-state controlled-input/delete-all))}]]))}]))
|
||||
(money/to-string init-amount))
|
||||
locked-amount
|
||||
(controlled-input/set-input-value
|
||||
locked-amount)))
|
||||
[crypto-currency? set-crypto-currency] (rn/use-state true)
|
||||
conversion-rate (-> token
|
||||
:market-values-per-currency
|
||||
currency
|
||||
:price)
|
||||
{token-balance :total-balance} (rf/sub [:wallet/token-by-symbol
|
||||
(str token-symbol)
|
||||
[chain-id]])
|
||||
current-crypto-limit (utils/get-standard-crypto-format
|
||||
token
|
||||
token-balance)
|
||||
current-fiat-limit (.toFixed (* token-balance conversion-rate) 2)
|
||||
current-limit (if crypto-currency?
|
||||
current-crypto-limit
|
||||
current-fiat-limit)
|
||||
crypto-decimals token-decimals
|
||||
input-amount (controlled-input/input-value input-state)
|
||||
[is-amount-locked? set-is-amount-locked] (rn/use-state (some? locked-amount))
|
||||
bottom (safe-area/get-bottom)
|
||||
amount-in-crypto (if crypto-currency?
|
||||
input-amount
|
||||
(number/remove-trailing-zeroes
|
||||
(.toFixed (/ input-amount
|
||||
conversion-rate)
|
||||
crypto-decimals)))
|
||||
locked-greater-then-send-amount? (let [amount (money/bignumber
|
||||
amount-in-crypto)
|
||||
send-amount (money/bignumber
|
||||
send-amount-in-crypto)]
|
||||
(and (money/bignumber? amount)
|
||||
(money/bignumber? send-amount)
|
||||
(money/greater-than amount
|
||||
send-amount)))
|
||||
swap-between-fiat-and-crypto (fn [swap-to-crypto-currency?]
|
||||
(set-crypto-currency
|
||||
swap-to-crypto-currency?)
|
||||
(set-input-state
|
||||
(fn [input-state]
|
||||
(controlled-input/set-input-value
|
||||
input-state
|
||||
(let [value (controlled-input/input-value
|
||||
input-state)
|
||||
new-value
|
||||
(if
|
||||
swap-to-crypto-currency?
|
||||
(.toFixed
|
||||
(/ value
|
||||
conversion-rate)
|
||||
crypto-decimals)
|
||||
(.toFixed
|
||||
(* value
|
||||
conversion-rate)
|
||||
12))]
|
||||
(number/remove-trailing-zeroes
|
||||
new-value))))))
|
||||
lock-or-unlock-amount (fn []
|
||||
(if is-amount-locked?
|
||||
(rf/dispatch [:wallet/lock-from-amount
|
||||
chain-id
|
||||
amount-in-crypto])
|
||||
(rf/dispatch [:wallet/unlock-from-amount
|
||||
chain-id]))
|
||||
(rf/dispatch [:hide-bottom-sheet]))]
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
|
||||
[current-limit])
|
||||
[:<>
|
||||
[quo/drawer-top
|
||||
{:title (i18n/label :t/send-from-network {:network network-name-str})
|
||||
:description (i18n/label :t/define-amount-sent-from-network {:network network-name-str})}]
|
||||
[quo/token-input
|
||||
{:container-style style/input-container
|
||||
:token token-symbol
|
||||
:currency fiat-currency
|
||||
:currency-symbol currency-symbol
|
||||
:crypto-decimals (min token-decimals 6)
|
||||
:error? (controlled-input/input-error input-state)
|
||||
:networks [network-details]
|
||||
:title (i18n/label
|
||||
:t/send-limit
|
||||
{:limit (if crypto-currency?
|
||||
(utils/make-limit-label-crypto current-limit token-symbol)
|
||||
(utils/make-limit-label-fiat current-limit currency-symbol))})
|
||||
:conversion conversion-rate
|
||||
:show-keyboard? false
|
||||
:value (controlled-input/input-value input-state)
|
||||
:on-swap swap-between-fiat-and-crypto
|
||||
:allow-selection? false}]
|
||||
(when locked-greater-then-send-amount?
|
||||
[quo/information-box
|
||||
{:type :error
|
||||
:icon :i/info
|
||||
:style style/error-box}
|
||||
(i18n/label :t/value-higher-than-send-amount)])
|
||||
[quo/disclaimer
|
||||
{:on-change (fn [checked?]
|
||||
(set-is-amount-locked checked?))
|
||||
:checked? is-amount-locked?
|
||||
:container-style style/disclaimer
|
||||
:icon (if is-amount-locked?
|
||||
:i/locked
|
||||
:i/unlocked)
|
||||
:customization-color account-color}
|
||||
(i18n/label :t/dont-auto-recalculate-network {:network network-name-str})]
|
||||
[quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:button-one-label (i18n/label :t/update)
|
||||
:button-one-props {:on-press lock-or-unlock-amount
|
||||
:customization-color account-color
|
||||
:disabled? (or (controlled-input/empty-value? input-state)
|
||||
(controlled-input/input-error input-state)
|
||||
locked-greater-then-send-amount?)}}]
|
||||
[quo/numbered-keyboard
|
||||
{:container-style (style/keyboard-container bottom)
|
||||
:left-action :dot
|
||||
:delete-key? true
|
||||
:on-press (fn [c]
|
||||
(let [new-text (str input-amount c)
|
||||
max-decimals (if crypto-currency? crypto-decimals 2)
|
||||
regex-pattern (str "^\\d*\\.?\\d{0," max-decimals "}$")
|
||||
regex (re-pattern regex-pattern)]
|
||||
(when (re-matches regex new-text)
|
||||
(set-is-amount-locked true)
|
||||
(set-input-state #(controlled-input/add-character % c)))))
|
||||
:on-delete (fn []
|
||||
(set-is-amount-locked true)
|
||||
(set-input-state controlled-input/delete-last))
|
||||
:on-long-press-delete (fn []
|
||||
(set-is-amount-locked true)
|
||||
(set-input-state controlled-input/delete-all))}]]))}]))
|
||||
|
||||
(defn render-network-values
|
||||
[{:keys [network-values token-symbol on-press on-long-press receiver? loading-routes?
|
||||
@@ -388,13 +385,6 @@
|
||||
chain-id-to-disable
|
||||
disabled-from-chain-ids
|
||||
token-available-networks-for-suggested-routes))
|
||||
(when (ff/enabled? ::ff/wallet.custom-network-amounts)
|
||||
:on-long-press) (fn [chain-id amount-calculated-for-chain]
|
||||
(edit-amount
|
||||
{:chain-id chain-id
|
||||
:token-symbol token-symbol
|
||||
:send-amount-in-crypto send-amount-in-crypto
|
||||
:init-amount amount-calculated-for-chain}))
|
||||
:receiver? false
|
||||
:theme theme
|
||||
:loading-routes? loading-routes?
|
||||
|
||||
@@ -29,6 +29,21 @@
|
||||
[:wallet/pending-transaction-status-changed-received
|
||||
(transforms/js->clj event-js)]]]}
|
||||
|
||||
"wallet-collectibles-ownership-update-finished"
|
||||
{:fx [[:dispatch
|
||||
[:wallet/collectible-ownership-update-finished
|
||||
(transforms/js->clj event-js)]]]}
|
||||
|
||||
"wallet-collectibles-ownership-update-finished-with-error"
|
||||
{:fx [[:dispatch
|
||||
[:wallet/collectible-ownership-update-finished-with-error
|
||||
(transforms/js->clj event-js)]]]}
|
||||
|
||||
"wallet-collectibles-data-updated"
|
||||
{:fx [[:dispatch
|
||||
[:wallet/collectibles-data-updated
|
||||
(transforms/js->clj event-js)]]]}
|
||||
|
||||
"wallet-owned-collectibles-filtering-done"
|
||||
{:fx [[:dispatch
|
||||
[:wallet/owned-collectibles-filtering-done
|
||||
|
||||
@@ -52,6 +52,19 @@
|
||||
[proposal]
|
||||
(get-in proposal [:params :proposer :metadata]))
|
||||
|
||||
(defn get-current-request-dapp
|
||||
[request sessions]
|
||||
(let [dapp-url (get-in request [:event :verifyContext :verified :origin])]
|
||||
(->> sessions
|
||||
(filter (fn [session]
|
||||
(= (utils.string/remove-trailing-slash dapp-url)
|
||||
(utils.string/remove-trailing-slash (get session :url)))))
|
||||
first)))
|
||||
|
||||
(defn get-dapp-redirect-url
|
||||
[session]
|
||||
(get-in session [:peer :metadata :redirect :native]))
|
||||
|
||||
(defn get-db-current-request-params
|
||||
[db]
|
||||
(-> db
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.core-test
|
||||
(:require
|
||||
[cljs.test :refer-macros [deftest is testing]]
|
||||
[status-im.contexts.wallet.wallet-connect.core :as sut]))
|
||||
|
||||
(deftest get-current-request-dapp-test
|
||||
(testing "returns the correct dapp based on the request's origin"
|
||||
(let [request {:event {:verifyContext {:verified {:origin "https://dapp.com"}}}}
|
||||
sessions [{:url "https://dapp.com"}
|
||||
{:url "https://anotherdapp.com"}]]
|
||||
(is (= {:url "https://dapp.com"}
|
||||
(sut/get-current-request-dapp request sessions)))))
|
||||
|
||||
(testing "returns nil if no matching dapp is found"
|
||||
(let [request {:event {:verifyContext {:verified {:origin "https://dapp.com"}}}}
|
||||
sessions [{:url "https://anotherdapp.com"}]]
|
||||
(is (nil? (sut/get-current-request-dapp request sessions))))))
|
||||
|
||||
(deftest get-dapp-redirect-url-test
|
||||
(testing "returns the native redirect URL if it exists"
|
||||
(let [session {:peer {:metadata {:redirect {:native "native://redirect-url"}}}}]
|
||||
(is (= "native://redirect-url"
|
||||
(sut/get-dapp-redirect-url session)))))
|
||||
|
||||
(testing "returns nil if no redirect URL is found"
|
||||
(let [session {:peer {:metadata {}}}]
|
||||
(is (nil? (sut/get-dapp-redirect-url session))))))
|
||||
@@ -317,13 +317,17 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/persist-session
|
||||
(fn [_ [session-info]]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wallet_addWalletConnectSession"
|
||||
:params [(js/JSON.stringify session-info)]
|
||||
:on-success (fn []
|
||||
(log/info "Wallet Connect session persisted")
|
||||
(rf/dispatch [:wallet-connect/fetch-persisted-sessions]))
|
||||
:on-error #(log/info "Wallet Connect session persistence failed" %)}]]]}))
|
||||
(let [redirect-url (-> session-info
|
||||
(js->clj :keywordize-keys true)
|
||||
(wallet-connect-core/get-dapp-redirect-url))]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wallet_addWalletConnectSession"
|
||||
:params [(js/JSON.stringify session-info)]
|
||||
:on-success (fn []
|
||||
(log/info "Wallet Connect session persisted")
|
||||
(rf/dispatch [:wallet-connect/fetch-persisted-sessions])
|
||||
(rf/dispatch [:wallet-connect/redirect-to-dapp redirect-url]))
|
||||
:on-error #(log/info "Wallet Connect session persistence failed" %)}]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/disconnect-session
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
[status-im.contexts.wallet.wallet-connect.core :as wallet-connect-core]
|
||||
[status-im.contexts.wallet.wallet-connect.utils :as wc-utils]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.i18n :as i18n]))
|
||||
[utils.i18n :as i18n]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/respond-current-session
|
||||
@@ -132,8 +133,21 @@
|
||||
:event :wallet-connect/send-response
|
||||
:wallet-connect-event event}))
|
||||
:on-success (fn []
|
||||
(rf/dispatch [:wallet-connect/redirect-to-dapp])
|
||||
(log/info "Successfully sent Wallet Connect response to dApp"))}]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/redirect-to-dapp
|
||||
(fn [{:keys [db]} [url]]
|
||||
(let [redirect-url (or url
|
||||
(->> (get db :wallet-connect/current-request)
|
||||
(wallet-connect-core/get-current-request-dapp
|
||||
(get db :wallet-connect/sessions))
|
||||
:sessionJson
|
||||
transforms/json->clj
|
||||
wallet-connect-core/get-dapp-redirect-url))]
|
||||
{:fx [[:open-url redirect-url]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/dismiss-request-modal
|
||||
(fn [{:keys [db]} _]
|
||||
@@ -143,12 +157,6 @@
|
||||
wallet-connect-core/method-to-screen)]
|
||||
{:fx [[:dispatch [:dismiss-modal screen]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/finish-session-request
|
||||
(fn [_ [result]]
|
||||
{:fx [[:dispatch [:wallet-connect/send-response {:result result}]]
|
||||
[:dispatch [:wallet-connect/dismiss-request-modal]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/dismiss-request-modal
|
||||
(fn [{:keys [db]} _]
|
||||
@@ -168,11 +176,11 @@
|
||||
:wallet-connect/reject-session-proposal
|
||||
(fn [{:keys [db]} [proposal]]
|
||||
(let [web3-wallet (get db :wallet-connect/web3-wallet)
|
||||
{:keys [request response-sent?]} (or proposal (:wallet-connect/current-proposal db))]
|
||||
{:keys [request response-sent?]} (:wallet-connect/current-proposal db)]
|
||||
{:fx [(when-not response-sent?
|
||||
[:effects.wallet-connect/reject-session-proposal
|
||||
{:web3-wallet web3-wallet
|
||||
:proposal request
|
||||
:proposal (or proposal request)
|
||||
:on-success #(log/info "Wallet Connect session proposal rejected")
|
||||
:on-error #(log/error "Wallet Connect unable to reject session proposal")}])
|
||||
[:dispatch [:wallet-connect/reset-current-session-proposal]]]})))
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.responding-events-test
|
||||
(:require
|
||||
[cljs.test :refer-macros [is]]
|
||||
matcher-combinators.test
|
||||
[re-frame.db :as rf-db]
|
||||
[status-im.contexts.wallet.wallet-connect.core :as wallet-connect-core]
|
||||
status-im.contexts.wallet.wallet-connect.responding-events
|
||||
[test-helpers.unit :as h]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(h/deftest-event :wallet-connect/redirect-to-dapp
|
||||
[event-id dispatch]
|
||||
(let [current-request {:event {:verifyContext {:verified {:origin "https://dapp.com"}}}}
|
||||
session-json "{\"peer\":{\"metadata\":{\"redirect\":{\"native\":\"native://redirect-url\"}}}}"
|
||||
sessions [{:url "https://dapp.com"
|
||||
:sessionJson session-json}]]
|
||||
(reset! rf-db/app-db {:wallet-connect {:current-request current-request
|
||||
:sessions sessions}})
|
||||
(with-redefs [wallet-connect-core/get-current-request-dapp
|
||||
(fn [_ _] (first sessions))
|
||||
transforms/json->clj
|
||||
(fn [json] (js/JSON.parse json))
|
||||
wallet-connect-core/get-dapp-redirect-url
|
||||
(fn [_] "native://redirect-url")]
|
||||
|
||||
(is (match? {:fx [[:open-url "native://redirect-url"]]}
|
||||
(dispatch [event-id]))))))
|
||||
@@ -1,11 +1,14 @@
|
||||
(ns status-im.navigation.events
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.core :as react]
|
||||
[status-im.contexts.shell.jump-to.events :as shell.events]
|
||||
[status-im.contexts.shell.jump-to.state :as shell.state]
|
||||
[status-im.contexts.shell.jump-to.utils :as shell.utils]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.re-frame :as rf]))
|
||||
[utils.re-frame :as rf]
|
||||
[utils.url :as url]))
|
||||
|
||||
(defn- all-screens-params
|
||||
[db view screen-params]
|
||||
@@ -142,3 +145,9 @@
|
||||
{:fx [[:effects.share/open config]]})
|
||||
|
||||
(rf/reg-event-fx :open-share open-share)
|
||||
|
||||
(rf/reg-fx
|
||||
:open-url
|
||||
(fn [url]
|
||||
(when (not (string/blank? url))
|
||||
(.openURL ^js react/linking (url/normalize-url url)))))
|
||||
|
||||
@@ -137,3 +137,29 @@
|
||||
acc))
|
||||
0
|
||||
ownership))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet/collectibles
|
||||
:<- [:wallet/ui]
|
||||
:-> :collectibles)
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet/collectibles-updating
|
||||
:<- [:wallet/collectibles]
|
||||
:-> :updating)
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet/current-viewing-account-collectibles-updating?
|
||||
:<- [:wallet/collectibles-updating]
|
||||
:<- [:wallet/current-viewing-account-address]
|
||||
(fn [[updating-addresses address]]
|
||||
(contains? updating-addresses address)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet/home-tab-collectibles-updating?
|
||||
:<- [:wallet/collectibles-updating]
|
||||
:<- [:wallet/accounts-without-watched-accounts]
|
||||
(fn [[updating-addresses accounts]]
|
||||
(->> accounts
|
||||
(map :address)
|
||||
(every? #(contains? updating-addresses %)))))
|
||||
|
||||
@@ -41,12 +41,7 @@
|
||||
:<- [:wallet-connect/current-request]
|
||||
:<- [:wallet-connect/sessions]
|
||||
(fn [[request sessions]]
|
||||
(let [dapp-url (get-in request [:event :verifyContext :verified :origin])]
|
||||
(->> sessions
|
||||
(filter (fn [session]
|
||||
(= (utils.string/remove-trailing-slash dapp-url)
|
||||
(utils.string/remove-trailing-slash (get session :url)))))
|
||||
(first)))))
|
||||
(wallet-connect-core/get-current-request-dapp request sessions)))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/sessions-for-current-account
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
(def get-by-text (with-node-or-screen :get-by-text))
|
||||
(def query-all-by-text (with-node-or-screen :query-all-by-text))
|
||||
(def query-by-text (with-node-or-screen :query-by-text))
|
||||
(def query-first-by-text (comp first query-all-by-text))
|
||||
|
||||
(def get-all-by-label-text (with-node-or-screen :get-all-by-label-text))
|
||||
(def get-by-label-text (with-node-or-screen :get-by-label-text))
|
||||
|
||||
@@ -55,8 +55,9 @@
|
||||
(.lessThan ^js bn1 bn2))
|
||||
|
||||
(defn equal-to
|
||||
[bn1 bn2]
|
||||
(.eq ^js bn1 bn2))
|
||||
[n1 n2]
|
||||
(when-let [^js bn1 (bignumber n1)]
|
||||
(.eq ^js bn1 n2)))
|
||||
|
||||
(extend-type BigNumber
|
||||
IEquiv
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.184.48",
|
||||
"commit-sha1": "0f8e6d0b4e4ebfb1258dacde52d7603ad44c84d4",
|
||||
"src-sha256": "0jp91py71marsiiw726518d9pb38dg7wv1di55cc1rjmd312xplx"
|
||||
"version": "83f9ec909286cbebe1f68437aa51489922f59315",
|
||||
"commit-sha1": "83f9ec909286cbebe1f68437aa51489922f59315",
|
||||
"src-sha256": "0v6ad2cbmzmwdcpnlbw7maljir22939lbj5bk6agnxhfpacad490"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user