Merge branch 'develop' into 19375-remove-eth-accounts

This commit is contained in:
Ulises Manuel 2024-06-27 14:13:06 -06:00 committed by GitHub
commit 66574f4e9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
101 changed files with 1490 additions and 706 deletions

View File

@ -119,8 +119,6 @@
<array>
<string>armv7</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
@ -133,7 +131,7 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<true/>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A00000080400010101</string>

View File

@ -38,10 +38,12 @@
:always
(update :contacts conj (:id member))))
(defn community-chat-id->channel-id [chat-id] (subs chat-id constants/community-id-length))
(defn decode-chat-id
[chat-id]
(let [community-id (subs chat-id 0 constants/community-id-length)
channel-id (subs chat-id constants/community-id-length)]
channel-id (community-chat-id->channel-id chat-id)]
{:community-id community-id
:channel-id channel-id}))

View File

@ -28,7 +28,7 @@
[{:keys [db] :as cofx} {:keys [auth-method logout?]}]
(let [key-uid (get-in db [:profile/profile :key-uid])]
(rf/merge cofx
{:set-root :progress
{:dispatch [:init-root :progress]
:effects.shell/reset-state nil
:hide-popover nil
::logout nil

View File

@ -53,7 +53,8 @@
[]
[;;PROGRESS
{:name :progress
:options {:insets {:top? true}}
:options {:insets {:top? true}
:theme :dark}
:component progress/progress}
;;COMMUNITY

View File

@ -14,9 +14,7 @@
[react-native.reanimated :as reanimated]))
(defn drag-gesture
[x-pos disabled? track-width sliding-complete?
set-sliding-complete
on-complete reset-fn]
[x-pos disabled? track-width sliding-complete? set-sliding-complete on-complete reset-fn]
(-> (gesture/gesture-pan)
(gesture/with-test-ID :slide-button-gestures)
(gesture/enabled (not disabled?))
@ -71,14 +69,16 @@
(dimensions :thumb))
[dimensions])
custom-color (if (= type :danger) :danger customization-color)
gesture (rn/use-memo #(drag-gesture x-pos
disabled?
(dimensions :usable-track)
sliding-complete?
set-sliding-complete
on-complete
reset-fn)
[sliding-complete? disabled?])]
gesture (rn/use-memo
(fn []
(drag-gesture x-pos
disabled?
(dimensions :usable-track)
sliding-complete?
set-sliding-complete
on-complete
reset-fn))
[sliding-complete? disabled? on-complete])]
[gesture/gesture-detector
{:gesture gesture}
[reanimated/view

View File

@ -8,10 +8,11 @@
[react-native.core :as rn]))
(defn- get-icon-color
[danger? theme]
(if danger?
(colors/theme-colors colors/danger-50 colors/danger-60 theme)
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme)))
[blur? danger? theme]
(cond
danger? (colors/theme-colors colors/danger-50 colors/danger-60 theme)
blur? colors/white-opa-70
:else (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)))
(defn- divider
[theme blur?]
@ -51,7 +52,7 @@
:accessible true
:style (style/left-icon sub-label)}
[icon/icon icon
{:color (or icon-color (get-icon-color danger? theme))
{:color (or icon-color (get-icon-color blur? danger? theme))
:no-color no-icon-color?
:size 20}]])
[rn/view
@ -84,7 +85,7 @@
:accessible true
:accessibility-label :right-icon-for-action}
[icon/icon right-icon
{:color (get-icon-color danger? theme)
{:color (get-icon-color blur? danger? theme)
:size 20}]])
(when (= state :selected)
[rn/view {:style style/right-icon}

View File

@ -18,7 +18,7 @@
(defn- left-image
[{:keys [type customization-color account-avatar-emoji account-avatar-type icon-avatar
profile-picture]}]
profile-picture blur?]}]
(case type
:account [account-avatar/view
{:customization-color customization-color
@ -28,6 +28,7 @@
:keypair [icon-avatar/icon-avatar
{:icon icon-avatar
:border? true
:blur? blur?
:color :neutral}]
:default-keypair [user-avatar/user-avatar
@ -213,6 +214,7 @@
[rn/view {:style style/left-container}
[left-image
{:type type
:blur? blur?
:customization-color customization-color
:account-avatar-emoji account-avatar-emoji
:account-avatar-type account-avatar-type

View File

@ -31,7 +31,8 @@
:size :paragraph-2}
(:name account-props)]
[address-text/view
{:networks networks
{:blur? blur?
:networks networks
:address (:address account-props)
:format :short}]]]
(when (= action :icon)

View File

@ -34,7 +34,8 @@
(def container-info
{:flex-direction :row
:align-items :center})
:align-items :center
:flex 1})
(def user-info
{:margin-left 8})

View File

@ -25,14 +25,16 @@
:style {:width 32 :height 32}}]
[rn/view {:style style/user-info}
[text/text
{:weight :semi-bold
:size :paragraph-1
:style (style/style-text-name theme)}
{:weight :semi-bold
:size :paragraph-1
:number-of-lines 1
:style (style/style-text-name theme)}
(:name dapp)]
[text/text
{:weight :regular
:size :paragraph-2
:style (style/style-text-value theme)}
{:weight :regular
:size :paragraph-2
:number-of-lines 1
:style (style/style-text-value theme)}
(:value dapp)]]]
(when right-component
[right-component dapp])]))

View File

@ -31,7 +31,7 @@
(defn- checkbox-border-unchecked-color
[theme]
{:normal (colors/theme-colors colors/neutral-30 colors/neutral-70 theme)
:blur (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-40 theme)})
:blur (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-20 theme)})
(defn- filled-checkbox-background-color
[theme]

View File

@ -39,6 +39,12 @@
(def avatar-container-rounded
(assoc avatar-container-common :border-radius 16))
(def big-avatar-container-rounded
(assoc avatar-container-common
:width 84
:height 84
:border-radius 42))
(def community-logo-image
{:width 64
:height 64

View File

@ -13,8 +13,9 @@
:as props}]
[rn/view {:style style/avatar-overlay}
[rn/view
{:style (if (= avatar-type :wallet-account)
style/avatar-container-rounded
{:style (case avatar-type
:wallet-account style/avatar-container-rounded
:saved-address style/big-avatar-container-rounded
style/avatar-container-circular)}
(case avatar-type
:profile
@ -37,7 +38,7 @@
[channel-avatar/view (assoc props :locked? nil :size :size-64)]
:saved-address
[wallet-avatar/wallet-user-avatar (assoc props :size :size-64)]
[wallet-avatar/wallet-user-avatar (assoc props :size :size-80)]
nil)]])

View File

@ -28,5 +28,10 @@
:height 24
:border-radius 12})
(def dapp
{:width 24
:height 24
:border-radius 12})
(def token-image
{:border-radius 12})

View File

