Compare commits

..
120 changed files with 844 additions and 1737 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
name: MVPBug Report
about: MVPBug Report
title: ''
labels: ['E:Mobile Bug MVP', ':1234: low prio']
labels: 'E:Mobile Bug MVP'
assignees: ''
---
+3 -1
View File
@@ -119,6 +119,8 @@
<array>
<string>armv7</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
@@ -131,7 +133,7 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<false/>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A00000080400010101</string>
+1 -3
View File
@@ -38,12 +38,10 @@
: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 (community-chat-id->channel-id chat-id)]
channel-id (subs chat-id constants/community-id-length)]
{:community-id community-id
:channel-id channel-id}))
+1 -2
View File
@@ -135,8 +135,7 @@
(>= (- now app-in-background-since)
constants/ms-in-bg-for-require-bioauth))]
(rf/merge cofx
{:db (dissoc db :app-in-background-since)
:effects.biometric/get-supported-type nil}
{:db (dissoc db :app-in-background-since)}
(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
{:dispatch [:init-root :progress]
{:set-root :progress
:effects.shell/reset-state nil
:hide-popover nil
::logout nil
+1 -2
View File
@@ -53,8 +53,7 @@
[]
[;;PROGRESS
{:name :progress
:options {:insets {:top? true}
:theme :dark}
:options {:insets {:top? true}}
:component progress/progress}
;;COMMUNITY
@@ -14,7 +14,9 @@
[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?))
@@ -69,16 +71,14 @@
(dimensions :thumb))
[dimensions])
custom-color (if (= type :danger) :danger customization-color)
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 (rn/use-memo #(drag-gesture x-pos
disabled?
(dimensions :usable-track)
sliding-complete?
set-sliding-complete
on-complete
reset-fn)
[sliding-complete? disabled?])]
[gesture/gesture-detector
{:gesture gesture}
[reanimated/view
@@ -8,11 +8,10 @@
[react-native.core :as rn]))
(defn- get-icon-color
[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)))
[danger? theme]
(if danger?
(colors/theme-colors colors/danger-50 colors/danger-60 theme)
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme)))
(defn- divider
[theme blur?]
@@ -52,7 +51,7 @@
:accessible true
:style (style/left-icon sub-label)}
[icon/icon icon
{:color (or icon-color (get-icon-color blur? danger? theme))
{:color (or icon-color (get-icon-color danger? theme))
:no-color no-icon-color?
:size 20}]])
[rn/view
@@ -85,7 +84,7 @@
:accessible true
:accessibility-label :right-icon-for-action}
[icon/icon right-icon
{:color (get-icon-color blur? danger? theme)
{:color (get-icon-color 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 blur?]}]
profile-picture]}]
(case type
:account [account-avatar/view
{:customization-color customization-color
@@ -28,7 +28,6 @@
:keypair [icon-avatar/icon-avatar
{:icon icon-avatar
:border? true
:blur? blur?
:color :neutral}]
:default-keypair [user-avatar/user-avatar
@@ -214,7 +213,6 @@
[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,8 +31,7 @@
:size :paragraph-2}
(:name account-props)]
[address-text/view
{:blur? blur?
:networks networks
{:networks networks
:address (:address account-props)
:format :short}]]]
(when (= action :icon)
@@ -34,8 +34,7 @@
(def container-info
{:flex-direction :row
:align-items :center
:flex 1})
:align-items :center})
(def user-info
{:margin-left 8})
+6 -8
View File
@@ -25,16 +25,14 @@
:style {:width 32 :height 32}}]
[rn/view {:style style/user-info}
[text/text
{:weight :semi-bold
:size :paragraph-1
:number-of-lines 1
:style (style/style-text-name theme)}
{:weight :semi-bold
:size :paragraph-1
:style (style/style-text-name theme)}
(:name dapp)]
[text/text
{:weight :regular
:size :paragraph-2
:number-of-lines 1
:style (style/style-text-value theme)}
{:weight :regular
:size :paragraph-2
: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-20 theme)})
:blur (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-40 theme)})
(defn- filled-checkbox-background-color
[theme]
@@ -51,24 +51,3 @@
: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"))))
@@ -1,32 +0,0 @@
(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,13 +1,10 @@
(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}]
(condp = list-type
:settings [settings/settings-category props]
:data-item [data-item/view props]
:reorder [reorder/reorder-category props]
nil))
(if (= list-type :settings)
[settings/settings-category props]
[reorder/reorder-category props]))
@@ -39,12 +39,6 @@
(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
+3 -4
View File
@@ -13,9 +13,8 @@
:as props}]
[rn/view {:style style/avatar-overlay}
[rn/view
{:style (case avatar-type
:wallet-account style/avatar-container-rounded
:saved-address style/big-avatar-container-rounded
{:style (if (= avatar-type :wallet-account)
style/avatar-container-rounded
style/avatar-container-circular)}
(case avatar-type
:profile
@@ -38,7 +37,7 @@
[channel-avatar/view (assoc props :locked? nil :size :size-64)]
:saved-address
[wallet-avatar/wallet-user-avatar (assoc props :size :size-80)]
[wallet-avatar/wallet-user-avatar (assoc props :size :size-64)]
nil)]])
@@ -28,10 +28,5 @@
:height 24
:border-radius 12})
(def dapp
{:width 24
:height 24
:border-radius 12})
(def token-image
{:border-radius 12})
@@ -23,10 +23,6 @@
[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
@@ -54,7 +50,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 / :dapp
- :type - :token / :user / :collectible / :saved-address / :network / :account
- :emoji - string - emoji used for displaying account avatar
- :image-source - resource - image to display on :network, :collectible and :user
- :theme - :light / :dark"
+8 -8
View File
@@ -7,14 +7,14 @@
[{:keys [blur? customization-color theme selected? container-style]}]
(merge {:border-radius 16
:border-width 1
: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))}
: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}
container-style))
(def header-container
+23 -27
View File
@@ -47,13 +47,12 @@
:accessibility-label :title}
[text/text {:weight :semi-bold}
(if (= type :default-keypair) (keypair-string full-name) full-name)]
(case action
:none nil
:selector [selectors/view
{:type :radio
:checked? selected?
:blur? blur?
:customization-color customization-color}]
(if (= action :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?
@@ -95,23 +94,20 @@
(defn view
[{:keys [accounts action container-style selected? on-press] :as props}]
(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}}]]))
[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}}]])
@@ -11,7 +11,7 @@
[utils.i18n :as i18n]))
(defn title-view
[{:keys [keypairs blur? on-import-press show-import-all?]}]
[{:keys [keypairs blur? on-import-press]}]
(let [theme (quo.theme/use-theme)]
[rn/view
{:accessibility-label :title
@@ -29,13 +29,12 @@
:style {:color colors/warning-60}}
(i18n/label :t/amount-missing-keypairs
{:amount (str (count keypairs))})]
(when show-import-all?
[button/button
{:type :outline
:background :blur
:size 24
:on-press on-import-press}
(i18n/label :t/import)])]
[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,9 +81,8 @@
(js->clj :keywordize-keys true)
(on-selection-change))))]
(fn [{:keys [token customization-color show-keyboard? crypto? currency value error? selection
handle-on-swap allow-selection?]
:or {show-keyboard? true
allow-selection? true}}]
handle-on-swap]
:or {show-keyboard? true}}]
(let [theme (quo.theme/use-theme)
window-width (:width (rn/get-window))]
[rn/pressable
@@ -108,8 +107,7 @@
:selection-color customization-color
:show-soft-input-on-focus show-keyboard?
:on-selection-change handle-selection-change
:selection (clj->js selection)
:editable allow-selection?}
:selection (clj->js selection)}
controlled-input? (assoc :value value)
(not controlled-input?) (assoc :default-value value-internal))]
[token-name-text theme (if crypto? token currency)]]]
+3 -4
View File
@@ -11,10 +11,9 @@
(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)
constants/biometrics-type-touch-id (i18n/label :t/biometric-touchid)
(i18n/label :t/biometric)))
constants/biometrics-type-android (i18n/label :t/biometric-fingerprint)
constants/biometrics-type-face-id (i18n/label :t/biometric-faceid)
(i18n/label :t/biometric-touchid)))
(defn get-icon-by-type
[biometric-type]
+7 -3
View File
@@ -1,6 +1,7 @@
(ns status-im.common.bottom-sheet.style
(:require
[quo.foundations.colors :as colors]))
[quo.foundations.colors :as colors]
[react-native.platform :as platform]))
(def ^:private sheet-border-radius 20)
@@ -21,8 +22,11 @@
:left 0
:right 0})
(def shell-bg
{:background-color colors/bottom-sheet-background-blur
(defn shell-bg
[blur-background]
{:background-color (if blur-background
blur-background
(if platform/ios? colors/white-opa-5 colors/neutral-100-opa-90))
:flex 1})
(def shell-bg-container
+2 -2
View File
@@ -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]
gradient-cover? customization-color hide-handle? blur-radius blur-background]
: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
{:style (style/shell-bg blur-background)
:blur-radius (or blur-radius 20)
:blur-amount 32
:blur-type :transparent
@@ -1,5 +1,6 @@
(ns status-im.common.enter-seed-phrase.style
(:require [react-native.platform :as platform]))
(:require
[react-native.safe-area :as safe-area]))
(def full-layout {:flex 1})
@@ -10,13 +11,6 @@
: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
@@ -35,7 +29,9 @@
:margin-top 12
:margin-horizontal -20})
(def continue-button
{:margin-top :auto})
(defn continue-button
[keyboard-shown?]
{:margin-top :auto
:margin-bottom (when-not keyboard-shown? (safe-area/get-bottom))})
(def keyboard-container {:margin-top :auto})
@@ -96,7 +96,7 @@
(take 7)))
(defn recovery-phrase-screen
[{:keys [banner-offset initial-insets keypair title recovering-keypair? render-controls]}]
[{:keys [keypair title recovering-keypair? render-controls]}]
(reagent/with-let [keyboard-shown? (reagent/atom false)
keyboard-show-listener (.addListener rn/keyboard
"keyboardDidShow"
@@ -114,8 +114,7 @@
seed-phrase (reagent/atom "")
on-change-seed-phrase (fn [new-phrase]
(when @invalid-seed-phrase?
(reset! invalid-seed-phrase? false))
(when @incorrect-seed-phrase?
(reset! invalid-seed-phrase? false)
(reset! incorrect-seed-phrase? false))
(reset! seed-phrase new-phrase))
on-submit (fn []
@@ -162,10 +161,7 @@
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
@@ -176,18 +172,18 @@
(if (fn? render-controls)
(render-controls {:submit-disabled? button-disabled?
:keyboard-shown? @keyboard-shown?
:container-style style/continue-button
:container-style (style/continue-button @keyboard-shown?)
: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
{:container-style (style/continue-button @keyboard-shown?)
:type :primary
:disabled? button-disabled?
:on-press on-submit}
(i18n/label :t/continue)])]
(when (or @keyboard-shown? error-state?)
(when @keyboard-shown?
[rn/view {:style style/keyboard-container}
[quo/predictive-keyboard
{:type suggestions-state
@@ -201,8 +197,7 @@
(defn screen
[{:keys [initial-insets title keypair navigation-icon recovering-keypair? render-controls]}]
(let [{navigation-bar-top :top} initial-insets
banner-offset (rf/sub [:alert-banners/top-margin])]
(let [{navigation-bar-top :top} initial-insets]
[rn/view {:style style/full-layout}
[rn/keyboard-avoiding-view {:style style/page-container}
[quo/page-nav
@@ -215,8 +210,6 @@
{: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
content-container-style gradient-cover? keyboard-should-persist-taps]
gradient-cover? keyboard-should-persist-taps]
:or {footer-container-padding (safe-area/get-top)}}
& children]
(reagent/with-let [scroll-view-ref (atom nil)
@@ -110,9 +110,7 @@
:always-bounce-vertical @keyboard-did-show?
:shows-vertical-scroll-indicator false
:keyboard-should-persist-taps keyboard-should-persist-taps}
(into [rn/view
{:style content-container-style
:on-layout set-content-container-height}]
(into [rn/view {:on-layout set-content-container-height}]
children)]
[rn/keyboard-avoiding-view
{:style style/keyboard-avoiding-view
@@ -2,13 +2,12 @@
(:require [quo.foundations.colors :as colors]))
(def container
{:flex 1
:padding 10
:margin-top 10.5
:margin-bottom 0
:border-width 1
:border-color colors/neutral-10
:border-radius 16})
{:flex 1
:padding 10
:margin-vertical 10.5
: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
[data]
[{:keys [data]}]
[rn/scroll-view
{:style style/container
:content-container-style style/content}
+2 -4
View File
@@ -195,7 +195,7 @@
true)
(defn view
[{:keys [title subtitle validate-fn on-success-scan error-message share-button? import-keypair?]}]
[{:keys [title subtitle validate-fn on-success-scan error-message share-button?]}]
(let [insets (safe-area/get-insets)
qr-code-succeed? (reagent/atom false)
qr-view-finder (reagent/atom {})
@@ -233,9 +233,7 @@
:set-qr-code-succeeded (fn [value]
(when on-success-scan
(on-success-scan value))
(if import-keypair?
(set-rescan-timeout)
(rf/dispatch [:navigate-back])))
(rf/dispatch [:navigate-back]))
:set-rescan-timeout set-rescan-timeout}])
[rn/view {:style (style/root-container (:top insets))}
[header
@@ -33,7 +33,6 @@
: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 on-close] :as args}]]
[_ [{:keys [on-auth-success on-auth-fail] :as args}]]
(let [args-with-biometric-btn
(assoc args
:on-press-biometric
@@ -31,10 +31,7 @@
{:prompt-message (i18n/label :t/biometric-auth-confirm-message)
:on-cancel #(rf/dispatch [:standard-auth/authorize-with-password
args-with-biometric-btn])
:on-success (fn []
(when (fn? on-close)
(on-close))
(rf/dispatch [:standard-auth/on-biometric-success on-auth-success]))
:on-success #(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])
+3 -5
View File
@@ -14,12 +14,10 @@
(> (-> s str string/trim count) constants/key-pair-name-max-length))
(defn validation-keypair-name
[s existing-keypair-names]
[s]
(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/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)))
(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)))
@@ -2,7 +2,6 @@
(: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
@@ -19,12 +18,10 @@
(deftest validation-keypair-name-test
(are [arg expected]
(= (keypair-validator/validation-keypair-name arg #{"Collection"}) expected)
(= (keypair-validator/validation-keypair-name arg) 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/key-name-error-too-short
{:count constants/key-pair-name-min-length})
"Collection" (i18n/label :t/key-name-error-taken)
"abc" (i18n/label :t/your-key-pair-name-is-too-short)
(apply str (repeat 25 "a")) (i18n/label :t/your-key-pair-name-is-too-long)))
-6
View File
@@ -268,14 +268,12 @@
(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"})
@@ -494,10 +492,6 @@
(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 chat-id])
community-id])
theme (quo.theme/use-theme)]
(rn/use-mount (fn []
(rf/dispatch [:pin-message/load-pin-messages chat-id])))
+16 -8
View File
@@ -230,7 +230,7 @@
(when community
{:db (update db :communities/fetching-communities dissoc community-id)
:fx [[:dispatch [:communities/handle-community community]]
[:dispatch [:chat.ui/spectate-community community-id]]
[:dispatch [:communities/update-last-opened-at 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]}]]
[{:keys [db]} [{:keys [community-id update-last-opened-at?]}]]
(when (and community-id
(not (get-in db [:communities community-id]))
(not (get-in db [:communities/fetching-communities community-id])))
@@ -262,8 +262,11 @@
:WaitForResponse true}]
:on-success (fn [community]
(if community
(rf/dispatch [:chat.ui/community-fetched community-id
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]))
(failed-to-fetch-community
community-id
"community wasn't found at the store node")))
@@ -277,7 +280,8 @@
[:schema
[:vector
[:map {:closed true}
[:community-id {:optional true} :string]]]]]]
[:community-id {:optional true} :string]
[:update-last-opened-at? {:optional true} [:maybe :boolean]]]]]]]
[:maybe
[:map
[:db map?]
@@ -336,9 +340,10 @@
(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}]]
[:communities/fetch-community
{:community-id community-id
:update-last-opened-at? true}]]
[:dispatch [:navigate-to :community-overview community-id]]
(when (get-in db [:communities community-id :joined])
[:dispatch
@@ -353,7 +358,10 @@
(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}]])
[:dispatch
[:communities/fetch-community
{:community-id community-id
:update-last-opened-at? true}]])
(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 [:chat.ui/spectate-community community-id]]
[:dispatch [:communities/update-last-opened-at 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 [:chat.ui/spectate-community community-id]]
[:dispatch [:communities/update-last-opened-at 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 [:chat.ui/spectate-community community-id]]
[:dispatch [:communities/update-last-opened-at 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)
{:dispatch [:init-root :screen/onboarding.intro]}))))
{:set-root :screen/onboarding.intro}))))
(rf/defn password-set
{:events [:onboarding/password-set]}
@@ -1,7 +1,6 @@
(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]))
@@ -18,24 +17,6 @@
: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
@@ -43,11 +24,7 @@
:options [{:key :settings
:value :settings}
{:key :reorder
:value :reorder}
{:key :data-item
:value :data-item}]}])
(def ^:constant n-items 5)
:value :reorder}]}])
(defn view
[]
@@ -55,10 +32,7 @@
:blur? false
:list-type :settings})]
(fn []
(let [list-type (:list-type @state)
data (if (= list-type :data-item)
(create-data-item-array n-items)
(create-item-array n-items))]
(let [data (create-item-array 5)]
[preview/preview-container
{:state state
:descriptor descriptor
@@ -51,9 +51,7 @@
{:value "Saved address"
:key :saved-address}
{:value "Account"
:key :account}
{:value "Dapp"
:key :dapp}]}])
:key :account}]}])
(defn view
[]
@@ -23,8 +23,6 @@
:options [{:key :usd}
{:key :eur}]}
{:key :error?
:type :boolean}
{:key :allow-selection?
:type :boolean}])
(defn view
@@ -35,8 +33,7 @@
:networks networks
:title title
:customization-color :blue
:show-keyboard? false
:allow-selection? true})
:show-keyboard? false})
value (reagent/atom "")
set-value (fn [v]
(swap! value str v))
+2 -2
View File
@@ -45,14 +45,14 @@
(assoc :profile/profiles-overview profiles)
(update :profile/login #(select-profile % key-uid)))
db)
:fx [[:dispatch [:init-root :screen/profile.profiles]]
:fx [[:set-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 [[:dispatch [:init-root :screen/onboarding.intro]]]})))
{:fx [[:set-root :screen/onboarding.intro]]})))
(rf/reg-event-fx
:profile/update-setting-from-backup
@@ -74,7 +74,7 @@
(cond
pairing-completed?
[[:dispatch [:init-root :screen/onboarding.syncing-results]]]
[[:set-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]]
[:dispatch [:init-root :shell-stack]]
[:set-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 [[:dispatch [:init-root :progress]]
:fx [[:set-root :progress]
[:effects.profile/login
[(get-in db [:profile/login :key-uid])
(security/safe-unmask-data password)]]]})))
@@ -92,28 +92,23 @@
(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 on-success]}]]
[{:keys [db]} [{:keys [sha3-pwd keypairs-key-uids connection-string]}]]
(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 (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)}]))}]]}))
:on-success #(rf/dispatch [:wallet/make-keypairs-accounts-fully-operable %])
:on-fail #(rf/dispatch [:toasts/upsert
{:type :negative
:theme :dark
:text %}])}]]}))
(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 on-import-success]]
[_ [connection-string keypairs-key-uids]]
{:fx [[:dispatch
[:standard-auth/authorize-with-password
{:blur? true
@@ -125,8 +120,7 @@
[:wallet/connection-string-for-import-keypair
{:connection-string connection-string
:keypairs-key-uids keypairs-key-uids
:sha3-pwd password
:on-success on-import-success}]))}]]]})
:sha3-pwd password}]))}]]]})
(rf/reg-event-fx :wallet/success-keypair-qr-scan success-keypair-qr-scan)
@@ -152,7 +146,7 @@
{:fx [[:json-rpc/call
[{:method "accounts_makePrivateKeyKeypairFullyOperable"
:params [(security/safe-unmask-data private-key)
(security/safe-unmask-data password)]
(-> password security/safe-unmask-data native-module/sha3)]
:on-success on-success
:on-error on-error}]]]})
@@ -41,37 +41,31 @@
[quo/action-drawer
[(when has-paired-device
(if-not missing-keypair?
[{:blur? true
:icon :i/qr-code
[{: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}]
[{:blur? true
:icon :i/scan
[{: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 {:blur? true
:icon :i/seed
:seed {:icon :i/seed
:accessibility-label :import-seed-phrase
:label (i18n/label :t/import-by-entering-recovery-phrase)
:on-press on-import-seed-phrase}
:key {:blur? true
:icon :i/key
:key {:icon :i/key
:accessibility-label :import-private-key
:label (i18n/label :t/import-by-entering-private-key)
:on-press on-import-private-key}
nil))
{:blur? true
:icon :i/edit
{:icon :i/edit
:accessibility-label :rename-key-pair
:label (i18n/label :t/rename-key-pair)
:on-press on-rename-keypair}
{:blur? true
:icon :i/delete
{:icon :i/delete
:accessibility-label :remove-key-pair
:add-divider? true
:danger? true
@@ -11,16 +11,13 @@
[]
(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
[:navigate-back]])
(rf/dispatch [:wallet/success-keypair-qr-scan scanned-text
keypairs-key-uids])
[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-key-pair-qr)
:error-message (i18n/label :t/invalid-qr)
:on-success-scan on-success-scan}]))
@@ -4,8 +4,7 @@
{:margin-bottom 8})
(def bottom-action
{:margin-horizontal -20
:margin-vertical -12})
{:margin-horizontal -20})
(def error-container
{:margin-left 20
@@ -2,7 +2,6 @@
(: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]
@@ -15,24 +14,19 @@
(defn view
[]
(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])
(let [{:keys [name key-uid]} (rf/sub [:get-screen-params])
customization-color (rf/sub [:profile/customization-color])
[unsaved-keypair-name set-unsaved-keypair-name] (rn/use-state existing-keypair-name)
[unsaved-keypair-name set-unsaved-keypair-name] (rn/use-state 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 [input-name]
(fn [name]
(set-error-msg
(keypair-validator/validation-keypair-name
input-name
existing-keypair-names))
name))
(set-typing? false))
300)
[existing-keypair-names])
300))
on-change-text (rn/use-callback (fn [text]
(set-typing? true)
(set-unsaved-keypair-name
@@ -46,57 +40,45 @@
:keypair-name
unsaved-keypair-name}])
[unsaved-keypair-name key-uid])]
[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])]]))
[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])]))
@@ -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,12 +17,13 @@
(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}])
:theme (:theme drawer-props)
:shell? true}]))
:blur-background colors/bottom-sheet-background-blur
:theme (:theme drawer-props)
:shell? true}]))
(defn options-drawer-props
[{{:keys [name]} :keypair
@@ -69,7 +70,7 @@
{:blur? true
:status-indicator false
:stored :on-device
:action (if default-keypair? :none :options)
:action :options
:accounts accounts
:customization-color customization-color
:container-style style/keypair-container-style
@@ -82,16 +83,17 @@
(defn on-missing-keypair-options-press
[_event keypair-data]
(rf/dispatch [:show-bottom-sheet
{: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})}])}]))
{: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})}])}]))
(defn view
[]
@@ -125,7 +127,6 @@
: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,5 +1,6 @@
(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]
@@ -79,11 +80,12 @@
(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?}]))
{:content (fn [] [testnet/view
{:enable? enable?
:blur? blur?}])
:theme theme
:shell? blur?
:blur-background colors/bottom-sheet-background-blur}]))
(defn view
[]
@@ -27,5 +27,4 @@
{:color colors/white-opa-40})
(def saved-address-item
{:margin-top 4
:background-color colors/white-opa-5})
{:margin-top 4})
@@ -49,7 +49,6 @@
: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?
@@ -84,7 +83,7 @@
[quo/info-message
{:accessibility-label :error-message
:size :default
:icon :i/alert
:icon :i/info
:type :error
:style style/info-message}
error-msg])))
@@ -92,7 +91,8 @@
(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,19 +93,20 @@
:subtitle-type :default
:label :none
:blur? true
:right-icon (when-not ens? :i/advanced)
:icon-right? (not ens?)
:right-icon :i/advanced
:card? true
:title (i18n/label :t/address)
:subtitle ens
:custom-subtitle address-text
:on-press (when-not ens? open-network-preferences)
:on-press 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 (if edit? (+ (safe-area/get-bottom) 12) 0)
{:footer-container-padding 0
:header [quo/page-nav
{:type :no-title
:background :blur
@@ -132,7 +133,7 @@
:container-style style/avatar}]
[quo/title-input
{:blur? true
:auto-focus (not edit?)
:auto-focus true
:max-length 24
:size :heading-1
:placeholder placeholder
@@ -2,24 +2,20 @@
(: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 [[_ splitted-address] (network-utils/split-network-full-address address)
open-send-flow (rn/use-callback
(let [open-send-flow (rn/use-callback
#(rf/dispatch [:wallet/select-send-address
{:address full-address
:recipient {:label (utils/get-shortened-address
splitted-address)
:recipient-type :saved-address}
:recipient full-address
:stack-id :wallet-select-address
:start-flow? true}])
[full-address])
@@ -56,10 +52,11 @@
open-remove-confirmation-sheet (rn/use-callback
#(rf/dispatch
[:show-bottom-sheet
{:theme :dark
:shell? true
:content (fn []
[remove-address/view opts])}])
{:theme :dark
:shell? true
:blur-background colors/bottom-sheet-background-blur
:content (fn []
[remove-address/view opts])}])
[opts])
open-show-address-qr (rn/use-callback
#(rf/dispatch [:open-modal
@@ -73,34 +73,27 @@
(defn- filtered-list
[{:keys [search-text]}]
(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}])))
[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]}])
(defn- unfiltered-list
[{:keys [grouped-saved-addresses]}]
(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}}]))
[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]}])
(defn- navigate-back
[]
@@ -2,6 +2,7 @@
(: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]))
@@ -15,14 +16,16 @@
(defn basic-settings-options
[]
[{: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}])
[(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})])
(defn basic-settings
[]
@@ -71,5 +74,7 @@
[quo/page-top
{:title (i18n/label :t/wallet)
:title-accessibility-label :wallet-settings-header}]
[basic-settings]
(when (or (ff/enabled? ::ff/settings.keypairs-and-accounts)
(ff/enabled? ::ff/settings.saved-addresses))
[basic-settings])
[advanced-settings]]))
@@ -1,33 +1,26 @@
(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]
(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")})]]]]))
[:<>
[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")}]]]])
@@ -16,13 +16,12 @@
(rf/dispatch [:wallet/get-collectible-details id]))
(defn- on-collectible-long-press
[{:keys [preview-url collectible-details id]}]
[{:keys [preview-url collectible-details]}]
(rf/dispatch [:show-bottom-sheet
{:content (fn []
[options-drawer/view
{:name (:name collectible-details)
:image (:uri preview-url)
:id id}])}]))
:image (:uri preview-url)}])}]))
(defn- on-end-reached
[]
@@ -124,7 +124,7 @@
:on-success on-success
:on-error (fn [error]
(log/error
"Failed to resolve next derivation path"
"Failed to resolve next path 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 key-uid]}]]
(fn [_ [{:keys [password derived-from-address derivation-path account-preferences]}]]
{:fx [[:json-rpc/call
[{:method "wallet_getDerivedAddresses"
:params [(security/safe-unmask-data password)
@@ -199,10 +199,9 @@
[derivation-path]]
:on-success (fn [[derived-account]]
(rf/dispatch [:wallet/add-account
(assoc account-preferences
:key-uid key-uid
:password password)
(assoc account-preferences :password password)
derived-account]))
:on-error [:wallet/log-rpc-error
{:event :wallet/derive-address-and-add-account
:params [derived-from-address [derivation-path]]}]}]]]}))
:on-error #(log/info "Failed to get derived addresses"
derived-from-address
%)}]]]}))
@@ -105,7 +105,8 @@
[quo/bottom-actions
{:actions :one-action
:button-one-label (i18n/label :t/confirm-account-origin)
:button-one-props {:customization-color customization-color
:button-one-props {:disabled? (= selected-keypair selected-key-uid)
:customization-color customization-color
:on-press #(rf/dispatch [:wallet/confirm-account-origin
selected-key-uid])}
:container-style style/bottom-action-container}]]))
@@ -48,6 +48,7 @@
: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}
@@ -69,7 +70,7 @@
:icon-only? true
:on-press #(rf/dispatch [:emoji-picker/open {:on-select on-select-emoji}])
:container-style style/reaction-button-container}
:i/edit]])
:i/reaction]])
(defn- input
[_]
@@ -216,7 +217,6 @@
[: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)
(string/blank? @derivation-path)
(= "" @derivation-path)
(some? error))}}
[avatar
{:account-color @account-color
@@ -1,6 +1,5 @@
(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]
@@ -201,35 +200,25 @@
(rf/reg-event-fx :wallet/trigger-share-collectible
(fn [_ [{:keys [title 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})}]]]}))
{:fx [[:effects.share/open
{:title title
:message title
:url uri}]]}))
(rf/reg-event-fx :wallet/share-collectible
(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?])})]
(fn [_ [{:keys [title uri in-sheet?]}]]
(if in-sheet?
{:fx [[:dispatch
[:hide-bottom-sheet]]
[:dispatch-later
{:ms 600
:dispatch [:wallet/trigger-share-collectible
{:title title
:uri uri}]}]]})))
:uri uri}]}]]}
{:fx [[:dispatch
[:wallet/trigger-share-collectible
{:title title
:uri uri}]]]})))
(rf/reg-event-fx
:wallet/navigate-to-opensea
@@ -7,18 +7,15 @@
[utils.url :as url]))
(defn view
[{: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]))]
[{:keys [image name chain-id address]}]
(let [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)
contract-address]))
address]))
:label (i18n/label :t/view-on-eth)
:right-icon :i/external}]
[{:icon :i/save
@@ -37,14 +34,6 @@
:accessibility-label :share-collectible
:label (i18n/label :t/share-collectible)
:on-press #(rf/dispatch [:wallet/share-collectible
{: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"}
{:in-sheet? true
:title name
:uri uri}])}]]]))
@@ -79,8 +79,7 @@
(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
id]}]
[{:keys [scroll-amount title-opacity page-nav-type picture title description theme]}]
(let [blur-amount (header-animations/use-blur-amount scroll-amount)
layer-opacity (header-animations/use-layer-opacity
scroll-amount
@@ -111,8 +110,7 @@
{:content (fn []
[options-drawer/view
{:name title
:image picture
:id id}])
:image picture}])
:theme theme}])}]
:center-opacity title-opacity}]]]]))
@@ -199,8 +197,7 @@
[options-drawer/view
{:name collectible-name
:image
preview-uri
:id id}])}])}])))
preview-uri}])}])}])))
:on-collectible-load (fn []
;; We need to delay the measurement because the
;; navigation has an animation
@@ -249,8 +246,7 @@
{collection-name :name} collection-data]
[rn/view {:style (style/background-color theme)}
[animated-header
{:id (:id collectible)
:scroll-amount scroll-amount
{:scroll-amount scroll-amount
:title-opacity title-opacity
:page-nav-type :title-description
:picture preview-uri
@@ -4,6 +4,7 @@
[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
@@ -36,7 +37,7 @@
:networks networks
:align-center? true
:networks-on-press #(rf/dispatch [:show-bottom-sheet {:content network-filter/view}])
:right-side [(when (and true
:right-side [(when (and (ff/enabled? ::ff/wallet.wallet-connect)
(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-address-qr-code)
:subtitle (i18n/label :t/scan-an-account-qr-code)
:error-message (i18n/label :t/oops-this-qr-does-not-contain-an-address)
:validate-fn #(contains-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/edit]]
:i/reaction]]
[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 blur?]}]
[{:keys [network-name color on-change networks state label-props type]}]
(cond-> {:title (string/capitalize (name network-name))
:image :icon-avatar
:image-props {:icon (resources/get-network network-name)
@@ -230,7 +230,6 @@
(if (= :default state)
:filled-checkbox
:checkbox))
:blur? blur?
:customization-color color
:checked? (contains? networks network-name)
:on-change on-change}}
@@ -272,14 +271,6 @@
%)
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,6 +1,5 @@
(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]))
@@ -142,47 +141,3 @@
(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))
+1 -1
View File
@@ -73,7 +73,7 @@
(fn [resolver rejecter]
(json-rpc/call {:method "accounts_makeSeedPhraseKeypairFullyOperable"
:params [(security/safe-unmask-data mnemonic)
(security/safe-unmask-data password)]
(-> password security/safe-unmask-data native-module/sha3)]
:on-error (fn [error]
(rejecter (ex-info (str error) {:error error})))
:on-success (fn [value]
+16 -14
View File
@@ -215,12 +215,13 @@
[:dispatch [:wallet/clear-create-account]]]}))
(rf/reg-event-fx :wallet/add-account
(fn [_
[{:keys [key-uid password account-name emoji color type]
(fn [{:keys [db]}
[{:keys [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)
(string/lower-case))
key-uid (get-in db [:wallet :ui :create-account :selected-keypair-uid])
account-config {:key-uid (when (= type :generated) key-uid)
:wallet false
:chat false
@@ -528,17 +529,18 @@
:wallet/process-keypair-from-backup
(fn [{:keys [db]} [{:keys [backedUpKeypair]}]]
(let [{:keys [key-uid accounts]} backedUpKeypair
accounts-fx
(mapv (fn [{:keys [chat] :as account}]
;; We exclude the chat account from the profile keypair for fetching the assets
(when-not chat
[:dispatch
[:wallet/process-account-from-signal
account]]))
accounts)]
{:db (assoc-in db
[:wallet :keypairs key-uid]
(data-store/rpc->keypair backedUpKeypair))
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)
:fx accounts-fx})))
(rf/reg-event-fx
@@ -9,13 +9,16 @@
[utils.re-frame :as rf]))
(defn- on-collectible-long-press
[{: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)}])}]))
[{: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)}])}])))
(defn- on-collectible-press
[{:keys [id]}]
+15 -16
View File
@@ -205,22 +205,21 @@
token-networks-ids (mapv #(:chain-id %) token-networks)
token-not-supported-in-receiver-networks? (not-any? (set receiver-networks)
token-networks-ids)]
(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}]]]}))))
{: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}]]]})))
(rf/reg-event-fx
:wallet/edit-token-to-send
@@ -1,165 +0,0 @@
(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,7 +47,6 @@
:network-name :mainnet
:abbreviated-name
"Eth."
:full-name "Mainnet"
:chain-id 1
:related-chain-id 1
:layer 1}]
@@ -93,7 +92,6 @@
:short-name "eth"
:network-name :mainnet
:abbreviated-name "Eth."
:full-name "Mainnet"
:chain-id 1
:related-chain-id 1
:layer 1}]
@@ -15,7 +15,6 @@
[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]
@@ -25,17 +24,16 @@
(defn- estimated-fees
[{:keys [loading-routes? fees amount]}]
[rn/view {:style style/estimated-fees-container}
(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]])
[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)
@@ -349,24 +347,23 @@
: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
:allow-selection? false}]
{: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}]
[routes/view
{:token token-by-symbol
:input-value input-amount
@@ -379,7 +376,7 @@
sender-network-values
token-not-supported-in-receiver-networks?)
[token-not-available token-symbol receiver-networks token-networks])
(when (and (not no-routes-found?) (or loading-routes? route))
(when (or loading-routes? route)
[estimated-fees
{:loading-routes? loading-routes?
:fees fee-formatted
@@ -170,23 +170,22 @@
{:title (i18n/label :t/send-from-network {:network network-name-str})
:description (i18n/label :t/define-amount-sent-from-network {:network network-name-str})}]
[quo/token-input
{:container-style style/input-container
:token token-symbol
:currency fiat-currency
:currency-symbol currency-symbol
:crypto-decimals (min token-decimals 6)
:error? (controlled-input/input-error input-state)
:networks [network-details]
:title (i18n/label
:t/send-limit
{:limit (if crypto-currency?
(utils/make-limit-label-crypto current-limit token-symbol)
(utils/make-limit-label-fiat current-limit currency-symbol))})
:conversion conversion-rate
:show-keyboard? false
:value (controlled-input/input-value input-state)
:on-swap swap-between-fiat-and-crypto
:allow-selection? false}]
{: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}]
[quo/disclaimer
{:on-change (fn [checked?]
(set-is-amount-locked checked?))
@@ -4,7 +4,6 @@
[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]))
@@ -31,10 +30,7 @@
:full-address? true)
:on-press #(rf/dispatch [:wallet/select-send-address
{:address address
:recipient {:recipient-type :account
:label (:name account)
:customization-color (:color account)
:emoji (:emoji account)}
:recipient account
:stack-id :screen/wallet.select-address}])}])))])))
(defn- recent-transactions
@@ -52,9 +48,7 @@
{:address address
:on-press #(rf/dispatch [:wallet/select-send-address
{:address address
:recipient {:label (utils/get-shortened-address
address)
:recipient-type :address}
:recipient address
:stack-id :screen/wallet.select-address}])}]))
recent-recipients))))
@@ -65,9 +59,7 @@
#(rf/dispatch
[:wallet/select-send-address
{:address full-address
:recipient {:label name
:customization-color customization-color
:recipient-type :saved-address}
:recipient full-address
:stack-id :screen/wallet.select-address}])
[full-address])]
[quo/saved-address
@@ -90,12 +82,11 @@
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)
:container-style style/empty-container-style
: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)
:image (resources/get-themed-image :sweating-man
theme)}])
[theme])]
[rn/section-list
{:key-fn :title
@@ -103,7 +94,6 @@
: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,6 +1,5 @@
(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]
@@ -10,8 +9,6 @@
[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]
@@ -139,34 +136,7 @@
:keyboard-should-persist-taps :handled
:render-fn suggestion-component}]]))
(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
(defn- f-view
[]
(let [on-close (fn []
(rf/dispatch [:wallet/clean-scanned-address])
@@ -180,18 +150,31 @@
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?]))]
(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])]
[floating-button-page/view
{:content-container-style {:flex 1}
:footer-container-padding 0
{: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-not (string/blank? @input-value)
[footer @input-value])}
: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)])}
[quo/page-top
{:title (i18n/label :t/send-to)
:title-accessibility-label :title-label}]
@@ -222,3 +205,7 @@
:scrollable? true
:on-change on-change-tab}]
[tabs/view {:selected-tab selected-tab}]])]))))
(defn view
[]
[:f> f-view])
@@ -1,21 +1,22 @@
(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 :as utils]
[status-im.contexts.wallet.common.utils.networks :as network-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 route to-network image-url transaction-type
collectible? recipient]}]
[{:keys [token-display-name amount account to-address route to-network image-url
transaction-type collectible?]}]
(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}
@@ -106,7 +107,9 @@
:image-source (:source to-network)
:label (string/capitalize (name (:network-name to-network)))
:customization-color to-network-color}]
[quo/summary-tag (assoc recipient :type (:recipient-type recipient))])]
[quo/summary-tag
{:type :address
:label (utils/get-shortened-address to-address)}])]
(when (= transaction-type :tx/bridge)
[rn/view
{:style {:flex-direction :row
@@ -124,12 +127,20 @@
:customization-color (:color account)}]])]))
(defn- user-summary
[{: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)]
[{: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)]
[rn/view
{:style {:padding-horizontal 20
:padding-bottom 16}}
@@ -140,17 +151,10 @@
:accessibility-label accessibility-label}
label]
[quo/summary-info
{:type summary-info-type
{:type summary-type
:networks? true
:values network-values
: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)))}]]))
:account-props account-props}]]))
(defn- data-item
[{:keys [title subtitle]}]
@@ -198,45 +202,39 @@
[_]
(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 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)}]
(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)}]
[rn/view {:style {:flex 1}}
[floating-button-page/view
{:footer-container-padding 0
@@ -276,21 +274,23 @@
{:token-display-name token-symbol
:amount amount
:account account
:type type
:recipient recipient
:to-address to-address
:route route
:to-network bridge-to-network
:image-url image-url
:transaction-type transaction-type
:collectible? collectible?}]
[user-summary
{:summary-type :status-account
{:token-display-name token-symbol
: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
{:summary-type (if (= transaction-type :tx/bridge)
{:token-display-name token-symbol
:summary-type (if (= transaction-type :tx/bridge)
:status-account
:account)
:accessibility-label :summary-to-label
@@ -298,6 +298,5 @@
:account-props (if (= transaction-type :tx/bridge)
from-account-props
user-props)
:recipient recipient
:account-to? true
:network-values to-values-by-chain
:theme theme}]]]]))))
@@ -90,7 +90,10 @@
:address address
:blur? blur?
:format :long}])
:container-style style/data-item}])
:container-style (merge style/data-item
{:background-color (colors/theme-colors colors/neutral-2_5
colors/neutral-90
theme)})}])
[quo/category
{:list-type :settings
:blur? blur?
@@ -103,7 +106,6 @@
:normal-checkbox? receiver?
:networks (get-current-preferences-names)
:type :checkbox
:blur? blur?
:on-change (fn []
(toggle-network (:network-name
network))
@@ -135,7 +137,6 @@
:normal-checkbox? receiver?
:networks (get-current-preferences-names)
:type :checkbox
:blur? blur?
:on-change (fn []
(toggle-network (:network-name
network))
@@ -1,19 +1,8 @@
(ns status-im.contexts.wallet.wallet-connect.core
(:require [clojure.edn :as edn]
[clojure.string :as string]
[native-module.core :as native-module]
[status-im.constants :as constants]
(:require [native-module.core :as native-module]
[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))
@@ -22,13 +11,6 @@
[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))
@@ -41,14 +23,9 @@
[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]
(-> db
get-db-current-request-event
(-> (get-in db [:wallet-connect/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-request
:wallet-connect/reset-current-session-request
(fn [{:keys [db]}]
{:db (dissoc db :wallet-connect/current-request)}))
@@ -107,6 +107,12 @@
: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]}]
@@ -1,8 +0,0 @@
(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]))
@@ -1,18 +0,0 @@
(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})
@@ -1,35 +0,0 @@
(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]]]))
@@ -1,10 +0,0 @@
(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})
@@ -1,26 +0,0 @@
(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}]])]])
@@ -1,23 +0,0 @@
(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})
@@ -1,63 +0,0 @@
(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))}]]]]))
@@ -1,42 +0,0 @@
(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)}]]]]))
@@ -1,63 +0,0 @@
(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,32 +6,31 @@
[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 (wallet-connect-core/method-to-screen method)]
screen (method-to-screen method)]
(if screen
{:db (assoc-in db [:wallet-connect/current-request :event] event)
:fx [(condp = method
constants/wallet-connect-eth-send-transaction-method
[:dispatch [:wallet-connect/process-eth-send-transaction]]
constants/wallet-connect-personal-sign-method
[:dispatch [:wallet-connect/process-personal-sign]]
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]]
constants/wallet-connect-personal-sign-method
[:dispatch [:wallet-connect/process-personal-sign]])
[:dispatch [:wallet-connect/process-sign-typed]])
[:dispatch [:open-modal screen]]]}
(log/error "Didn't find screen for Wallet Connect method"
{:method method
@@ -61,34 +60,6 @@
: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,19 +13,9 @@
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]]
@@ -67,50 +57,12 @@
: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)
screen (wallet-connect-core/method-to-screen method)]
method (wallet-connect-core/get-request-method event)]
(log/error "Failed to sign Wallet Connect request"
{:error error
:address address
@@ -118,8 +70,7 @@
:method method
:wallet-connect-event event
:event :wallet-connect/on-sign-error})
{:fx [[:dispatch [:dismiss-modal screen]]
[:dispatch [:wallet-connect/reset-current-request]]]})))
{:fx [[:dispatch [:wallet-connect/close-session-request]]]})))
(rf/reg-event-fx
@@ -127,7 +78,6 @@
(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
@@ -140,9 +90,7 @@
:method method
:event :wallet-connect/send-response
:wallet-connect-event event})
(rf/dispatch [:dismiss-modal screen])
(rf/dispatch [:wallet-connect/reset-current-request]))
(rf/dispatch [:wallet-connect/close-session-request]))
:on-success (fn []
(log/info "Successfully sent Wallet Connect response to dApp")
(rf/dispatch [:dismiss-modal screen])
(rf/dispatch [:wallet-connect/reset-current-request]))}]]})))
(rf/dispatch [:wallet-connect/close-session-request]))}]]})))
@@ -24,3 +24,8 @@
(def approval-li-spacer
{:width 8})
(def detail-item
{:margin-bottom 20
:margin-horizontal 20
:padding 12})
@@ -2,7 +2,6 @@
(:require
[quo.core :as quo]
[quo.foundations.colors :as colors]
[quo.foundations.resources :as quo.resources]
[quo.theme]
[react-native.core :as rn]
[status-im.common.floating-button-page.view :as floating-button-page]
@@ -45,47 +44,41 @@
[quo/text label]])
labels)]))
(defn- get-placeholder-networks
(defn- accounts-data-item
[]
[{:source (quo.resources/get-network :ethereum)}
{:source (quo.resources/get-network :optimism)}
{:source (quo.resources/get-network :arbitrum)}])
;; TODO. This account is currently hard coded in
;; `status-im.contexts.wallet.wallet-connect.events`. Should be selectable and changeable
(let [accounts (rf/sub [:wallet/accounts-without-watched-accounts])
name (-> accounts first :name)]
[quo/data-item
{:container-style style/detail-item
:blur? false
:description :default
:icon-right? true
:right-icon :i/chevron-right
:icon-color colors/neutral-10
:card? false
:label :preview
;; TODO. The quo component for data item doesn't support showing accounts yet
:status :default
:size :small
:title (i18n/label :t/account-title)
:subtitle name}]))
(defn- connection-category
(defn- networks-data-item
[]
(let [{:keys [name emoji customization-color]} (first (rf/sub
[:wallet/accounts-without-watched-accounts]))
data-item-common-props {:blur? false
:description :default
:card? false
:label :preview
:status :default
:size :default}
account-data-item-props (assoc data-item-common-props
:right-content {:type :accounts
:size :size-32
:data [{:emoji emoji
:customization-color
customization-color}]}
:on-press #(js/alert "Not yet implemented")
:title (i18n/label :t/account-title)
:subtitle name
:icon-right? true
:right-icon :i/chevron-right
:icon-color colors/neutral-10)
networks-data-item-props (assoc data-item-common-props
:right-content {:type :network
:data
(get-placeholder-networks)}
:title (i18n/label :t/networks)
;; TODO. The quo component for data-item
;; does not support showing networks yet
:subtitle "Networks placeholder")]
[quo/category
{:blur? false
:list-type :data-item
:data [account-data-item-props
networks-data-item-props]}]))
[quo/data-item
{:container-style style/detail-item
:blur? false
:description :default
:icon-right? true
:card? true
:label :none
:status :default
:size :small
:title (i18n/label :t/networks)
;; TODO. The quo component for data-item does not support showing networks yet
:subtitle "Networks will show up here"}])
(defn- footer
[]
@@ -121,5 +114,6 @@
:footer [footer]}
[rn/view
[dapp-metadata]
[connection-category]
[accounts-data-item]
[networks-data-item]
[approval-note]]])

Some files were not shown because too many files have changed in this diff Show More