watch only qrcode and already exists check

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
tbenr 2020-02-14 08:38:42 +01:00 committed by Churikova Tetiana
parent 7485093398
commit eb1cc65a3d
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
6 changed files with 51 additions and 5 deletions

View File

@ -543,6 +543,12 @@
(or (not (ethereum/address? address))
(some #(when (= (:address %) address) %) accounts))))
(re-frame/reg-sub
:add-account-scanned-address
:<- [:add-account]
(fn [add-account]
(get add-account :scanned-address)))
;;CHAT ==============================================================================================================
(re-frame/reg-sub

View File

@ -11,8 +11,8 @@
[status-im.multiaccounts.db :as multiaccounts.db]
[status-im.ui.components.toolbar :as toolbar]
[status-im.ui.components.styles :as components.styles]
[status-im.ethereum.core :as ethereum]
[status-im.ui.components.topbar :as topbar]))
[status-im.ui.components.topbar :as topbar]
[status-im.utils.utils :as utils.utils]))
(defn add-account []
[react/view {:flex 1}
@ -62,10 +62,25 @@
:padding-horizontal 16
:background-color colors/gray-lighter})
(defn- request-camera-permissions []
(let [options {:handler :wallet.add-new/qr-scanner-result}]
(re-frame/dispatch
[:request-permissions
{:permissions [:camera]
:on-allowed
#(re-frame/dispatch [:wallet.add-new/qr-scanner-allowed options])
:on-denied
#(utils.utils/set-timeout
(fn []
(utils.utils/show-popup (i18n/label :t/error)
(i18n/label :t/camera-access-error)))
50)}])))
(defview add-watch-account []
(letsubs [add-account-disabled? [:add-account-disabled?]]
(letsubs [add-account-disabled? [:add-account-disabled?]
add-account-scanned-address [:add-account-scanned-address]]
[react/keyboard-avoiding-view {:flex 1}
[topbar/topbar]
[topbar/topbar {:accessories [{:icon :qr :handler #(request-camera-permissions)}]}]
[react/view {:flex 1
:justify-content :space-between
:align-items :center :margin-horizontal 16}
@ -78,6 +93,7 @@
[react/text-input {:auto-focus true
:multiline true
:text-align :center
:default-value add-account-scanned-address
:placeholder (i18n/label :t/enter-address)
:style {:typography :header :flex 1}
:on-change-text #(re-frame/dispatch [:set-in [:add-account :address] %])}]]]

View File

@ -3,6 +3,7 @@
[status-im.constants :as constants]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip55 :as eip55]
[status-im.ethereum.eip681 :as eip681]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.i18n :as i18n]
[status-im.multiaccounts.update.core :as multiaccounts.update]
@ -169,3 +170,17 @@
:type :watch
:color (rand-nth colors/account-colors)})}
(navigation/navigate-to-cofx :account-added nil))))
(fx/defn view-only-qr-scanner-result
{:events [:wallet.add-new/qr-scanner-result]}
[{db :db :as cofx} data _]
(let [address (or (when (ethereum/address? data) data)
(:address (eip681/parse-uri data)))]
(fx/merge cofx
(merge {:db (-> db
(assoc-in [:add-account :scanned-address] address)
(assoc-in [:add-account :address] address))}
(when-not address
{:utils/show-popup {:title (i18n/label :t/error)
:content (i18n/label :t/invalid-address-qr-code)}}))
(navigation/navigate-back))))

View File

@ -629,6 +629,13 @@
(bottom-sheet/hide-bottom-sheet)
(navigation/navigate-to-cofx :qr-scanner options)))
(fx/defn view-only-qr-scanner-allowed
{:events [:wallet.add-new/qr-scanner-allowed]}
[{:keys [db] :as cofx} options]
(fx/merge cofx
{:db (update-in db [:add-account] dissoc :address)}
(navigation/navigate-to-cofx :qr-scanner options)))
(fx/defn wallet-send-set-symbol
{:events [:wallet.send/set-symbol]}
[{:keys [db] :as cofx} symbol]

View File

@ -550,6 +550,7 @@
:intro-wizard-title4
:intro-wizard-title5
:intro-wizard-title6
:invalid-address-qr-code
:invalid-extension
:invalid-format
:invalid-key-confirm

View File

@ -440,7 +440,7 @@
"enter-recipient-address-or-username": "Enter address or username of the recepient",
"enter-seed-phrase": "Enter seed phrase",
"enter-url": "Enter URL",
"enter-watch-account-address": "Enter the address to watch",
"enter-watch-account-address": "Scan a QR code\nor\nenter the address to watch",
"enter-word": "Enter word",
"enter-your-code": "Enter your 6-digit passcode",
"enter-your-password": "Enter your password",
@ -563,6 +563,7 @@
"intro-wizard-title6": "Enable notifications",
"are-you-sure-to-cancel": "Are you sure you want to cancel?",
"you-will-start-from-scratch": "You will start from scratch with a new set of keys",
"invalid-address-qr-code": "Scanned QR code doesn't contain a valid address",
"invalid-extension": "Invalid extension URI",
"invalid-format": "Invalid format\nMust be {{format}}",
"invalid-key-confirm": "Apply",