@ -23,6 +23,10 @@
[rn/image
{:source image-source
:style style/network}]
:dapp
[rn/image
{:source image-source
:style style/dapp}]
:saved-address
[wallet-user-avatar/wallet-user-avatar
{:full-name label
@ -50,7 +54,7 @@
- :label - string - tag label
- :customization-color - color - It will be passed down to components that
should vary based on a custom color.
- :type - :token / :user / :collectible / :saved-address / :network / :account
- :type - :token / :user / :collectible / :saved-address / :network / :account / :dapp
- :emoji - string - emoji used for displaying account avatar
- :image-source - resource - image to display on :network, :collectible and :user
- :theme - :light / :dark"

View File

@ -7,14 +7,14 @@
[{:keys [blur? customization-color theme selected? container-style]}]
(merge {:border-radius 16
:border-width 1
:border-color (if selected?
(if blur?
colors/white
(colors/resolve-color customization-color theme))
(if blur?
colors/white-opa-5
(colors/theme-colors colors/neutral-10 colors/neutral-80 theme)))
:padding-bottom 8}
:padding-bottom 8
:border-color (cond
(and selected? blur?) colors/white
selected? (colors/resolve-color customization-color theme)
blur? colors/white-opa-5
:else (colors/theme-colors colors/neutral-10
colors/neutral-80
theme))}
container-style))
(def header-container

View File

@ -47,12 +47,13 @@
:accessibility-label :title}
[text/text {:weight :semi-bold}
(if (= type :default-keypair) (keypair-string full-name) full-name)]
(if (= action :selector)
[selectors/view
{:type :radio
:checked? selected?
:blur? blur?
:customization-color customization-color}]
(case action
:none nil
:selector [selectors/view
{:type :radio
:checked? selected?
:blur? blur?
:customization-color customization-color}]
[rn/pressable {:on-press on-options-press}
[icon/icon :i/options
{:color (if blur?
@ -94,20 +95,23 @@
(defn view
[{:keys [accounts action container-style selected? on-press] :as props}]
[rn/pressable
{:style (style/container (merge props
{:selected? selected?
:container-style container-style}))
:on-press #(when (= action :selector) (on-press))}
[rn/view {:style style/header-container}
[avatar props]
[rn/view
{:style {:margin-left 8
:flex 1}}
[title-view (assoc props :selected? selected?)]
[details-view props]]]
[rn/flat-list
{:data accounts
:render-fn acc-list-card
:separator [rn/view {:style {:height 8}}]
:style {:padding-horizontal 8}}]])
(let [theme (quo.theme/use-theme)]
[rn/pressable
{:style (style/container (assoc props
:selected? selected?
:container-style container-style
:theme theme))
:on-press #(when (= action :selector) (on-press))
:pointer-events :box-only}
[rn/view {:style style/header-container}
[avatar props]
[rn/view
{:style {:margin-left 8
:flex 1}}
[title-view (assoc props :selected? selected?)]
[details-view props]]]
[rn/flat-list
{:data accounts
:render-fn acc-list-card
:separator [rn/view {:style {:height 8}}]
:style {:padding-horizontal 8}}]]))

View File

@ -11,7 +11,7 @@
[utils.i18n :as i18n]))
(defn title-view
[{:keys [keypairs blur? on-import-press]}]
[{:keys [keypairs blur? on-import-press show-import-all?]}]
(let [theme (quo.theme/use-theme)]
[rn/view
{:accessibility-label :title
@ -29,12 +29,13 @@
:style {:color colors/warning-60}}
(i18n/label :t/amount-missing-keypairs
{:amount (str (count keypairs))})]
[button/button
{:type :outline
:background :blur
:size 24
:on-press on-import-press}
(i18n/label :t/import)]]
(when show-import-all?
[button/button
{:type :outline
:background :blur
:size 24
:on-press on-import-press}
(i18n/label :t/import)])]
[text/text
{:size :paragraph-2
:style (style/subtitle blur? theme)}

View File

@ -1,7 +1,6 @@
(ns status-im.common.bottom-sheet.style
(:require
[quo.foundations.colors :as colors]
[react-native.platform :as platform]))
[quo.foundations.colors :as colors]))
(def ^:private sheet-border-radius 20)
@ -22,11 +21,8 @@
:left 0
:right 0})
(defn shell-bg
[blur-background]
{:background-color (if blur-background
blur-background
(if platform/ios? colors/white-opa-5 colors/neutral-100-opa-90))
(def shell-bg
{:background-color colors/bottom-sheet-background-blur
:flex 1})
(def shell-bg-container

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 blur-background]
gradient-cover? customization-color hide-handle? blur-radius]
:or {border-radius 12}}]
(let [theme (quo.theme/use-theme)
{window-height :height} (rn/get-window)
@ -134,7 +134,7 @@
(when shell?
[rn/view {:style style/shell-bg-container}
[quo/blur
{:style (style/shell-bg blur-background)
{:style style/shell-bg
:blur-radius (or blur-radius 20)
:blur-amount 32
:blur-type :transparent

View File

@ -1,6 +1,5 @@
(ns status-im.common.enter-seed-phrase.style
(:require
[react-native.safe-area :as safe-area]))
(:require [react-native.platform :as platform]))
(def full-layout {:flex 1})
@ -11,6 +10,13 @@
:left 0
:right 0})
(defn recovery-phrase-container
[{:keys [banner-offset insets keyboard-shown?]}]
{:flex 1
:padding-bottom (if keyboard-shown?
(when platform/ios? banner-offset)
(:bottom insets))})
(def form-container
{:flex 1
:padding-horizontal 20
@ -29,9 +35,7 @@
:margin-top 12
:margin-horizontal -20})
(defn continue-button
[keyboard-shown?]
{:margin-top :auto
:margin-bottom (when-not keyboard-shown? (safe-area/get-bottom))})
(def continue-button
{:margin-top :auto})
(def keyboard-container {:margin-top :auto})

View File

@ -96,7 +96,7 @@
(take 7)))
(defn recovery-phrase-screen
[{:keys [keypair title recovering-keypair? render-controls]}]
[{:keys [banner-offset initial-insets keypair title recovering-keypair? render-controls]}]
(reagent/with-let [keyboard-shown? (reagent/atom false)
keyboard-show-listener (.addListener rn/keyboard
"keyboardDidShow"
@ -114,7 +114,8 @@
seed-phrase (reagent/atom "")
on-change-seed-phrase (fn [new-phrase]
(when @invalid-seed-phrase?
(reset! invalid-seed-phrase? false)
(reset! invalid-seed-phrase? false))
(when @incorrect-seed-phrase?
(reset! incorrect-seed-phrase? false))
(reset! seed-phrase new-phrase))
on-submit (fn []
@ -161,7 +162,10 @@
button-disabled? (or error-state?
(not (constants/seed-phrase-valid-length word-count))
(not all-words-valid?))]
[:<>
[rn/view
{:style (style/recovery-phrase-container {:insets initial-insets
:banner-offset banner-offset
:keyboard-shown? @keyboard-shown?})}
[recovery-phrase-form
{:title title
:keypair keypair
@ -172,18 +176,18 @@
(if (fn? render-controls)
(render-controls {:submit-disabled? button-disabled?
:keyboard-shown? @keyboard-shown?
:container-style (style/continue-button @keyboard-shown?)
:container-style style/continue-button
:prepare-seed-phrase secure-clean-seed-phrase
:focus-input focus-input
:seed-phrase (security/mask-data @seed-phrase)
:set-incorrect-seed-phrase set-incorrect-seed-phrase})
[quo/button
{:container-style (style/continue-button @keyboard-shown?)
{:container-style style/continue-button
:type :primary
:disabled? button-disabled?
:on-press on-submit}
(i18n/label :t/continue)])]
(when @keyboard-shown?
(when (or @keyboard-shown? error-state?)
[rn/view {:style style/keyboard-container}
[quo/predictive-keyboard
{:type suggestions-state
@ -197,7 +201,8 @@
(defn screen
[{:keys [initial-insets title keypair navigation-icon recovering-keypair? render-controls]}]
(let [{navigation-bar-top :top} initial-insets]
(let [{navigation-bar-top :top} initial-insets
banner-offset (rf/sub [:alert-banners/top-margin])]
[rn/view {:style style/full-layout}
[rn/keyboard-avoiding-view {:style style/page-container}
[quo/page-nav
@ -210,6 +215,8 @@
{:title title
:keypair keypair
:render-controls render-controls
:banner-offset banner-offset
:initial-insets initial-insets
:recovering-keypair? recovering-keypair?}]]]))
(defn view

View File

@ -58,7 +58,7 @@
(defn view
[{:keys [header footer customization-color footer-container-padding header-container-style
gradient-cover? keyboard-should-persist-taps]
content-container-style gradient-cover? keyboard-should-persist-taps]
:or {footer-container-padding (safe-area/get-top)}}
& children]
(reagent/with-let [scroll-view-ref (atom nil)
@ -110,7 +110,9 @@
:always-bounce-vertical @keyboard-did-show?
:shows-vertical-scroll-indicator false
:keyboard-should-persist-taps keyboard-should-persist-taps}
(into [rn/view {:on-layout set-content-container-height}]
(into [rn/view
{:style content-container-style
:on-layout set-content-container-height}]
children)]
[rn/keyboard-avoiding-view
{:style style/keyboard-avoiding-view

View File

@ -2,12 +2,13 @@
(:require [quo.foundations.colors :as colors]))
(def container
{:flex 1
:padding 10
:margin-vertical 10.5
:border-width 1
:border-color colors/neutral-10
:border-radius 16})
{:flex 1
:padding 10
:margin-top 10.5
:margin-bottom 0
:border-width 1
:border-color colors/neutral-10
:border-radius 16})
(def content
{:padding-bottom 20})

View File

@ -4,7 +4,7 @@
[status-im.common.raw-data-block.style :as style]))
(defn view
[{:keys [data]}]
[data]
[rn/scroll-view
{:style style/container
:content-container-style style/content}

View File

@ -195,7 +195,7 @@
true)
(defn view
[{:keys [title subtitle validate-fn on-success-scan error-message share-button?]}]
[{:keys [title subtitle validate-fn on-success-scan error-message share-button? import-keypair?]}]
(let [insets (safe-area/get-insets)
qr-code-succeed? (reagent/atom false)
qr-view-finder (reagent/atom {})
@ -233,7 +233,9 @@
:set-qr-code-succeeded (fn [value]
(when on-success-scan
(on-success-scan value))
(rf/dispatch [:navigate-back]))
(if import-keypair?
(set-rescan-timeout)
(rf/dispatch [:navigate-back])))
:set-rescan-timeout set-rescan-timeout}])
[rn/view {:style (style/root-container (:top insets))}
[header

View File

@ -33,6 +33,7 @@
:size 24}]]
[password-input/view
{:on-press-biometrics on-press-biometrics
:blur? true
:processing processing
:error error
:default-password password

View File

@ -20,7 +20,7 @@
(rf/reg-event-fx :standard-auth/authorize authorize)
(defn authorize-with-biometric
[_ [{:keys [on-auth-success on-auth-fail] :as args}]]
[_ [{:keys [on-auth-success on-auth-fail on-close] :as args}]]
(let [args-with-biometric-btn
(assoc args
:on-press-biometric
@ -31,7 +31,10 @@
{:prompt-message (i18n/label :t/biometric-auth-confirm-message)
:on-cancel #(rf/dispatch [:standard-auth/authorize-with-password
args-with-biometric-btn])
:on-success #(rf/dispatch [:standard-auth/on-biometric-success on-auth-success])
:on-success (fn []
(when (fn? on-close)
(on-close))
(rf/dispatch [:standard-auth/on-biometric-success on-auth-success]))
:on-fail (fn [err]
(rf/dispatch [:standard-auth/authorize-with-password
args-with-biometric-btn])

View File

@ -14,10 +14,12 @@
(> (-> s str string/trim count) constants/key-pair-name-max-length))
(defn validation-keypair-name
[s]
[s existing-keypair-names]
(cond
(string/blank? s) nil
(validators/has-emojis? s) (i18n/label :t/key-name-error-emoji)
(validators/has-special-characters? s) (i18n/label :t/key-name-error-special-char)
(keypair-too-short? s) (i18n/label :t/your-key-pair-name-is-too-short)
(keypair-too-long? s) (i18n/label :t/your-key-pair-name-is-too-long)))
(keypair-too-short? s) (i18n/label :t/key-name-error-too-short
{:count constants/key-pair-name-min-length})
(keypair-too-long? s) (i18n/label :t/your-key-pair-name-is-too-long)
(contains? existing-keypair-names s) (i18n/label :t/key-name-error-taken)))

View File

@ -2,6 +2,7 @@
(:require
[cljs.test :refer-macros [deftest are]]
[status-im.common.validation.keypair :as keypair-validator]
[status-im.constants :as constants]
[utils.i18n :as i18n]))
(deftest keypair-name-too-short-test
@ -18,10 +19,12 @@
(deftest validation-keypair-name-test
(are [arg expected]
(= (keypair-validator/validation-keypair-name arg) expected)
(= (keypair-validator/validation-keypair-name arg #{"Collection"}) expected)
nil nil
"" nil
"name !" (i18n/label :t/key-name-error-special-char)
"Hello 😊" (i18n/label :t/key-name-error-emoji)
"abc" (i18n/label :t/your-key-pair-name-is-too-short)
"abc" (i18n/label :t/key-name-error-too-short
{:count constants/key-pair-name-min-length})
"Collection" (i18n/label :t/key-name-error-taken)
(apply str (repeat 25 "a")) (i18n/label :t/your-key-pair-name-is-too-long)))

View File

@ -268,12 +268,14 @@
(def ^:const wallet-connect-personal-sign-method "personal_sign")
(def ^:const wallet-connect-eth-sign-method "eth_sign")
(def ^:const wallet-connect-eth-send-transaction-method "eth_sendTransaction")
(def ^:const wallet-connect-eth-sign-transaction-method "eth_signTransaction")
(def ^:const wallet-connect-eth-sign-typed-method "eth_signTypedData")
(def ^:const wallet-connect-eth-sign-typed-v4-method "eth_signTypedData_v4")
(def ^:const wallet-connect-supported-methods
#{wallet-connect-personal-sign-method
wallet-connect-eth-sign-method
wallet-connect-eth-send-transaction-method
wallet-connect-eth-sign-transaction-method
wallet-connect-eth-sign-typed-method
wallet-connect-eth-sign-typed-v4-method})
(def ^:const wallet-connect-supported-events #{"accountsChanged" "chainChanged"})
@ -492,6 +494,10 @@
(def ^:const optimism-abbreviated-name "Oeth.")
(def ^:const arbitrum-abbreviated-name "Arb1.")
(def ^:const mainnet-full-name "Mainnet")
(def ^:const optimism-full-name "Optimism")
(def ^:const arbitrum-full-name "Arbitrum")
(def ^:const mainnet-network-name :mainnet)
(def ^:const ethereum-network-name :ethereum)
(def ^:const optimism-network-name :optimism)

View File

@ -65,7 +65,7 @@
:as chat} (rf/sub [:chats/chat-by-id chat-id])
pins-count (rf/sub [:chats/pin-messages-count chat-id])
items (rf/sub [:communities/sorted-community-members-section-list
community-id])
community-id chat-id])
theme (quo.theme/use-theme)]
(rn/use-mount (fn []
(rf/dispatch [:pin-message/load-pin-messages chat-id])))

View File

@ -89,7 +89,7 @@
(merge
{:db (assoc db :profile/profiles-overview multiaccounts)}
(when-not (seq multiaccounts)
{:set-root :screen/onboarding.intro}))))
{:dispatch [:init-root :screen/onboarding.intro]}))))
(rf/defn password-set
{:events [:onboarding/password-set]}

View File

@ -51,7 +51,9 @@
{:value "Saved address"
:key :saved-address}
{:value "Account"
:key :account}]}])
:key :account}
{:value "Dapp"
:key :dapp}]}])
(defn view
[]

View File

@ -45,14 +45,14 @@
(assoc :profile/profiles-overview profiles)
(update :profile/login #(select-profile % key-uid)))
db)
:fx [[:set-root :screen/profile.profiles]
:fx [[:dispatch [:init-root :screen/profile.profiles]]
(when key-uid
[:effects.biometric/check-if-available
{:key-uid key-uid
:on-success (fn [auth-method]
(rf/dispatch [:profile.login/check-biometric-success key-uid
auth-method]))}])]})
{:fx [[:set-root :screen/onboarding.intro]]})))
{:fx [[:dispatch [:init-root :screen/onboarding.intro]]]})))
(rf/reg-event-fx
:profile/update-setting-from-backup

View File

@ -74,7 +74,7 @@
(cond
pairing-completed?
[[:set-root :screen/onboarding.syncing-results]]
[[:dispatch [:init-root :screen/onboarding.syncing-results]]]
(get db :onboarding/new-account?)
[[:dispatch [:onboarding/finalize-setup]]]
@ -85,7 +85,7 @@
constants/theme-type-dark)
:shell-stack
false]]
[:set-root :shell-stack]
[:dispatch [:init-root :shell-stack]]
[:dispatch [:profile/show-testnet-mode-banner-if-enabled]]]))})))
;; login phase 2: we want to load and show chats faster, so we split login into 2 phases
@ -179,7 +179,7 @@
{:db (-> db
(assoc-in [:profile/login :password] password)
(assoc-in [:profile/login :processing] true))
:fx [[:set-root :progress]
:fx [[:dispatch [:init-root :progress]]
[:effects.profile/login
[(get-in db [:profile/login :key-uid])
(security/safe-unmask-data password)]]]})))

View File

@ -92,23 +92,28 @@
(rf/reg-event-fx :wallet/make-keypairs-accounts-fully-operable make-keypairs-accounts-fully-operable)
(defn connection-string-for-import-keypair
[{:keys [db]} [{:keys [sha3-pwd keypairs-key-uids connection-string]}]]
[{:keys [db]} [{:keys [sha3-pwd keypairs-key-uids connection-string on-success]}]]
(let [key-uid (get-in db [:profile/profile :key-uid])]
{:fx [[:effects.syncing/import-keypairs-keystores
{:key-uid key-uid
:sha3-pwd sha3-pwd
:keypairs-key-uids keypairs-key-uids
:connection-string connection-string
:on-success #(rf/dispatch [:wallet/make-keypairs-accounts-fully-operable %])
:on-fail #(rf/dispatch [:toasts/upsert
{:type :negative
:theme :dark
:text %}])}]]}))
:on-success (fn [key-uids]
(rf/call-continuation on-success)
(rf/dispatch [:wallet/make-keypairs-accounts-fully-operable key-uids]))
:on-fail (fn [error]
(log/error "failed to import missing key pairs with connection string"
{:error error})
(rf/dispatch [:toasts/upsert
{:type :negative
:theme :dark
:text (i18n/label :t/incorrect-qr-code)}]))}]]}))
(rf/reg-event-fx :wallet/connection-string-for-import-keypair connection-string-for-import-keypair)
(defn success-keypair-qr-scan
[_ [connection-string keypairs-key-uids]]
[_ [connection-string keypairs-key-uids on-import-success]]
{:fx [[:dispatch
[:standard-auth/authorize-with-password
{:blur? true
@ -120,7 +125,8 @@
[:wallet/connection-string-for-import-keypair
{:connection-string connection-string
:keypairs-key-uids keypairs-key-uids
:sha3-pwd password}]))}]]]})
:sha3-pwd password
:on-success on-import-success}]))}]]]})
(rf/reg-event-fx :wallet/success-keypair-qr-scan success-keypair-qr-scan)
@ -146,7 +152,7 @@
{:fx [[:json-rpc/call
[{:method "accounts_makePrivateKeyKeypairFullyOperable"
:params [(security/safe-unmask-data private-key)
(-> password security/safe-unmask-data native-module/sha3)]
(security/safe-unmask-data password)]
:on-success on-success
:on-error on-error}]]]})

View File

