This commit is contained in:
janherich 2017-10-12 12:24:01 +02:00 committed by Roman Volosovskyi
parent 748f1c6772
commit 5267d55ec8
5 changed files with 42 additions and 34 deletions

View File

@ -403,16 +403,7 @@ function handleSend(params, context) {
web3.eth.sendTransaction(data, function(error, hash) { web3.eth.sendTransaction(data, function(error, hash) {
if (error) { if (error) {
status.sendSignal("handler-result", { // Do nothing, as error handling will be done as response to transaction.failed event from go
status: "failed",
error: {
markup: status.components.validationMessage(
I18n.t('validation_tx_title'),
I18n.t('validation_tx_failed')
)
},
origParams: context["orig-params"]
});
} else { } else {
status.sendSignal("handler-result", { status.sendSignal("handler-result", {
status: "success", status: "success",

View File

@ -18,9 +18,10 @@
(spec/def ::camera-flashlight #{:on :off}) (spec/def ::camera-flashlight #{:on :off})
(spec/def ::camera-permitted? boolean?) (spec/def ::camera-permitted? boolean?)
(spec/def ::in-progress? boolean?) (spec/def ::in-progress? boolean?)
(spec/def ::from-chat? 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 :opt-un [::amount ::to-address ::to-name ::amount-error ::password
::waiting-signal? ::signing? ::transaction-id ::later? ::waiting-signal? ::signing? ::transaction-id ::later?
::camera-dimensions ::camera-flashlight ::in-progress? ::camera-dimensions ::camera-flashlight ::in-progress?
::wrong-password? ::camera-permitted?])) ::wrong-password? ::camera-permitted? ::from-chat?]))

View File

@ -40,6 +40,11 @@
(assoc-in [:wallet/send-transaction :amount] amount) (assoc-in [:wallet/send-transaction :amount] amount)
(assoc-in [:wallet/send-transaction :amount-error] error))}))) (assoc-in [:wallet/send-transaction :amount-error] error))})))
(def ^:private clear-send-properties {:transaction-id nil
:wrong-password? false
:waiting-signal? false
:from-chat? false})
(handlers/register-handler-fx (handlers/register-handler-fx
::transaction-completed ::transaction-completed
(fn [{db :db} [_ {:keys [id response]}]] (fn [{db :db} [_ {:keys [id response]}]]
@ -48,8 +53,7 @@
(if-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) (update :wallet/send-transaction merge clear-send-properties))
(assoc-in [:wallet/send-transaction :wrong-password?] false))
:dispatch [:navigate-to :wallet-transaction-sent]} :dispatch [:navigate-to :wallet-transaction-sent]}
{:db db'})))) {:db db'}))))
@ -68,9 +72,7 @@
{:db db'} {:db db'}
{:db (-> db' {:db (-> db'
(update-in [:wallet :transactions-unsigned] dissoc id) (update-in [:wallet :transactions-unsigned] dissoc id)
(update :wallet/send-transaction assoc (update :wallet/send-transaction merge clear-send-properties))
:transaction-id nil
:wrong-password? false))
:dispatch [:navigate-back]})))) :dispatch [:navigate-back]}))))
(defn on-transactions-modal-completed [raw-results] (defn on-transactions-modal-completed [raw-results]
@ -121,16 +123,27 @@
:password password :password password
:on-completed on-transactions-modal-completed}}))) :on-completed on-transactions-modal-completed}})))
(handlers/register-handler-fx (defn discard-transaction
:wallet/discard-transaction [{{: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 (update db :wallet/send-transaction assoc (merge {:db (update db :wallet/send-transaction assoc
:signing? false :signing? false
:transaction-id nil :transaction-id nil
:wrong-password? false)} :wrong-password? false)}
(when transaction-id (when transaction-id
{:discard-transaction transaction-id}))))) {:discard-transaction transaction-id}))))
(handlers/register-handler-fx
:wallet/discard-transaction
(fn [cofx _]
(discard-transaction cofx)))
(handlers/register-handler-fx
:wallet/discard-transaction-navigate-back
(fn [cofx _]
(-> cofx
discard-transaction
(assoc :dispatch [:navigate-back]))))
(handlers/register-handler-fx (handlers/register-handler-fx
:wallet/cancel-signing-modal :wallet/cancel-signing-modal

View File

@ -22,8 +22,7 @@
(defn toolbar-view [signing?] (defn toolbar-view [signing?]
[toolbar/toolbar2 {:style wallet.styles/toolbar} [toolbar/toolbar2 {:style wallet.styles/toolbar}
[toolbar/nav-button (act/back-white (if signing? [toolbar/nav-button (act/back-white (if signing?
#(do (re-frame/dispatch [:wallet/discard-transaction]) #(re-frame/dispatch [:wallet/discard-transaction-navigate-back])
(act/default-handler))
act/default-handler))] act/default-handler))]
[toolbar/content-title {:color :white} (i18n/label :t/send-transaction)]]) [toolbar/content-title {:color :white} (i18n/label :t/send-transaction)]])
@ -144,9 +143,11 @@
[sign-panel])] [sign-panel])]
(when in-progress? [react/view send.styles/processing-view])]))) (when in-progress? [react/view send.styles/processing-view])])))
(defn toolbar-modal [] (defn toolbar-modal [from-chat?]
[toolbar/toolbar2 {:style wallet.styles/toolbar} [toolbar/toolbar2 {:style wallet.styles/toolbar}
[toolbar/nav-button (act/close-white act/default-handler)] [toolbar/nav-button (act/close-white (if from-chat?
#(re-frame/dispatch [:wallet/discard-transaction-navigate-back])
act/default-handler))]
[toolbar/content-title {:color :white} (i18n/label :t/send-transaction)]]) [toolbar/content-title {:color :white} (i18n/label :t/send-transaction)]])
(defview send-transaction-modal [] (defview send-transaction-modal []
@ -156,11 +157,12 @@
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?]]] in-progress? [:get-in [:wallet/send-transaction :in-progress?]]
from-chat? [:get-in [:wallet/send-transaction :from-chat?]]]
[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}]
[toolbar-modal] [toolbar-modal from-chat?]
[react/scroll-view {:keyboardShouldPersistTaps :always} [react/scroll-view {:keyboardShouldPersistTaps :always}
[react/view components.styles/flex [react/view components.styles/flex
[react/view wallet.styles/choose-participant-container [react/view wallet.styles/choose-participant-container

View File

@ -49,7 +49,8 @@
{:dispatch [:navigate-to-modal :wallet-send-transaction-modal {:amount (str (money/wei->ether value)) {:dispatch [:navigate-to-modal :wallet-send-transaction-modal {:amount (str (money/wei->ether value))
:transaction-id id :transaction-id id
:to-address to :to-address to
:to-name to}]})))) :to-name to
:from-chat? true}]}))))
{:discard-transaction id}))) {:discard-transaction id})))
;TRANSACTION FAILED signal from status-go ;TRANSACTION FAILED signal from status-go