Add progress-spinner to sign-transaction
Disable screen while transaction is signing Add handling for incorrect password on signing Fix bug where spinner doesn't appear on the second time Address feedback More rebase fixes Fix spec failure
This commit is contained in:
parent
639606a716
commit
3225d1a258
|
@ -16,7 +16,10 @@
|
||||||
(spec/def ::width double?)
|
(spec/def ::width double?)
|
||||||
(spec/def ::camera-dimensions (spec/keys :req-un [::height ::width]))
|
(spec/def ::camera-dimensions (spec/keys :req-un [::height ::width]))
|
||||||
(spec/def ::camera-flashlight #{:on :off})
|
(spec/def ::camera-flashlight #{:on :off})
|
||||||
|
(spec/def ::in-progress? boolean?)
|
||||||
|
|
||||||
(spec/def :wallet/send-transaction (allowed-keys
|
(spec/def :wallet/send-transaction (allowed-keys
|
||||||
:opt-un [::amount ::to-address ::to-name ::amount-error ::password ::wrong-password?
|
:opt-un [::amount ::to-address ::to-name ::amount-error ::password
|
||||||
::waiting-signal? ::signing? ::transaction-id ::later? ::camera-dimensions ::camera-flashlight]))
|
::waiting-signal? ::signing? ::transaction-id ::later?
|
||||||
|
::camera-dimensions ::camera-flashlight ::in-progress?
|
||||||
|
::wrong-password?]))
|
||||||
|
|
|
@ -43,14 +43,15 @@
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
::transaction-completed
|
::transaction-completed
|
||||||
(fn [{db :db} [_ {:keys [id response]}]]
|
(fn [{db :db} [_ {:keys [id response]}]]
|
||||||
(let [{:keys [hash error]} response]
|
(let [{:keys [hash error]} response
|
||||||
;; error is handling in TRANSACTION FAILED signal from status-go
|
db' (assoc-in db [:wallet/send-transaction :in-progress?] false)]
|
||||||
(when-not (and error (string? error) (not (string/blank? error)))
|
(if-not (and error (string? error) (not (string/blank? error)))
|
||||||
{:db (-> db
|
{:db (-> db'
|
||||||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||||
(assoc-in [:wallet/send-transaction :transaction-id] nil)
|
(assoc-in [:wallet/send-transaction :transaction-id] nil)
|
||||||
(assoc-in [:wallet/send-transaction :wrong-password?] false))
|
(assoc-in [:wallet/send-transaction :wrong-password?] false))
|
||||||
:dispatch [:navigate-to :wallet-transaction-sent]}))))
|
:dispatch [:navigate-to :wallet-transaction-sent]}
|
||||||
|
{:db db'}))))
|
||||||
|
|
||||||
(defn on-transactions-completed [raw-results]
|
(defn on-transactions-completed [raw-results]
|
||||||
(let [results (:results (types/json->clj raw-results))]
|
(let [results (:results (types/json->clj raw-results))]
|
||||||
|
@ -95,10 +96,12 @@
|
||||||
(if transaction-id
|
(if transaction-id
|
||||||
{::accept-transaction {:id transaction-id
|
{::accept-transaction {:id transaction-id
|
||||||
:password password
|
:password password
|
||||||
:on-completed on-transactions-completed}}
|
:on-completed on-transactions-completed}
|
||||||
{:db (update-in db [:wallet/send-transaction]
|
:db (assoc-in db [:wallet/send-transaction :in-progress?] true)}
|
||||||
#(assoc % :waiting-signal? true
|
{:db (update db :wallet/send-transaction assoc
|
||||||
:later? later?))
|
:waiting-signal? true
|
||||||
|
:later? later?
|
||||||
|
:in-progress? true)
|
||||||
::send-transaction {:web3 web3
|
::send-transaction {:web3 web3
|
||||||
:from (get-in accounts [current-account-id :address])
|
:from (get-in accounts [current-account-id :address])
|
||||||
:to (:to-address send-transaction)
|
:to (:to-address send-transaction)
|
||||||
|
@ -119,9 +122,10 @@
|
||||||
:wallet/discard-transaction
|
:wallet/discard-transaction
|
||||||
(fn [{{:wallet/keys [send-transaction] :as db} :db} _]
|
(fn [{{:wallet/keys [send-transaction] :as db} :db} _]
|
||||||
(let [{:keys [transaction-id]} send-transaction]
|
(let [{:keys [transaction-id]} send-transaction]
|
||||||
(merge {:db (-> db
|
(merge {:db (update db :wallet/send-transaction assoc
|
||||||
(update-in [:wallet/send-transaction]
|
:signing? false
|
||||||
#(assoc % :signing? false :transaction-id nil :wrong-password? false)))}
|
:transaction-id nil
|
||||||
|
:wrong-password? false)}
|
||||||
(when transaction-id
|
(when transaction-id
|
||||||
{:discard-transaction transaction-id})))))
|
{:discard-transaction transaction-id})))))
|
||||||
|
|
||||||
|
|
|
@ -60,4 +60,14 @@
|
||||||
{:padding 0
|
{:padding 0
|
||||||
:font-size 15
|
:font-size 15
|
||||||
:letter-spacing -0.2
|
:letter-spacing -0.2
|
||||||
:height 20})
|
:height 20})
|
||||||
|
|
||||||
|
(def processing-view
|
||||||
|
{:position :absolute
|
||||||
|
:top 0
|
||||||
|
:bottom 0
|
||||||
|
:right 0
|
||||||
|
:left 0
|
||||||
|
:align-items :center
|
||||||
|
:justify-content :center
|
||||||
|
:background-color (str styles/color-black "1A")})
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
|
|
||||||
;; "Cancel" and "Sign Transaction >" buttons, signing with password
|
;; "Cancel" and "Sign Transaction >" buttons, signing with password
|
||||||
(defview signing-buttons [cancel-handler sign-handler]
|
(defview signing-buttons [cancel-handler sign-handler in-progress?]
|
||||||
(letsubs [sign-enabled? [:wallet.send/sign-password-enabled?]]
|
(letsubs [sign-enabled? [:wallet.send/sign-password-enabled?]]
|
||||||
[react/view wallet.styles/buttons-container
|
[react/view wallet.styles/buttons-container
|
||||||
[react/touchable-highlight {:on-press cancel-handler}
|
[react/touchable-highlight {:on-press cancel-handler}
|
||||||
|
@ -68,6 +68,7 @@
|
||||||
[react/view components.styles/flex]
|
[react/view components.styles/flex]
|
||||||
[react/touchable-highlight {:on-press sign-handler}
|
[react/touchable-highlight {:on-press sign-handler}
|
||||||
[react/view (wallet.styles/button-container sign-enabled?)
|
[react/view (wallet.styles/button-container sign-enabled?)
|
||||||
|
(when in-progress? [react/activity-indicator {:animating? true}])
|
||||||
[components/button-text (i18n/label :t/transactions-sign-transaction)]
|
[components/button-text (i18n/label :t/transactions-sign-transaction)]
|
||||||
[vector-icons/icon :icons/forward {:color :white :container-style wallet.styles/forward-icon-container}]]]]))
|
[vector-icons/icon :icons/forward {:color :white :container-style wallet.styles/forward-icon-container}]]]]))
|
||||||
|
|
||||||
|
@ -101,7 +102,8 @@
|
||||||
amount-error [:get-in [:wallet/send-transaction :amount-error]]
|
amount-error [:get-in [:wallet/send-transaction :amount-error]]
|
||||||
signing? [:get-in [:wallet/send-transaction :signing?]]
|
signing? [:get-in [:wallet/send-transaction :signing?]]
|
||||||
to-address [:get-in [:wallet/send-transaction :to-address]]
|
to-address [:get-in [:wallet/send-transaction :to-address]]
|
||||||
to-name [:get-in [:wallet/send-transaction :to-name]]]
|
to-name [:get-in [:wallet/send-transaction :to-name]]
|
||||||
|
in-progress? [:get-in [:wallet/send-transaction :in-progress?]]]
|
||||||
(let [sufficient-funds? (sufficient-funds? amount balance)]
|
(let [sufficient-funds? (sufficient-funds? amount balance)]
|
||||||
[react/keyboard-avoiding-view wallet.styles/wallet-modal-container
|
[react/keyboard-avoiding-view wallet.styles/wallet-modal-container
|
||||||
[react/view components.styles/flex
|
[react/view components.styles/flex
|
||||||
|
@ -117,7 +119,8 @@
|
||||||
[components/choose-wallet]]
|
[components/choose-wallet]]
|
||||||
[react/view wallet.styles/amount-container
|
[react/view wallet.styles/amount-container
|
||||||
[components/amount-input
|
[components/amount-input
|
||||||
{:error (or amount-error (when-not sufficient-funds? (i18n/label :t/wallet-insufficient-funds)))
|
{:error (or amount-error
|
||||||
|
(when-not sufficient-funds? (i18n/label :t/wallet-insufficient-funds)))
|
||||||
:input-options {:auto-focus true
|
:input-options {:auto-focus true
|
||||||
:default-value amount
|
:default-value amount
|
||||||
:on-change-text #(let [value (string/trim %)]
|
:on-change-text #(let [value (string/trim %)]
|
||||||
|
@ -128,10 +131,12 @@
|
||||||
(if signing?
|
(if signing?
|
||||||
[signing-buttons
|
[signing-buttons
|
||||||
#(re-frame/dispatch [:wallet/discard-transaction])
|
#(re-frame/dispatch [:wallet/discard-transaction])
|
||||||
#(re-frame/dispatch [:wallet/sign-transaction])]
|
#(re-frame/dispatch [:wallet/sign-transaction])
|
||||||
|
in-progress?]
|
||||||
[sign-buttons amount-error to-address amount sufficient-funds? sign-later])
|
[sign-buttons amount-error to-address amount sufficient-funds? sign-later])
|
||||||
(when signing?
|
(when signing?
|
||||||
[sign-panel])]])))
|
[sign-panel])]
|
||||||
|
(when in-progress? [react/view send.styles/processing-view])])))
|
||||||
|
|
||||||
(defn toolbar-modal []
|
(defn toolbar-modal []
|
||||||
[toolbar/toolbar2 {:style wallet.styles/toolbar}
|
[toolbar/toolbar2 {:style wallet.styles/toolbar}
|
||||||
|
@ -144,7 +149,8 @@
|
||||||
signing? [:get-in [:wallet/send-transaction :signing?]]
|
signing? [:get-in [:wallet/send-transaction :signing?]]
|
||||||
to-address [:get-in [:wallet/send-transaction :to-address]]
|
to-address [:get-in [:wallet/send-transaction :to-address]]
|
||||||
to-name [:get-in [:wallet/send-transaction :to-name]]
|
to-name [:get-in [:wallet/send-transaction :to-name]]
|
||||||
recipient [:contact-by-address @to-name]]
|
recipient [:contact-by-address @to-name]
|
||||||
|
in-progress? [:get-in [:wallet/send-transaction :in-progress?]]]
|
||||||
[react/keyboard-avoiding-view wallet.styles/wallet-modal-container
|
[react/keyboard-avoiding-view wallet.styles/wallet-modal-container
|
||||||
[react/view components.styles/flex
|
[react/view components.styles/flex
|
||||||
[status-bar/status-bar {:type :wallet}]
|
[status-bar/status-bar {:type :wallet}]
|
||||||
|
@ -164,7 +170,8 @@
|
||||||
(if signing?
|
(if signing?
|
||||||
[signing-buttons
|
[signing-buttons
|
||||||
#(re-frame/dispatch [:wallet/cancel-signing-modal])
|
#(re-frame/dispatch [:wallet/cancel-signing-modal])
|
||||||
#(re-frame/dispatch [:wallet/sign-transaction-modal])]
|
#(re-frame/dispatch [:wallet/sign-transaction-modal])
|
||||||
|
in-progress?]
|
||||||
[sign-buttons amount-error to-address amount true #(re-frame/dispatch [:navigate-back])])
|
[sign-buttons amount-error to-address amount true #(re-frame/dispatch [:navigate-back])])
|
||||||
(when signing?
|
(when signing?
|
||||||
[sign-panel])]]))
|
[sign-panel])]]))
|
||||||
|
|
Loading…
Reference in New Issue