@ -41,31 +41,37 @@
[quo/action-drawer
[(when has-paired-device
(if-not missing-keypair?
[{:icon :i/qr-code
[{:blur? true
:icon :i/qr-code
:accessibility-label :show-key-pr-qr
:label (i18n/label :t/show-encrypted-qr-of-key-pairs)
:on-press on-show-qr}]
[{:icon :i/scan
[{:blur? true
:icon :i/scan
:accessibility-label :import-by-scan-qr
:label (i18n/label :t/import-by-scanning-encrypted-qr)
:on-press on-scan-qr}]))
(when (= (:type drawer-props) :keypair)
[(when missing-keypair?
(case (:type keypair)
:seed {:icon :i/seed
:seed {:blur? true
:icon :i/seed
:accessibility-label :import-seed-phrase
:label (i18n/label :t/import-by-entering-recovery-phrase)
:on-press on-import-seed-phrase}
:key {:icon :i/key
:key {:blur? true
:icon :i/key
:accessibility-label :import-private-key
:label (i18n/label :t/import-by-entering-private-key)
:on-press on-import-private-key}
nil))
{:icon :i/edit
{:blur? true
:icon :i/edit
:accessibility-label :rename-key-pair
:label (i18n/label :t/rename-key-pair)
:on-press on-rename-keypair}
{:icon :i/delete
{:blur? true
:icon :i/delete
:accessibility-label :remove-key-pair
:add-divider? true
:danger? true

View File

@ -11,13 +11,16 @@
[]
(let [keypairs-key-uids (rf/sub [:get-screen-params])
on-success-scan (rn/use-callback (fn [scanned-text]
(rf/dispatch [:wallet/success-keypair-qr-scan scanned-text
keypairs-key-uids])
(rf/dispatch [:wallet/success-keypair-qr-scan
scanned-text
keypairs-key-uids
[:navigate-back]])
[keypairs-key-uids]))]
[scan-qr-code/view
{:title (i18n/label :t/scan-key-pairs-qr-code)
:subtitle (i18n/label :t/find-it-in-setting)
:share-button? false
:import-keypair? true
:validate-fn sync-utils/valid-connection-string?
:error-message (i18n/label :t/invalid-qr)
:error-message (i18n/label :t/invalid-key-pair-qr)
:on-success-scan on-success-scan}]))

View File

@ -4,7 +4,8 @@
{:margin-bottom 8})
(def bottom-action
{:margin-horizontal -20})
{:margin-horizontal -20
:margin-vertical -12})
(def error-container
{:margin-left 20

View File

@ -2,6 +2,7 @@
(:require [clojure.string :as string]
[quo.core :as quo]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.common.floating-button-page.view :as floating-button-page]
[status-im.common.validation.keypair :as keypair-validator]
[status-im.constants :as constants]
@ -14,19 +15,24 @@
(defn view
[]
(let [{:keys [name key-uid]} (rf/sub [:get-screen-params])
(let [insets (safe-area/get-insets)
{existing-keypair-name :name
:keys [key-uid]} (rf/sub [:get-screen-params])
existing-keypair-names (rf/sub [:wallet/keypair-names])
customization-color (rf/sub [:profile/customization-color])
[unsaved-keypair-name set-unsaved-keypair-name] (rn/use-state name)
[unsaved-keypair-name set-unsaved-keypair-name] (rn/use-state existing-keypair-name)
[error-msg set-error-msg] (rn/use-state nil)
[typing? set-typing?] (rn/use-state false)
validate-keypair-name (rn/use-callback
(debounce/debounce
(fn [name]
(fn [input-name]
(set-error-msg
(keypair-validator/validation-keypair-name
name))
input-name
existing-keypair-names))
(set-typing? false))
300))
300)
[existing-keypair-names])
on-change-text (rn/use-callback (fn [text]
(set-typing? true)
(set-unsaved-keypair-name
@ -40,45 +46,57 @@
:keypair-name
unsaved-keypair-name}])
[unsaved-keypair-name key-uid])]
[floating-button-page/view
{:header [quo/page-nav
{:icon-name :i/close
:on-press navigate-back
:accessibility-label :top-bar}]
:footer [quo/bottom-actions
{:actions :one-action
:button-one-label (i18n/label :t/save)
:button-one-props {:disabled? (or typing?
(string/blank? unsaved-keypair-name)
(not (string/blank? error-msg)))
:customization-color customization-color
:on-press on-save}
:container-style style/bottom-action}]}
[quo/page-top
{:container-style style/header-container
:title (i18n/label :t/rename-key-pair)
:description :context-tag
:context-tag {:type :icon
:size 24
:context name
:icon :i/seed-phrase}}]
[quo/input
{:container-style {:margin-horizontal 20}
:placeholder (i18n/label :t/keypair-name-input-placeholder)
:label (i18n/label :t/keypair-name)
:default-value unsaved-keypair-name
:char-limit constants/key-pair-name-max-length
:max-length constants/key-pair-name-max-length
:auto-focus true
:clearable? (not (string/blank? unsaved-keypair-name))
:on-clear on-clear
:on-change-text on-change-text
:error? (not (string/blank? error-msg))}]
(when-not (string/blank? error-msg)
[quo/info-message
{:type :error
:size :default
:icon :i/info
:container-style style/error-container}
error-msg])]))
[quo/overlay {:type :shell}
[floating-button-page/view
{:footer-container-padding 0
:blur? true
:header [quo/page-nav
{:margin-top (:top insets)
:icon-name :i/close
:background :blur
:on-press navigate-back
:accessibility-label :top-bar}]
:footer [quo/bottom-actions
{:actions :one-action
:blur? true
:button-one-label (i18n/label :t/save)
:button-one-props {:blur? true
:disabled? (or typing?
(= existing-keypair-name
unsaved-keypair-name)
(string/blank?
unsaved-keypair-name)
(not (string/blank?
error-msg)))
:customization-color customization-color
:on-press on-save}
:container-style style/bottom-action}]}
[quo/page-top
{:container-style style/header-container
:title (i18n/label :t/rename-key-pair)
:description :context-tag
:blur? true
:context-tag {:type :icon
:size 24
:context existing-keypair-name
:icon :i/seed-phrase}}]
[quo/input
{:blur? true
:container-style {:margin-horizontal 20}
:placeholder (i18n/label :t/keypair-name-input-placeholder)
:label (i18n/label :t/keypair-name)
:default-value unsaved-keypair-name
:char-limit constants/key-pair-name-max-length
:auto-focus true
:clearable? (not (string/blank? unsaved-keypair-name))
:on-clear on-clear
:on-change-text on-change-text
:error? (not (string/blank? error-msg))}]
(when-not (string/blank? error-msg)
[quo/info-message
{:type :error
:size :default
:icon :i/info
:container-style style/error-container}
error-msg])]]))

View File

@ -1,11 +1,11 @@
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.view
(:require [quo.core :as quo]
[quo.foundations.colors :as colors]
[quo.theme]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.contexts.settings.wallet.keypairs-and-accounts.actions.view :as actions]
[status-im.contexts.settings.wallet.keypairs-and-accounts.style :as style]
[status-im.feature-flags :as ff]
[utils.address :as utils]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
@ -17,13 +17,12 @@
(defn on-options-press
[{:keys [drawer-props keypair]}]
(rf/dispatch [:show-bottom-sheet
{:content (fn [] [actions/view
{:drawer-props drawer-props
:keypair keypair}])
{:content (fn [] [actions/view
{:drawer-props drawer-props
:keypair keypair}])
:blur-background colors/bottom-sheet-background-blur
:theme (:theme drawer-props)
:shell? true}]))
:theme (:theme drawer-props)
:shell? true}]))
(defn options-drawer-props
[{{:keys [name]} :keypair
@ -70,7 +69,7 @@
{:blur? true
:status-indicator false
:stored :on-device
:action :options
:action (if default-keypair? :none :options)
:accounts accounts
:customization-color customization-color
:container-style style/keypair-container-style
@ -83,17 +82,16 @@
(defn on-missing-keypair-options-press
[_event keypair-data]
(rf/dispatch [:show-bottom-sheet
{:theme :dark
:shell? true
:blur-background colors/bottom-sheet-background-blur
:content (fn [] [actions/view
{:keypair keypair-data
:drawer-props (options-drawer-props
{:theme :dark
:type :keypair
:stored :missing
:blur? true
:keypair keypair-data})}])}]))
{:theme :dark
:shell? true
:content (fn [] [actions/view
{:keypair keypair-data
:drawer-props (options-drawer-props
{:theme :dark
:type :keypair
:stored :missing
:blur? true
:keypair keypair-data})}])}]))
(defn view
[]
@ -127,6 +125,7 @@
:header (when (seq missing-keypairs)
[quo/missing-keypairs
{:blur? true
:show-import-all? (ff/enabled? ::ff/settings.import-all-keypairs)
:keypairs missing-keypairs
:on-import-press on-import-press
:container-style style/missing-keypairs-container-style

View File

@ -1,6 +1,5 @@
(ns status-im.contexts.settings.wallet.network-settings.view
(:require [quo.core :as quo]
[quo.foundations.colors :as colors]
[quo.foundations.resources :as resources]
[quo.theme]
[react-native.core :as rn]
@ -80,12 +79,11 @@
(defn on-change-testnet
[{:keys [enable? blur? theme]}]
(rf/dispatch [:show-bottom-sheet
{:content (fn [] [testnet/view
{:enable? enable?
:blur? blur?}])
:theme theme
:shell? blur?
:blur-background colors/bottom-sheet-background-blur}]))
{:content (fn [] [testnet/view
{:enable? enable?
:blur? blur?}])
:theme theme
:shell? blur?}]))
(defn view
[]

View File

@ -27,4 +27,5 @@
{:color colors/white-opa-40})
(def saved-address-item
{:margin-top 4})
{:margin-top 4
:background-color colors/white-opa-5})

View File

@ -49,6 +49,7 @@
:multiline? true
:on-clear clear-input
:return-key-type :done
:auto-focus true
:clearable? (not empty-input?)
:on-change-text on-change-text
:button (when empty-input?
@ -83,7 +84,7 @@
[quo/info-message
{:accessibility-label :error-message
:size :default
:icon :i/info
:icon :i/alert
:type :error
:style style/info-message}
error-msg])))
@ -91,8 +92,7 @@
(defn- existing-saved-address
[{:keys [address]}]
(let [{:keys [name customization-color chain-short-names ens ens?]}
(rf/sub [:wallet/saved-address-by-address
address])]
(rf/sub [:wallet/saved-address-by-address address])]
[rn/view {:style style/existing-saved-address-container}
[quo/text
{:size :paragraph-1

View File

@ -93,20 +93,19 @@
:subtitle-type :default
:label :none
:blur? true
:icon-right? (not ens?)
:right-icon :i/advanced
:right-icon (when-not ens? :i/advanced)
:card? true
:title (i18n/label :t/address)
:subtitle ens
:custom-subtitle address-text
:on-press open-network-preferences
:on-press (when-not ens? open-network-preferences)
:container-style style/data-item}
ens?
(dissoc :custom-subtitle))
[ens ens? open-network-preferences address-text])]
[quo/overlay {:type :shell}
[floating-button-page/view
{:footer-container-padding 0
{:footer-container-padding (if edit? (+ (safe-area/get-bottom) 12) 0)
:header [quo/page-nav
{:type :no-title
:background :blur
@ -133,7 +132,7 @@
:container-style style/avatar}]
[quo/title-input
{:blur? true
:auto-focus true
:auto-focus (not edit?)
:max-length 24
:size :heading-1
:placeholder placeholder

View File

@ -2,20 +2,24 @@
(:require
[clojure.string :as string]
[quo.core :as quo]
[quo.foundations.colors :as colors]
[react-native.core :as rn]
[react-native.platform :as platform]
[status-im.constants :as constants]
[status-im.contexts.settings.wallet.saved-addresses.sheets.remove-address.view :as remove-address]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.common.utils.networks :as network-utils]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn view
[{:keys [name full-address chain-short-names address] :as opts}]
(let [open-send-flow (rn/use-callback
(let [[_ splitted-address] (network-utils/split-network-full-address address)
open-send-flow (rn/use-callback
#(rf/dispatch [:wallet/select-send-address
{:address full-address
:recipient full-address
:recipient {:label (utils/get-shortened-address
splitted-address)
:recipient-type :saved-address}
:stack-id :wallet-select-address
:start-flow? true}])
[full-address])
@ -52,11 +56,10 @@
open-remove-confirmation-sheet (rn/use-callback
#(rf/dispatch
[:show-bottom-sheet
{:theme :dark
:shell? true
:blur-background colors/bottom-sheet-background-blur
:content (fn []
[remove-address/view opts])}])
{:theme :dark
:shell? true
:content (fn []
[remove-address/view opts])}])
[opts])
open-show-address-qr (rn/use-callback
#(rf/dispatch [:open-modal

View File

@ -73,27 +73,34 @@
(defn- filtered-list
[{:keys [search-text]}]
[rn/flat-list
{:key-fn :address
:data (rf/sub [:wallet/filtered-saved-addresses search-text])
:render-fn saved-address
:shows-vertical-scroll-indicator false
:keyboard-should-persist-taps :always
:content-container-style {:flex-grow 1}
:empty-component [empty-result]}])
(let [search-result (rf/sub [:wallet/filtered-saved-addresses search-text])]
(if (empty? search-result)
[empty-result]
[rn/flat-list
{:key-fn :address
:data search-result
:render-fn saved-address
:shows-vertical-scroll-indicator false
:keyboard-should-persist-taps :always
:content-container-style {:flex-grow 1}
:bounces false
:over-scroll-mode :never}])))
(defn- unfiltered-list
[{:keys [grouped-saved-addresses]}]
[rn/section-list
{:key-fn :title
:shows-vertical-scroll-indicator false
:sticky-section-headers-enabled false
:keyboard-should-persist-taps :always
:render-section-header-fn header
:sections grouped-saved-addresses
:render-fn saved-address
:content-container-style {:flex-grow 1}
:empty-component [empty-list]}])
(if (empty? grouped-saved-addresses)
[empty-list]
[rn/section-list
{:key-fn :title
:shows-vertical-scroll-indicator false
:sticky-section-headers-enabled false
:keyboard-should-persist-taps :always
:render-section-header-fn header
:sections grouped-saved-addresses
:render-fn saved-address
:bounces false
:over-scroll-mode :never
:content-container-style {:flex-grow 1}}]))
(defn- navigate-back
[]

View File

@ -2,7 +2,6 @@
(:require [quo.core :as quo]
[react-native.safe-area :as safe-area]
[status-im.contexts.settings.wallet.wallet-options.style :as style]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
@ -16,16 +15,14 @@
(defn basic-settings-options
[]
[(when (ff/enabled? ::ff/settings.keypairs-and-accounts)
{:title (i18n/label :t/keypairs-and-accounts)
:blur? true
:on-press open-keypairs-and-accounts-settings-modal
:action :arrow})
(when (ff/enabled? ::ff/settings.saved-addresses)
{:title (i18n/label :t/saved-addresses)
:blur? true
:on-press open-saved-addresses-settings-modal
:action :arrow})])
[{:title (i18n/label :t/keypairs-and-accounts)
:blur? true
:on-press open-keypairs-and-accounts-settings-modal
:action :arrow}
{:title (i18n/label :t/saved-addresses)
:blur? true
:on-press open-saved-addresses-settings-modal
:action :arrow}])
(defn basic-settings
[]
@ -74,7 +71,5 @@
[quo/page-top
{:title (i18n/label :t/wallet)
:title-accessibility-label :wallet-settings-header}]
(when (or (ff/enabled? ::ff/settings.keypairs-and-accounts)
(ff/enabled? ::ff/settings.saved-addresses))
[basic-settings])
[basic-settings]
[advanced-settings]]))

View File

@ -1,26 +1,33 @@
(ns status-im.contexts.shell.qr-reader.sheets.scanned-wallet-address
(:require
[quo.core :as quo]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.common.utils.networks :as network-utils]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn view
[address]
[:<>
[quo/drawer-top
{:title address
:type :address}]
[quo/action-drawer
[[{:icon :i/send
:accessibility-label :send-asset
:label (i18n/label :t/send-to-this-address)
:on-press (fn []
(rf/dispatch [:wallet/select-send-address
{:address address
:recipient address
:stack-id :wallet-select-address
:start-flow? true}]))}
{:icon :i/save
:accessibility-label :save-address
:label (i18n/label :t/save-address)
:on-press #(js/alert "feature not implemented")}]]]])
(let [[_ splitted-address] (network-utils/split-network-full-address address)]
[:<>
[quo/drawer-top
{:title address
:type :address}]
[quo/action-drawer
[[{:icon :i/send
:accessibility-label :send-asset
:label (i18n/label :t/send-to-this-address)
:on-press (fn []
(rf/dispatch [:wallet/select-send-address
{:address address
:recipient {:recipient-type :address
:label (utils/get-shortened-address
splitted-address)}
:stack-id :wallet-select-address
:start-flow? true}]))}
(when (ff/enabled? :ff/wallet.saved-addresses)
{:icon :i/save
:accessibility-label :save-address
:label (i18n/label :t/save-address)
:on-press #(js/alert "feature not implemented")})]]]]))

View File

@ -124,7 +124,7 @@
:on-success on-success
:on-error (fn [error]
(log/error
"Failed to resolve next path derivation path"
"Failed to resolve next derivation path"
{:event :wallet/next-derivation-path
:method "accounts_resolveSuggestedPathForKeypair"
:error error
@ -191,7 +191,7 @@
(rf/reg-event-fx
:wallet/derive-address-and-add-account
(fn [_ [{:keys [password derived-from-address derivation-path account-preferences]}]]
(fn [_ [{:keys [password derived-from-address derivation-path account-preferences key-uid]}]]
{:fx [[:json-rpc/call
[{:method "wallet_getDerivedAddresses"
:params [(security/safe-unmask-data password)
@ -199,9 +199,10 @@
[derivation-path]]
:on-success (fn [[derived-account]]
(rf/dispatch [:wallet/add-account
(assoc account-preferences :password password)
(assoc account-preferences
:key-uid key-uid
:password password)
derived-account]))
:on-error #(log/info "Failed to get derived addresses"
derived-from-address
%)}]]]}))
:on-error [:wallet/log-rpc-error
{:event :wallet/derive-address-and-add-account
:params [derived-from-address [derivation-path]]}]}]]]}))

View File

@ -105,8 +105,7 @@
[quo/bottom-actions
{:actions :one-action
:button-one-label (i18n/label :t/confirm-account-origin)
:button-one-props {:disabled? (= selected-keypair selected-key-uid)
:customization-color customization-color
:button-one-props {:customization-color customization-color
:on-press #(rf/dispatch [:wallet/confirm-account-origin
selected-key-uid])}
:container-style style/bottom-action-container}]]))

View File

@ -48,7 +48,6 @@
:action-props {:on-press #(rf/dispatch [:standard-auth/authorize
{:on-auth-success on-auth-success
:auth-button-label (i18n/label :t/continue)}])
:button-text (i18n/label :t/edit)
:icon-left :i/face-id
:alignment :flex-start}
@ -70,7 +69,7 @@
:icon-only? true
:on-press #(rf/dispatch [:emoji-picker/open {:on-select on-select-emoji}])
:container-style style/reaction-button-container}
:i/reaction]])
:i/edit]])
(defn- input
[_]
@ -217,6 +216,7 @@
[:wallet/derive-address-and-add-account
{:password password
:derived-from-address derived-from
:key-uid key-uid
:derivation-path @derivation-path
:account-preferences preferences}])))
[derived-from])]
@ -231,7 +231,7 @@
{:account-color @account-color
:slide-button-props {:on-auth-success on-auth-success
:disabled? (or (empty? @account-name)
(= "" @derivation-path)
(string/blank? @derivation-path)
(some? error))}}
[avatar
{:account-color @account-color

View File

@ -4,7 +4,6 @@
[status-im.contexts.wallet.sheets.account-options.view :as account-options]
[status-im.contexts.wallet.sheets.network-filter.view :as network-filter]
[status-im.contexts.wallet.sheets.select-account.view :as select-account]
[status-im.feature-flags :as ff]
[utils.re-frame :as rf]))
(defn get-bottom-sheet-args
@ -37,7 +36,7 @@
:networks networks
:align-center? true
:networks-on-press #(rf/dispatch [:show-bottom-sheet {:content network-filter/view}])
:right-side [(when (and (ff/enabled? ::ff/wallet.wallet-connect)
:right-side [(when (and true
(not watch-only?))
{:icon-name :i/dapps
:on-press #(rf/dispatch [:navigate-to :screen/wallet.connected-dapps])})

View File

@ -28,7 +28,7 @@
(let [{:keys [on-result]} (rf/sub [:get-screen-params])]
[scan-qr-code/view
{:title (i18n/label :t/scan-qr)
:subtitle (i18n/label :t/scan-an-account-qr-code)
:subtitle (i18n/label :t/scan-an-address-qr-code)
:error-message (i18n/label :t/oops-this-qr-does-not-contain-an-address)
:validate-fn #(contains-supported-address? %)
:on-success-scan (fn [result]

View File

@ -49,7 +49,7 @@
:icon-only? true
:on-press #(rf/dispatch [:emoji-picker/open {:on-select on-change-emoji}])
:container-style style/reaction-button-container}
:i/reaction]]
:i/edit]]
[rn/view
[quo/title-input

View File

@ -220,7 +220,7 @@
(defn make-network-item
"This function generates props for quo/category component item"
[{:keys [network-name color on-change networks state label-props type]}]
[{:keys [network-name color on-change networks state label-props type blur?]}]
(cond-> {:title (string/capitalize (name network-name))
:image :icon-avatar
:image-props {:icon (resources/get-network network-name)
@ -230,6 +230,7 @@
(if (= :default state)
:filled-checkbox
:checkbox))
:blur? blur?
:customization-color color
:checked? (contains? networks network-name)
:on-change on-change}}
@ -271,6 +272,14 @@
%)
address-tokens)))
(defn get-shortened-address
"Takes first and last 4 digits from address including leading 0x
and adds unicode ellipsis in between"
[address]
(when address
(let [counter (count address)]
(str (subs address 0 6) "\u2026" (subs address (- counter 3) counter)))))
(defn make-limit-label-crypto
[amount currency]
(str amount

View File

@ -1,5 +1,6 @@
(ns status-im.contexts.wallet.common.utils.networks
(:require [clojure.string :as string]
[quo.foundations.resources :as resources]
[status-im.constants :as constants]
[utils.number]))
@ -141,3 +142,47 @@
(let [token-networks-ids (mapv #(:chain-id %) token-networks)
token-networks-ids-set (set token-networks-ids)]
(contains? token-networks-ids-set chain-id)))
(defn split-network-full-address
[address]
(as-> address $
(string/split $ ":")
[(butlast $) (last $)]))
(def mainnet-network-details
{:source (resources/get-network constants/mainnet-network-name)
:short-name constants/mainnet-short-name
:full-name constants/mainnet-full-name
:network-name constants/mainnet-network-name
:abbreviated-name constants/mainnet-abbreviated-name})
(def arbitrum-network-details
{:source (resources/get-network constants/arbitrum-network-name)
:short-name constants/arbitrum-short-name
:full-name constants/arbitrum-full-name
:network-name constants/arbitrum-network-name
:abbreviated-name constants/arbitrum-abbreviated-name})
(def optimism-network-details
{:source (resources/get-network constants/optimism-network-name)
:short-name constants/optimism-short-name
:full-name constants/optimism-full-name
:network-name constants/optimism-network-name
:abbreviated-name constants/optimism-abbreviated-name})
(defn get-network-details
[chain-id]
(condp contains? chain-id
#{constants/ethereum-mainnet-chain-id constants/ethereum-goerli-chain-id
constants/ethereum-sepolia-chain-id}
mainnet-network-details
#{constants/arbitrum-mainnet-chain-id constants/arbitrum-goerli-chain-id
constants/arbitrum-sepolia-chain-id}
arbitrum-network-details
#{constants/optimism-mainnet-chain-id constants/optimism-goerli-chain-id
constants/optimism-sepolia-chain-id}
optimism-network-details
nil))

View File

@ -73,7 +73,7 @@
(fn [resolver rejecter]
(json-rpc/call {:method "accounts_makeSeedPhraseKeypairFullyOperable"
:params [(security/safe-unmask-data mnemonic)
(-> password security/safe-unmask-data native-module/sha3)]
(security/safe-unmask-data password)]
:on-error (fn [error]
(rejecter (ex-info (str error) {:error error})))
:on-success (fn [value]

View File

@ -215,13 +215,12 @@
[:dispatch [:wallet/clear-create-account]]]}))
(rf/reg-event-fx :wallet/add-account
(fn [{:keys [db]}
[{:keys [password account-name emoji color type]
(fn [_
[{:keys [key-uid password account-name emoji color type]
:or {type :generated}}
{:keys [public-key address path] :as _derived-account}]]
(let [lowercase-address (some-> address
(string/lower-case))
key-uid (get-in db [:wallet :ui :create-account :selected-keypair-uid])
string/lower-case)
account-config {:key-uid (when (= type :generated) key-uid)
:wallet false
:chat false
@ -529,18 +528,17 @@
:wallet/process-keypair-from-backup
(fn [{:keys [db]} [{:keys [backedUpKeypair]}]]
(let [{:keys [key-uid accounts]} backedUpKeypair
updated-keypairs (assoc-in db
[:wallet :keypairs key-uid]
(data-store/rpc->keypair backedUpKeypair))
accounts-fx (mapv (fn [{:keys [chat] :as account}]
;; We exclude the chat account from the profile keypair
;; for fetching the assets
(when-not chat
[:dispatch
[:wallet/process-account-from-signal
account]]))
accounts)]
{:db (assoc-in db [:wallet :keypairs] updated-keypairs)
accounts-fx
(mapv (fn [{:keys [chat] :as account}]
;; We exclude the chat account from the profile keypair for fetching the assets
(when-not chat
[:dispatch
[:wallet/process-account-from-signal
account]]))
accounts)]
{:db (assoc-in db
[:wallet :keypairs key-uid]
(data-store/rpc->keypair backedUpKeypair))
:fx accounts-fx})))
(rf/reg-event-fx

View File

@ -205,21 +205,22 @@
token-networks-ids (mapv #(:chain-id %) token-networks)
token-not-supported-in-receiver-networks? (not-any? (set receiver-networks)
token-networks-ids)]
{:db (cond-> db
:always (update-in [:wallet :ui :send] dissoc :collectible)
:always (assoc-in [:wallet :ui :send :token-display-name]
(:symbol token))
:always (assoc-in
[:wallet :ui :send :token-not-supported-in-receiver-networks?]
token-not-supported-in-receiver-networks?)
token (assoc-in [:wallet :ui :send :token] token)
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol))
:fx [[:dispatch [:wallet/clean-suggested-routes]]
[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-send-flow}]]]})))
(when (or token token-symbol)
{:db (cond-> db
:always (update-in [:wallet :ui :send] dissoc :collectible)
:always (assoc-in
[:wallet :ui :send :token-not-supported-in-receiver-networks?]
token-not-supported-in-receiver-networks?)
token (assoc-in [:wallet :ui :send :token] token)
token (assoc-in [:wallet :ui :send :token-display-name]
(:symbol token))
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol))
:fx [[:dispatch [:wallet/clean-suggested-routes]]
[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-send-flow}]]]}))))
(rf/reg-event-fx
:wallet/edit-token-to-send

View File

@ -0,0 +1,165 @@
(ns status-im.contexts.wallet.send.events-test
(:require
[cljs.test :refer-macros [is testing]]
[re-frame.db :as rf-db]
status-im.contexts.wallet.send.events
[test-helpers.unit :as h]))
(h/deftest-event :wallet/update-receiver-networks
[event-id dispatch]
(testing "reciever networks changed"
(let [selected-networks-before [:ethereum :optimism :arbitrum]
selected-networks-after [:ethereum :optimism]
expected-db {:wallet {:ui {:send {:receiver-networks selected-networks-after}}}}]
(reset! rf-db/app-db {:wallet {:ui {:send {:receiver-networks selected-networks-before}}}})
(is (match? expected-db (:db (dispatch [event-id selected-networks-after]))))))
(testing "if receiver network removed, it is also removed from disabled ones"
(let [selected-networks-before [:ethereum :optimism :arbitrum]
selected-networks-after [:ethereum :optimism]
disabled-from-chain-ids-before [:optimism :arbitrum]
disabled-from-chain-ids-after [:optimism]
expected-db {:wallet {:ui {:send {:receiver-networks selected-networks-after
:disabled-from-chain-ids
disabled-from-chain-ids-after}}}}]
(reset! rf-db/app-db {:wallet {:ui {:send {:receiver-networks selected-networks-before
:disabled-from-chain-ids
disabled-from-chain-ids-before}}}})
(is (match? expected-db (:db (dispatch [event-id selected-networks-after])))))))
(h/deftest-event :wallet/set-token-to-send
[event-id dispatch]
(let [token-symbol "ETH"
token {:symbol "ETH"
:name "Ether"
:networks #{{:chain-id 421614}
{:chain-id 11155420}
{:chain-id 11155111}}}
receiver-networks [421614 11155420]]
(testing "can be called with :token"
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks}}}}
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
:token-not-supported-in-receiver-networks? false}}}}
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id {:token token}])]
(is (match? expected-db (:db result)))))
(testing "can be called with :token-symbol"
(testing "can be called with :token"
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks}}}}
expected-db {:wallet {:ui {:send {:token-symbol token-symbol
:token-not-supported-in-receiver-networks? true}}}}
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id {:token-symbol token-symbol}])]
(is (match? expected-db (:db result))))))
(testing "shouldn't have changes if called without :token or :token-symbol")
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks}}}}
expected-db nil
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id {}])]
(is (match? expected-db (:db result))))
(testing "should clean :collectible set"
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks
:collectible "some-collectible"}}}}
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
:token-not-supported-in-receiver-networks? false}}}}
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id {:token token}])]
(is (match? expected-db (:db result)))
(is (match? nil (get-in result [:db :wallet :ui :send :collectible])))))
(testing "should set :token-not-supported-in-receiver-networks?"
(let [initial-db {:wallet {:ui {:send {:receiver-networks []}}}}
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
:token-not-supported-in-receiver-networks? true}}}}
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id {:token token}])]
(is (match? expected-db (:db result)))))))
(h/deftest-event :wallet/edit-token-to-send
[event-id dispatch]
(let [token-symbol "ETH"
token {:symbol "ETH"
:name "Ether"
:networks #{{:chain-id 421614}
{:chain-id 11155420}
{:chain-id 11155111}}}
receiver-networks [421614 11155420]]
(testing "can be called with :token"
(let [initial-db {:wallet {:ui {:send {:receiver-networks receiver-networks
:token-display-name "DAI"
:token-not-supported-in-receiver-networks? true}}}}
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
:token-not-supported-in-receiver-networks? false}}}}
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id token])]
(is (match? expected-db (:db result)))))
(testing "should set :token-not-supported-in-receiver-networks?"
(let [initial-db {:wallet {:ui {:send {:receiver-networks []
:token-display-name "DAI"
:token-not-supported-in-receiver-networks? false}}}}
expected-db {:wallet {:ui {:send {:token-display-name token-symbol
:token-not-supported-in-receiver-networks? true}}}}
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id token])]
(is (match? expected-db (:db result)))))))
(h/deftest-event :wallet/set-collectible-to-send
[event-id dispatch]
(let
[collectible
{:data-type 2
:id
{:contract-id
{:chain-id 11155111
:address "0x1ed60fedff775d500dde21a974cd4e92e0047cc8"}
:token-id "15"}
:contract-type 3
:collectible-data
{:name "DOG #1"
:description
"dogs are cute and this one is the cutestdogs are cute and this one is the cutest"}
:collection-data
{:name "ERC-1155 Faucet"}
:ownership
[{:address "0xf90014b2027e584fc96e6f6c8078998fe46c5ccb"
:balance "1"
:tx-timestamp 1710331776}]
:preview-url
{:uri
"https://ipfs.io/ipfs/bafybeie7b7g7iibpac4k6ydw4m5ivgqw5vov7oyzlf4v5zoor57wokmsxy/isolated-happy-smiling-dog-white-background-portrait-4_1562-693.avif"}}
initial-db {:wallet {:ui {:send {:token {:symbol "ETH"}}}}}
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id {:collectible collectible}])]
(testing ":collectible field assigned"
(is (match? collectible (get-in result [:db :wallet :ui :send :collectible]))))
(testing ":token should be removed"
(is (match? nil (get-in result [:db :wallet :ui :send :token]))))
(testing ":token-display-name assigned"
(is (match? "DOG #1" (get-in result [:db :wallet :ui :send :token-display-name]))))
(testing ":tx-type assigned"
(is (match? :tx/collectible-erc-1155 (get-in result [:db :wallet :ui :send :tx-type]))))
(testing "amount set if collectible was single"
(is (match? 1 (get-in result [:db :wallet :ui :send :amount]))))))
(h/deftest-event :wallet/set-collectible-amount-to-send
[event-id dispatch]
(let [initial-db {:wallet {:ui {:send nil}}}
expected-fx [[:dispatch [:wallet/get-suggested-routes {:amount 10}]]
[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen nil :flow-id :wallet-send-flow}]]]
amount 10
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id {:amount amount}])]
(testing "amount set"
(is (match? amount (get-in result [:db :wallet :ui :send :amount]))))
(testing "effects match"
(is (match? expected-fx (:fx result))))))
(h/deftest-event :wallet/set-token-amount-to-send
[event-id dispatch]
(let [initial-db {:wallet {:ui {:send {:token {:symbol "ETH"}}}}}
amount 10
_ (reset! rf-db/app-db initial-db)
result (dispatch [event-id {:amount amount}])]
(testing "amount set"
(is (match? amount (get-in result [:db :wallet :ui :send :amount]))))))

