Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d9bedf11c | ||
|
|
3e268936f6 | ||
|
|
e92da6d24b | ||
|
|
34c95c42d1 | ||
|
|
1ee44259c4 | ||
|
|
112b69c1d6 | ||
|
|
3ce6a86e9b | ||
|
|
b005eb8181 | ||
|
|
4bd7abaace | ||
|
|
e2e8afb7b1 | ||
|
|
256f3f8f24 | ||
|
|
6931fd0052 | ||
|
|
136c3c0032 | ||
|
|
a92b50afea | ||
|
|
fd3a21a320 | ||
|
|
f93e372d18 | ||
|
|
0ed39a42ef |
@@ -2,7 +2,7 @@
|
||||
name: MVPBug Report
|
||||
about: MVPBug Report
|
||||
title: ''
|
||||
labels: 'E:Mobile Bug MVP'
|
||||
labels: ['E:Mobile Bug MVP', ':1234: low prio']
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
@@ -119,8 +119,6 @@
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UIStatusBarStyle</key>
|
||||
<string>UIStatusBarStyleLightContent</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
@@ -133,7 +131,7 @@
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<true/>
|
||||
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
|
||||
<array>
|
||||
<string>A00000080400010101</string>
|
||||
|
||||
@@ -38,10 +38,12 @@
|
||||
:always
|
||||
(update :contacts conj (:id member))))
|
||||
|
||||
(defn community-chat-id->channel-id [chat-id] (subs chat-id constants/community-id-length))
|
||||
|
||||
(defn decode-chat-id
|
||||
[chat-id]
|
||||
(let [community-id (subs chat-id 0 constants/community-id-length)
|
||||
channel-id (subs chat-id constants/community-id-length)]
|
||||
channel-id (community-chat-id->channel-id chat-id)]
|
||||
{:community-id community-id
|
||||
:channel-id channel-id}))
|
||||
|
||||
|
||||
@@ -135,7 +135,8 @@
|
||||
(>= (- now app-in-background-since)
|
||||
constants/ms-in-bg-for-require-bioauth))]
|
||||
(rf/merge cofx
|
||||
{:db (dissoc db :app-in-background-since)}
|
||||
{:db (dissoc db :app-in-background-since)
|
||||
:effects.biometric/get-supported-type nil}
|
||||
(mailserver/process-next-messages-request)
|
||||
(when-not new-account?
|
||||
(universal-links/process-stored-event))
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
[{:keys [db] :as cofx} {:keys [auth-method logout?]}]
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])]
|
||||
(rf/merge cofx
|
||||
{:set-root :progress
|
||||
{:dispatch [:init-root :progress]
|
||||
:effects.shell/reset-state nil
|
||||
:hide-popover nil
|
||||
::logout nil
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
[]
|
||||
[;;PROGRESS
|
||||
{:name :progress
|
||||
:options {:insets {:top? true}}
|
||||
:options {:insets {:top? true}
|
||||
:theme :dark}
|
||||
:component progress/progress}
|
||||
|
||||
;;COMMUNITY
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
[react-native.reanimated :as reanimated]))
|
||||
|
||||
(defn drag-gesture
|
||||
[x-pos disabled? track-width sliding-complete?
|
||||
set-sliding-complete
|
||||
on-complete reset-fn]
|
||||
[x-pos disabled? track-width sliding-complete? set-sliding-complete on-complete reset-fn]
|
||||
(-> (gesture/gesture-pan)
|
||||
(gesture/with-test-ID :slide-button-gestures)
|
||||
(gesture/enabled (not disabled?))
|
||||
@@ -71,14 +69,16 @@
|
||||
(dimensions :thumb))
|
||||
[dimensions])
|
||||
custom-color (if (= type :danger) :danger customization-color)
|
||||
gesture (rn/use-memo #(drag-gesture x-pos
|
||||
disabled?
|
||||
(dimensions :usable-track)
|
||||
sliding-complete?
|
||||
set-sliding-complete
|
||||
on-complete
|
||||
reset-fn)
|
||||
[sliding-complete? disabled?])]
|
||||
gesture (rn/use-memo
|
||||
(fn []
|
||||
(drag-gesture x-pos
|
||||
disabled?
|
||||
(dimensions :usable-track)
|
||||
sliding-complete?
|
||||
set-sliding-complete
|
||||
on-complete
|
||||
reset-fn))
|
||||
[sliding-complete? disabled? on-complete])]
|
||||
[gesture/gesture-detector
|
||||
{:gesture gesture}
|
||||
[reanimated/view
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn- get-icon-color
|
||||
[danger? theme]
|
||||
(if danger?
|
||||
(colors/theme-colors colors/danger-50 colors/danger-60 theme)
|
||||
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme)))
|
||||
[blur? danger? theme]
|
||||
(cond
|
||||
danger? (colors/theme-colors colors/danger-50 colors/danger-60 theme)
|
||||
blur? colors/white-opa-70
|
||||
:else (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)))
|
||||
|
||||
(defn- divider
|
||||
[theme blur?]
|
||||
@@ -51,7 +52,7 @@
|
||||
:accessible true
|
||||
:style (style/left-icon sub-label)}
|
||||
[icon/icon icon
|
||||
{:color (or icon-color (get-icon-color danger? theme))
|
||||
{:color (or icon-color (get-icon-color blur? danger? theme))
|
||||
:no-color no-icon-color?
|
||||
:size 20}]])
|
||||
[rn/view
|
||||
@@ -84,7 +85,7 @@
|
||||
:accessible true
|
||||
:accessibility-label :right-icon-for-action}
|
||||
[icon/icon right-icon
|
||||
{:color (get-icon-color danger? theme)
|
||||
{:color (get-icon-color blur? danger? theme)
|
||||
:size 20}]])
|
||||
(when (= state :selected)
|
||||
[rn/view {:style style/right-icon}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
(defn- left-image
|
||||
[{:keys [type customization-color account-avatar-emoji account-avatar-type icon-avatar
|
||||
profile-picture]}]
|
||||
profile-picture blur?]}]
|
||||
(case type
|
||||
:account [account-avatar/view
|
||||
{:customization-color customization-color
|
||||
@@ -28,6 +28,7 @@
|
||||
:keypair [icon-avatar/icon-avatar
|
||||
{:icon icon-avatar
|
||||
:border? true
|
||||
:blur? blur?
|
||||
:color :neutral}]
|
||||
|
||||
:default-keypair [user-avatar/user-avatar
|
||||
@@ -213,6 +214,7 @@
|
||||
[rn/view {:style style/left-container}
|
||||
[left-image
|
||||
{:type type
|
||||
:blur? blur?
|
||||
:customization-color customization-color
|
||||
:account-avatar-emoji account-avatar-emoji
|
||||
:account-avatar-type account-avatar-type
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
:size :paragraph-2}
|
||||
(:name account-props)]
|
||||
[address-text/view
|
||||
{:networks networks
|
||||
{:blur? blur?
|
||||
:networks networks
|
||||
:address (:address account-props)
|
||||
:format :short}]]]
|
||||
(when (= action :icon)
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
|
||||
(def container-info
|
||||
{:flex-direction :row
|
||||
:align-items :center})
|
||||
:align-items :center
|
||||
:flex 1})
|
||||
|
||||
(def user-info
|
||||
{:margin-left 8})
|
||||
|
||||
@@ -25,14 +25,16 @@
|
||||
:style {:width 32 :height 32}}]
|
||||
[rn/view {:style style/user-info}
|
||||
[text/text
|
||||
{:weight :semi-bold
|
||||
:size :paragraph-1
|
||||
:style (style/style-text-name theme)}
|
||||
{:weight :semi-bold
|
||||
:size :paragraph-1
|
||||
:number-of-lines 1
|
||||
:style (style/style-text-name theme)}
|
||||
(:name dapp)]
|
||||
[text/text
|
||||
{:weight :regular
|
||||
:size :paragraph-2
|
||||
:style (style/style-text-value theme)}
|
||||
{:weight :regular
|
||||
:size :paragraph-2
|
||||
:number-of-lines 1
|
||||
:style (style/style-text-value theme)}
|
||||
(:value dapp)]]]
|
||||
(when right-component
|
||||
[right-component dapp])]))
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
(defn- checkbox-border-unchecked-color
|
||||
[theme]
|
||||
{:normal (colors/theme-colors colors/neutral-30 colors/neutral-70 theme)
|
||||
:blur (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-40 theme)})
|
||||
:blur (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-20 theme)})
|
||||
|
||||
(defn- filled-checkbox-background-color
|
||||
[theme]
|
||||
|
||||
@@ -51,3 +51,24 @@
|
||||
:right-icon :i/globe
|
||||
:chevron? true}]}])
|
||||
(h/is-truthy (h/get-by-text "subtitle"))))
|
||||
|
||||
(h/describe "Data Item Category tests"
|
||||
(h/test "category renders"
|
||||
(h/render [category/category
|
||||
{:list-type :data-item
|
||||
:label "Label"
|
||||
:data [{:title "Item 1"
|
||||
:subtitle "subtitle"
|
||||
:right-icon :i/globe}]}])
|
||||
(h/is-truthy (h/get-by-text "Label"))
|
||||
(h/is-truthy (h/get-by-text "Item 1"))
|
||||
(h/is-truthy (h/get-by-text "subtitle")))
|
||||
|
||||
(h/test "category renders without label"
|
||||
(h/render [category/category
|
||||
{:list-type :data-item
|
||||
:data [{:title "Item 1"
|
||||
:subtitle "subtitle"
|
||||
:right-icon :i/globe}]}])
|
||||
(h/is-falsy (h/query-by-label-text "Label"))
|
||||
(h/is-truthy (h/get-by-text "Item 1"))))
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
(ns quo.components.settings.category.data-item.view
|
||||
(:require
|
||||
[quo.components.markdown.text :as text]
|
||||
[quo.components.settings.category.style :as style]
|
||||
[quo.components.settings.data-item.view :as data-item]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn view
|
||||
[{:keys [label data container-style blur?]}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
last-item (rn/use-memo #(last data) [data])]
|
||||
[rn/view {:style (merge (style/container label) container-style)}
|
||||
(when label
|
||||
[text/text
|
||||
{:weight :medium
|
||||
:size :paragraph-2
|
||||
:style (style/label blur? theme)}
|
||||
label])
|
||||
[rn/view {:style (style/settings-items blur? theme)}
|
||||
(for [item data
|
||||
;; NOTE: overwriting the background of the data-item in favor of the category bg
|
||||
:let [data-item-container-style (-> item :container-style (assoc :background-color nil))
|
||||
data-item-props (assoc item
|
||||
:blur? blur?
|
||||
:container-style data-item-container-style)]]
|
||||
^{:key item}
|
||||
[:<>
|
||||
[data-item/view data-item-props]
|
||||
(when-not (= item last-item)
|
||||
[rn/view {:style (style/settings-separator blur? theme)}])])]]))
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
(ns quo.components.settings.category.view
|
||||
(:require
|
||||
[quo.components.settings.category.data-item.view :as data-item]
|
||||
[quo.components.settings.category.reorder.view :as reorder]
|
||||
[quo.components.settings.category.settings.view :as settings]))
|
||||
|
||||
(defn category
|
||||
[{:keys [list-type] :as props}]
|
||||
(if (= list-type :settings)
|
||||
[settings/settings-category props]
|
||||
[reorder/reorder-category props]))
|
||||
(condp = list-type
|
||||
:settings [settings/settings-category props]
|
||||
:data-item [data-item/view props]
|
||||
:reorder [reorder/reorder-category props]
|
||||
nil))
|
||||
|
||||
@@ -39,6 +39,12 @@
|
||||
(def avatar-container-rounded
|
||||
(assoc avatar-container-common :border-radius 16))
|
||||
|
||||
(def big-avatar-container-rounded
|
||||
(assoc avatar-container-common
|
||||
:width 84
|
||||
:height 84
|
||||
:border-radius 42))
|
||||
|
||||
(def community-logo-image
|
||||
{:width 64
|
||||
:height 64
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
:as props}]
|
||||
[rn/view {:style style/avatar-overlay}
|
||||
[rn/view
|
||||
{:style (if (= avatar-type :wallet-account)
|
||||
style/avatar-container-rounded
|
||||
{:style (case avatar-type
|
||||
:wallet-account style/avatar-container-rounded
|
||||
:saved-address style/big-avatar-container-rounded
|
||||
style/avatar-container-circular)}
|
||||
(case avatar-type
|
||||
:profile
|
||||
@@ -37,7 +38,7 @@
|
||||
[channel-avatar/view (assoc props :locked? nil :size :size-64)]
|
||||
|
||||
:saved-address
|
||||
[wallet-avatar/wallet-user-avatar (assoc props :size :size-64)]
|
||||
[wallet-avatar/wallet-user-avatar (assoc props :size :size-80)]
|
||||
|
||||
nil)]])
|
||||
|
||||
|
||||
@@ -28,5 +28,10 @@
|
||||
:height 24
|
||||
:border-radius 12})
|
||||
|
||||
(def dapp
|
||||
{:width 24
|
||||
:height 24
|
||||
:border-radius 12})
|
||||
|
||||
(def token-image
|
||||
{:border-radius 12})
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
[rn/image
|
||||
{:source image-source
|
||||
:style style/network}]
|
||||
:dapp
|
||||
[rn/image
|
||||
{:source image-source
|
||||
:style style/dapp}]
|
||||
:saved-address
|
||||
[wallet-user-avatar/wallet-user-avatar
|
||||
{:full-name label
|
||||
@@ -50,7 +54,7 @@
|
||||
- :label - string - tag label
|
||||
- :customization-color - color - It will be passed down to components that
|
||||
should vary based on a custom color.
|
||||
- :type - :token / :user / :collectible / :saved-address / :network / :account
|
||||
- :type - :token / :user / :collectible / :saved-address / :network / :account / :dapp
|
||||
- :emoji - string - emoji used for displaying account avatar
|
||||
- :image-source - resource - image to display on :network, :collectible and :user
|
||||
- :theme - :light / :dark"
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
[{:keys [blur? customization-color theme selected? container-style]}]
|
||||
(merge {:border-radius 16
|
||||
:border-width 1
|
||||
:border-color (if selected?
|
||||
(if blur?
|
||||
colors/white
|
||||
(colors/resolve-color customization-color theme))
|
||||
(if blur?
|
||||
colors/white-opa-5
|
||||
(colors/theme-colors colors/neutral-10 colors/neutral-80 theme)))
|
||||
:padding-bottom 8}
|
||||
:padding-bottom 8
|
||||
:border-color (cond
|
||||
(and selected? blur?) colors/white
|
||||
selected? (colors/resolve-color customization-color theme)
|
||||
blur? colors/white-opa-5
|
||||
:else (colors/theme-colors colors/neutral-10
|
||||
colors/neutral-80
|
||||
theme))}
|
||||
container-style))
|
||||
|
||||
(def header-container
|
||||
|
||||
@@ -47,12 +47,13 @@
|
||||
:accessibility-label :title}
|
||||
[text/text {:weight :semi-bold}
|
||||
(if (= type :default-keypair) (keypair-string full-name) full-name)]
|
||||
(if (= action :selector)
|
||||
[selectors/view
|
||||
{:type :radio
|
||||
:checked? selected?
|
||||
:blur? blur?
|
||||
:customization-color customization-color}]
|
||||
(case action
|
||||
:none nil
|
||||
:selector [selectors/view
|
||||
{:type :radio
|
||||
:checked? selected?
|
||||
:blur? blur?
|
||||
:customization-color customization-color}]
|
||||
[rn/pressable {:on-press on-options-press}
|
||||
[icon/icon :i/options
|
||||
{:color (if blur?
|
||||
@@ -94,20 +95,23 @@
|
||||
|
||||
(defn view
|
||||
[{:keys [accounts action container-style selected? on-press] :as props}]
|
||||
[rn/pressable
|
||||
{:style (style/container (merge props
|
||||
{:selected? selected?
|
||||
:container-style container-style}))
|
||||
:on-press #(when (= action :selector) (on-press))}
|
||||
[rn/view {:style style/header-container}
|
||||
[avatar props]
|
||||
[rn/view
|
||||
{:style {:margin-left 8
|
||||
:flex 1}}
|
||||
[title-view (assoc props :selected? selected?)]
|
||||
[details-view props]]]
|
||||
[rn/flat-list
|
||||
{:data accounts
|
||||
:render-fn acc-list-card
|
||||
:separator [rn/view {:style {:height 8}}]
|
||||
:style {:padding-horizontal 8}}]])
|
||||
(let [theme (quo.theme/use-theme)]
|
||||
[rn/pressable
|
||||
{:style (style/container (assoc props
|
||||
:selected? selected?
|
||||
:container-style container-style
|
||||
:theme theme))
|
||||
:on-press #(when (= action :selector) (on-press))
|
||||
:pointer-events :box-only}
|
||||
[rn/view {:style style/header-container}
|
||||
[avatar props]
|
||||
[rn/view
|
||||
{:style {:margin-left 8
|
||||
:flex 1}}
|
||||
[title-view (assoc props :selected? selected?)]
|
||||
[details-view props]]]
|
||||
[rn/flat-list
|
||||
{:data accounts
|
||||
:render-fn acc-list-card
|
||||
:separator [rn/view {:style {:height 8}}]
|
||||
:style {:padding-horizontal 8}}]]))
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
[utils.i18n :as i18n]))
|
||||
|
||||
(defn title-view
|
||||
[{:keys [keypairs blur? on-import-press]}]
|
||||
[{:keys [keypairs blur? on-import-press show-import-all?]}]
|
||||
(let [theme (quo.theme/use-theme)]
|
||||
[rn/view
|
||||
{:accessibility-label :title
|
||||
@@ -29,12 +29,13 @@
|
||||
:style {:color colors/warning-60}}
|
||||
(i18n/label :t/amount-missing-keypairs
|
||||
{:amount (str (count keypairs))})]
|
||||
[button/button
|
||||
{:type :outline
|
||||
:background :blur
|
||||
:size 24
|
||||
:on-press on-import-press}
|
||||
(i18n/label :t/import)]]
|
||||
(when show-import-all?
|
||||
[button/button
|
||||
{:type :outline
|
||||
:background :blur
|
||||
:size 24
|
||||
:on-press on-import-press}
|
||||
(i18n/label :t/import)])]
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:style (style/subtitle blur? theme)}
|
||||
|
||||
@@ -81,8 +81,9 @@
|
||||
(js->clj :keywordize-keys true)
|
||||
(on-selection-change))))]
|
||||
(fn [{:keys [token customization-color show-keyboard? crypto? currency value error? selection
|
||||
handle-on-swap]
|
||||
:or {show-keyboard? true}}]
|
||||
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
|
||||
@@ -107,7 +108,8 @@
|
||||
:selection-color customization-color
|
||||
:show-soft-input-on-focus show-keyboard?
|
||||
:on-selection-change handle-selection-change
|
||||
:selection (clj->js selection)}
|
||||
: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)]]]
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
(defn get-label-by-type
|
||||
[biometric-type]
|
||||
(condp = biometric-type
|
||||
constants/biometrics-type-android (i18n/label :t/biometric-fingerprint)
|
||||
constants/biometrics-type-face-id (i18n/label :t/biometric-faceid)
|
||||
(i18n/label :t/biometric-touchid)))
|
||||
constants/biometrics-type-android (i18n/label :t/biometric-fingerprint)
|
||||
constants/biometrics-type-face-id (i18n/label :t/biometric-faceid)
|
||||
constants/biometrics-type-touch-id (i18n/label :t/biometric-touchid)
|
||||
(i18n/label :t/biometric)))
|
||||
|
||||
(defn get-icon-by-type
|
||||
[biometric-type]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns status-im.common.bottom-sheet.style
|
||||
(:require
|
||||
[quo.foundations.colors :as colors]
|
||||
[react-native.platform :as platform]))
|
||||
[quo.foundations.colors :as colors]))
|
||||
|
||||
(def ^:private sheet-border-radius 20)
|
||||
|
||||
@@ -22,11 +21,8 @@
|
||||
:left 0
|
||||
:right 0})
|
||||
|
||||
(defn shell-bg
|
||||
[blur-background]
|
||||
{:background-color (if blur-background
|
||||
blur-background
|
||||
(if platform/ios? colors/white-opa-5 colors/neutral-100-opa-90))
|
||||
(def shell-bg
|
||||
{:background-color colors/bottom-sheet-background-blur
|
||||
:flex 1})
|
||||
|
||||
(def shell-bg-container
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
(defn view
|
||||
[{:keys [hide? insets]}
|
||||
{:keys [content selected-item padding-bottom-override border-radius on-close shell?
|
||||
gradient-cover? customization-color hide-handle? blur-radius blur-background]
|
||||
gradient-cover? customization-color hide-handle? blur-radius]
|
||||
:or {border-radius 12}}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
{window-height :height} (rn/get-window)
|
||||
@@ -134,7 +134,7 @@
|
||||
(when shell?
|
||||
[rn/view {:style style/shell-bg-container}
|
||||
[quo/blur
|
||||
{:style (style/shell-bg blur-background)
|
||||
{:style style/shell-bg
|
||||
:blur-radius (or blur-radius 20)
|
||||
:blur-amount 32
|
||||
:blur-type :transparent
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
(ns status-im.common.enter-seed-phrase.style
|
||||
(:require
|
||||
[react-native.safe-area :as safe-area]))
|
||||
(:require [react-native.platform :as platform]))
|
||||
|
||||
(def full-layout {:flex 1})
|
||||
|
||||
@@ -11,6 +10,13 @@
|
||||
:left 0
|
||||
:right 0})
|
||||
|
||||
(defn recovery-phrase-container
|
||||
[{:keys [banner-offset insets keyboard-shown?]}]
|
||||
{:flex 1
|
||||
:padding-bottom (if keyboard-shown?
|
||||
(when platform/ios? banner-offset)
|
||||
(:bottom insets))})
|
||||
|
||||
(def form-container
|
||||
{:flex 1
|
||||
:padding-horizontal 20
|
||||
@@ -29,9 +35,7 @@
|
||||
:margin-top 12
|
||||
:margin-horizontal -20})
|
||||
|
||||
(defn continue-button
|
||||
[keyboard-shown?]
|
||||
{:margin-top :auto
|
||||
:margin-bottom (when-not keyboard-shown? (safe-area/get-bottom))})
|
||||
(def continue-button
|
||||
{:margin-top :auto})
|
||||
|
||||
(def keyboard-container {:margin-top :auto})
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
(take 7)))
|
||||
|
||||
(defn recovery-phrase-screen
|
||||
[{:keys [keypair title recovering-keypair? render-controls]}]
|
||||
[{:keys [banner-offset initial-insets keypair title recovering-keypair? render-controls]}]
|
||||
(reagent/with-let [keyboard-shown? (reagent/atom false)
|
||||
keyboard-show-listener (.addListener rn/keyboard
|
||||
"keyboardDidShow"
|
||||
@@ -114,7 +114,8 @@
|
||||
seed-phrase (reagent/atom "")
|
||||
on-change-seed-phrase (fn [new-phrase]
|
||||
(when @invalid-seed-phrase?
|
||||
(reset! invalid-seed-phrase? false)
|
||||
(reset! invalid-seed-phrase? false))
|
||||
(when @incorrect-seed-phrase?
|
||||
(reset! incorrect-seed-phrase? false))
|
||||
(reset! seed-phrase new-phrase))
|
||||
on-submit (fn []
|
||||
@@ -161,7 +162,10 @@
|
||||
button-disabled? (or error-state?
|
||||
(not (constants/seed-phrase-valid-length word-count))
|
||||
(not all-words-valid?))]
|
||||
[:<>
|
||||
[rn/view
|
||||
{:style (style/recovery-phrase-container {:insets initial-insets
|
||||
:banner-offset banner-offset
|
||||
:keyboard-shown? @keyboard-shown?})}
|
||||
[recovery-phrase-form
|
||||
{:title title
|
||||
:keypair keypair
|
||||
@@ -172,18 +176,18 @@
|
||||
(if (fn? render-controls)
|
||||
(render-controls {:submit-disabled? button-disabled?
|
||||
:keyboard-shown? @keyboard-shown?
|
||||
:container-style (style/continue-button @keyboard-shown?)
|
||||
:container-style style/continue-button
|
||||
:prepare-seed-phrase secure-clean-seed-phrase
|
||||
:focus-input focus-input
|
||||
:seed-phrase (security/mask-data @seed-phrase)
|
||||
:set-incorrect-seed-phrase set-incorrect-seed-phrase})
|
||||
[quo/button
|
||||
{:container-style (style/continue-button @keyboard-shown?)
|
||||
{:container-style style/continue-button
|
||||
:type :primary
|
||||
:disabled? button-disabled?
|
||||
:on-press on-submit}
|
||||
(i18n/label :t/continue)])]
|
||||
(when @keyboard-shown?
|
||||
(when (or @keyboard-shown? error-state?)
|
||||
[rn/view {:style style/keyboard-container}
|
||||
[quo/predictive-keyboard
|
||||
{:type suggestions-state
|
||||
@@ -197,7 +201,8 @@
|
||||
|
||||
(defn screen
|
||||
[{:keys [initial-insets title keypair navigation-icon recovering-keypair? render-controls]}]
|
||||
(let [{navigation-bar-top :top} initial-insets]
|
||||
(let [{navigation-bar-top :top} initial-insets
|
||||
banner-offset (rf/sub [:alert-banners/top-margin])]
|
||||
[rn/view {:style style/full-layout}
|
||||
[rn/keyboard-avoiding-view {:style style/page-container}
|
||||
[quo/page-nav
|
||||
@@ -210,6 +215,8 @@
|
||||
{:title title
|
||||
:keypair keypair
|
||||
:render-controls render-controls
|
||||
:banner-offset banner-offset
|
||||
:initial-insets initial-insets
|
||||
:recovering-keypair? recovering-keypair?}]]]))
|
||||
|
||||
(defn view
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
(defn view
|
||||
[{:keys [header footer customization-color footer-container-padding header-container-style
|
||||
gradient-cover? keyboard-should-persist-taps]
|
||||
content-container-style gradient-cover? keyboard-should-persist-taps]
|
||||
:or {footer-container-padding (safe-area/get-top)}}
|
||||
& children]
|
||||
(reagent/with-let [scroll-view-ref (atom nil)
|
||||
@@ -110,7 +110,9 @@
|
||||
:always-bounce-vertical @keyboard-did-show?
|
||||
:shows-vertical-scroll-indicator false
|
||||
:keyboard-should-persist-taps keyboard-should-persist-taps}
|
||||
(into [rn/view {:on-layout set-content-container-height}]
|
||||
(into [rn/view
|
||||
{:style content-container-style
|
||||
:on-layout set-content-container-height}]
|
||||
children)]
|
||||
[rn/keyboard-avoiding-view
|
||||
{:style style/keyboard-avoiding-view
|
||||
|
||||
@@ -448,7 +448,7 @@
|
||||
(destructive-actions item inside-chat?)])])
|
||||
|
||||
(defn contact-actions
|
||||
[{:keys [public-key] :as contact} {:keys [chat-id admin?] :as extra-data}]
|
||||
[{:keys [public-key added?] :as contact} {:keys [chat-id admin?] :as extra-data}]
|
||||
(let [current-pub-key (rf/sub [:multiaccount/public-key])]
|
||||
[quo/action-drawer
|
||||
[[(view-profile-entry public-key)
|
||||
@@ -459,7 +459,7 @@
|
||||
[(when-not (= current-pub-key public-key)
|
||||
(when config/show-not-implemented-features?
|
||||
(mark-untrustworthy-entry)))
|
||||
(when-not (= current-pub-key public-key) (remove-from-contacts-entry contact))
|
||||
(when added? (remove-from-contacts-entry contact))
|
||||
(when-not (= current-pub-key public-key) (block-user-entry contact))]
|
||||
(when (and admin? chat-id)
|
||||
[(if (= current-pub-key public-key)
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
(:require [quo.foundations.colors :as colors]))
|
||||
|
||||
(def container
|
||||
{:flex 1
|
||||
:padding 10
|
||||
:margin-vertical 10.5
|
||||
:border-width 1
|
||||
:border-color colors/neutral-10
|
||||
:border-radius 16})
|
||||
{:flex 1
|
||||
:padding 10
|
||||
:margin-top 10.5
|
||||
:margin-bottom 0
|
||||
:border-width 1
|
||||
:border-color colors/neutral-10
|
||||
:border-radius 16})
|
||||
|
||||
(def content
|
||||
{:padding-bottom 20})
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
[status-im.common.raw-data-block.style :as style]))
|
||||
|
||||
(defn view
|
||||
[{:keys [data]}]
|
||||
[data]
|
||||
[rn/scroll-view
|
||||
{:style style/container
|
||||
:content-container-style style/content}
|
||||
|
||||
@@ -195,7 +195,7 @@
|
||||
true)
|
||||
|
||||
(defn view
|
||||
[{:keys [title subtitle validate-fn on-success-scan error-message share-button?]}]
|
||||
[{:keys [title subtitle validate-fn on-success-scan error-message share-button? import-keypair?]}]
|
||||
(let [insets (safe-area/get-insets)
|
||||
qr-code-succeed? (reagent/atom false)
|
||||
qr-view-finder (reagent/atom {})
|
||||
@@ -233,7 +233,9 @@
|
||||
:set-qr-code-succeeded (fn [value]
|
||||
(when on-success-scan
|
||||
(on-success-scan value))
|
||||
(rf/dispatch [:navigate-back]))
|
||||
(if import-keypair?
|
||||
(set-rescan-timeout)
|
||||
(rf/dispatch [:navigate-back])))
|
||||
:set-rescan-timeout set-rescan-timeout}])
|
||||
[rn/view {:style (style/root-container (:top insets))}
|
||||
[header
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
:size 24}]]
|
||||
[password-input/view
|
||||
{:on-press-biometrics on-press-biometrics
|
||||
:blur? true
|
||||
:processing processing
|
||||
:error error
|
||||
:default-password password
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
(rf/reg-event-fx :standard-auth/authorize authorize)
|
||||
|
||||
(defn authorize-with-biometric
|
||||
[_ [{:keys [on-auth-success on-auth-fail] :as args}]]
|
||||
[_ [{:keys [on-auth-success on-auth-fail on-close] :as args}]]
|
||||
(let [args-with-biometric-btn
|
||||
(assoc args
|
||||
:on-press-biometric
|
||||
@@ -31,7 +31,10 @@
|
||||
{:prompt-message (i18n/label :t/biometric-auth-confirm-message)
|
||||
:on-cancel #(rf/dispatch [:standard-auth/authorize-with-password
|
||||
args-with-biometric-btn])
|
||||
:on-success #(rf/dispatch [:standard-auth/on-biometric-success on-auth-success])
|
||||
:on-success (fn []
|
||||
(when (fn? on-close)
|
||||
(on-close))
|
||||
(rf/dispatch [:standard-auth/on-biometric-success on-auth-success]))
|
||||
:on-fail (fn [err]
|
||||
(rf/dispatch [:standard-auth/authorize-with-password
|
||||
args-with-biometric-btn])
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
(> (-> s str string/trim count) constants/key-pair-name-max-length))
|
||||
|
||||
(defn validation-keypair-name
|
||||
[s]
|
||||
[s existing-keypair-names]
|
||||
(cond
|
||||
(string/blank? s) nil
|
||||
(validators/has-emojis? s) (i18n/label :t/key-name-error-emoji)
|
||||
(validators/has-special-characters? s) (i18n/label :t/key-name-error-special-char)
|
||||
(keypair-too-short? s) (i18n/label :t/your-key-pair-name-is-too-short)
|
||||
(keypair-too-long? s) (i18n/label :t/your-key-pair-name-is-too-long)))
|
||||
(keypair-too-short? s) (i18n/label :t/key-name-error-too-short
|
||||
{:count constants/key-pair-name-min-length})
|
||||
(keypair-too-long? s) (i18n/label :t/your-key-pair-name-is-too-long)
|
||||
(contains? existing-keypair-names s) (i18n/label :t/key-name-error-taken)))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
(:require
|
||||
[cljs.test :refer-macros [deftest are]]
|
||||
[status-im.common.validation.keypair :as keypair-validator]
|
||||
[status-im.constants :as constants]
|
||||
[utils.i18n :as i18n]))
|
||||
|
||||
(deftest keypair-name-too-short-test
|
||||
@@ -18,10 +19,12 @@
|
||||
|
||||
(deftest validation-keypair-name-test
|
||||
(are [arg expected]
|
||||
(= (keypair-validator/validation-keypair-name arg) expected)
|
||||
(= (keypair-validator/validation-keypair-name arg #{"Collection"}) expected)
|
||||
nil nil
|
||||
"" nil
|
||||
"name !" (i18n/label :t/key-name-error-special-char)
|
||||
"Hello 😊" (i18n/label :t/key-name-error-emoji)
|
||||
"abc" (i18n/label :t/your-key-pair-name-is-too-short)
|
||||
"abc" (i18n/label :t/key-name-error-too-short
|
||||
{:count constants/key-pair-name-min-length})
|
||||
"Collection" (i18n/label :t/key-name-error-taken)
|
||||
(apply str (repeat 25 "a")) (i18n/label :t/your-key-pair-name-is-too-long)))
|
||||
|
||||
@@ -268,12 +268,14 @@
|
||||
(def ^:const wallet-connect-personal-sign-method "personal_sign")
|
||||
(def ^:const wallet-connect-eth-sign-method "eth_sign")
|
||||
(def ^:const wallet-connect-eth-send-transaction-method "eth_sendTransaction")
|
||||
(def ^:const wallet-connect-eth-sign-transaction-method "eth_signTransaction")
|
||||
(def ^:const wallet-connect-eth-sign-typed-method "eth_signTypedData")
|
||||
(def ^:const wallet-connect-eth-sign-typed-v4-method "eth_signTypedData_v4")
|
||||
(def ^:const wallet-connect-supported-methods
|
||||
#{wallet-connect-personal-sign-method
|
||||
wallet-connect-eth-sign-method
|
||||
wallet-connect-eth-send-transaction-method
|
||||
wallet-connect-eth-sign-transaction-method
|
||||
wallet-connect-eth-sign-typed-method
|
||||
wallet-connect-eth-sign-typed-v4-method})
|
||||
(def ^:const wallet-connect-supported-events #{"accountsChanged" "chainChanged"})
|
||||
@@ -492,6 +494,10 @@
|
||||
(def ^:const optimism-abbreviated-name "Oeth.")
|
||||
(def ^:const arbitrum-abbreviated-name "Arb1.")
|
||||
|
||||
(def ^:const mainnet-full-name "Mainnet")
|
||||
(def ^:const optimism-full-name "Optimism")
|
||||
(def ^:const arbitrum-full-name "Arbitrum")
|
||||
|
||||
(def ^:const mainnet-network-name :mainnet)
|
||||
(def ^:const ethereum-network-name :ethereum)
|
||||
(def ^:const optimism-network-name :optimism)
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
:as chat} (rf/sub [:chats/chat-by-id chat-id])
|
||||
pins-count (rf/sub [:chats/pin-messages-count chat-id])
|
||||
items (rf/sub [:communities/sorted-community-members-section-list
|
||||
community-id])
|
||||
community-id chat-id])
|
||||
theme (quo.theme/use-theme)]
|
||||
(rn/use-mount (fn []
|
||||
(rf/dispatch [:pin-message/load-pin-messages chat-id])))
|
||||
|
||||
@@ -230,7 +230,7 @@
|
||||
(when community
|
||||
{:db (update db :communities/fetching-communities dissoc community-id)
|
||||
:fx [[:dispatch [:communities/handle-community community]]
|
||||
[:dispatch [:communities/update-last-opened-at community-id]]
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
||||
[:dispatch
|
||||
[:chat.ui/cache-link-preview-data (link-preview.events/community-link community-id)
|
||||
community]]]}))
|
||||
@@ -251,7 +251,7 @@
|
||||
:error err}))
|
||||
|
||||
(defn fetch-community
|
||||
[{:keys [db]} [{:keys [community-id update-last-opened-at?]}]]
|
||||
[{:keys [db]} [{:keys [community-id]}]]
|
||||
(when (and community-id
|
||||
(not (get-in db [:communities community-id]))
|
||||
(not (get-in db [:communities/fetching-communities community-id])))
|
||||
@@ -262,11 +262,8 @@
|
||||
:WaitForResponse true}]
|
||||
:on-success (fn [community]
|
||||
(if community
|
||||
(do (when update-last-opened-at?
|
||||
(rf/dispatch [:communities/update-last-opened-at
|
||||
community-id]))
|
||||
(rf/dispatch [:chat.ui/community-fetched community-id
|
||||
community]))
|
||||
(rf/dispatch [:chat.ui/community-fetched community-id
|
||||
community])
|
||||
(failed-to-fetch-community
|
||||
community-id
|
||||
"community wasn't found at the store node")))
|
||||
@@ -280,8 +277,7 @@
|
||||
[:schema
|
||||
[:vector
|
||||
[:map {:closed true}
|
||||
[:community-id {:optional true} :string]
|
||||
[:update-last-opened-at? {:optional true} [:maybe :boolean]]]]]]]
|
||||
[:community-id {:optional true} :string]]]]]]
|
||||
[:maybe
|
||||
[:map
|
||||
[:db map?]
|
||||
@@ -340,10 +336,9 @@
|
||||
(rf/merge
|
||||
cofx
|
||||
{:fx [[:dispatch [:chat.ui/spectate-community community-id]]
|
||||
[:dispatch [:communities/update-last-opened-at community-id]]
|
||||
[:dispatch
|
||||
[:communities/fetch-community
|
||||
{:community-id community-id
|
||||
:update-last-opened-at? true}]]
|
||||
[:communities/fetch-community {:community-id community-id}]]
|
||||
[:dispatch [:navigate-to :community-overview community-id]]
|
||||
(when (get-in db [:communities community-id :joined])
|
||||
[:dispatch
|
||||
@@ -358,10 +353,7 @@
|
||||
(let [community-id (or community-id (get-in db [:chats chat-id :community-id]))]
|
||||
(merge
|
||||
{:fx [(when community-id
|
||||
[:dispatch
|
||||
[:communities/fetch-community
|
||||
{:community-id community-id
|
||||
:update-last-opened-at? true}]])
|
||||
[:dispatch [:communities/fetch-community {:community-id community-id}]])
|
||||
(if pop-to-root?
|
||||
[:dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]]
|
||||
[:dispatch
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
(testing "dispatch fxs"
|
||||
(is (match?
|
||||
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
|
||||
[:dispatch [:communities/update-last-opened-at community-id]]
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
||||
[:dispatch
|
||||
[:chat.ui/cache-link-preview-data "community-link+community-id"
|
||||
{:id community-id}]]]}
|
||||
@@ -60,7 +60,7 @@
|
||||
(testing "dispatch fxs, do not spectate community"
|
||||
(is (match?
|
||||
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
|
||||
[:dispatch [:communities/update-last-opened-at community-id]]
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
||||
[:dispatch
|
||||
[:chat.ui/cache-link-preview-data "community-link+community-id"
|
||||
{:id community-id}]]]}
|
||||
@@ -71,7 +71,7 @@
|
||||
(testing "dispatch fxs, do not spectate community"
|
||||
(is (match?
|
||||
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
|
||||
[:dispatch [:communities/update-last-opened-at community-id]]
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
||||
[:dispatch
|
||||
[:chat.ui/cache-link-preview-data "community-link+community-id"
|
||||
{:id community-id}]]]}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
(merge
|
||||
{:db (assoc db :profile/profiles-overview multiaccounts)}
|
||||
(when-not (seq multiaccounts)
|
||||
{:set-root :screen/onboarding.intro}))))
|
||||
{:dispatch [:init-root :screen/onboarding.intro]}))))
|
||||
|
||||
(rf/defn password-set
|
||||
{:events [:onboarding/password-set]}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
(ns status-im.contexts.preview.quo.settings.category
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[reagent.core :as reagent]
|
||||
[status-im.common.resources :as resources]
|
||||
[status-im.contexts.preview.quo.preview :as preview]))
|
||||
@@ -17,6 +18,24 @@
|
||||
:image-props :i/browser
|
||||
:image-size 32})))
|
||||
|
||||
(defn create-data-item-array
|
||||
[n]
|
||||
(vec
|
||||
(for [i (range n)]
|
||||
{:blur? false
|
||||
:description :default
|
||||
:icon-right? true
|
||||
:right-icon :i/chevron-right
|
||||
:icon-color colors/neutral-10
|
||||
:card? false
|
||||
:label :preview
|
||||
:status :default
|
||||
:size :default
|
||||
:right-content {:type :accounts
|
||||
:data [{:emoji "🔥" :customization-color :yellow}]}
|
||||
:title (str "Item title " i)
|
||||
:subtitle "Item subtitle"})))
|
||||
|
||||
(def descriptor
|
||||
[{:key :blur? :type :boolean}
|
||||
{:key :list-type
|
||||
@@ -24,7 +43,11 @@
|
||||
:options [{:key :settings
|
||||
:value :settings}
|
||||
{:key :reorder
|
||||
:value :reorder}]}])
|
||||
:value :reorder}
|
||||
{:key :data-item
|
||||
:value :data-item}]}])
|
||||
|
||||
(def ^:constant n-items 5)
|
||||
|
||||
(defn view
|
||||
[]
|
||||
@@ -32,7 +55,10 @@
|
||||
:blur? false
|
||||
:list-type :settings})]
|
||||
(fn []
|
||||
(let [data (create-item-array 5)]
|
||||
(let [list-type (:list-type @state)
|
||||
data (if (= list-type :data-item)
|
||||
(create-data-item-array n-items)
|
||||
(create-item-array n-items))]
|
||||
[preview/preview-container
|
||||
{:state state
|
||||
:descriptor descriptor
|
||||
|
||||
@@ -51,7 +51,9 @@
|
||||
{:value "Saved address"
|
||||
:key :saved-address}
|
||||
{:value "Account"
|
||||
:key :account}]}])
|
||||
:key :account}
|
||||
{:value "Dapp"
|
||||
:key :dapp}]}])
|
||||
|
||||
(defn view
|
||||
[]
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
:options [{:key :usd}
|
||||
{:key :eur}]}
|
||||
{:key :error?
|
||||
:type :boolean}
|
||||
{:key :allow-selection?
|
||||
:type :boolean}])
|
||||
|
||||
(defn view
|
||||
@@ -33,7 +35,8 @@
|
||||
:networks networks
|
||||
:title title
|
||||
:customization-color :blue
|
||||
:show-keyboard? false})
|
||||
:show-keyboard? false
|
||||
:allow-selection? true})
|
||||
value (reagent/atom "")
|
||||
set-value (fn [v]
|
||||
(swap! value str v))
|
||||
|
||||
@@ -45,14 +45,14 @@
|
||||
(assoc :profile/profiles-overview profiles)
|
||||
(update :profile/login #(select-profile % key-uid)))
|
||||
db)
|
||||
:fx [[:set-root :screen/profile.profiles]
|
||||
:fx [[:dispatch [:init-root :screen/profile.profiles]]
|
||||
(when key-uid
|
||||
[:effects.biometric/check-if-available
|
||||
{:key-uid key-uid
|
||||
:on-success (fn [auth-method]
|
||||
(rf/dispatch [:profile.login/check-biometric-success key-uid
|
||||
auth-method]))}])]})
|
||||
{:fx [[:set-root :screen/onboarding.intro]]})))
|
||||
{:fx [[:dispatch [:init-root :screen/onboarding.intro]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:profile/update-setting-from-backup
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
(cond
|
||||
pairing-completed?
|
||||
[[:set-root :screen/onboarding.syncing-results]]
|
||||
[[:dispatch [:init-root :screen/onboarding.syncing-results]]]
|
||||
|
||||
(get db :onboarding/new-account?)
|
||||
[[:dispatch [:onboarding/finalize-setup]]]
|
||||
@@ -85,7 +85,7 @@
|
||||
constants/theme-type-dark)
|
||||
:shell-stack
|
||||
false]]
|
||||
[:set-root :shell-stack]
|
||||
[:dispatch [:init-root :shell-stack]]
|
||||
[:dispatch [:profile/show-testnet-mode-banner-if-enabled]]]))})))
|
||||
|
||||
;; login phase 2: we want to load and show chats faster, so we split login into 2 phases
|
||||
@@ -179,7 +179,7 @@
|
||||
{:db (-> db
|
||||
(assoc-in [:profile/login :password] password)
|
||||
(assoc-in [:profile/login :processing] true))
|
||||
:fx [[:set-root :progress]
|
||||
:fx [[:dispatch [:init-root :progress]]
|
||||
[:effects.profile/login
|
||||
[(get-in db [:profile/login :key-uid])
|
||||
(security/safe-unmask-data password)]]]})))
|
||||
|
||||
@@ -92,23 +92,28 @@
|
||||
(rf/reg-event-fx :wallet/make-keypairs-accounts-fully-operable make-keypairs-accounts-fully-operable)
|
||||
|
||||
(defn connection-string-for-import-keypair
|
||||
[{:keys [db]} [{:keys [sha3-pwd keypairs-key-uids connection-string]}]]
|
||||
[{:keys [db]} [{:keys [sha3-pwd keypairs-key-uids connection-string on-success]}]]
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])]
|
||||
{:fx [[:effects.syncing/import-keypairs-keystores
|
||||
{:key-uid key-uid
|
||||
:sha3-pwd sha3-pwd
|
||||
:keypairs-key-uids keypairs-key-uids
|
||||
:connection-string connection-string
|
||||
:on-success #(rf/dispatch [:wallet/make-keypairs-accounts-fully-operable %])
|
||||
:on-fail #(rf/dispatch [:toasts/upsert
|
||||
{:type :negative
|
||||
:theme :dark
|
||||
:text %}])}]]}))
|
||||
:on-success (fn [key-uids]
|
||||
(rf/call-continuation on-success)
|
||||
(rf/dispatch [:wallet/make-keypairs-accounts-fully-operable key-uids]))
|
||||
:on-fail (fn [error]
|
||||
(log/error "failed to import missing key pairs with connection string"
|
||||
{:error error})
|
||||
(rf/dispatch [:toasts/upsert
|
||||
{:type :negative
|
||||
:theme :dark
|
||||
:text (i18n/label :t/incorrect-qr-code)}]))}]]}))
|
||||
|
||||
(rf/reg-event-fx :wallet/connection-string-for-import-keypair connection-string-for-import-keypair)
|
||||
|
||||
(defn success-keypair-qr-scan
|
||||
[_ [connection-string keypairs-key-uids]]
|
||||
[_ [connection-string keypairs-key-uids on-import-success]]
|
||||
{:fx [[:dispatch
|
||||
[:standard-auth/authorize-with-password
|
||||
{:blur? true
|
||||
@@ -120,7 +125,8 @@
|
||||
[:wallet/connection-string-for-import-keypair
|
||||
{:connection-string connection-string
|
||||
:keypairs-key-uids keypairs-key-uids
|
||||
:sha3-pwd password}]))}]]]})
|
||||
:sha3-pwd password
|
||||
:on-success on-import-success}]))}]]]})
|
||||
|
||||
(rf/reg-event-fx :wallet/success-keypair-qr-scan success-keypair-qr-scan)
|
||||
|
||||
@@ -146,7 +152,7 @@
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "accounts_makePrivateKeyKeypairFullyOperable"
|
||||
:params [(security/safe-unmask-data private-key)
|
||||
(-> password security/safe-unmask-data native-module/sha3)]
|
||||
(security/safe-unmask-data password)]
|
||||
:on-success on-success
|
||||
:on-error on-error}]]]})
|
||||
|
||||
|
||||
@@ -41,31 +41,37 @@
|
||||
[quo/action-drawer
|
||||
[(when has-paired-device
|
||||
(if-not missing-keypair?
|
||||
[{:icon :i/qr-code
|
||||
[{:blur? true
|
||||
:icon :i/qr-code
|
||||
:accessibility-label :show-key-pr-qr
|
||||
:label (i18n/label :t/show-encrypted-qr-of-key-pairs)
|
||||
:on-press on-show-qr}]
|
||||
[{:icon :i/scan
|
||||
[{:blur? true
|
||||
:icon :i/scan
|
||||
:accessibility-label :import-by-scan-qr
|
||||
:label (i18n/label :t/import-by-scanning-encrypted-qr)
|
||||
:on-press on-scan-qr}]))
|
||||
(when (= (:type drawer-props) :keypair)
|
||||
[(when missing-keypair?
|
||||
(case (:type keypair)
|
||||
:seed {:icon :i/seed
|
||||
:seed {:blur? true
|
||||
:icon :i/seed
|
||||
:accessibility-label :import-seed-phrase
|
||||
:label (i18n/label :t/import-by-entering-recovery-phrase)
|
||||
:on-press on-import-seed-phrase}
|
||||
:key {:icon :i/key
|
||||
:key {:blur? true
|
||||
:icon :i/key
|
||||
:accessibility-label :import-private-key
|
||||
:label (i18n/label :t/import-by-entering-private-key)
|
||||
:on-press on-import-private-key}
|
||||
nil))
|
||||
{:icon :i/edit
|
||||
{:blur? true
|
||||
:icon :i/edit
|
||||
:accessibility-label :rename-key-pair
|
||||
:label (i18n/label :t/rename-key-pair)
|
||||
:on-press on-rename-keypair}
|
||||
{:icon :i/delete
|
||||
{:blur? true
|
||||
:icon :i/delete
|
||||
:accessibility-label :remove-key-pair
|
||||
:add-divider? true
|
||||
:danger? true
|
||||
|
||||
+6
-3
@@ -11,13 +11,16 @@
|
||||
[]
|
||||
(let [keypairs-key-uids (rf/sub [:get-screen-params])
|
||||
on-success-scan (rn/use-callback (fn [scanned-text]
|
||||
(rf/dispatch [:wallet/success-keypair-qr-scan scanned-text
|
||||
keypairs-key-uids])
|
||||
(rf/dispatch [:wallet/success-keypair-qr-scan
|
||||
scanned-text
|
||||
keypairs-key-uids
|
||||
[:navigate-back]])
|
||||
[keypairs-key-uids]))]
|
||||
[scan-qr-code/view
|
||||
{:title (i18n/label :t/scan-key-pairs-qr-code)
|
||||
:subtitle (i18n/label :t/find-it-in-setting)
|
||||
:share-button? false
|
||||
:import-keypair? true
|
||||
:validate-fn sync-utils/valid-connection-string?
|
||||
:error-message (i18n/label :t/invalid-qr)
|
||||
:error-message (i18n/label :t/invalid-key-pair-qr)
|
||||
:on-success-scan on-success-scan}]))
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
{:margin-bottom 8})
|
||||
|
||||
(def bottom-action
|
||||
{:margin-horizontal -20})
|
||||
{:margin-horizontal -20
|
||||
:margin-vertical -12})
|
||||
|
||||
(def error-container
|
||||
{:margin-left 20
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
(:require [clojure.string :as string]
|
||||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.common.validation.keypair :as keypair-validator]
|
||||
[status-im.constants :as constants]
|
||||
@@ -14,19 +15,24 @@
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [{:keys [name key-uid]} (rf/sub [:get-screen-params])
|
||||
(let [insets (safe-area/get-insets)
|
||||
{existing-keypair-name :name
|
||||
:keys [key-uid]} (rf/sub [:get-screen-params])
|
||||
existing-keypair-names (rf/sub [:wallet/keypair-names])
|
||||
customization-color (rf/sub [:profile/customization-color])
|
||||
[unsaved-keypair-name set-unsaved-keypair-name] (rn/use-state name)
|
||||
[unsaved-keypair-name set-unsaved-keypair-name] (rn/use-state existing-keypair-name)
|
||||
[error-msg set-error-msg] (rn/use-state nil)
|
||||
[typing? set-typing?] (rn/use-state false)
|
||||
validate-keypair-name (rn/use-callback
|
||||
(debounce/debounce
|
||||
(fn [name]
|
||||
(fn [input-name]
|
||||
(set-error-msg
|
||||
(keypair-validator/validation-keypair-name
|
||||
name))
|
||||
input-name
|
||||
existing-keypair-names))
|
||||
(set-typing? false))
|
||||
300))
|
||||
300)
|
||||
[existing-keypair-names])
|
||||
on-change-text (rn/use-callback (fn [text]
|
||||
(set-typing? true)
|
||||
(set-unsaved-keypair-name
|
||||
@@ -40,45 +46,57 @@
|
||||
:keypair-name
|
||||
unsaved-keypair-name}])
|
||||
[unsaved-keypair-name key-uid])]
|
||||
[floating-button-page/view
|
||||
{:header [quo/page-nav
|
||||
{:icon-name :i/close
|
||||
:on-press navigate-back
|
||||
:accessibility-label :top-bar}]
|
||||
:footer [quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:button-one-label (i18n/label :t/save)
|
||||
:button-one-props {:disabled? (or typing?
|
||||
(string/blank? unsaved-keypair-name)
|
||||
(not (string/blank? error-msg)))
|
||||
:customization-color customization-color
|
||||
:on-press on-save}
|
||||
:container-style style/bottom-action}]}
|
||||
[quo/page-top
|
||||
{:container-style style/header-container
|
||||
:title (i18n/label :t/rename-key-pair)
|
||||
:description :context-tag
|
||||
:context-tag {:type :icon
|
||||
:size 24
|
||||
:context name
|
||||
:icon :i/seed-phrase}}]
|
||||
[quo/input
|
||||
{:container-style {:margin-horizontal 20}
|
||||
:placeholder (i18n/label :t/keypair-name-input-placeholder)
|
||||
:label (i18n/label :t/keypair-name)
|
||||
:default-value unsaved-keypair-name
|
||||
:char-limit constants/key-pair-name-max-length
|
||||
:max-length constants/key-pair-name-max-length
|
||||
:auto-focus true
|
||||
:clearable? (not (string/blank? unsaved-keypair-name))
|
||||
:on-clear on-clear
|
||||
:on-change-text on-change-text
|
||||
:error? (not (string/blank? error-msg))}]
|
||||
(when-not (string/blank? error-msg)
|
||||
[quo/info-message
|
||||
{:type :error
|
||||
:size :default
|
||||
:icon :i/info
|
||||
:container-style style/error-container}
|
||||
error-msg])]))
|
||||
[quo/overlay {:type :shell}
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
:blur? true
|
||||
:header [quo/page-nav
|
||||
{:margin-top (:top insets)
|
||||
:icon-name :i/close
|
||||
:background :blur
|
||||
:on-press navigate-back
|
||||
:accessibility-label :top-bar}]
|
||||
:footer [quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:blur? true
|
||||
:button-one-label (i18n/label :t/save)
|
||||
:button-one-props {:blur? true
|
||||
:disabled? (or typing?
|
||||
(= existing-keypair-name
|
||||
unsaved-keypair-name)
|
||||
(string/blank?
|
||||
unsaved-keypair-name)
|
||||
(not (string/blank?
|
||||
error-msg)))
|
||||
:customization-color customization-color
|
||||
:on-press on-save}
|
||||
:container-style style/bottom-action}]}
|
||||
[quo/page-top
|
||||
{:container-style style/header-container
|
||||
:title (i18n/label :t/rename-key-pair)
|
||||
:description :context-tag
|
||||
:blur? true
|
||||
:context-tag {:type :icon
|
||||
:size 24
|
||||
:context existing-keypair-name
|
||||
:icon :i/seed-phrase}}]
|
||||
[quo/input
|
||||
{:blur? true
|
||||
:container-style {:margin-horizontal 20}
|
||||
:placeholder (i18n/label :t/keypair-name-input-placeholder)
|
||||
:label (i18n/label :t/keypair-name)
|
||||
:default-value unsaved-keypair-name
|
||||
:char-limit constants/key-pair-name-max-length
|
||||
:auto-focus true
|
||||
:clearable? (not (string/blank? unsaved-keypair-name))
|
||||
:on-clear on-clear
|
||||
:on-change-text on-change-text
|
||||
:error? (not (string/blank? error-msg))}]
|
||||
(when-not (string/blank? error-msg)
|
||||
[quo/info-message
|
||||
{:type :error
|
||||
:size :default
|
||||
:icon :i/info
|
||||
:container-style style/error-container}
|
||||
error-msg])]]))
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.view
|
||||
(:require [quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.actions.view :as actions]
|
||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.style :as style]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.address :as utils]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
@@ -17,13 +17,12 @@
|
||||
(defn on-options-press
|
||||
[{:keys [drawer-props keypair]}]
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content (fn [] [actions/view
|
||||
{:drawer-props drawer-props
|
||||
:keypair keypair}])
|
||||
{:content (fn [] [actions/view
|
||||
{:drawer-props drawer-props
|
||||
:keypair keypair}])
|
||||
|
||||
:blur-background colors/bottom-sheet-background-blur
|
||||
:theme (:theme drawer-props)
|
||||
:shell? true}]))
|
||||
:theme (:theme drawer-props)
|
||||
:shell? true}]))
|
||||
|
||||
(defn options-drawer-props
|
||||
[{{:keys [name]} :keypair
|
||||
@@ -70,7 +69,7 @@
|
||||
{:blur? true
|
||||
:status-indicator false
|
||||
:stored :on-device
|
||||
:action :options
|
||||
:action (if default-keypair? :none :options)
|
||||
:accounts accounts
|
||||
:customization-color customization-color
|
||||
:container-style style/keypair-container-style
|
||||
@@ -83,17 +82,16 @@
|
||||
(defn on-missing-keypair-options-press
|
||||
[_event keypair-data]
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:theme :dark
|
||||
:shell? true
|
||||
:blur-background colors/bottom-sheet-background-blur
|
||||
:content (fn [] [actions/view
|
||||
{:keypair keypair-data
|
||||
:drawer-props (options-drawer-props
|
||||
{:theme :dark
|
||||
:type :keypair
|
||||
:stored :missing
|
||||
:blur? true
|
||||
:keypair keypair-data})}])}]))
|
||||
{:theme :dark
|
||||
:shell? true
|
||||
:content (fn [] [actions/view
|
||||
{:keypair keypair-data
|
||||
:drawer-props (options-drawer-props
|
||||
{:theme :dark
|
||||
:type :keypair
|
||||
:stored :missing
|
||||
:blur? true
|
||||
:keypair keypair-data})}])}]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
@@ -127,6 +125,7 @@
|
||||
:header (when (seq missing-keypairs)
|
||||
[quo/missing-keypairs
|
||||
{:blur? true
|
||||
:show-import-all? (ff/enabled? ::ff/settings.import-all-keypairs)
|
||||
:keypairs missing-keypairs
|
||||
:on-import-press on-import-press
|
||||
:container-style style/missing-keypairs-container-style
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
(ns status-im.contexts.settings.wallet.network-settings.view
|
||||
(:require [quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.foundations.resources :as resources]
|
||||
[quo.theme]
|
||||
[react-native.core :as rn]
|
||||
@@ -80,12 +79,11 @@
|
||||
(defn on-change-testnet
|
||||
[{:keys [enable? blur? theme]}]
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content (fn [] [testnet/view
|
||||
{:enable? enable?
|
||||
:blur? blur?}])
|
||||
:theme theme
|
||||
:shell? blur?
|
||||
:blur-background colors/bottom-sheet-background-blur}]))
|
||||
{:content (fn [] [testnet/view
|
||||
{:enable? enable?
|
||||
:blur? blur?}])
|
||||
:theme theme
|
||||
:shell? blur?}]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
|
||||
+2
-1
@@ -27,4 +27,5 @@
|
||||
{:color colors/white-opa-40})
|
||||
|
||||
(def saved-address-item
|
||||
{:margin-top 4})
|
||||
{:margin-top 4
|
||||
:background-color colors/white-opa-5})
|
||||
|
||||
+3
-3
@@ -49,6 +49,7 @@
|
||||
:multiline? true
|
||||
:on-clear clear-input
|
||||
:return-key-type :done
|
||||
:auto-focus true
|
||||
:clearable? (not empty-input?)
|
||||
:on-change-text on-change-text
|
||||
:button (when empty-input?
|
||||
@@ -83,7 +84,7 @@
|
||||
[quo/info-message
|
||||
{:accessibility-label :error-message
|
||||
:size :default
|
||||
:icon :i/info
|
||||
:icon :i/alert
|
||||
:type :error
|
||||
:style style/info-message}
|
||||
error-msg])))
|
||||
@@ -91,8 +92,7 @@
|
||||
(defn- existing-saved-address
|
||||
[{:keys [address]}]
|
||||
(let [{:keys [name customization-color chain-short-names ens ens?]}
|
||||
(rf/sub [:wallet/saved-address-by-address
|
||||
address])]
|
||||
(rf/sub [:wallet/saved-address-by-address address])]
|
||||
[rn/view {:style style/existing-saved-address-container}
|
||||
[quo/text
|
||||
{:size :paragraph-1
|
||||
|
||||
@@ -93,20 +93,19 @@
|
||||
:subtitle-type :default
|
||||
:label :none
|
||||
:blur? true
|
||||
:icon-right? (not ens?)
|
||||
:right-icon :i/advanced
|
||||
:right-icon (when-not ens? :i/advanced)
|
||||
:card? true
|
||||
:title (i18n/label :t/address)
|
||||
:subtitle ens
|
||||
:custom-subtitle address-text
|
||||
:on-press open-network-preferences
|
||||
:on-press (when-not ens? open-network-preferences)
|
||||
:container-style style/data-item}
|
||||
ens?
|
||||
(dissoc :custom-subtitle))
|
||||
[ens ens? open-network-preferences address-text])]
|
||||
[quo/overlay {:type :shell}
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
{:footer-container-padding (if edit? (+ (safe-area/get-bottom) 12) 0)
|
||||
:header [quo/page-nav
|
||||
{:type :no-title
|
||||
:background :blur
|
||||
@@ -133,7 +132,7 @@
|
||||
:container-style style/avatar}]
|
||||
[quo/title-input
|
||||
{:blur? true
|
||||
:auto-focus true
|
||||
:auto-focus (not edit?)
|
||||
:max-length 24
|
||||
:size :heading-1
|
||||
:placeholder placeholder
|
||||
|
||||
+11
-8
@@ -2,20 +2,24 @@
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[react-native.core :as rn]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.settings.wallet.saved-addresses.sheets.remove-address.view :as remove-address]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[{:keys [name full-address chain-short-names address] :as opts}]
|
||||
(let [open-send-flow (rn/use-callback
|
||||
(let [[_ splitted-address] (network-utils/split-network-full-address address)
|
||||
open-send-flow (rn/use-callback
|
||||
#(rf/dispatch [:wallet/select-send-address
|
||||
{:address full-address
|
||||
:recipient full-address
|
||||
:recipient {:label (utils/get-shortened-address
|
||||
splitted-address)
|
||||
:recipient-type :saved-address}
|
||||
:stack-id :wallet-select-address
|
||||
:start-flow? true}])
|
||||
[full-address])
|
||||
@@ -52,11 +56,10 @@
|
||||
open-remove-confirmation-sheet (rn/use-callback
|
||||
#(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:theme :dark
|
||||
:shell? true
|
||||
:blur-background colors/bottom-sheet-background-blur
|
||||
:content (fn []
|
||||
[remove-address/view opts])}])
|
||||
{:theme :dark
|
||||
:shell? true
|
||||
:content (fn []
|
||||
[remove-address/view opts])}])
|
||||
[opts])
|
||||
open-show-address-qr (rn/use-callback
|
||||
#(rf/dispatch [:open-modal
|
||||
|
||||
@@ -73,27 +73,34 @@
|
||||
|
||||
(defn- filtered-list
|
||||
[{:keys [search-text]}]
|
||||
[rn/flat-list
|
||||
{:key-fn :address
|
||||
:data (rf/sub [:wallet/filtered-saved-addresses search-text])
|
||||
:render-fn saved-address
|
||||
:shows-vertical-scroll-indicator false
|
||||
:keyboard-should-persist-taps :always
|
||||
:content-container-style {:flex-grow 1}
|
||||
:empty-component [empty-result]}])
|
||||
(let [search-result (rf/sub [:wallet/filtered-saved-addresses search-text])]
|
||||
(if (empty? search-result)
|
||||
[empty-result]
|
||||
[rn/flat-list
|
||||
{:key-fn :address
|
||||
:data search-result
|
||||
:render-fn saved-address
|
||||
:shows-vertical-scroll-indicator false
|
||||
:keyboard-should-persist-taps :always
|
||||
:content-container-style {:flex-grow 1}
|
||||
:bounces false
|
||||
:over-scroll-mode :never}])))
|
||||
|
||||
(defn- unfiltered-list
|
||||
[{:keys [grouped-saved-addresses]}]
|
||||
[rn/section-list
|
||||
{:key-fn :title
|
||||
:shows-vertical-scroll-indicator false
|
||||
:sticky-section-headers-enabled false
|
||||
:keyboard-should-persist-taps :always
|
||||
:render-section-header-fn header
|
||||
:sections grouped-saved-addresses
|
||||
:render-fn saved-address
|
||||
:content-container-style {:flex-grow 1}
|
||||
:empty-component [empty-list]}])
|
||||
(if (empty? grouped-saved-addresses)
|
||||
[empty-list]
|
||||
[rn/section-list
|
||||
{:key-fn :title
|
||||
:shows-vertical-scroll-indicator false
|
||||
:sticky-section-headers-enabled false
|
||||
:keyboard-should-persist-taps :always
|
||||
:render-section-header-fn header
|
||||
:sections grouped-saved-addresses
|
||||
:render-fn saved-address
|
||||
:bounces false
|
||||
:over-scroll-mode :never
|
||||
:content-container-style {:flex-grow 1}}]))
|
||||
|
||||
(defn- navigate-back
|
||||
[]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
(:require [quo.core :as quo]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.contexts.settings.wallet.wallet-options.style :as style]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
@@ -16,16 +15,14 @@
|
||||
|
||||
(defn basic-settings-options
|
||||
[]
|
||||
[(when (ff/enabled? ::ff/settings.keypairs-and-accounts)
|
||||
{:title (i18n/label :t/keypairs-and-accounts)
|
||||
:blur? true
|
||||
:on-press open-keypairs-and-accounts-settings-modal
|
||||
:action :arrow})
|
||||
(when (ff/enabled? ::ff/settings.saved-addresses)
|
||||
{:title (i18n/label :t/saved-addresses)
|
||||
:blur? true
|
||||
:on-press open-saved-addresses-settings-modal
|
||||
:action :arrow})])
|
||||
[{:title (i18n/label :t/keypairs-and-accounts)
|
||||
:blur? true
|
||||
:on-press open-keypairs-and-accounts-settings-modal
|
||||
:action :arrow}
|
||||
{:title (i18n/label :t/saved-addresses)
|
||||
:blur? true
|
||||
:on-press open-saved-addresses-settings-modal
|
||||
:action :arrow}])
|
||||
|
||||
(defn basic-settings
|
||||
[]
|
||||
@@ -74,7 +71,5 @@
|
||||
[quo/page-top
|
||||
{:title (i18n/label :t/wallet)
|
||||
:title-accessibility-label :wallet-settings-header}]
|
||||
(when (or (ff/enabled? ::ff/settings.keypairs-and-accounts)
|
||||
(ff/enabled? ::ff/settings.saved-addresses))
|
||||
[basic-settings])
|
||||
[basic-settings]
|
||||
[advanced-settings]]))
|
||||
|
||||
@@ -1,26 +1,33 @@
|
||||
(ns status-im.contexts.shell.qr-reader.sheets.scanned-wallet-address
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[address]
|
||||
[:<>
|
||||
[quo/drawer-top
|
||||
{:title address
|
||||
:type :address}]
|
||||
[quo/action-drawer
|
||||
[[{:icon :i/send
|
||||
:accessibility-label :send-asset
|
||||
:label (i18n/label :t/send-to-this-address)
|
||||
:on-press (fn []
|
||||
(rf/dispatch [:wallet/select-send-address
|
||||
{:address address
|
||||
:recipient address
|
||||
:stack-id :wallet-select-address
|
||||
:start-flow? true}]))}
|
||||
{:icon :i/save
|
||||
:accessibility-label :save-address
|
||||
:label (i18n/label :t/save-address)
|
||||
:on-press #(js/alert "feature not implemented")}]]]])
|
||||
(let [[_ splitted-address] (network-utils/split-network-full-address address)]
|
||||
[:<>
|
||||
[quo/drawer-top
|
||||
{:title address
|
||||
:type :address}]
|
||||
[quo/action-drawer
|
||||
[[{:icon :i/send
|
||||
:accessibility-label :send-asset
|
||||
:label (i18n/label :t/send-to-this-address)
|
||||
:on-press (fn []
|
||||
(rf/dispatch [:wallet/select-send-address
|
||||
{:address address
|
||||
:recipient {:recipient-type :address
|
||||
:label (utils/get-shortened-address
|
||||
splitted-address)}
|
||||
:stack-id :wallet-select-address
|
||||
:start-flow? true}]))}
|
||||
(when (ff/enabled? :ff/wallet.saved-addresses)
|
||||
{:icon :i/save
|
||||
:accessibility-label :save-address
|
||||
:label (i18n/label :t/save-address)
|
||||
:on-press #(js/alert "feature not implemented")})]]]]))
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
(rf/dispatch [:wallet/get-collectible-details id]))
|
||||
|
||||
(defn- on-collectible-long-press
|
||||
[{:keys [preview-url collectible-details]}]
|
||||
[{:keys [preview-url collectible-details id]}]
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content (fn []
|
||||
[options-drawer/view
|
||||
{:name (:name collectible-details)
|
||||
:image (:uri preview-url)}])}]))
|
||||
:image (:uri preview-url)
|
||||
:id id}])}]))
|
||||
|
||||
(defn- on-end-reached
|
||||
[]
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
:on-success on-success
|
||||
:on-error (fn [error]
|
||||
(log/error
|
||||
"Failed to resolve next path derivation path"
|
||||
"Failed to resolve next derivation path"
|
||||
{:event :wallet/next-derivation-path
|
||||
:method "accounts_resolveSuggestedPathForKeypair"
|
||||
:error error
|
||||
@@ -191,7 +191,7 @@
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/derive-address-and-add-account
|
||||
(fn [_ [{:keys [password derived-from-address derivation-path account-preferences]}]]
|
||||
(fn [_ [{:keys [password derived-from-address derivation-path account-preferences key-uid]}]]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wallet_getDerivedAddresses"
|
||||
:params [(security/safe-unmask-data password)
|
||||
@@ -199,9 +199,10 @@
|
||||
[derivation-path]]
|
||||
:on-success (fn [[derived-account]]
|
||||
(rf/dispatch [:wallet/add-account
|
||||
(assoc account-preferences :password password)
|
||||
(assoc account-preferences
|
||||
:key-uid key-uid
|
||||
:password password)
|
||||
derived-account]))
|
||||
:on-error #(log/info "Failed to get derived addresses"
|
||||
derived-from-address
|
||||
%)}]]]}))
|
||||
|
||||
:on-error [:wallet/log-rpc-error
|
||||
{:event :wallet/derive-address-and-add-account
|
||||
:params [derived-from-address [derivation-path]]}]}]]]}))
|
||||
|
||||
@@ -105,8 +105,7 @@
|
||||
[quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:button-one-label (i18n/label :t/confirm-account-origin)
|
||||
:button-one-props {:disabled? (= selected-keypair selected-key-uid)
|
||||
:customization-color customization-color
|
||||
:button-one-props {:customization-color customization-color
|
||||
:on-press #(rf/dispatch [:wallet/confirm-account-origin
|
||||
selected-key-uid])}
|
||||
:container-style style/bottom-action-container}]]))
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
:action-props {:on-press #(rf/dispatch [:standard-auth/authorize
|
||||
{:on-auth-success on-auth-success
|
||||
:auth-button-label (i18n/label :t/continue)}])
|
||||
|
||||
:button-text (i18n/label :t/edit)
|
||||
:icon-left :i/face-id
|
||||
:alignment :flex-start}
|
||||
@@ -70,7 +69,7 @@
|
||||
:icon-only? true
|
||||
:on-press #(rf/dispatch [:emoji-picker/open {:on-select on-select-emoji}])
|
||||
:container-style style/reaction-button-container}
|
||||
:i/reaction]])
|
||||
:i/edit]])
|
||||
|
||||
(defn- input
|
||||
[_]
|
||||
@@ -217,6 +216,7 @@
|
||||
[:wallet/derive-address-and-add-account
|
||||
{:password password
|
||||
:derived-from-address derived-from
|
||||
:key-uid key-uid
|
||||
:derivation-path @derivation-path
|
||||
:account-preferences preferences}])))
|
||||
[derived-from])]
|
||||
@@ -231,7 +231,7 @@
|
||||
{:account-color @account-color
|
||||
:slide-button-props {:on-auth-success on-auth-success
|
||||
:disabled? (or (empty? @account-name)
|
||||
(= "" @derivation-path)
|
||||
(string/blank? @derivation-path)
|
||||
(some? error))}}
|
||||
[avatar
|
||||
{:account-color @account-color
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns status-im.contexts.wallet.collectible.events
|
||||
(:require [camel-snake-kebab.extras :as cske]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.contexts.wallet.collectible.utils :as collectible-utils]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.ethereum.chain :as chain]
|
||||
@@ -200,25 +201,35 @@
|
||||
|
||||
(rf/reg-event-fx :wallet/trigger-share-collectible
|
||||
(fn [_ [{:keys [title uri]}]]
|
||||
{:fx [[:effects.share/open
|
||||
{:title title
|
||||
:message title
|
||||
:url uri}]]}))
|
||||
{:fx [[:dispatch
|
||||
[:open-share
|
||||
{:options (if platform/ios?
|
||||
{:activityItemSources
|
||||
[{:placeholderItem {:type :text
|
||||
:content uri}
|
||||
:item {:default {:type :url
|
||||
:content uri}}
|
||||
:linkMetadata {:title title}}]}
|
||||
{:title title
|
||||
:subject title
|
||||
:url uri
|
||||
:isNewTask true})}]]]}))
|
||||
|
||||
(rf/reg-event-fx :wallet/share-collectible
|
||||
(fn [_ [{:keys [title uri in-sheet?]}]]
|
||||
(if in-sheet?
|
||||
(fn [{:keys [db]} [{:keys [title token-id contract-address chain-id]}]]
|
||||
(let [uri (collectible-utils/get-opensea-collectible-url
|
||||
{:chain-id chain-id
|
||||
:token-id token-id
|
||||
:contract-address contract-address
|
||||
:test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
||||
:is-goerli-enabled? (get-in db [:profile/profile :is-goerli-enabled?])})]
|
||||
{:fx [[:dispatch
|
||||
[:hide-bottom-sheet]]
|
||||
[:dispatch-later
|
||||
{:ms 600
|
||||
:dispatch [:wallet/trigger-share-collectible
|
||||
{:title title
|
||||
:uri uri}]}]]}
|
||||
{:fx [[:dispatch
|
||||
[:wallet/trigger-share-collectible
|
||||
{:title title
|
||||
:uri uri}]]]})))
|
||||
:uri uri}]}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/navigate-to-opensea
|
||||
|
||||
@@ -7,15 +7,18 @@
|
||||
[utils.url :as url]))
|
||||
|
||||
(defn view
|
||||
[{:keys [image name chain-id address]}]
|
||||
(let [uri (url/replace-port image (rf/sub [:mediaserver/port]))]
|
||||
[{:keys [image name id]}]
|
||||
(let [chain-id (get-in id [:contract-id :chain-id])
|
||||
token-id (:token-id id)
|
||||
contract-address (get-in id [:contract-id :address])
|
||||
uri (url/replace-port image (rf/sub [:mediaserver/port]))]
|
||||
[quo/action-drawer
|
||||
[[{:icon :i/link
|
||||
:accessibility-label :view-on-etherscan
|
||||
:on-press (fn []
|
||||
(rf/dispatch [:wallet/navigate-to-chain-explorer-from-bottom-sheet
|
||||
(external-links/get-explorer-url-by-chain-id chain-id)
|
||||
address]))
|
||||
contract-address]))
|
||||
:label (i18n/label :t/view-on-eth)
|
||||
:right-icon :i/external}]
|
||||
[{:icon :i/save
|
||||
@@ -34,6 +37,14 @@
|
||||
:accessibility-label :share-collectible
|
||||
:label (i18n/label :t/share-collectible)
|
||||
:on-press #(rf/dispatch [:wallet/share-collectible
|
||||
{:in-sheet? true
|
||||
:title name
|
||||
:uri uri}])}]]]))
|
||||
{:token-id token-id
|
||||
:contract-address contract-address
|
||||
:chain-id chain-id
|
||||
:title name}])}]]]))
|
||||
|
||||
"222"
|
||||
"https://nft-cdn.alchemy.com/eth-mainnet/219530f9b3a7901f02169334d593823e"
|
||||
"Tengria #913"
|
||||
{:contract-id {:chain-id 1 :address "0x1a4ceef5d575c2228d142ef862a9b60be8161e7f"} :token-id "913"}
|
||||
|
||||
{:contract-id {:chain-id 1 :address "0x1a4ceef5d575c2228d142ef862a9b60be8161e7f"} :token-id "913"}
|
||||
|
||||
@@ -79,7 +79,8 @@
|
||||
(js/setTimeout #(rf/dispatch [:wallet/clear-last-collectible-details]) 700))
|
||||
|
||||
(defn animated-header
|
||||
[{:keys [scroll-amount title-opacity page-nav-type picture title description theme]}]
|
||||
[{:keys [scroll-amount title-opacity page-nav-type picture title description theme
|
||||
id]}]
|
||||
(let [blur-amount (header-animations/use-blur-amount scroll-amount)
|
||||
layer-opacity (header-animations/use-layer-opacity
|
||||
scroll-amount
|
||||
@@ -110,7 +111,8 @@
|
||||
{:content (fn []
|
||||
[options-drawer/view
|
||||
{:name title
|
||||
:image picture}])
|
||||
:image picture
|
||||
:id id}])
|
||||
:theme theme}])}]
|
||||
:center-opacity title-opacity}]]]]))
|
||||
|
||||
@@ -197,7 +199,8 @@
|
||||
[options-drawer/view
|
||||
{:name collectible-name
|
||||
:image
|
||||
preview-uri}])}])}])))
|
||||
preview-uri
|
||||
:id id}])}])}])))
|
||||
:on-collectible-load (fn []
|
||||
;; We need to delay the measurement because the
|
||||
;; navigation has an animation
|
||||
@@ -246,7 +249,8 @@
|
||||
{collection-name :name} collection-data]
|
||||
[rn/view {:style (style/background-color theme)}
|
||||
[animated-header
|
||||
{:scroll-amount scroll-amount
|
||||
{:id (:id collectible)
|
||||
:scroll-amount scroll-amount
|
||||
:title-opacity title-opacity
|
||||
:page-nav-type :title-description
|
||||
:picture preview-uri
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
[status-im.contexts.wallet.sheets.account-options.view :as account-options]
|
||||
[status-im.contexts.wallet.sheets.network-filter.view :as network-filter]
|
||||
[status-im.contexts.wallet.sheets.select-account.view :as select-account]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn get-bottom-sheet-args
|
||||
@@ -37,7 +36,7 @@
|
||||
:networks networks
|
||||
:align-center? true
|
||||
:networks-on-press #(rf/dispatch [:show-bottom-sheet {:content network-filter/view}])
|
||||
:right-side [(when (and (ff/enabled? ::ff/wallet.wallet-connect)
|
||||
:right-side [(when (and true
|
||||
(not watch-only?))
|
||||
{:icon-name :i/dapps
|
||||
:on-press #(rf/dispatch [:navigate-to :screen/wallet.connected-dapps])})
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
(let [{:keys [on-result]} (rf/sub [:get-screen-params])]
|
||||
[scan-qr-code/view
|
||||
{:title (i18n/label :t/scan-qr)
|
||||
:subtitle (i18n/label :t/scan-an-account-qr-code)
|
||||
:subtitle (i18n/label :t/scan-an-address-qr-code)
|
||||
:error-message (i18n/label :t/oops-this-qr-does-not-contain-an-address)
|
||||
:validate-fn #(contains-supported-address? %)
|
||||
:on-success-scan (fn [result]
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
:icon-only? true
|
||||
:on-press #(rf/dispatch [:emoji-picker/open {:on-select on-change-emoji}])
|
||||
:container-style style/reaction-button-container}
|
||||
:i/reaction]]
|
||||
:i/edit]]
|
||||
|
||||
[rn/view
|
||||
[quo/title-input
|
||||
|
||||
@@ -220,7 +220,7 @@
|
||||
|
||||
(defn make-network-item
|
||||
"This function generates props for quo/category component item"
|
||||
[{:keys [network-name color on-change networks state label-props type]}]
|
||||
[{:keys [network-name color on-change networks state label-props type blur?]}]
|
||||
(cond-> {:title (string/capitalize (name network-name))
|
||||
:image :icon-avatar
|
||||
:image-props {:icon (resources/get-network network-name)
|
||||
@@ -230,6 +230,7 @@
|
||||
(if (= :default state)
|
||||
:filled-checkbox
|
||||
:checkbox))
|
||||
:blur? blur?
|
||||
:customization-color color
|
||||
:checked? (contains? networks network-name)
|
||||
:on-change on-change}}
|
||||
@@ -271,6 +272,14 @@
|
||||
%)
|
||||
address-tokens)))
|
||||
|
||||
(defn get-shortened-address
|
||||
"Takes first and last 4 digits from address including leading 0x
|
||||
and adds unicode ellipsis in between"
|
||||
[address]
|
||||
(when address
|
||||
(let [counter (count address)]
|
||||
(str (subs address 0 6) "\u2026" (subs address (- counter 3) counter)))))
|
||||
|
||||
(defn make-limit-label-crypto
|
||||
[amount currency]
|
||||
(str amount
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns status-im.contexts.wallet.common.utils.networks
|
||||
(:require [clojure.string :as string]
|
||||
[quo.foundations.resources :as resources]
|
||||
[status-im.constants :as constants]
|
||||
[utils.number]))
|
||||
|
||||
@@ -141,3 +142,47 @@
|
||||
(let [token-networks-ids (mapv #(:chain-id %) token-networks)
|
||||
token-networks-ids-set (set token-networks-ids)]
|
||||
(contains? token-networks-ids-set chain-id)))
|
||||
|
||||
(defn split-network-full-address
|
||||
[address]
|
||||
(as-> address $
|
||||
(string/split $ ":")
|
||||
[(butlast $) (last $)]))
|
||||
|
||||
(def mainnet-network-details
|
||||
{:source (resources/get-network constants/mainnet-network-name)
|
||||
:short-name constants/mainnet-short-name
|
||||
:full-name constants/mainnet-full-name
|
||||
:network-name constants/mainnet-network-name
|
||||
:abbreviated-name constants/mainnet-abbreviated-name})
|
||||
|
||||
(def arbitrum-network-details
|
||||
{:source (resources/get-network constants/arbitrum-network-name)
|
||||
:short-name constants/arbitrum-short-name
|
||||
:full-name constants/arbitrum-full-name
|
||||
:network-name constants/arbitrum-network-name
|
||||
:abbreviated-name constants/arbitrum-abbreviated-name})
|
||||
|
||||
(def optimism-network-details
|
||||
{:source (resources/get-network constants/optimism-network-name)
|
||||
:short-name constants/optimism-short-name
|
||||
:full-name constants/optimism-full-name
|
||||
:network-name constants/optimism-network-name
|
||||
:abbreviated-name constants/optimism-abbreviated-name})
|
||||
|
||||
(defn get-network-details
|
||||
[chain-id]
|
||||
(condp contains? chain-id
|
||||
#{constants/ethereum-mainnet-chain-id constants/ethereum-goerli-chain-id
|
||||
constants/ethereum-sepolia-chain-id}
|
||||
mainnet-network-details
|
||||
|
||||
#{constants/arbitrum-mainnet-chain-id constants/arbitrum-goerli-chain-id
|
||||
constants/arbitrum-sepolia-chain-id}
|
||||
arbitrum-network-details
|
||||
|
||||
#{constants/optimism-mainnet-chain-id constants/optimism-goerli-chain-id
|
||||
constants/optimism-sepolia-chain-id}
|
||||
optimism-network-details
|
||||
|
||||
nil))
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
(fn [resolver rejecter]
|
||||
(json-rpc/call {:method "accounts_makeSeedPhraseKeypairFullyOperable"
|
||||
:params [(security/safe-unmask-data mnemonic)
|
||||
(-> password security/safe-unmask-data native-module/sha3)]
|
||||
(security/safe-unmask-data password)]
|
||||
:on-error (fn [error]
|
||||
(rejecter (ex-info (str error) {:error error})))
|
||||
:on-success (fn [value]
|
||||
|
||||
@@ -215,13 +215,12 @@
|
||||
[:dispatch [:wallet/clear-create-account]]]}))
|
||||
|
||||
(rf/reg-event-fx :wallet/add-account
|
||||
(fn [{:keys [db]}
|
||||
[{:keys [password account-name emoji color type]
|
||||
(fn [_
|
||||
[{:keys [key-uid password account-name emoji color type]
|
||||
:or {type :generated}}
|
||||
{:keys [public-key address path] :as _derived-account}]]
|
||||
(let [lowercase-address (some-> address
|
||||
(string/lower-case))
|
||||
key-uid (get-in db [:wallet :ui :create-account :selected-keypair-uid])
|
||||
string/lower-case)
|
||||
account-config {:key-uid (when (= type :generated) key-uid)
|
||||
:wallet false
|
||||
:chat false
|
||||
@@ -529,18 +528,17 @@
|
||||
:wallet/process-keypair-from-backup
|
||||
(fn [{:keys [db]} [{:keys [backedUpKeypair]}]]
|
||||
(let [{:keys [key-uid accounts]} backedUpKeypair
|
||||
updated-keypairs (assoc-in db
|
||||
[:wallet :keypairs key-uid]
|
||||
(data-store/rpc->keypair 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] updated-keypairs)
|
||||
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})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
|
||||
@@ -9,16 +9,13 @@
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- on-collectible-long-press
|
||||
[{:keys [preview-url collectible-details id]}]
|
||||
(let [chain-id (get-in id [:contract-id :chain-id])
|
||||
address (get-in id [:contract-id :address])]
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content (fn []
|
||||
[options-drawer/view
|
||||
{:chain-id chain-id
|
||||
:address address
|
||||
:name (:name collectible-details)
|
||||
:image (:uri preview-url)}])}])))
|
||||
[{:keys [preview-url :collectible-data id]}]
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content (fn []
|
||||
[options-drawer/view
|
||||
{:id id
|
||||
:name (:name collectible-data)
|
||||
:image (:uri preview-url)}])}]))
|
||||
|
||||
(defn- on-collectible-press
|
||||
[{:keys [id]}]
|
||||
|
||||
@@ -205,21 +205,22 @@
|
||||
token-networks-ids (mapv #(:chain-id %) token-networks)
|
||||
token-not-supported-in-receiver-networks? (not-any? (set receiver-networks)
|
||||
token-networks-ids)]
|
||||
{:db (cond-> db
|
||||
:always (update-in [:wallet :ui :send] dissoc :collectible)
|
||||
:always (assoc-in [:wallet :ui :send :token-display-name]
|
||||
(:symbol token))
|
||||
:always (assoc-in
|
||||
[:wallet :ui :send :token-not-supported-in-receiver-networks?]
|
||||
token-not-supported-in-receiver-networks?)
|
||||
token (assoc-in [:wallet :ui :send :token] token)
|
||||
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol))
|
||||
:fx [[:dispatch [:wallet/clean-suggested-routes]]
|
||||
[:dispatch
|
||||
[:wallet/wizard-navigate-forward
|
||||
{:current-screen stack-id
|
||||
:start-flow? start-flow?
|
||||
:flow-id :wallet-send-flow}]]]})))
|
||||
(when (or token token-symbol)
|
||||
{:db (cond-> db
|
||||
:always (update-in [:wallet :ui :send] dissoc :collectible)
|
||||
:always (assoc-in
|
||||
[:wallet :ui :send :token-not-supported-in-receiver-networks?]
|
||||
token-not-supported-in-receiver-networks?)
|
||||
token (assoc-in [:wallet :ui :send :token] token)
|
||||
token (assoc-in [:wallet :ui :send :token-display-name]
|
||||
(:symbol token))
|
||||
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol))
|
||||
:fx [[:dispatch [:wallet/clean-suggested-routes]]
|
||||
[:dispatch
|
||||
[:wallet/wizard-navigate-forward
|
||||
{:current-screen stack-id
|
||||
:start-flow? start-flow?
|
||||
:flow-id :wallet-send-flow}]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/edit-token-to-send
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
(ns status-im.contexts.wallet.send.events-test
|
||||
(:require
|
||||
[cljs.test :refer-macros [is testing]]
|
||||
[re-frame.db :as rf-db]
|
||||
status-im.contexts.wallet.send.events
|
||||
[test-helpers.unit :as h]))
|
||||
|
||||
(h/deftest-event :wallet/update-receiver-networks
|
||||
[event-id dispatch]
|
||||
(testing "reciever networks changed"
|
||||
(let [selected-networks-before [:ethereum :optimism :arbitrum]
|
||||
selected-networks-after [:ethereum :optimism]
|
||||
expected-db {:wallet {:ui {:send {:receiver-networks selected-networks-after}}}}]
|
||||
(reset! rf-db/app-db {:wallet {:ui {:send {:receiver-networks selected-networks-before}}}})
|
||||
(is (match? expected-db (:db (dispatch [event-id selected-networks-after]))))))
|
||||
|
||||
(testing "if receiver network removed, it is also removed from disabled ones"
|
||||
(let [selected-networks-before [:ethereum :optimism :arbitrum]
|
||||
selected-networks-after [:ethereum :optimism]
|
||||
disabled-from-chain-ids-before [:optimism :arbitrum]
|
||||
disabled-from-chain-ids-after [:optimism]
|
||||
expected-db {:wallet {:ui {:send {:receiver-networks selected-networks-after
|
||||
:disabled-from-chain-ids
|
||||
disabled-from-chain-ids-after}}}}]
|
||||
(reset! rf-db/app-db {:wallet {:ui {:send {:receiver-networks selected-networks-before
|
||||
:disabled-from-chain-ids
|
||||
disabled-from-chain-ids-before}}}})
|
||||
(is (match? expected-db (:db (dispatch [event-id selected-networks-after])))))))
|
||||
|
||||
(h/deftest-event :wallet/set-token-to-send
|
||||
[event-id dispatch]
|
||||
(let [token-symbol "ETH"
|
||||
token {:symbol "ETH"
|
||||
:name "Ether"
|
||||
:networks #{{:chain-id 421614}
|
||||
{:chain-id 11155420}
|
||||
{:chain-id 11155111}}}
|
||||
receiver-networks [421614 11155420]]
|
||||
(testing "can be called with :token"
|
||||
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks}}}}
|
||||
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
|
||||
:token-not-supported-in-receiver-networks? false}}}}
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id {:token token}])]
|
||||
(is (match? expected-db (:db result)))))
|
||||
(testing "can be called with :token-symbol"
|
||||
(testing "can be called with :token"
|
||||
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks}}}}
|
||||
expected-db {:wallet {:ui {:send {:token-symbol token-symbol
|
||||
:token-not-supported-in-receiver-networks? true}}}}
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id {:token-symbol token-symbol}])]
|
||||
(is (match? expected-db (:db result))))))
|
||||
(testing "shouldn't have changes if called without :token or :token-symbol")
|
||||
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks}}}}
|
||||
expected-db nil
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id {}])]
|
||||
(is (match? expected-db (:db result))))
|
||||
(testing "should clean :collectible set"
|
||||
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks
|
||||
:collectible "some-collectible"}}}}
|
||||
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
|
||||
:token-not-supported-in-receiver-networks? false}}}}
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id {:token token}])]
|
||||
(is (match? expected-db (:db result)))
|
||||
(is (match? nil (get-in result [:db :wallet :ui :send :collectible])))))
|
||||
(testing "should set :token-not-supported-in-receiver-networks?"
|
||||
(let [initial-db {:wallet {:ui {:send {:receiver-networks []}}}}
|
||||
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
|
||||
:token-not-supported-in-receiver-networks? true}}}}
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id {:token token}])]
|
||||
(is (match? expected-db (:db result)))))))
|
||||
|
||||
(h/deftest-event :wallet/edit-token-to-send
|
||||
[event-id dispatch]
|
||||
(let [token-symbol "ETH"
|
||||
token {:symbol "ETH"
|
||||
:name "Ether"
|
||||
:networks #{{:chain-id 421614}
|
||||
{:chain-id 11155420}
|
||||
{:chain-id 11155111}}}
|
||||
receiver-networks [421614 11155420]]
|
||||
(testing "can be called with :token"
|
||||
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks
|
||||
:token-display-name "DAI"
|
||||
:token-not-supported-in-receiver-networks? true}}}}
|
||||
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
|
||||
:token-not-supported-in-receiver-networks? false}}}}
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id token])]
|
||||
(is (match? expected-db (:db result)))))
|
||||
(testing "should set :token-not-supported-in-receiver-networks?"
|
||||
(let [initial-db {:wallet {:ui {:send {:receiver-networks []
|
||||
:token-display-name "DAI"
|
||||
:token-not-supported-in-receiver-networks? false}}}}
|
||||
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
|
||||
:token-not-supported-in-receiver-networks? true}}}}
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id token])]
|
||||
(is (match? expected-db (:db result)))))))
|
||||
|
||||
(h/deftest-event :wallet/set-collectible-to-send
|
||||
[event-id dispatch]
|
||||
(let
|
||||
[collectible
|
||||
{:data-type 2
|
||||
:id
|
||||
{:contract-id
|
||||
{:chain-id 11155111
|
||||
:address "0x1ed60fedff775d500dde21a974cd4e92e0047cc8"}
|
||||
:token-id "15"}
|
||||
:contract-type 3
|
||||
:collectible-data
|
||||
{:name "DOG #1"
|
||||
:description
|
||||
"dogs are cute and this one is the cutestdogs are cute and this one is the cutest"}
|
||||
:collection-data
|
||||
{:name "ERC-1155 Faucet"}
|
||||
:ownership
|
||||
[{:address "0xf90014b2027e584fc96e6f6c8078998fe46c5ccb"
|
||||
:balance "1"
|
||||
:tx-timestamp 1710331776}]
|
||||
:preview-url
|
||||
{:uri
|
||||
"https://ipfs.io/ipfs/bafybeie7b7g7iibpac4k6ydw4m5ivgqw5vov7oyzlf4v5zoor57wokmsxy/isolated-happy-smiling-dog-white-background-portrait-4_1562-693.avif"}}
|
||||
initial-db {:wallet {:ui {:send {:token {:symbol "ETH"}}}}}
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id {:collectible collectible}])]
|
||||
(testing ":collectible field assigned"
|
||||
(is (match? collectible (get-in result [:db :wallet :ui :send :collectible]))))
|
||||
(testing ":token should be removed"
|
||||
(is (match? nil (get-in result [:db :wallet :ui :send :token]))))
|
||||
(testing ":token-display-name assigned"
|
||||
(is (match? "DOG #1" (get-in result [:db :wallet :ui :send :token-display-name]))))
|
||||
(testing ":tx-type assigned"
|
||||
(is (match? :tx/collectible-erc-1155 (get-in result [:db :wallet :ui :send :tx-type]))))
|
||||
(testing "amount set if collectible was single"
|
||||
(is (match? 1 (get-in result [:db :wallet :ui :send :amount]))))))
|
||||
|
||||
(h/deftest-event :wallet/set-collectible-amount-to-send
|
||||
[event-id dispatch]
|
||||
(let [initial-db {:wallet {:ui {:send nil}}}
|
||||
expected-fx [[:dispatch [:wallet/get-suggested-routes {:amount 10}]]
|
||||
[:dispatch
|
||||
[:wallet/wizard-navigate-forward
|
||||
{:current-screen nil :flow-id :wallet-send-flow}]]]
|
||||
amount 10
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id {:amount amount}])]
|
||||
(testing "amount set"
|
||||
(is (match? amount (get-in result [:db :wallet :ui :send :amount]))))
|
||||
(testing "effects match"
|
||||
(is (match? expected-fx (:fx result))))))
|
||||
|
||||
(h/deftest-event :wallet/set-token-amount-to-send
|
||||
[event-id dispatch]
|
||||
(let [initial-db {:wallet {:ui {:send {:token {:symbol "ETH"}}}}}
|
||||
amount 10
|
||||
_ (reset! rf-db/app-db initial-db)
|
||||
result (dispatch [event-id {:amount amount}])]
|
||||
(testing "amount set"
|
||||
(is (match? amount (get-in result [:db :wallet :ui :send :amount]))))))
|
||||
@@ -47,6 +47,7 @@
|
||||
:network-name :mainnet
|
||||
:abbreviated-name
|
||||
"Eth."
|
||||
:full-name "Mainnet"
|
||||
:chain-id 1
|
||||
:related-chain-id 1
|
||||
:layer 1}]
|
||||
@@ -92,6 +93,7 @@
|
||||
:short-name "eth"
|
||||
:network-name :mainnet
|
||||
:abbreviated-name "Eth."
|
||||
:full-name "Mainnet"
|
||||
:chain-id 1
|
||||
:related-chain-id 1
|
||||
:layer 1}]
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
[status-im.contexts.wallet.send.routes.view :as routes]
|
||||
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
|
||||
[status-im.contexts.wallet.sheets.unpreferred-networks-alert.view :as unpreferred-networks-alert]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.debounce :as debounce]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.money :as money]
|
||||
@@ -24,16 +25,17 @@
|
||||
(defn- estimated-fees
|
||||
[{:keys [loading-routes? fees amount]}]
|
||||
[rn/view {:style style/estimated-fees-container}
|
||||
[rn/view {:style style/estimated-fees-content-container}
|
||||
[quo/button
|
||||
{:icon-only? true
|
||||
:type :outline
|
||||
:size 32
|
||||
:inner-style {:opacity 1}
|
||||
:accessibility-label :advanced-button
|
||||
:disabled? loading-routes?
|
||||
:on-press #(js/alert "Not implemented yet")}
|
||||
:i/advanced]]
|
||||
(when (ff/enabled? ::ff/wallet.advanced-sending)
|
||||
[rn/view {:style style/estimated-fees-content-container}
|
||||
[quo/button
|
||||
{:icon-only? true
|
||||
:type :outline
|
||||
:size 32
|
||||
:inner-style {:opacity 1}
|
||||
:accessibility-label :advanced-button
|
||||
:disabled? loading-routes?
|
||||
:on-press #(js/alert "Not implemented yet")}
|
||||
:i/advanced]])
|
||||
[quo/data-item
|
||||
{:container-style style/fees-data-item
|
||||
:status (if loading-routes? :loading :default)
|
||||
@@ -347,23 +349,24 @@
|
||||
:on-press on-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 send-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}]
|
||||
{: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 send-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}]
|
||||
[routes/view
|
||||
{:token token-by-symbol
|
||||
:input-value input-amount
|
||||
@@ -376,7 +379,7 @@
|
||||
sender-network-values
|
||||
token-not-supported-in-receiver-networks?)
|
||||
[token-not-available token-symbol receiver-networks token-networks])
|
||||
(when (or loading-routes? route)
|
||||
(when (and (not no-routes-found?) (or loading-routes? route))
|
||||
[estimated-fees
|
||||
{:loading-routes? loading-routes?
|
||||
:fees fee-formatted
|
||||
|
||||
@@ -170,22 +170,23 @@
|
||||
{: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}]
|
||||
{: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}]
|
||||
[quo/disclaimer
|
||||
{:on-change (fn [checked?]
|
||||
(set-is-amount-locked checked?))
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[status-im.common.resources :as resources]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.send.select-address.tabs.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
@@ -30,7 +31,10 @@
|
||||
:full-address? true)
|
||||
:on-press #(rf/dispatch [:wallet/select-send-address
|
||||
{:address address
|
||||
:recipient account
|
||||
:recipient {:recipient-type :account
|
||||
:label (:name account)
|
||||
:customization-color (:color account)
|
||||
:emoji (:emoji account)}
|
||||
:stack-id :screen/wallet.select-address}])}])))])))
|
||||
|
||||
(defn- recent-transactions
|
||||
@@ -48,7 +52,9 @@
|
||||
{:address address
|
||||
:on-press #(rf/dispatch [:wallet/select-send-address
|
||||
{:address address
|
||||
:recipient address
|
||||
:recipient {:label (utils/get-shortened-address
|
||||
address)
|
||||
:recipient-type :address}
|
||||
:stack-id :screen/wallet.select-address}])}]))
|
||||
recent-recipients))))
|
||||
|
||||
@@ -59,7 +65,9 @@
|
||||
#(rf/dispatch
|
||||
[:wallet/select-send-address
|
||||
{:address full-address
|
||||
:recipient full-address
|
||||
:recipient {:label name
|
||||
:customization-color customization-color
|
||||
:recipient-type :saved-address}
|
||||
:stack-id :screen/wallet.select-address}])
|
||||
[full-address])]
|
||||
[quo/saved-address
|
||||
@@ -82,11 +90,12 @@
|
||||
empty-state-component (rn/use-memo
|
||||
(fn []
|
||||
[quo/empty-state
|
||||
{:title (i18n/label :t/no-saved-addresses)
|
||||
:description (i18n/label
|
||||
:t/you-like-to-type-43-characters)
|
||||
:image (resources/get-themed-image :sweating-man
|
||||
theme)}])
|
||||
{:title (i18n/label :t/no-saved-addresses)
|
||||
:description (i18n/label
|
||||
:t/you-like-to-type-43-characters)
|
||||
:container-style style/empty-container-style
|
||||
:image (resources/get-themed-image :sweating-man
|
||||
theme)}])
|
||||
[theme])]
|
||||
[rn/section-list
|
||||
{:key-fn :title
|
||||
@@ -94,6 +103,7 @@
|
||||
:render-section-header-fn section-header
|
||||
:sections group-saved-addresses
|
||||
:render-fn saved-address
|
||||
:content-container-style {:flex 1}
|
||||
:empty-component empty-state-component}]))
|
||||
|
||||
(defn view
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns status-im.contexts.wallet.send.select-address.view
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme]
|
||||
@@ -9,6 +10,8 @@
|
||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[status-im.contexts.wallet.common.validation :as validation]
|
||||
[status-im.contexts.wallet.item-types :as types]
|
||||
[status-im.contexts.wallet.send.select-address.style :as style]
|
||||
@@ -136,7 +139,34 @@
|
||||
:keyboard-should-persist-taps :handled
|
||||
:render-fn suggestion-component}]]))
|
||||
|
||||
(defn- f-view
|
||||
(defn- footer
|
||||
[input-value]
|
||||
(let [local-suggestion-address (rf/sub [:wallet/local-suggestions->full-address])
|
||||
color (rf/sub [:wallet/current-viewing-account-color])
|
||||
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))]
|
||||
[quo/button
|
||||
{:accessibility-label :continue-button
|
||||
:type :primary
|
||||
:disabled? (not valid-ens-or-address?)
|
||||
:on-press (fn []
|
||||
(let [address (or
|
||||
local-suggestion-address
|
||||
input-value)
|
||||
[_ splitted-address] (network-utils/split-network-full-address
|
||||
address)]
|
||||
(rf/dispatch
|
||||
[:wallet/select-send-address
|
||||
{:address address
|
||||
:recipient {:label
|
||||
(utils/get-shortened-address
|
||||
splitted-address)
|
||||
:recipient-type :address}
|
||||
:stack-id
|
||||
:screen/wallet.select-address}])))
|
||||
:customization-color color}
|
||||
(i18n/label :t/continue)]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [on-close (fn []
|
||||
(rf/dispatch [:wallet/clean-scanned-address])
|
||||
@@ -150,31 +180,18 @@
|
||||
input-value (reagent/atom "")
|
||||
input-focused? (reagent/atom false)]
|
||||
(fn []
|
||||
(let [selected-tab (or (rf/sub [:wallet/send-tab]) (:id (first tabs-data)))
|
||||
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))
|
||||
local-suggestion-address (rf/sub [:wallet/local-suggestions->full-address])
|
||||
color (rf/sub [:wallet/current-viewing-account-color])]
|
||||
(let [selected-tab (or (rf/sub [:wallet/send-tab]) (:id (first tabs-data)))
|
||||
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))]
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
{:content-container-style {:flex 1}
|
||||
:footer-container-padding 0
|
||||
:keyboard-should-persist-taps true
|
||||
:header [account-switcher/view
|
||||
{:on-press on-close
|
||||
:margin-top (safe-area/get-top)
|
||||
:switcher-type :select-account}]
|
||||
:footer (when (> (count @input-value) 0)
|
||||
[quo/button
|
||||
{:accessibility-label :continue-button
|
||||
:type :primary
|
||||
:disabled? (not valid-ens-or-address?)
|
||||
:on-press #(rf/dispatch
|
||||
[:wallet/select-send-address
|
||||
{:address (or
|
||||
local-suggestion-address
|
||||
@input-value)
|
||||
:stack-id
|
||||
:screen/wallet.select-address}])
|
||||
:customization-color color}
|
||||
(i18n/label :t/continue)])}
|
||||
:footer (when-not (string/blank? @input-value)
|
||||
[footer @input-value])}
|
||||
[quo/page-top
|
||||
{:title (i18n/label :t/send-to)
|
||||
:title-accessibility-label :title-label}]
|
||||
@@ -205,7 +222,3 @@
|
||||
:scrollable? true
|
||||
:on-change on-change-tab}]
|
||||
[tabs/view {:selected-tab selected-tab}]])]))))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
[:f> f-view])
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
(ns status-im.contexts.wallet.send.transaction-confirmation.view
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[legacy.status-im.utils.utils :as utils]
|
||||
[quo.core :as quo]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.common.standard-authentication.core :as standard-auth]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.send.transaction-confirmation.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.security.core :as security]))
|
||||
|
||||
(defn- transaction-title
|
||||
[{:keys [token-display-name amount account to-address route to-network image-url
|
||||
transaction-type collectible?]}]
|
||||
[{:keys [token-display-name amount account route to-network image-url transaction-type
|
||||
collectible? recipient]}]
|
||||
(let [to-network-name (:network-name to-network)
|
||||
to-network-color (if (= to-network-name :mainnet) :ethereum to-network-name)]
|
||||
[rn/view {:style style/content-container}
|
||||
@@ -107,9 +106,7 @@
|
||||
:image-source (:source to-network)
|
||||
:label (string/capitalize (name (:network-name to-network)))
|
||||
:customization-color to-network-color}]
|
||||
[quo/summary-tag
|
||||
{:type :address
|
||||
:label (utils/get-shortened-address to-address)}])]
|
||||
[quo/summary-tag (assoc recipient :type (:recipient-type recipient))])]
|
||||
(when (= transaction-type :tx/bridge)
|
||||
[rn/view
|
||||
{:style {:flex-direction :row
|
||||
@@ -127,20 +124,12 @@
|
||||
:customization-color (:color account)}]])]))
|
||||
|
||||
(defn- user-summary
|
||||
[{:keys [network-values token-display-name account-props theme label accessibility-label
|
||||
summary-type]}]
|
||||
(let [network-values (reduce-kv
|
||||
(fn [acc chain-id amount]
|
||||
(let [network-name (network-utils/id->network chain-id)
|
||||
network-keyword (if (= network-name :mainnet)
|
||||
:ethereum
|
||||
network-name)]
|
||||
(assoc acc
|
||||
network-keyword
|
||||
{:amount amount
|
||||
:token-symbol token-display-name})))
|
||||
{}
|
||||
network-values)]
|
||||
[{:keys [account-props theme label accessibility-label summary-type recipient account-to?]}]
|
||||
(let [network-values (rf/sub [:wallet/network-values account-to?])
|
||||
summary-info-type (case (:recipient-type recipient)
|
||||
:saved-address :saved-account
|
||||
:account :status-account
|
||||
summary-type)]
|
||||
[rn/view
|
||||
{:style {:padding-horizontal 20
|
||||
:padding-bottom 16}}
|
||||
@@ -151,10 +140,17 @@
|
||||
:accessibility-label accessibility-label}
|
||||
label]
|
||||
[quo/summary-info
|
||||
{:type summary-type
|
||||
{:type summary-info-type
|
||||
:networks? true
|
||||
:values network-values
|
||||
:account-props account-props}]]))
|
||||
:account-props (cond-> account-props
|
||||
account-to?
|
||||
(assoc
|
||||
:size 32
|
||||
:name (:label recipient)
|
||||
:full-name (:label recipient)
|
||||
:emoji (:emoji recipient)
|
||||
:customization-color (:customization-color recipient)))}]]))
|
||||
|
||||
(defn- data-item
|
||||
[{:keys [title subtitle]}]
|
||||
@@ -202,39 +198,45 @@
|
||||
[_]
|
||||
(let [on-close #(rf/dispatch [:navigate-back])]
|
||||
(fn []
|
||||
(let [theme (quo.theme/use-theme)
|
||||
send-transaction-data (rf/sub [:wallet/wallet-send])
|
||||
{:keys [token-display-name collectible amount route
|
||||
to-address bridge-to-chain-id
|
||||
from-values-by-chain
|
||||
to-values-by-chain]} send-transaction-data
|
||||
collectible? (some? collectible)
|
||||
image-url (when collectible
|
||||
(get-in collectible [:preview-url :uri]))
|
||||
transaction-type (:tx-type send-transaction-data)
|
||||
estimated-time-min (reduce + (map :estimated-time route))
|
||||
token-symbol (or token-display-name
|
||||
(-> send-transaction-data :token :symbol))
|
||||
first-route (first route)
|
||||
native-currency-symbol (get-in first-route [:from :native-currency-symbol])
|
||||
native-token (when native-currency-symbol
|
||||
(rf/sub [:wallet/token-by-symbol native-currency-symbol]))
|
||||
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted native-token])
|
||||
account (rf/sub [:wallet/current-viewing-account])
|
||||
account-color (:color account)
|
||||
bridge-to-network (when bridge-to-chain-id
|
||||
(rf/sub [:wallet/network-details-by-chain-id
|
||||
bridge-to-chain-id]))
|
||||
loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
|
||||
from-account-props {:customization-color account-color
|
||||
:size 32
|
||||
:emoji (:emoji account)
|
||||
:type :default
|
||||
:name (:name account)
|
||||
:address (utils/get-shortened-address (:address
|
||||
account))}
|
||||
user-props {:full-name to-address
|
||||
:address (utils/get-shortened-address to-address)}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
send-transaction-data (rf/sub [:wallet/wallet-send])
|
||||
{:keys [token-display-name collectible amount
|
||||
route
|
||||
to-address bridge-to-chain-id type
|
||||
recipient]} send-transaction-data
|
||||
collectible? (some? collectible)
|
||||
image-url (when collectible
|
||||
(get-in collectible [:preview-url :uri]))
|
||||
transaction-type (:tx-type send-transaction-data)
|
||||
estimated-time-min (reduce + (map :estimated-time route))
|
||||
token-symbol (or token-display-name
|
||||
(-> send-transaction-data :token :symbol))
|
||||
first-route (first route)
|
||||
native-currency-symbol (get-in first-route
|
||||
[:from :native-currency-symbol])
|
||||
native-token (when native-currency-symbol
|
||||
(rf/sub [:wallet/token-by-symbol
|
||||
native-currency-symbol]))
|
||||
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted
|
||||
native-token])
|
||||
account (rf/sub [:wallet/current-viewing-account])
|
||||
account-color (:color account)
|
||||
bridge-to-network (when bridge-to-chain-id
|
||||
(rf/sub [:wallet/network-details-by-chain-id
|
||||
bridge-to-chain-id]))
|
||||
loading-suggested-routes? (rf/sub
|
||||
[:wallet/wallet-send-loading-suggested-routes?])
|
||||
from-account-props {:customization-color account-color
|
||||
:size 32
|
||||
:emoji (:emoji account)
|
||||
:type :default
|
||||
:name (:name account)
|
||||
:address (utils/get-shortened-address
|
||||
(:address
|
||||
account))}
|
||||
user-props {:full-name to-address
|
||||
:address (utils/get-shortened-address
|
||||
to-address)}]
|
||||
[rn/view {:style {:flex 1}}
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
@@ -274,23 +276,21 @@
|
||||
{:token-display-name token-symbol
|
||||
:amount amount
|
||||
:account account
|
||||
:to-address to-address
|
||||
:type type
|
||||
:recipient recipient
|
||||
:route route
|
||||
:to-network bridge-to-network
|
||||
:image-url image-url
|
||||
:transaction-type transaction-type
|
||||
:collectible? collectible?}]
|
||||
[user-summary
|
||||
{:token-display-name token-symbol
|
||||
:summary-type :status-account
|
||||
{:summary-type :status-account
|
||||
:accessibility-label :summary-from-label
|
||||
:label (i18n/label :t/from-capitalized)
|
||||
:network-values from-values-by-chain
|
||||
:account-props from-account-props
|
||||
:theme theme}]
|
||||
[user-summary
|
||||
{:token-display-name token-symbol
|
||||
:summary-type (if (= transaction-type :tx/bridge)
|
||||
{:summary-type (if (= transaction-type :tx/bridge)
|
||||
:status-account
|
||||
:account)
|
||||
:accessibility-label :summary-to-label
|
||||
@@ -298,5 +298,6 @@
|
||||
:account-props (if (= transaction-type :tx/bridge)
|
||||
from-account-props
|
||||
user-props)
|
||||
:network-values to-values-by-chain
|
||||
:recipient recipient
|
||||
:account-to? true
|
||||
:theme theme}]]]]))))
|
||||
|
||||
@@ -90,10 +90,7 @@
|
||||
:address address
|
||||
:blur? blur?
|
||||
:format :long}])
|
||||
:container-style (merge style/data-item
|
||||
{:background-color (colors/theme-colors colors/neutral-2_5
|
||||
colors/neutral-90
|
||||
theme)})}])
|
||||
:container-style style/data-item}])
|
||||
[quo/category
|
||||
{:list-type :settings
|
||||
:blur? blur?
|
||||
@@ -106,6 +103,7 @@
|
||||
:normal-checkbox? receiver?
|
||||
:networks (get-current-preferences-names)
|
||||
:type :checkbox
|
||||
:blur? blur?
|
||||
:on-change (fn []
|
||||
(toggle-network (:network-name
|
||||
network))
|
||||
@@ -137,6 +135,7 @@
|
||||
:normal-checkbox? receiver?
|
||||
:networks (get-current-preferences-names)
|
||||
:type :checkbox
|
||||
:blur? blur?
|
||||
:on-change (fn []
|
||||
(toggle-network (:network-name
|
||||
network))
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.core
|
||||
(:require [native-module.core :as native-module]
|
||||
(:require [clojure.edn :as edn]
|
||||
[clojure.string :as string]
|
||||
[native-module.core :as native-module]
|
||||
[status-im.constants :as constants]
|
||||
[utils.security.core :as security]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(def method-to-screen
|
||||
{constants/wallet-connect-personal-sign-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-sign-typed-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-sign-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-sign-typed-v4-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-send-transaction-method :screen/wallet-connect.send-transaction
|
||||
constants/wallet-connect-eth-sign-transaction-method :screen/wallet-connect.sign-transaction})
|
||||
|
||||
(defn extract-native-call-signature
|
||||
[data]
|
||||
(-> data transforms/json->clj :result))
|
||||
@@ -11,6 +22,13 @@
|
||||
[chain-id]
|
||||
(str "eip155:" chain-id))
|
||||
|
||||
(defn eip155->chain-id
|
||||
[chain-id-str]
|
||||
(-> chain-id-str
|
||||
(string/split #":")
|
||||
last
|
||||
edn/read-string))
|
||||
|
||||
(defn format-eip155-address
|
||||
[address chain-id]
|
||||
(str chain-id ":" address))
|
||||
@@ -23,9 +41,14 @@
|
||||
[event]
|
||||
(get-in event [:params :request :params]))
|
||||
|
||||
(defn get-db-current-request-event
|
||||
[db]
|
||||
(get-in db [:wallet-connect/current-request :event]))
|
||||
|
||||
(defn get-db-current-request-params
|
||||
[db]
|
||||
(-> (get-in db [:wallet-connect/current-request :event])
|
||||
(-> db
|
||||
get-db-current-request-event
|
||||
get-request-params))
|
||||
|
||||
(def ^:private sign-typed-data-by-version
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
{:db (dissoc db :wallet-connect/current-proposal)}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/reset-current-session-request
|
||||
:wallet-connect/reset-current-request
|
||||
(fn [{:keys [db]}]
|
||||
{:db (dissoc db :wallet-connect/current-request)}))
|
||||
|
||||
@@ -107,12 +107,6 @@
|
||||
:on-fail #(log/error "Failed to pair with dApp" {:error %})
|
||||
:on-success #(log/info "dApp paired successfully")}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/close-session-request
|
||||
(fn [_ _]
|
||||
{:fx [[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]
|
||||
[:dispatch [:wallet-connect/reset-current-session-request]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/fetch-active-sessions
|
||||
(fn [{:keys [db]}]
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.common.data-block.view
|
||||
(:require [status-im.common.raw-data-block.view :as raw-data-block]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [display-data (rf/sub [:wallet-connect/current-request-display-data])]
|
||||
[raw-data-block/view display-data]))
|
||||
@@ -0,0 +1,18 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.common.footer.style)
|
||||
|
||||
(def content-container
|
||||
{:padding-horizontal 20})
|
||||
|
||||
(def data-items-container
|
||||
{:flex-direction :row
|
||||
:padding-top 12
|
||||
:padding-bottom 4
|
||||
:gap 16})
|
||||
|
||||
(def auth-container
|
||||
{:height 48
|
||||
:margin-vertical 12})
|
||||
|
||||
(def warning-container
|
||||
{:align-items :center
|
||||
:margin-bottom 12})
|
||||
@@ -0,0 +1,35 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.common.footer.view
|
||||
(:require [quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[react-native.core :as rn]
|
||||
[status-im.common.standard-authentication.core :as standard-authentication]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.footer.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- on-auth-success
|
||||
[password]
|
||||
(rf/dispatch [:hide-bottom-sheet])
|
||||
(rf/dispatch [:wallet-connect/respond-current-session password]))
|
||||
|
||||
(defn view
|
||||
[{:keys [warning-label slide-button-text disabed?]} & children]
|
||||
(let [{:keys [customization-color]} (rf/sub [:wallet-connect/current-request-account-details])]
|
||||
[rn/view {:style style/content-container}
|
||||
(into [rn/view
|
||||
{:style style/data-items-container}]
|
||||
children)
|
||||
[rn/view {:style style/auth-container}
|
||||
[standard-authentication/slide-button
|
||||
{:size :size-48
|
||||
:track-text slide-button-text
|
||||
:disabled? disabed?
|
||||
:customization-color customization-color
|
||||
:on-auth-success on-auth-success
|
||||
:auth-button-label (i18n/label :t/confirm)}]]
|
||||
[rn/view {:style style/warning-container}
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:style {:color colors/neutral-80-opa-70}
|
||||
:weight :medium}
|
||||
warning-label]]]))
|
||||
@@ -0,0 +1,10 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.common.header.style)
|
||||
|
||||
(def header-container
|
||||
{:padding-vertical 12})
|
||||
|
||||
(def header-dapp-name
|
||||
{:margin-top -4})
|
||||
|
||||
(def header-account-name
|
||||
{:padding-top 4})
|
||||
@@ -0,0 +1,26 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.common.header.view
|
||||
(:require [quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.header.style :as style]))
|
||||
|
||||
(defn view
|
||||
[{:keys [label dapp account]}]
|
||||
[rn/view
|
||||
{:style style/header-container}
|
||||
[quo/text
|
||||
{:size :heading-1
|
||||
:weight :semi-bold}
|
||||
(let [{:keys [name icons]} (:peerMetadata dapp)]
|
||||
[rn/view {:style style/header-dapp-name}
|
||||
[quo/summary-tag
|
||||
{:type :dapp
|
||||
:label name
|
||||
:image-source (first icons)}]])
|
||||
(str " " label " ")
|
||||
(let [{:keys [emoji customization-color name]} account]
|
||||
[rn/view {:style style/header-account-name}
|
||||
[quo/summary-tag
|
||||
{:type :account
|
||||
:emoji emoji
|
||||
:label name
|
||||
:customization-color customization-color}]])]])
|
||||
@@ -0,0 +1,23 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.common.style
|
||||
(:require [status-im.constants :as constants]))
|
||||
|
||||
(defn container
|
||||
[bottom]
|
||||
{:position :absolute
|
||||
:bottom bottom
|
||||
:top 0
|
||||
:left 0
|
||||
:right 0
|
||||
:padding-top constants/sheet-screen-handle-height})
|
||||
|
||||
(def data-content-container
|
||||
{:flex 1
|
||||
:padding-horizontal 20})
|
||||
|
||||
(def sign-message-content-container
|
||||
(merge data-content-container
|
||||
{:margin-bottom 10.5}))
|
||||
|
||||
(def data-item
|
||||
{:flex 1
|
||||
:background-color :transparent})
|
||||
@@ -0,0 +1,63 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.send-transaction.view
|
||||
(:require [quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.data-block.view :as data-block]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.footer.view :as footer]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.header.view :as header]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [bottom (safe-area/get-bottom)
|
||||
{:keys [customization-color]
|
||||
:as account} (rf/sub [:wallet-connect/current-request-account-details])
|
||||
dapp (rf/sub [:wallet-connect/current-request-dapp])
|
||||
network (rf/sub [:wallet-connect/current-request-network])
|
||||
{:keys [max-fees-fiat-formatted
|
||||
error-state]} (rf/sub [:wallet-connect/current-request-transaction-information])]
|
||||
[rn/view {:style (style/container bottom)}
|
||||
[quo/gradient-cover {:customization-color customization-color}]
|
||||
[quo/page-nav
|
||||
{:icon-name :i/close
|
||||
:background :blur
|
||||
:on-press #(rf/dispatch [:navigate-back])
|
||||
:accessibility-label :wallet-connect-sign-message-close}]
|
||||
[rn/view {:flex 1}
|
||||
[rn/view {:style style/data-content-container}
|
||||
[header/view
|
||||
{:label (i18n/label :t/wallet-connect-send-transaction-header)
|
||||
:dapp dapp
|
||||
:account account}]
|
||||
[data-block/view]]
|
||||
(when error-state
|
||||
[quo/alert-banner
|
||||
{:action? false
|
||||
:text (i18n/label (condp = error-state
|
||||
:not-enough-assets-to-pay-gas-fees
|
||||
:t/not-enough-assets-to-pay-gas-fees
|
||||
|
||||
:not-enough-assets
|
||||
:t/not-enough-assets))}])
|
||||
[footer/view
|
||||
{:warning-label (i18n/label :t/wallet-connect-send-transaction-warning)
|
||||
:slide-button-text (i18n/label :t/slide-to-send)
|
||||
:disabled? error-state}
|
||||
[quo/data-item
|
||||
{:status :default
|
||||
:card? false
|
||||
:container-style style/data-item
|
||||
:title (i18n/label :t/network)
|
||||
:subtitle-type :network
|
||||
:network-image (:source network)
|
||||
:subtitle (:full-name network)}]
|
||||
[quo/data-item
|
||||
{:size :small
|
||||
:status :default
|
||||
:card? false
|
||||
:container-style style/data-item
|
||||
:title (i18n/label :t/max-fees)
|
||||
:subtitle (or max-fees-fiat-formatted (i18n/label :t/no-fees))}]]]]))
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.sign-message.view
|
||||
(:require [quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.data-block.view :as data-block]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.footer.view :as footer]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.header.view :as header]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [bottom (safe-area/get-bottom)
|
||||
{:keys [customization-color]
|
||||
:as account} (rf/sub [:wallet-connect/current-request-account-details])
|
||||
dapp (rf/sub [:wallet-connect/current-request-dapp])]
|
||||
[rn/view {:style (style/container bottom)}
|
||||
[quo/gradient-cover {:customization-color customization-color}]
|
||||
[quo/page-nav
|
||||
{:icon-name :i/close
|
||||
:background :blur
|
||||
:on-press #(rf/dispatch [:navigate-back])
|
||||
:accessibility-label :wallet-connect-sign-message-close}]
|
||||
[rn/view {:flex 1}
|
||||
[rn/view {:style style/sign-message-content-container}
|
||||
[header/view
|
||||
{:label (i18n/label :t/wallet-connect-sign-message-header)
|
||||
:dapp dapp
|
||||
:account account}]
|
||||
[data-block/view]]
|
||||
[footer/view
|
||||
{:warning-label (i18n/label :t/wallet-connect-sign-message-warning)
|
||||
:slide-button-text (i18n/label :t/slide-to-sign)}
|
||||
[quo/data-item
|
||||
{:size :small
|
||||
:status :default
|
||||
:card? false
|
||||
:container-style style/data-item
|
||||
:title (i18n/label :t/max-fees)
|
||||
:subtitle (i18n/label :t/no-fees)}]]]]))
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.sign-transaction.view
|
||||
(:require [quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.data-block.view :as data-block]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.footer.view :as footer]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.header.view :as header]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [bottom (safe-area/get-bottom)
|
||||
{:keys [customization-color]
|
||||
:as account} (rf/sub [:wallet-connect/current-request-account-details])
|
||||
dapp (rf/sub [:wallet-connect/current-request-dapp])
|
||||
network (rf/sub [:wallet-connect/current-request-network])
|
||||
{:keys [max-fees-fiat-formatted
|
||||
error-state]} (rf/sub [:wallet-connect/current-request-transaction-information])]
|
||||
[rn/view {:style (style/container bottom)}
|
||||
[quo/gradient-cover {:customization-color customization-color}]
|
||||
[quo/page-nav
|
||||
{:icon-name :i/close
|
||||
:background :blur
|
||||
:on-press #(rf/dispatch [:navigate-back])
|
||||
:accessibility-label :wallet-connect-sign-message-close}]
|
||||
[rn/view {:flex 1}
|
||||
[rn/view {:style style/data-content-container}
|
||||
[header/view
|
||||
{:label (i18n/label :t/wallet-connect-sign-transaction-header)
|
||||
:dapp dapp
|
||||
:account account}]
|
||||
[data-block/view]]
|
||||
(when error-state
|
||||
[quo/alert-banner
|
||||
{:action? false
|
||||
:text (i18n/label (condp = error-state
|
||||
:not-enough-assets-to-pay-gas-fees
|
||||
:t/not-enough-assets-to-pay-gas-fees
|
||||
|
||||
:not-enough-assets
|
||||
:t/not-enough-assets))}])
|
||||
[footer/view
|
||||
{:warning-label (i18n/label :t/wallet-connect-sign-transaction-warning)
|
||||
:slide-button-text (i18n/label :t/slide-to-sign)
|
||||
:disabled? error-state}
|
||||
[quo/data-item
|
||||
{:status :default
|
||||
:card? false
|
||||
:container-style style/data-item
|
||||
:title (i18n/label :t/network)
|
||||
:subtitle-type :network
|
||||
:network-image (:source network)
|
||||
:subtitle (:full-name network)}]
|
||||
[quo/data-item
|
||||
{:size :small
|
||||
:status :default
|
||||
:card? false
|
||||
:container-style style/data-item
|
||||
:title (i18n/label :t/max-fees)
|
||||
:subtitle (or max-fees-fiat-formatted (i18n/label :t/no-fees))}]]]]))
|
||||
|
||||
@@ -6,31 +6,32 @@
|
||||
[taoensso.timbre :as log]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(def ^:private method-to-screen
|
||||
{constants/wallet-connect-personal-sign-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-sign-typed-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-sign-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-sign-typed-v4-method :screen/wallet-connect.sign-message})
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/process-session-request
|
||||
(fn [{:keys [db]} [event]]
|
||||
(let [method (wallet-connect-core/get-request-method event)
|
||||
screen (method-to-screen method)]
|
||||
screen (wallet-connect-core/method-to-screen method)]
|
||||
(if screen
|
||||
{:db (assoc-in db [:wallet-connect/current-request :event] event)
|
||||
:fx [(condp = method
|
||||
constants/wallet-connect-personal-sign-method
|
||||
[:dispatch [:wallet-connect/process-personal-sign]]
|
||||
constants/wallet-connect-eth-send-transaction-method
|
||||
[:dispatch [:wallet-connect/process-eth-send-transaction]]
|
||||
|
||||
constants/wallet-connect-eth-sign-method
|
||||
[:dispatch [:wallet-connect/process-eth-sign]]
|
||||
|
||||
constants/wallet-connect-eth-sign-transaction-method
|
||||
[:dispatch [:wallet-connect/process-eth-sign-transaction]]
|
||||
|
||||
constants/wallet-connect-eth-sign-typed-method
|
||||
[:dispatch [:wallet-connect/process-sign-typed]]
|
||||
|
||||
constants/wallet-connect-eth-sign-typed-v4-method
|
||||
[:dispatch [:wallet-connect/process-sign-typed]])
|
||||
[:dispatch [:wallet-connect/process-sign-typed]]
|
||||
|
||||
constants/wallet-connect-personal-sign-method
|
||||
[:dispatch [:wallet-connect/process-personal-sign]])
|
||||
|
||||
[:dispatch [:open-modal screen]]]}
|
||||
(log/error "Didn't find screen for Wallet Connect method"
|
||||
{:method method
|
||||
@@ -60,6 +61,34 @@
|
||||
:raw-data raw-data
|
||||
:display-data (or parsed-data raw-data))})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/process-eth-send-transaction
|
||||
(fn [{:keys [db]}]
|
||||
(let [event (wallet-connect-core/get-db-current-request-event db)
|
||||
display-data (-> event
|
||||
clj->js
|
||||
(js/JSON.stringify nil 2))
|
||||
{:keys [to]} (-> event wallet-connect-core/get-request-params first)]
|
||||
{:db (update-in db
|
||||
[:wallet-connect/current-request]
|
||||
assoc
|
||||
:address to
|
||||
:raw-data event
|
||||
:display-data display-data)})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/process-eth-sign-transaction
|
||||
(fn [{:keys [db]}]
|
||||
(let [event (wallet-connect-core/get-db-current-request-event db)
|
||||
display-data (.stringify js/JSON (clj->js event) nil 2)
|
||||
{:keys [to]} (-> event wallet-connect-core/get-request-params first)]
|
||||
{:db (update-in db
|
||||
[:wallet-connect/current-request]
|
||||
assoc
|
||||
:address to
|
||||
:raw-data event
|
||||
:display-data display-data)})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/process-sign-typed
|
||||
(fn [{:keys [db]}]
|
||||
|
||||
@@ -13,9 +13,19 @@
|
||||
constants/wallet-connect-personal-sign-method
|
||||
[:dispatch [:wallet-connect/respond-personal-sign password]]
|
||||
|
||||
constants/wallet-connect-eth-send-transaction-method
|
||||
[:dispatch
|
||||
[:wallet-connect/respond-build-transaction
|
||||
#(rf/dispatch [:wallet-connect/respond-send-transaction-data password %])]]
|
||||
|
||||
constants/wallet-connect-eth-sign-method
|
||||
[:dispatch [:wallet-connect/respond-eth-sign password]]
|
||||
|
||||
constants/wallet-connect-eth-sign-transaction-method
|
||||
[:dispatch
|
||||
[:wallet-connect/respond-build-transaction
|
||||
#(rf/dispatch [:wallet-connect/respond-sign-transaction-data password %])]]
|
||||
|
||||
constants/wallet-connect-eth-sign-typed-method
|
||||
[:dispatch [:wallet-connect/respond-sign-typed-data password :v1]]
|
||||
|
||||
@@ -57,12 +67,50 @@
|
||||
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
|
||||
:on-success #(rf/dispatch [:wallet-connect/send-response %])}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/respond-build-transaction
|
||||
(fn [{:keys [db]} [on-success]]
|
||||
(let [{:keys [raw-data]} (get db :wallet-connect/current-request)
|
||||
chain-id (-> raw-data
|
||||
(get-in [:params :chainId])
|
||||
wallet-connect-core/eip155->chain-id)]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wallet_buildTransaction"
|
||||
:params [chain-id (js/JSON.stringify raw-data)]
|
||||
:on-success on-success
|
||||
:on-error [:wallet-connect/on-sign-error]}]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/respond-send-transaction-data
|
||||
(fn [_ [password data]]
|
||||
(let [{:keys [address]
|
||||
message-to-sign :messageToSign} data]
|
||||
{:fx [[:effects.wallet-connect/sign-message
|
||||
{:password password
|
||||
:address address
|
||||
:data message-to-sign
|
||||
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
|
||||
:on-success #(rf/dispatch [:wallet-connect/send-response %])}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/respond-sign-transaction-data
|
||||
(fn [_ [password data]]
|
||||
(let [{:keys [address]
|
||||
message-to-sign :messageToSign} data]
|
||||
{:fx [[:effects.wallet-connect/sign-message
|
||||
{:password password
|
||||
:address address
|
||||
:data message-to-sign
|
||||
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
|
||||
:on-success #(rf/dispatch [:wallet-connect/send-response %])}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/on-sign-error
|
||||
(fn [{:keys [db]} [error]]
|
||||
(let [event (get-in db [:wallet-connect/current-request :event])
|
||||
{:keys [raw-data address]} (get db :wallet-connect/current-request)
|
||||
method (wallet-connect-core/get-request-method event)]
|
||||
method (wallet-connect-core/get-request-method event)
|
||||
screen (wallet-connect-core/method-to-screen method)]
|
||||
(log/error "Failed to sign Wallet Connect request"
|
||||
{:error error
|
||||
:address address
|
||||
@@ -70,7 +118,8 @@
|
||||
:method method
|
||||
:wallet-connect-event event
|
||||
:event :wallet-connect/on-sign-error})
|
||||
{:fx [[:dispatch [:wallet-connect/close-session-request]]]})))
|
||||
{:fx [[:dispatch [:dismiss-modal screen]]
|
||||
[:dispatch [:wallet-connect/reset-current-request]]]})))
|
||||
|
||||
|
||||
(rf/reg-event-fx
|
||||
@@ -78,6 +127,7 @@
|
||||
(fn [{:keys [db]} [result]]
|
||||
(let [{:keys [id topic] :as event} (get-in db [:wallet-connect/current-request :event])
|
||||
method (wallet-connect-core/get-request-method event)
|
||||
screen (wallet-connect-core/method-to-screen method)
|
||||
web3-wallet (get db :wallet-connect/web3-wallet)]
|
||||
{:fx [[:effects.wallet-connect/respond-session-request
|
||||
{:web3-wallet web3-wallet
|
||||
@@ -90,7 +140,9 @@
|
||||
:method method
|
||||
:event :wallet-connect/send-response
|
||||
:wallet-connect-event event})
|
||||
(rf/dispatch [:wallet-connect/close-session-request]))
|
||||
(rf/dispatch [:dismiss-modal screen])
|
||||
(rf/dispatch [:wallet-connect/reset-current-request]))
|
||||
:on-success (fn []
|
||||
(log/info "Successfully sent Wallet Connect response to dApp")
|
||||
(rf/dispatch [:wallet-connect/close-session-request]))}]]})))
|
||||
(rf/dispatch [:dismiss-modal screen])
|
||||
(rf/dispatch [:wallet-connect/reset-current-request]))}]]})))
|
||||
|
||||
@@ -24,8 +24,3 @@
|
||||
|
||||
(def approval-li-spacer
|
||||
{:width 8})
|
||||
|
||||
(def detail-item
|
||||
{:margin-bottom 20
|
||||
:margin-horizontal 20
|
||||
:padding 12})
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user