View File

@ -47,6 +47,7 @@
:network-name :mainnet
:abbreviated-name
"Eth."
:full-name "Mainnet"
:chain-id 1
:related-chain-id 1
:layer 1}]
@ -92,6 +93,7 @@
:short-name "eth"
:network-name :mainnet
:abbreviated-name "Eth."
:full-name "Mainnet"
:chain-id 1
:related-chain-id 1
:layer 1}]

View File

@ -15,6 +15,7 @@
[status-im.contexts.wallet.send.routes.view :as routes]
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
[status-im.contexts.wallet.sheets.unpreferred-networks-alert.view :as unpreferred-networks-alert]
[status-im.feature-flags :as ff]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
[utils.money :as money]
@ -24,16 +25,17 @@
(defn- estimated-fees
[{:keys [loading-routes? fees amount]}]
[rn/view {:style style/estimated-fees-container}
[rn/view {:style style/estimated-fees-content-container}
[quo/button
{:icon-only? true
:type :outline
:size 32
:inner-style {:opacity 1}
:accessibility-label :advanced-button
:disabled? loading-routes?
:on-press #(js/alert "Not implemented yet")}
:i/advanced]]
(when (ff/enabled? ::ff/wallet.advanced-sending)
[rn/view {:style style/estimated-fees-content-container}
[quo/button
{:icon-only? true
:type :outline
:size 32
:inner-style {:opacity 1}
:accessibility-label :advanced-button
:disabled? loading-routes?
:on-press #(js/alert "Not implemented yet")}
:i/advanced]])
[quo/data-item
{:container-style style/fees-data-item
:status (if loading-routes? :loading :default)
@ -376,7 +378,7 @@
sender-network-values
token-not-supported-in-receiver-networks?)
[token-not-available token-symbol receiver-networks token-networks])
(when (or loading-routes? route)
(when (and (not no-routes-found?) (or loading-routes? route))
[estimated-fees
{:loading-routes? loading-routes?
:fees fee-formatted

View File

@ -4,6 +4,7 @@
[quo.theme :as quo.theme]
[react-native.core :as rn]
[status-im.common.resources :as resources]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.send.select-address.tabs.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
@ -30,7 +31,10 @@
:full-address? true)
:on-press #(rf/dispatch [:wallet/select-send-address
{:address address
:recipient account
:recipient {:recipient-type :account
:label (:name account)
:customization-color (:color account)
:emoji (:emoji account)}
:stack-id :screen/wallet.select-address}])}])))])))
(defn- recent-transactions
@ -48,7 +52,9 @@
{:address address
:on-press #(rf/dispatch [:wallet/select-send-address
{:address address
:recipient address
:recipient {:label (utils/get-shortened-address
address)
:recipient-type :address}
:stack-id :screen/wallet.select-address}])}]))
recent-recipients))))
@ -59,7 +65,9 @@
#(rf/dispatch
[:wallet/select-send-address
{:address full-address
:recipient full-address
:recipient {:label name
:customization-color customization-color
:recipient-type :saved-address}
:stack-id :screen/wallet.select-address}])
[full-address])]
[quo/saved-address
@ -82,11 +90,12 @@
empty-state-component (rn/use-memo
(fn []
[quo/empty-state
{:title (i18n/label :t/no-saved-addresses)
:description (i18n/label
:t/you-like-to-type-43-characters)
:image (resources/get-themed-image :sweating-man
theme)}])
{:title (i18n/label :t/no-saved-addresses)
:description (i18n/label
:t/you-like-to-type-43-characters)
:container-style style/empty-container-style
:image (resources/get-themed-image :sweating-man
theme)}])
[theme])]
[rn/section-list
{:key-fn :title
@ -94,6 +103,7 @@
:render-section-header-fn section-header
:sections group-saved-addresses
:render-fn saved-address
:content-container-style {:flex 1}
:empty-component empty-state-component}]))
(defn view

View File

@ -1,5 +1,6 @@
(ns status-im.contexts.wallet.send.select-address.view
(:require
[clojure.string :as string]
[quo.core :as quo]
[quo.foundations.colors :as colors]
[quo.theme]
@ -9,6 +10,8 @@
[status-im.common.floating-button-page.view :as floating-button-page]
[status-im.constants :as constants]
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.common.utils.networks :as network-utils]
[status-im.contexts.wallet.common.validation :as validation]
[status-im.contexts.wallet.item-types :as types]
[status-im.contexts.wallet.send.select-address.style :as style]
@ -136,7 +139,34 @@
:keyboard-should-persist-taps :handled
:render-fn suggestion-component}]]))
(defn- f-view
(defn- footer
[input-value]
(let [local-suggestion-address (rf/sub [:wallet/local-suggestions->full-address])
color (rf/sub [:wallet/current-viewing-account-color])
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))]
[quo/button
{:accessibility-label :continue-button
:type :primary
:disabled? (not valid-ens-or-address?)
:on-press (fn []
(let [address (or
local-suggestion-address
input-value)
[_ splitted-address] (network-utils/split-network-full-address
address)]
(rf/dispatch
[:wallet/select-send-address
{:address address
:recipient {:label
(utils/get-shortened-address
splitted-address)
:recipient-type :address}
:stack-id
:screen/wallet.select-address}])))
:customization-color color}
(i18n/label :t/continue)]))
(defn view
[]
(let [on-close (fn []
(rf/dispatch [:wallet/clean-scanned-address])
@ -150,31 +180,18 @@
input-value (reagent/atom "")
input-focused? (reagent/atom false)]
(fn []
(let [selected-tab (or (rf/sub [:wallet/send-tab]) (:id (first tabs-data)))
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))
local-suggestion-address (rf/sub [:wallet/local-suggestions->full-address])
color (rf/sub [:wallet/current-viewing-account-color])]
(let [selected-tab (or (rf/sub [:wallet/send-tab]) (:id (first tabs-data)))
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))]
[floating-button-page/view
{:footer-container-padding 0
{:content-container-style {:flex 1}
:footer-container-padding 0
:keyboard-should-persist-taps true
:header [account-switcher/view
{:on-press on-close
:margin-top (safe-area/get-top)
:switcher-type :select-account}]
:footer (when (> (count @input-value) 0)
[quo/button
{:accessibility-label :continue-button
:type :primary
:disabled? (not valid-ens-or-address?)
:on-press #(rf/dispatch
[:wallet/select-send-address
{:address (or
local-suggestion-address
@input-value)
:stack-id
:screen/wallet.select-address}])
:customization-color color}
(i18n/label :t/continue)])}
:footer (when-not (string/blank? @input-value)
[footer @input-value])}
[quo/page-top
{:title (i18n/label :t/send-to)
:title-accessibility-label :title-label}]
@ -205,7 +222,3 @@
:scrollable? true
:on-change on-change-tab}]
[tabs/view {:selected-tab selected-tab}]])]))))
(defn view
[]
[:f> f-view])

View File

@ -1,22 +1,21 @@
(ns status-im.contexts.wallet.send.transaction-confirmation.view
(:require
[clojure.string :as string]
[legacy.status-im.utils.utils :as utils]
[quo.core :as quo]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.common.floating-button-page.view :as floating-button-page]
[status-im.common.standard-authentication.core :as standard-auth]
[status-im.contexts.wallet.common.utils.networks :as network-utils]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.send.transaction-confirmation.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]
[utils.security.core :as security]))
(defn- transaction-title
[{:keys [token-display-name amount account to-address route to-network image-url
transaction-type collectible?]}]
[{:keys [token-display-name amount account route to-network image-url transaction-type
collectible? recipient]}]
(let [to-network-name (:network-name to-network)
to-network-color (if (= to-network-name :mainnet) :ethereum to-network-name)]
[rn/view {:style style/content-container}
@ -107,9 +106,7 @@
:image-source (:source to-network)
:label (string/capitalize (name (:network-name to-network)))
:customization-color to-network-color}]
[quo/summary-tag
{:type :address
:label (utils/get-shortened-address to-address)}])]
[quo/summary-tag (assoc recipient :type (:recipient-type recipient))])]
(when (= transaction-type :tx/bridge)
[rn/view
{:style {:flex-direction :row
@ -127,20 +124,12 @@
:customization-color (:color account)}]])]))
(defn- user-summary
[{:keys [network-values token-display-name account-props theme label accessibility-label
summary-type]}]
(let [network-values (reduce-kv
(fn [acc chain-id amount]
(let [network-name (network-utils/id->network chain-id)
network-keyword (if (= network-name :mainnet)
:ethereum
network-name)]
(assoc acc
network-keyword
{:amount amount
:token-symbol token-display-name})))
{}
network-values)]
[{:keys [account-props theme label accessibility-label summary-type recipient account-to?]}]
(let [network-values (rf/sub [:wallet/network-values account-to?])
summary-info-type (case (:recipient-type recipient)
:saved-address :saved-account
:account :status-account
summary-type)]
[rn/view
{:style {:padding-horizontal 20
:padding-bottom 16}}
@ -151,10 +140,17 @@
:accessibility-label accessibility-label}
label]
[quo/summary-info
{:type summary-type
{:type summary-info-type
:networks? true
:values network-values
:account-props account-props}]]))
:account-props (cond-> account-props
account-to?
(assoc
:size 32
:name (:label recipient)
:full-name (:label recipient)
:emoji (:emoji recipient)
:customization-color (:customization-color recipient)))}]]))
(defn- data-item
[{:keys [title subtitle]}]
@ -202,39 +198,45 @@
[_]
(let [on-close #(rf/dispatch [:navigate-back])]
(fn []
(let [theme (quo.theme/use-theme)
send-transaction-data (rf/sub [:wallet/wallet-send])
{:keys [token-display-name collectible amount route
to-address bridge-to-chain-id
from-values-by-chain
to-values-by-chain]} send-transaction-data
collectible? (some? collectible)
image-url (when collectible
(get-in collectible [:preview-url :uri]))
transaction-type (:tx-type send-transaction-data)
estimated-time-min (reduce + (map :estimated-time route))
token-symbol (or token-display-name
(-> send-transaction-data :token :symbol))
first-route (first route)
native-currency-symbol (get-in first-route [:from :native-currency-symbol])
native-token (when native-currency-symbol
(rf/sub [:wallet/token-by-symbol native-currency-symbol]))
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted native-token])
account (rf/sub [:wallet/current-viewing-account])
account-color (:color account)
bridge-to-network (when bridge-to-chain-id
(rf/sub [:wallet/network-details-by-chain-id
bridge-to-chain-id]))
loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
from-account-props {:customization-color account-color
:size 32
:emoji (:emoji account)
:type :default
:name (:name account)
:address (utils/get-shortened-address (:address
account))}
user-props {:full-name to-address
:address (utils/get-shortened-address to-address)}]
(let [theme (quo.theme/use-theme)
send-transaction-data (rf/sub [:wallet/wallet-send])
{:keys [token-display-name collectible amount
route
to-address bridge-to-chain-id type
recipient]} send-transaction-data
collectible? (some? collectible)
image-url (when collectible
(get-in collectible [:preview-url :uri]))
transaction-type (:tx-type send-transaction-data)
estimated-time-min (reduce + (map :estimated-time route))
token-symbol (or token-display-name
(-> send-transaction-data :token :symbol))
first-route (first route)
native-currency-symbol (get-in first-route
[:from :native-currency-symbol])
native-token (when native-currency-symbol
(rf/sub [:wallet/token-by-symbol
native-currency-symbol]))
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted
native-token])
account (rf/sub [:wallet/current-viewing-account])
account-color (:color account)
bridge-to-network (when bridge-to-chain-id
(rf/sub [:wallet/network-details-by-chain-id
bridge-to-chain-id]))
loading-suggested-routes? (rf/sub
[:wallet/wallet-send-loading-suggested-routes?])
from-account-props {:customization-color account-color
:size 32
:emoji (:emoji account)
:type :default
:name (:name account)
:address (utils/get-shortened-address
(:address
account))}
user-props {:full-name to-address
:address (utils/get-shortened-address
to-address)}]
[rn/view {:style {:flex 1}}
[floating-button-page/view
{:footer-container-padding 0
@ -274,23 +276,21 @@
{:token-display-name token-symbol
:amount amount
:account account
:to-address to-address
:type type
:recipient recipient
:route route
:to-network bridge-to-network
:image-url image-url
:transaction-type transaction-type
:collectible? collectible?}]
[user-summary
{:token-display-name token-symbol
:summary-type :status-account
{:summary-type :status-account
:accessibility-label :summary-from-label
:label (i18n/label :t/from-capitalized)
:network-values from-values-by-chain
:account-props from-account-props
:theme theme}]
[user-summary
{:token-display-name token-symbol
:summary-type (if (= transaction-type :tx/bridge)
{:summary-type (if (= transaction-type :tx/bridge)
:status-account
:account)
:accessibility-label :summary-to-label
@ -298,5 +298,6 @@
:account-props (if (= transaction-type :tx/bridge)
from-account-props
user-props)
:network-values to-values-by-chain
:recipient recipient
:account-to? true
:theme theme}]]]]))))

View File

@ -90,10 +90,7 @@
:address address
:blur? blur?
:format :long}])
:container-style (merge style/data-item
{:background-color (colors/theme-colors colors/neutral-2_5
colors/neutral-90
theme)})}])
:container-style style/data-item}])
[quo/category
{:list-type :settings
:blur? blur?
@ -106,6 +103,7 @@
:normal-checkbox? receiver?
:networks (get-current-preferences-names)
:type :checkbox
:blur? blur?
:on-change (fn []
(toggle-network (:network-name
network))
@ -137,6 +135,7 @@
:normal-checkbox? receiver?
:networks (get-current-preferences-names)
:type :checkbox
:blur? blur?
:on-change (fn []
(toggle-network (:network-name
network))

View File

@ -1,8 +1,19 @@
(ns status-im.contexts.wallet.wallet-connect.core
(:require [native-module.core :as native-module]
(:require [clojure.edn :as edn]
[clojure.string :as string]
[native-module.core :as native-module]
[status-im.constants :as constants]
[utils.security.core :as security]
[utils.transforms :as transforms]))
(def method-to-screen
{constants/wallet-connect-personal-sign-method :screen/wallet-connect.sign-message
constants/wallet-connect-eth-sign-typed-method :screen/wallet-connect.sign-message
constants/wallet-connect-eth-sign-method :screen/wallet-connect.sign-message
constants/wallet-connect-eth-sign-typed-v4-method :screen/wallet-connect.sign-message
constants/wallet-connect-eth-send-transaction-method :screen/wallet-connect.send-transaction
constants/wallet-connect-eth-sign-transaction-method :screen/wallet-connect.sign-transaction})
(defn extract-native-call-signature
[data]
(-> data transforms/json->clj :result))
@ -11,6 +22,13 @@
[chain-id]
(str "eip155:" chain-id))
(defn eip155->chain-id
[chain-id-str]
(-> chain-id-str
(string/split #":")
last
edn/read-string))
(defn format-eip155-address
[address chain-id]
(str chain-id ":" address))
@ -23,9 +41,14 @@
[event]
(get-in event [:params :request :params]))
(defn get-db-current-request-event
[db]
(get-in db [:wallet-connect/current-request :event]))
(defn get-db-current-request-params
[db]
(-> (get-in db [:wallet-connect/current-request :event])
(-> db
get-db-current-request-event
get-request-params))
(def ^:private sign-typed-data-by-version

View File

@ -70,7 +70,7 @@
{:db (dissoc db :wallet-connect/current-proposal)}))
(rf/reg-event-fx
:wallet-connect/reset-current-session-request
:wallet-connect/reset-current-request
(fn [{:keys [db]}]
{:db (dissoc db :wallet-connect/current-request)}))
@ -107,12 +107,6 @@
:on-fail #(log/error "Failed to pair with dApp" {:error %})
:on-success #(log/info "dApp paired successfully")}]]})))
(rf/reg-event-fx
:wallet-connect/close-session-request
(fn [_ _]
{:fx [[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]
[:dispatch [:wallet-connect/reset-current-session-request]]]}))
(rf/reg-event-fx
:wallet-connect/fetch-active-sessions
(fn [{:keys [db]}]

View File

@ -0,0 +1,8 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.data-block.view
(:require [status-im.common.raw-data-block.view :as raw-data-block]
[utils.re-frame :as rf]))
(defn view
[]
(let [display-data (rf/sub [:wallet-connect/current-request-display-data])]
[raw-data-block/view display-data]))

View File

@ -0,0 +1,18 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.footer.style)
(def content-container
{:padding-horizontal 20})
(def data-items-container
{:flex-direction :row
:padding-top 12
:padding-bottom 4
:gap 16})
(def auth-container
{:height 48
:margin-vertical 12})
(def warning-container
{:align-items :center
:margin-bottom 12})

View File

@ -0,0 +1,35 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.footer.view
(:require [quo.core :as quo]
[quo.foundations.colors :as colors]
[react-native.core :as rn]
[status-im.common.standard-authentication.core :as standard-authentication]
[status-im.contexts.wallet.wallet-connect.modals.common.footer.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn- on-auth-success
[password]
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:wallet-connect/respond-current-session password]))
(defn view
[{:keys [warning-label slide-button-text disabed?]} & children]
(let [{:keys [customization-color]} (rf/sub [:wallet-connect/current-request-account-details])]
[rn/view {:style style/content-container}
(into [rn/view
{:style style/data-items-container}]
children)
[rn/view {:style style/auth-container}
[standard-authentication/slide-button
{:size :size-48
:track-text slide-button-text
:disabled? disabed?
:customization-color customization-color
:on-auth-success on-auth-success
:auth-button-label (i18n/label :t/confirm)}]]
[rn/view {:style style/warning-container}
[quo/text
{:size :paragraph-2
:style {:color colors/neutral-80-opa-70}
:weight :medium}
warning-label]]]))

View File

@ -0,0 +1,10 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.header.style)
(def header-container
{:padding-vertical 12})
(def header-dapp-name
{:margin-top -4})
(def header-account-name
{:padding-top 4})

View File

@ -0,0 +1,26 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.header.view
(:require [quo.core :as quo]
[react-native.core :as rn]
[status-im.contexts.wallet.wallet-connect.modals.common.header.style :as style]))
(defn view
[{:keys [label dapp account]}]
[rn/view
{:style style/header-container}
[quo/text
{:size :heading-1
:weight :semi-bold}
(let [{:keys [name icons]} (:peerMetadata dapp)]
[rn/view {:style style/header-dapp-name}
[quo/summary-tag
{:type :dapp
:label name
:image-source (first icons)}]])
(str " " label " ")
(let [{:keys [emoji customization-color name]} account]
[rn/view {:style style/header-account-name}
[quo/summary-tag
{:type :account
:emoji emoji
:label name
:customization-color customization-color}]])]])

View File

@ -0,0 +1,23 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.style
(:require [status-im.constants :as constants]))
(defn container
[bottom]
{:position :absolute
:bottom bottom
:top 0
:left 0
:right 0
:padding-top constants/sheet-screen-handle-height})
(def data-content-container
{:flex 1
:padding-horizontal 20})
(def sign-message-content-container
(merge data-content-container
{:margin-bottom 10.5}))
(def data-item
{:flex 1
:background-color :transparent})

View File

@ -0,0 +1,63 @@
(ns status-im.contexts.wallet.wallet-connect.modals.send-transaction.view
(:require [quo.core :as quo]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.contexts.wallet.wallet-connect.modals.common.data-block.view :as data-block]
[status-im.contexts.wallet.wallet-connect.modals.common.footer.view :as footer]
[status-im.contexts.wallet.wallet-connect.modals.common.header.view :as header]
[status-im.contexts.wallet.wallet-connect.modals.common.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn view
[]
(let [bottom (safe-area/get-bottom)
{:keys [customization-color]
:as account} (rf/sub [:wallet-connect/current-request-account-details])
dapp (rf/sub [:wallet-connect/current-request-dapp])
network (rf/sub [:wallet-connect/current-request-network])
{:keys [max-fees-fiat-formatted
error-state]} (rf/sub [:wallet-connect/current-request-transaction-information])]
[rn/view {:style (style/container bottom)}
[quo/gradient-cover {:customization-color customization-color}]
[quo/page-nav
{:icon-name :i/close
:background :blur
:on-press #(rf/dispatch [:navigate-back])
:accessibility-label :wallet-connect-sign-message-close}]
[rn/view {:flex 1}
[rn/view {:style style/data-content-container}
[header/view
{:label (i18n/label :t/wallet-connect-send-transaction-header)
:dapp dapp
:account account}]
[data-block/view]]
(when error-state
[quo/alert-banner
{:action? false
:text (i18n/label (condp = error-state
:not-enough-assets-to-pay-gas-fees
:t/not-enough-assets-to-pay-gas-fees
:not-enough-assets
:t/not-enough-assets))}])
[footer/view
{:warning-label (i18n/label :t/wallet-connect-send-transaction-warning)
:slide-button-text (i18n/label :t/slide-to-send)
:disabled? error-state}
[quo/data-item
{:status :default
:card? false
:container-style style/data-item
:title (i18n/label :t/network)
:subtitle-type :network
:network-image (:source network)
:subtitle (:full-name network)}]
[quo/data-item
{:size :small
:status :default
:card? false
:container-style style/data-item
:title (i18n/label :t/max-fees)
:subtitle (or max-fees-fiat-formatted (i18n/label :t/no-fees))}]]]]))

View File

@ -0,0 +1,42 @@
(ns status-im.contexts.wallet.wallet-connect.modals.sign-message.view
(:require [quo.core :as quo]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.contexts.wallet.wallet-connect.modals.common.data-block.view :as data-block]
[status-im.contexts.wallet.wallet-connect.modals.common.footer.view :as footer]
[status-im.contexts.wallet.wallet-connect.modals.common.header.view :as header]
[status-im.contexts.wallet.wallet-connect.modals.common.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn view
[]
(let [bottom (safe-area/get-bottom)
{:keys [customization-color]
:as account} (rf/sub [:wallet-connect/current-request-account-details])
dapp (rf/sub [:wallet-connect/current-request-dapp])]
[rn/view {:style (style/container bottom)}
[quo/gradient-cover {:customization-color customization-color}]
[quo/page-nav
{:icon-name :i/close
:background :blur
:on-press #(rf/dispatch [:navigate-back])
:accessibility-label :wallet-connect-sign-message-close}]
[rn/view {:flex 1}
[rn/view {:style style/sign-message-content-container}
[header/view
{:label (i18n/label :t/wallet-connect-sign-message-header)
:dapp dapp
:account account}]
[data-block/view]]
[footer/view
{:warning-label (i18n/label :t/wallet-connect-sign-message-warning)
:slide-button-text (i18n/label :t/slide-to-sign)}
[quo/data-item
{:size :small
:status :default
:card? false
:container-style style/data-item
:title (i18n/label :t/max-fees)
:subtitle (i18n/label :t/no-fees)}]]]]))

View File

@ -0,0 +1,63 @@
(ns status-im.contexts.wallet.wallet-connect.modals.sign-transaction.view
(:require [quo.core :as quo]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.contexts.wallet.wallet-connect.modals.common.data-block.view :as data-block]
[status-im.contexts.wallet.wallet-connect.modals.common.footer.view :as footer]
[status-im.contexts.wallet.wallet-connect.modals.common.header.view :as header]
[status-im.contexts.wallet.wallet-connect.modals.common.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn view
[]
(let [bottom (safe-area/get-bottom)
{:keys [customization-color]
:as account} (rf/sub [:wallet-connect/current-request-account-details])
dapp (rf/sub [:wallet-connect/current-request-dapp])
network (rf/sub [:wallet-connect/current-request-network])
{:keys [max-fees-fiat-formatted
error-state]} (rf/sub [:wallet-connect/current-request-transaction-information])]
[rn/view {:style (style/container bottom)}
[quo/gradient-cover {:customization-color customization-color}]
[quo/page-nav
{:icon-name :i/close
:background :blur
:on-press #(rf/dispatch [:navigate-back])
:accessibility-label :wallet-connect-sign-message-close}]
[rn/view {:flex 1}
[rn/view {:style style/data-content-container}
[header/view
{:label (i18n/label :t/wallet-connect-sign-transaction-header)
:dapp dapp
:account account}]
[data-block/view]]
(when error-state
[quo/alert-banner
{:action? false
:text (i18n/label (condp = error-state
:not-enough-assets-to-pay-gas-fees
:t/not-enough-assets-to-pay-gas-fees
:not-enough-assets
:t/not-enough-assets))}])
[footer/view
{:warning-label (i18n/label :t/wallet-connect-sign-transaction-warning)
:slide-button-text (i18n/label :t/slide-to-sign)
:disabled? error-state}
[quo/data-item
{:status :default
:card? false
:container-style style/data-item
:title (i18n/label :t/network)
:subtitle-type :network
:network-image (:source network)
:subtitle (:full-name network)}]
[quo/data-item
{:size :small
:status :default
:card? false
:container-style style/data-item
:title (i18n/label :t/max-fees)
:subtitle (or max-fees-fiat-formatted (i18n/label :t/no-fees))}]]]]))

View File

@ -6,31 +6,32 @@
[taoensso.timbre :as log]
[utils.transforms :as transforms]))
(def ^:private method-to-screen
{constants/wallet-connect-personal-sign-method :screen/wallet-connect.sign-message
constants/wallet-connect-eth-sign-typed-method :screen/wallet-connect.sign-message
constants/wallet-connect-eth-sign-method :screen/wallet-connect.sign-message
constants/wallet-connect-eth-sign-typed-v4-method :screen/wallet-connect.sign-message})
(rf/reg-event-fx
:wallet-connect/process-session-request
(fn [{:keys [db]} [event]]
(let [method (wallet-connect-core/get-request-method event)
screen (method-to-screen method)]
screen (wallet-connect-core/method-to-screen method)]
(if screen
{:db (assoc-in db [:wallet-connect/current-request :event] event)
:fx [(condp = method
constants/wallet-connect-personal-sign-method
[:dispatch [:wallet-connect/process-personal-sign]]
constants/wallet-connect-eth-send-transaction-method
[:dispatch [:wallet-connect/process-eth-send-transaction]]
constants/wallet-connect-eth-sign-method
[:dispatch [:wallet-connect/process-eth-sign]]
constants/wallet-connect-eth-sign-transaction-method
[:dispatch [:wallet-connect/process-eth-sign-transaction]]
constants/wallet-connect-eth-sign-typed-method
[:dispatch [:wallet-connect/process-sign-typed]]
constants/wallet-connect-eth-sign-typed-v4-method
[:dispatch [:wallet-connect/process-sign-typed]])
[:dispatch [:wallet-connect/process-sign-typed]]
constants/wallet-connect-personal-sign-method
[:dispatch [:wallet-connect/process-personal-sign]])
[:dispatch [:open-modal screen]]]}
(log/error "Didn't find screen for Wallet Connect method"
{:method method
@ -60,6 +61,34 @@
:raw-data raw-data
:display-data (or parsed-data raw-data))})))
(rf/reg-event-fx
:wallet-connect/process-eth-send-transaction
(fn [{:keys [db]}]
(let [event (wallet-connect-core/get-db-current-request-event db)
display-data (-> event
clj->js
(js/JSON.stringify nil 2))
{:keys [to]} (-> event wallet-connect-core/get-request-params first)]
{:db (update-in db
[:wallet-connect/current-request]
assoc
:address to
:raw-data event
:display-data display-data)})))
(rf/reg-event-fx
:wallet-connect/process-eth-sign-transaction
(fn [{:keys [db]}]
(let [event (wallet-connect-core/get-db-current-request-event db)
display-data (.stringify js/JSON (clj->js event) nil 2)
{:keys [to]} (-> event wallet-connect-core/get-request-params first)]
{:db (update-in db
[:wallet-connect/current-request]
assoc
:address to
:raw-data event
:display-data display-data)})))
(rf/reg-event-fx
:wallet-connect/process-sign-typed
(fn [{:keys [db]}]

View File

@ -13,9 +13,19 @@
constants/wallet-connect-personal-sign-method
[:dispatch [:wallet-connect/respond-personal-sign password]]
constants/wallet-connect-eth-send-transaction-method
[:dispatch
[:wallet-connect/respond-build-transaction
#(rf/dispatch [:wallet-connect/respond-send-transaction-data password %])]]
constants/wallet-connect-eth-sign-method
[:dispatch [:wallet-connect/respond-eth-sign password]]
constants/wallet-connect-eth-sign-transaction-method
[:dispatch
[:wallet-connect/respond-build-transaction
#(rf/dispatch [:wallet-connect/respond-sign-transaction-data password %])]]
constants/wallet-connect-eth-sign-typed-method
[:dispatch [:wallet-connect/respond-sign-typed-data password :v1]]
@ -57,12 +67,50 @@
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
:on-success #(rf/dispatch [:wallet-connect/send-response %])}]]})))
(rf/reg-event-fx
:wallet-connect/respond-build-transaction
(fn [{:keys [db]} [on-success]]
(let [{:keys [raw-data]} (get db :wallet-connect/current-request)
chain-id (-> raw-data
(get-in [:params :chainId])
wallet-connect-core/eip155->chain-id)]
{:fx [[:json-rpc/call
[{:method "wallet_buildTransaction"
:params [chain-id (js/JSON.stringify raw-data)]
:on-success on-success
:on-error [:wallet-connect/on-sign-error]}]]]})))
(rf/reg-event-fx
:wallet-connect/respond-send-transaction-data
(fn [_ [password data]]
(let [{:keys [address]
message-to-sign :messageToSign} data]
{:fx [[:effects.wallet-connect/sign-message
{:password password
:address address
:data message-to-sign
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
:on-success #(rf/dispatch [:wallet-connect/send-response %])}]]})))
(rf/reg-event-fx
:wallet-connect/respond-sign-transaction-data
(fn [_ [password data]]
(let [{:keys [address]
message-to-sign :messageToSign} data]
{:fx [[:effects.wallet-connect/sign-message
{:password password
:address address
:data message-to-sign
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
:on-success #(rf/dispatch [:wallet-connect/send-response %])}]]})))
(rf/reg-event-fx
:wallet-connect/on-sign-error
(fn [{:keys [db]} [error]]
(let [event (get-in db [:wallet-connect/current-request :event])
{:keys [raw-data address]} (get db :wallet-connect/current-request)
method (wallet-connect-core/get-request-method event)]
method (wallet-connect-core/get-request-method event)
screen (wallet-connect-core/method-to-screen method)]
(log/error "Failed to sign Wallet Connect request"
{:error error
:address address
@ -70,7 +118,8 @@
:method method
:wallet-connect-event event
:event :wallet-connect/on-sign-error})
{:fx [[:dispatch [:wallet-connect/close-session-request]]]})))
{:fx [[:dispatch [:dismiss-modal screen]]
[:dispatch [:wallet-connect/reset-current-request]]]})))
(rf/reg-event-fx
@ -78,6 +127,7 @@
(fn [{:keys [db]} [result]]
(let [{:keys [id topic] :as event} (get-in db [:wallet-connect/current-request :event])
method (wallet-connect-core/get-request-method event)
screen (wallet-connect-core/method-to-screen method)
web3-wallet (get db :wallet-connect/web3-wallet)]
{:fx [[:effects.wallet-connect/respond-session-request
{:web3-wallet web3-wallet
@ -90,7 +140,9 @@
:method method
:event :wallet-connect/send-response
:wallet-connect-event event})
(rf/dispatch [:wallet-connect/close-session-request]))
(rf/dispatch [:dismiss-modal screen])
(rf/dispatch [:wallet-connect/reset-current-request]))
:on-success (fn []
(log/info "Successfully sent Wallet Connect response to dApp")
(rf/dispatch [:wallet-connect/close-session-request]))}]]})))
(rf/dispatch [:dismiss-modal screen])
(rf/dispatch [:wallet-connect/reset-current-request]))}]]})))

View File

@ -1,29 +0,0 @@
(ns status-im.contexts.wallet.wallet-connect.sign-message.style
(:require [quo.foundations.colors :as colors]
[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 content-container
{:flex 1
:padding-horizontal 20})
(def fees-container
{:padding-top 12
:padding-bottom 4
:background-color colors/white})
(def auth-container
{:height 48
:margin-vertical 12})
(def warning-container
{:align-items :center
:margin-bottom 12})

View File

@ -1,82 +0,0 @@
(ns status-im.contexts.wallet.wallet-connect.sign-message.view
(:require [quo.core :as quo]
[quo.foundations.colors :as colors]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.common.raw-data-block.view :as raw-data-block]
[status-im.common.standard-authentication.core :as standard-authentication]
[status-im.contexts.wallet.wallet-connect.sign-message.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn- close-sheet
[]
(rf/dispatch [:navigate-back]))
(defn- on-auth-success
[password]
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:wallet-connect/respond-current-session password]))
;; NOTE: this will be a reusable component
(defn- header
[{:keys [emoji customization-color name]}]
[rn/view
{:style {:padding-vertical 12}}
[quo/text
{:size :heading-1
:weight :semi-bold}
[rn/view {:style {:margin-top -4}}
[quo/summary-tag
{:label "dapp placeholder"}]]
(i18n/label :t/wallet-connect-sign-header)
[rn/view {:style {:padding-top 4}}
[quo/summary-tag
{:type :account
:emoji emoji
:label name
:customization-color customization-color}]]]])
(defn data-block
[]
(let [display-data (rf/sub [:wallet-connect/current-request-display-data])]
[raw-data-block/view {:data display-data}]))
(defn view
[]
(let [bottom (safe-area/get-bottom)
{:keys [name emoji customization-color]} (rf/sub
[:wallet-connect/current-request-account-details])]
[rn/view {:style (style/container bottom)}
[quo/gradient-cover {:customization-color customization-color}]
[quo/page-nav
{:icon-name :i/close
:background :blur
:on-press close-sheet
:accessibility-label :wallet-connect-sign-message-close}]
[rn/view {:style style/content-container}
[header
{:emoji emoji
:customization-color customization-color
:name name}]
[data-block]
[quo/data-item
{:size :small
:status :default
:card? false
:container-style style/fees-container
:title (i18n/label :t/max-fees)
:subtitle (i18n/label :t/no-fees)}]
[rn/view {:style style/auth-container}
[standard-authentication/slide-button
{:size :size-48
:track-text (i18n/label :t/slide-to-sign)
: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}
(i18n/label :t/wallet-connect-sign-warning)]]]]))

View File

@ -11,11 +11,10 @@
(def ^:private initial-flags
{::community.edit-account-selection (enabled-in-env? :FLAG_EDIT_ACCOUNT_SELECTION_ENABLED)
::settings.keypairs-and-accounts (enabled-in-env?
:FLAG_WALLET_SETTINGS_KEYPAIRS_AND_ACCOUNTS_ENABLED)
::settings.saved-addresses (enabled-in-env?
:FLAG_WALLET_SETTINGS_SAVED_ADDRESSES_ENABLED)
::settings.import-all-keypairs (enabled-in-env?
:FLAG_WALLET_SETTINGS_IMPORT_ALL_KEYPAIRS)
::shell.jump-to (enabled-in-env? :ENABLE_JUMP_TO)
::wallet.advanced-sending (enabled-in-env? :FLAG_ADVANCED_SENDING)
::wallet.assets-modal-hide (enabled-in-env? :FLAG_ASSETS_MODAL_HIDE)
::wallet.assets-modal-manage-tokens (enabled-in-env? :FLAG_ASSETS_MODAL_MANAGE_TOKENS)
::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED)
@ -24,6 +23,7 @@
::wallet.graph (enabled-in-env? :FLAG_GRAPH_ENABLED)
::wallet.import-private-key (enabled-in-env? :FLAG_IMPORT_PRIVATE_KEY_ENABLED)
::wallet.long-press-watch-only-asset (enabled-in-env? :FLAG_LONG_PRESS_WATCH_ONLY_ASSET_ENABLED)
::wallet.saved-addresses (enabled-in-env? :WALLET_SAVED_ADDRESSES)
::wallet.swap (enabled-in-env? :FLAG_SWAP_ENABLED)
::wallet.wallet-connect (enabled-in-env? :FLAG_WALLET_CONNECT_ENABLED)})

View File

@ -2,7 +2,6 @@
(:require
[quo.foundations.colors :as colors]
[quo.theme]
[react-native.core :as rn]
[react-native.navigation :as navigation]
[react-native.platform :as platform]
[react-native.share :as share]
@ -17,37 +16,36 @@
(defn get-status-nav-color
[view-id theme]
(let [theme (or (get-in views/screens [view-id :options :theme])
theme)
[rnn-status-bar rn-status-bar]
(if (or (= theme :dark)
@state/alert-banner-shown?
(and (= view-id :shell-stack) (not (jump-to.utils/home-stack-open?))))
[:light "light-content"]
[:dark "dark-content"])
home-stack? (some #(= view-id %) shell.constants/stacks-ids)
(let [theme (or (get-in views/screens [view-id :options :theme])
theme)
status-bar-theme (if (or (= theme :dark)
@state/alert-banner-shown?
(and (= view-id :shell-stack)
(not (jump-to.utils/home-stack-open?))))
:light
:dark)
home-stack? (some #(= view-id %) shell.constants/stacks-ids)
;; Home screen nav bar always dark due to bottom tabs
nav-bar-color (if (or home-stack?
(= view-id :shell-stack)
(= theme :dark))
colors/neutral-100
colors/white)
comp-id (if (or home-stack?
(jump-to.utils/shell-navigation? view-id)
(= view-id :shell))
:shell-stack
view-id)]
[rnn-status-bar rn-status-bar nav-bar-color comp-id]))
nav-bar-color (if (or home-stack?
(= view-id :shell-stack)
(= theme :dark))
colors/neutral-100
colors/white)
comp-id (if (or home-stack?
(jump-to.utils/shell-navigation? view-id)
(= view-id :shell))
:shell-stack
view-id)]
[status-bar-theme nav-bar-color comp-id]))
(defn reload-status-nav-color-fx
[[view-id theme]]
(when (and (= @state/root-id :shell-stack) view-id)
(let [[rnn-status-bar rn-status-bar nav-bar-color comp-id] (get-status-nav-color view-id theme)]
(if platform/ios?
(rn/set-status-bar-style rn-status-bar true)
(let [[status-bar-theme nav-bar-color comp-id] (get-status-nav-color view-id theme)]
(when platform/android?
(navigation/merge-options
(name comp-id)
{:statusBar {:style rnn-status-bar}
{:statusBar {:style status-bar-theme}
:navigationBar {:backgroundColor nav-bar-color}})))))
(rf/reg-fx :reload-status-nav-color-fx reload-status-nav-color-fx)
@ -72,8 +70,9 @@
;;;; Root
(rf/reg-fx :set-root
(fn [root-id]
(let [root (get (roots/roots) root-id)]
(fn [[root-id theme]]
(let [[status-bar-theme] (get-status-nav-color root-id theme)
root (get (roots/roots status-bar-theme) root-id)]
(dismiss-all-modals)
(rf/dispatch [:profile.settings/switch-theme
(get roots/themes root-id)
@ -212,9 +211,9 @@
(rf/reg-fx :show-toasts
(fn [[view-id theme]]
(let [[rnn-status-bar nav-bar-color] (get-status-nav-color view-id theme)]
(let [[status-bar-theme nav-bar-color] (get-status-nav-color view-id theme)]
(show-overlay "toasts"
(assoc (options/statusbar-and-navbar-options nil rnn-status-bar nav-bar-color)
(assoc (options/statusbar-and-navbar-options nil status-bar-theme nav-bar-color)
:overlay
{:interceptTouchOutside false})))))
@ -233,7 +232,10 @@
;;;; Alert Banner
(rf/reg-fx :show-alert-banner
(fn [[view-id theme]]
(show-overlay "alert-banner" {:overlay {:interceptTouchOutside false}})
(show-overlay "alert-banner"
(assoc (options/statusbar-and-navbar-options nil :light nil)
:overlay
{:interceptTouchOutside false}))
(reset! state/alert-banner-shown? true)
(reload-status-nav-color-fx [view-id theme])))

View File

@ -71,8 +71,8 @@
(rf/defn init-root
{:events [:init-root]}
[_ root-id]
{:set-root root-id})
[{:keys [db]} root-id]
{:set-root [root-id (:theme db)]})
(rf/defn set-stack-root
{:events [:set-stack-root]}

View File

@ -15,7 +15,7 @@
:shell-stack nil})
(defn roots-internal
[]
[status-bar-theme]
{:screen/onboarding.intro
{:root
{:stack {:id :screen/onboarding.intro
@ -28,7 +28,8 @@
:children [{:component {:name :shell-stack
:id :shell-stack
:options (options/root-options
{:nav-bar-color colors/neutral-100})}}]}}}
{:nav-bar-color colors/neutral-100
:status-bar-theme status-bar-theme})}}]}}}
:screen/profile.profiles
{:root
{:stack {:id :screen/profile.profiles
@ -51,17 +52,18 @@
:options (options/dark-root-options)}}]}}}})
(defn old-roots
[]
[status-bar-theme]
{:progress
{:root {:stack {:children [{:component {:name :progress
:id :progress
:options (options/root-options nil)}}]
:options (options/root-options {:status-bar-theme
status-bar-theme})}}]
:options (assoc (options/root-options nil)
:topBar
{:visible false})}}}})
(defn roots
[]
[status-bar-theme]
(merge
(old-roots)
(roots-internal)))
(old-roots status-bar-theme)
(roots-internal status-bar-theme)))

View File

@ -116,8 +116,12 @@
[status-im.contexts.wallet.send.transaction-confirmation.view :as wallet-transaction-confirmation]
[status-im.contexts.wallet.send.transaction-progress.view :as wallet-transaction-progress]
[status-im.contexts.wallet.swap.select-asset-to-pay.view :as wallet-swap-select-asset-to-pay]
[status-im.contexts.wallet.wallet-connect.modals.send-transaction.view :as
wallet-connect-send-transaction]
[status-im.contexts.wallet.wallet-connect.modals.sign-message.view :as wallet-connect-sign-message]
[status-im.contexts.wallet.wallet-connect.modals.sign-transaction.view :as
wallet-connect-sign-transaction]
[status-im.contexts.wallet.wallet-connect.session-proposal.view :as wallet-connect-session-proposal]
[status-im.contexts.wallet.wallet-connect.sign-message.view :as wallet-connect-sign-message]
[status-im.navigation.options :as options]
[status-im.navigation.transitions :as transitions]))
@ -531,6 +535,14 @@
:options {:sheet? true}
:component wallet-connect-sign-message/view}
{:name :screen/wallet-connect.sign-transaction
:options {:sheet? true}
:component wallet-connect-sign-transaction/view}
{:name :screen/wallet-connect.send-transaction
:options {:sheet? true}
:component wallet-connect-send-transaction/view}
;; Settings
{:name :screen/settings-password
@ -542,7 +554,7 @@
:component wallet-options/view}
{:name :screen/settings.rename-keypair
:options (assoc options/dark-screen :sheet? true)
:options options/transparent-screen-options
:component keypair-rename/view}
{:name :screen/settings.encrypted-keypair-qr
@ -558,7 +570,7 @@
:component keypairs-and-accounts/view}
{:name :screen/settings.scan-keypair-qr
:options options/transparent-modal-screen-options
:options options/transparent-screen-options
:component scan-keypair-qr/view}
{:name :screen/settings.missing-keypair.import-seed-phrase

View File

@ -1,6 +1,7 @@
(ns status-im.subs.communities
(:require
[clojure.string :as string]
[legacy.status-im.data-store.chats :as data-store.chats]
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
[re-frame.core :as re-frame]
[status-im.constants :as constants]
@ -49,6 +50,16 @@
(fn [[{:keys [members]}] _]
members))
(re-frame/reg-sub
:communities/community-chat-members
(fn [[_ community-id]]
[(re-frame/subscribe [:communities/community community-id])])
(fn [[{:keys [members chats]}] [_ _ chat-id]]
(let [channel-id (data-store.chats/community-chat-id->channel-id chat-id)]
(if (get-in chats [channel-id :token-gated?])
(get-in chats [channel-id :members])
members))))
(defn- keys->names
[public-keys profile]
(reduce (fn [acc contact-identity]
@ -80,10 +91,10 @@
(re-frame/reg-sub
:communities/sorted-community-members-section-list
(fn [[_ community-id]]
(fn [[_ community-id chat-id]]
(let [profile (re-frame/subscribe [:profile/profile])
members (re-frame/subscribe [:communities/community-members
community-id])
members (re-frame/subscribe [:communities/community-chat-members
community-id chat-id])
visibility-status-updates (re-frame/subscribe
[:visibility-status-updates])
my-status-update (re-frame/subscribe

View File

@ -10,7 +10,7 @@
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(def community-id "0x1")
(def community-id "0x02b5bdaf5a25fcfe2ee14c501fab1836b8de57f61621080c3d52073d16de0d98d6")
(h/deftest-sub :communities
[sub-name]
@ -461,32 +461,39 @@
[sub-name]
(testing "returns sorted community members per online status"
(let [token-image-eth "data:image/jpeg;base64,/9j/2w"
channel-id-1 "89f98a1e-6776-4e5f-8626-8ab9f855253f"
channel-id-2 "a076358e-4638-470e-a3fb-584d0a542ce6"
chat-id-1 (str community-id channel-id-1)
chat-id-2 (str community-id channel-id-2)
community {:id community-id
:permissions {:access 3}
:token-images {"ETH" token-image-eth}
:name "Community super name"
:chats {"89f98a1e-6776-4e5f-8626-8ab9f855253f"
:chats {channel-id-1
{:description "x"
:emoji "🎲"
:permissions {:access 1}
:color "#88B0FF"
:name "random"
:categoryID "0c3c64e7-d56e-439b-a3fb-a946d83cb056"
:id "89f98a1e-6776-4e5f-8626-8ab9f855253f"
:id channel-id-1
:position 4
:can-post? false
:members {"0x04" {"roles" [1]}}}
"a076358e-4638-470e-a3fb-584d0a542ce6"
{:description "General channel for the community"
:emoji "🥔"
:permissions {:access 1}
:color "#4360DF"
:name "general"
:categoryID "0c3c64e7-d56e-439b-a3fb-a946d83cb056"
:id "a076358e-4638-470e-a3fb-584d0a542ce6"
:position 0
:can-post? false
:members {"0x04" {"roles" [1]}}}}
:members nil}
channel-id-2
{:description "General channel for the community"
:emoji "🥔"
:permissions {:access 1}
:color "#4360DF"
:name "general"
:categoryID "0c3c64e7-d56e-439b-a3fb-a946d83cb056"
:id channel-id-2
:position 0
:token-gated? true
:can-post? false
:members {"0x01" {"roles" [1]}
"0x02" {"roles" [1]}
"0x05" {"roles" [1]}}}}
:members {"0x01" {"roles" [1]}
"0x02" {"roles" [1]}
"0x03" {"roles" [1]}
@ -500,8 +507,15 @@
:visibility-status-updates
{"0x01" {:status-type constants/visibility-status-always-online}
"0x02" {:status-type constants/visibility-status-always-online}})
(is (= [{:title (i18n/label :t/online)
:data ["0x01" "0x02"]}
{:title (i18n/label :t/offline)
:data ["0x03" "0x04"]}]
(rf/sub [sub-name community-id]))))))
(testing "a non-token gated community should look at all members of a community"
(is (= [{:title (i18n/label :t/online)
:data ["0x01" "0x02"]}
{:title (i18n/label :t/offline)
:data ["0x03" "0x04"]}]
(rf/sub [sub-name community-id chat-id-1]))))
(testing "a token gated community should use the members option in the channel"
(is (= [{:title (i18n/label :t/online)
:data ["0x01" "0x02"]}
{:title (i18n/label :t/offline)
:data ["0x05"]}]
(rf/sub [sub-name community-id chat-id-2])))))))

View File

@ -1,7 +1,5 @@
(ns status-im.subs.wallet.networks
(:require [quo.foundations.resources :as resources]
[re-frame.core :as re-frame]
[status-im.constants :as constants]
(:require [re-frame.core :as re-frame]
[status-im.contexts.wallet.common.utils.networks :as network-utils]))
(def max-network-prefixes 2)
@ -18,41 +16,6 @@
(fn [[networks test-networks-enabled?]]
(get networks (if test-networks-enabled? :test :prod))))
(def mainnet-network-details
{:source (resources/get-network constants/mainnet-network-name)
:short-name constants/mainnet-short-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
: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
: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))
(re-frame/reg-sub
:wallet/network-details
:<- [:wallet/networks-by-mode]
@ -60,7 +23,7 @@
(->> networks
(map
(fn [{:keys [chain-id related-chain-id layer]}]
(assoc (get-network-details chain-id)
(assoc (network-utils/get-network-details chain-id)
:chain-id chain-id
:related-chain-id related-chain-id
:layer layer)))
@ -101,3 +64,19 @@
short-names))
transformed-address (str prefix address)]
transformed-address)))
(re-frame/reg-sub
:wallet/network-values
:<- [:wallet/wallet-send]
(fn [{:keys [from-values-by-chain to-values-by-chain token-display-name] :as send-data} [_ to-values?]]
(let [network-values (if to-values? to-values-by-chain from-values-by-chain)
token-symbol (or token-display-name
(-> send-data :token :symbol))]
(reduce-kv
(fn [acc chain-id amount]
(let [network-name (network-utils/id->network chain-id)]
(assoc acc
(if (= network-name :mainnet) :ethereum network-name)
{:amount amount :token-symbol token-symbol})))
{}
network-values))))

View File

@ -12,6 +12,7 @@
:short-name "eth"
:network-name :mainnet
:abbreviated-name "Eth."
:full-name "Mainnet"
:related-chain-id 1
:chain-id 3
:layer 1}
@ -47,15 +48,18 @@
:short-name "eth"
:chain-id 1
:abbreviated-name "Eth."
:full-name "Mainnet"
:layer 1}
{:network-name :arbitrum
:short-name "arb1"
:abbreviated-name "Arb1."
:full-name "Arbitrum"
:chain-id 42161
:layer 2}
{:network-name :optimism
:short-name "oeth"
:abbreviated-name "Oeth."
:full-name "Optimism"
:chain-id 10
:layer 2}]
(map #(dissoc % :source :related-chain-id) (rf/sub [sub-name]))))))
@ -70,15 +74,18 @@
:short-name "eth"
:chain-id 1
:abbreviated-name "Eth."
:full-name "Mainnet"
:layer 1}
:arbitrum {:network-name :arbitrum
:short-name "arb1"
:abbreviated-name "Arb1."
:full-name "Arbitrum"
:chain-id 42161
:layer 2}
:optimism {:network-name :optimism
:short-name "oeth"
:abbreviated-name "Oeth."
:full-name "Optimism"
:chain-id 10
:layer 2}}
(rf/sub [sub-name])))))
@ -93,3 +100,23 @@
"returns the address without the prefixes when an address and equal or more than 3 network preferences are passed"
(is
(match? "0x01" (rf/sub [sub-name "0x01" [:ethereum :optimism :arbitrum]])))))
(h/deftest-sub :wallet/network-values
[sub-name]
(testing "network values for the from account are returned correctly"
(swap! rf-db/app-db assoc-in
[:wallet :ui :send]
{:from-values-by-chain {1 100}
:to-values-by-chain {42161 100}
:token-display-name "ETH"})
(is
(match? {:ethereum {:amount 100 :token-symbol "ETH"}} (rf/sub [sub-name false]))))
(testing "network values for the to account are returned correctly"
(swap! rf-db/app-db assoc-in
[:wallet :ui :send]
{:from-values-by-chain {1 100}
:to-values-by-chain {42161 100}
:token-display-name "ARB1"})
(is
(match? {:arbitrum {:amount 100 :token-symbol "ARB1"}} (rf/sub [sub-name true])))))

View File

@ -54,7 +54,7 @@
:wallet/saved-address-by-address
:<- [:wallet/saved-addresses-by-network-mode]
(fn [saved-addresses [_ address]]
(get saved-addresses address)))
(get saved-addresses (string/lower-case address))))
(rf/reg-sub
:wallet/filtered-saved-addresses
@ -65,7 +65,7 @@
(sort-by :name)
(filter
(fn [{:keys [name address ens chain-short-names]}]
(let [lowercase-query (string/lower-case query)]
(let [lowercase-query (string/lower-case (string/trim query))]
(or
(string/includes? (string/lower-case name) lowercase-query)
(string/includes? address lowercase-query)

View File

@ -205,6 +205,12 @@
(fn [{:keys [keypairs]}]
(vals keypairs)))
(rf/reg-sub
:wallet/keypair-names
:<- [:wallet/keypairs-list]
(fn [keypairs]
(set (map :name keypairs))))
(rf/reg-sub
:wallet/selected-keypair-uid
:<- [:wallet/create-account]
@ -244,7 +250,7 @@
size 32}}]
(->> accounts
(keep (fn [{:keys [path color emoji name address]}]
(when-not (string/starts-with? path constants/path-eip1581)
(when-not (string/starts-with? (str path) constants/path-eip1581)
{:account-props {:customization-color color
:size size
:emoji emoji

View File

@ -1,6 +1,9 @@
(ns status-im.subs.wallet.wallet-connect
(:require [re-frame.core :as rf]
[status-im.contexts.wallet.common.utils :as wallet-utils]))
[status-im.contexts.wallet.common.utils :as wallet-utils]
[status-im.contexts.wallet.common.utils.networks :as networks]
[status-im.contexts.wallet.wallet-connect.core :as wallet-connect-core]
[utils.money :as money]))
(rf/reg-sub
:wallet-connect/current-request-address
@ -31,6 +34,79 @@
:name name
:emoji emoji})))
(rf/reg-sub
:wallet-connect/current-request-dapp
:<- [:wallet-connect/current-request]
:<- [:wallet-connect/pairings]
(fn [[request pairings]]
(let [dapp-url (get-in request [:raw-data :verifyContext :verified :origin])]
(->> pairings
(filter (fn [pairing]
(= dapp-url (get-in pairing [:peerMetadata :url]))))
(first)))))
(rf/reg-sub
:wallet-connect/current-request-network
:<- [:wallet-connect/current-request]
(fn [request]
(-> request
(get-in [:raw-data :params :chainId])
(wallet-connect-core/eip155->chain-id)
(networks/get-network-details))))
(rf/reg-sub
:wallet-connect/current-request-transaction-information
:<- [:wallet-connect/current-request]
:<- [:wallet/accounts]
:<- [:profile/currency]
:<- [:profile/currency-symbol]
(fn [[request accounts currency currency-symbol]]
(let [chain-id (-> request
(get-in [:raw-data :params :chainId])
(wallet-connect-core/eip155->chain-id))
all-tokens (->> accounts
(filter #(= (:address %)
(:address request)))
(first)
:tokens)
eth-token (->> all-tokens
(filter #(= (:symbol %) "ETH"))
(first))
{:keys [gasPrice gasLimit value]} (-> request
:raw-data
wallet-connect-core/get-request-params
first)
max-fees-wei (money/bignumber (* gasPrice gasLimit))]
(when (and gasPrice gasLimit)
(let [max-fees-ether (money/wei->ether max-fees-wei)
token-fiat-value (wallet-utils/calculate-token-fiat-value {:currency currency
:balance max-fees-ether
:token eth-token})
crypto-formatted (wallet-utils/get-standard-crypto-format eth-token max-fees-ether)
fiat-formatted (wallet-utils/get-standard-fiat-format crypto-formatted
currency-symbol
token-fiat-value)
balance (-> eth-token
(get-in [:balances-per-chain chain-id :raw-balance])
(money/bignumber))
value (money/bignumber value)
total-transaction-value (money/add max-fees-wei value)]
{:total-transaction-value total-transaction-value
:balance balance
:max-fees max-fees-wei
:max-fees-fiat-value token-fiat-value
:max-fees-fiat-formatted fiat-formatted
:error-state (cond
(and
(money/sufficient-funds? value balance)
(not (money/sufficient-funds? total-transaction-value balance)))
:not-enough-assets-to-pay-gas-fees
(not (money/sufficient-funds? value balance))
:not-enough-assets
:else nil)})))))
(rf/reg-sub
:wallet-connect/session-proposer
:<- [:wallet-connect/current-proposal]

View File

@ -526,18 +526,21 @@
(match? [{:short-name "eth"
:network-name :mainnet
:abbreviated-name "Eth."
:full-name "Mainnet"
:chain-id 1
:related-chain-id nil
:layer 1}
{:short-name "arb1"
:network-name :arbitrum
:abbreviated-name "Arb1."
:full-name "Arbitrum"
:chain-id 42161
:related-chain-id nil
:layer 2}
{:short-name "oeth"
:network-name :optimism
:abbreviated-name "Oeth."
:full-name "Optimism"
:chain-id 10
:related-chain-id nil
:layer 2}]
@ -643,18 +646,20 @@
:removed false})
(def profile-key-pair-key-uid "abc")
(def profile-key-pair-name "My Profile")
(def seed-phrase-key-pair-key-uid "def")
(def seed-phrase-key-pair-name "My Key Pair")
(def profile-keypair
{:key-uid profile-key-pair-key-uid
:name "My Profile"
:name profile-key-pair-name
:type :profile
:lowest-operability :fully
:accounts []})
(def seed-phrase-keypair
{:key-uid seed-phrase-key-pair-key-uid
:name "My Key Pair"
:name seed-phrase-key-pair-name
:type :seed
:lowest-operability :no
:accounts []})
@ -676,6 +681,14 @@
(is (= 2 (count result)))
(is (match? expected result))))
(h/deftest-sub :wallet/keypair-names
[sub-name]
(swap! rf-db/app-db assoc-in
[:wallet :keypairs]
{profile-key-pair-key-uid profile-keypair
seed-phrase-key-pair-key-uid seed-phrase-keypair})
(is (match? #{seed-phrase-key-pair-name profile-key-pair-name} (rf/sub [sub-name]))))
(h/deftest-sub :wallet/settings-keypairs-accounts
[sub-name]
(testing "returns formatted key-pairs and accounts"

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.180.31",
"commit-sha1": "e0673ad1ffec65e3bd96a46b5054fc2d36071cc4",
"src-sha256": "15y3fl0q8kqxbsqj9snyg7spaqj09xid9rfza7l5zpk8p0ajqnmk"
"version": "v0.181.31",
"commit-sha1": "6e056348e6d28f962167118612826f1ef0e47b22",
"src-sha256": "1qvfwk28sg93basjzy8r55qz8pk9xg0h7kxv5ykxkbfh4q17a1ns"
}

View File

@ -160,10 +160,13 @@ class GithubHtmlReport(BaseTestReport):
html += "Device %d:" % i
html += "<ul>"
if test_run.first_commands:
html += "<li><a href=\"%s\">Steps, video, logs</a></li>" % \
self.get_sauce_job_url(job_id, test_run.first_commands[job_id])
try:
first_command = test_run.first_commands[job_id]
except KeyError:
first_command = 0
else:
html += "<li><a href=\"%s\">Steps, video, logs</a></li>" % self.get_sauce_job_url(job_id)
first_command = 0
html += "<li><a href=\"%s\">Steps, video, logs</a></li>" % self.get_sauce_job_url(job_id, first_command)
# if test_run.error:
# html += "<li><a href=\"%s\">Failure screenshot</a></li>" % self.get_sauce_final_screenshot_url(job_id)
html += "</ul></p>"

View File

@ -190,7 +190,10 @@ class TestrailReport(BaseTestReport):
test_steps += step + "\n"
for i, device in enumerate(last_testrun.jobs):
if last_testrun.first_commands:
first_command = last_testrun.first_commands[device]
try:
first_command = last_testrun.first_commands[device]
except KeyError:
first_command = 0
else:
first_command = 0
try:
@ -233,7 +236,10 @@ class TestrailReport(BaseTestReport):
continue
for res in results:
if last_testrun.first_commands:
pattern = r"%s\?auth=.*#%s" % (device, str(last_testrun.first_commands[device]))
try:
pattern = r"%s\?auth=.*#%s" % (device, str(last_testrun.first_commands[device]))
except KeyError:
pattern = device
else:
pattern = device
if re.findall(pattern, res['comment']):
@ -285,10 +291,13 @@ class TestrailReport(BaseTestReport):
error = "```%s```\n **%s** \n" % (code_error, no_code_error_str)
for job_id, f in last_testrun.jobs.items():
if last_testrun.first_commands:
job_url = self.get_sauce_job_url(job_id=job_id,
first_command=last_testrun.first_commands[job_id])
try:
first_command = last_testrun.first_commands[job_id]
except KeyError:
first_command = 0
else:
job_url = self.get_sauce_job_url(job_id=job_id)
first_command = 0
job_url = self.get_sauce_job_url(job_id=job_id, first_command=first_command)
case_info = "Logs for device %d: [steps](%s), [failure screenshot](%s)" \
% (f, job_url, self.get_sauce_final_screenshot_url(job_id))

View File

@ -2,7 +2,7 @@ import time
import pytest
from tests import marks, common_password, used_fleet
from tests import marks, common_password
from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase
from views.sign_in_view import SignInView
from tests.users import basic_user, ens_user, ens_user_message_sender, transaction_senders, chat_users
@ -415,8 +415,8 @@ class TestBrowserProfileOneDevice(MultipleSharedDeviceTestCase):
profile = self.home.profile_button.click()
profile.advanced_button.click()
if not profile.element_by_text(used_fleet).is_element_displayed():
self.errors.append('%s is not selected by default' % used_fleet)
# if not profile.element_by_text(used_fleet).is_element_displayed():
# self.errors.append('%s is not selected by default' % used_fleet)
self.home.just_fyi('Set another fleet and check that changes are applied')
profile.fleet_setting_button.click()

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