bugs #4724 and #5131 - fixed by adding wallet onboarding for dapp txs

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
Goran Jovic 2018-07-22 11:05:10 +02:00 committed by Julien Eluard
parent 0f2af863e7
commit f38a95fd71
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
6 changed files with 55 additions and 35 deletions

View File

@ -155,19 +155,22 @@
(fn [cofx [_ dev-mode]]
(accounts.utils/account-update {:dev-mode? dev-mode} cofx)))
(defn wallet-set-up-passed [db cofx]
(defn chat-send? [transaction]
(and (seq transaction)
(not (:in-progress? transaction))
(:from-chat? transaction)))
(defn wallet-set-up-passed [db modal? cofx]
(let [transaction (get-in db [:wallet :send-transaction])]
(merge
{:db (navigation/navigate-back db)}
(when (and (seq transaction)
(not (:in-progress? transaction))
(:from-chat? transaction))
{:dispatch [:navigate-to :wallet-send-transaction-chat]}))))
(cond modal? {:dispatch [:navigate-to-modal :wallet-send-transaction-modal]}
(chat-send? transaction) {:db (navigation/navigate-back db)
:dispatch [:navigate-to :wallet-send-transaction-chat]}
:else {:db (navigation/navigate-back db)})))
(handlers/register-handler-fx
:wallet-set-up-passed
(fn [{:keys [db] :as cofx}]
(fn [{:keys [db] :as cofx} [_ modal?]]
(handlers-macro/merge-fx
cofx
(wallet-set-up-passed db)
(wallet-set-up-passed db modal?)
(accounts.utils/account-update {:wallet-set-up-passed? true}))))

View File

@ -111,6 +111,7 @@
:wallet-transaction-sent-modal transaction-sent-modal
:wallet-sign-message-modal sign-message-modal
:wallet-transaction-fee wallet.send/transaction-fee
:wallet-onboarding-setup-modal wallet.onboarding.setup/modal
[react/view [react/text (str "Unknown modal view: " modal-view)]]))
(defview main-modal []

View File

@ -40,4 +40,8 @@
:padding-vertical 8})
(def got-it-button-text
{:padding-horizontal 0})
{:padding-horizontal 0})
(def modal
{:flex 1
:background-color colors/blue})

View File

@ -6,12 +6,13 @@
[status-im.react-native.resources :as resources]
[status-im.ui.components.react :as react]
[status-im.ui.components.styles :as components.styles]
[status-im.ui.screens.wallet.components :as comp]
[status-im.ui.screens.wallet.components :as wallet.components]
[status-im.ui.screens.wallet.onboarding.setup.styles :as styles]
[status-im.ui.components.bottom-buttons.view :as bottom-buttons]
[status-im.ui.components.button.view :as button]
[status-im.utils.utils :as utils]
[status-im.ui.components.toolbar.actions :as actions]))
[status-im.ui.components.toolbar.actions :as actions]
[status-im.ui.components.status-bar.view :as status-bar]))
(defn signing-word [word]
[react/view styles/signing-word
@ -20,17 +21,19 @@
:number-of-lines 1}
word]])
(defn display-confirmation []
(defn display-confirmation [modal?]
(utils/show-question
(i18n/label :t/wallet-set-up-confirm-title)
(i18n/label :t/wallet-set-up-confirm-description)
#(re-frame/dispatch [:wallet-set-up-passed])))
#(re-frame/dispatch [:wallet-set-up-passed modal?])))
(views/defview screen []
(views/defview onboarding-panel [modal?]
(views/letsubs [{:keys [signing-phrase]} [:get-current-account]]
(let [signing-words (string/split signing-phrase #" ")]
[comp/simple-screen {:avoid-keyboard? true}
[comp/toolbar
(let [signing-words (string/split signing-phrase #" ")
container (if modal? react/view wallet.components/simple-screen)
container-opts (if modal? components.styles/flex {:avoid-keyboard? true})]
[container container-opts
[wallet.components/toolbar
{}
(actions/back-white #(re-frame/dispatch [:wallet-setup-navigate-back]))
(i18n/label :t/wallet-set-up-title)]
@ -46,8 +49,16 @@
(i18n/label :t/wallet-set-up-signing-phrase)]
[bottom-buttons/bottom-buttons styles/bottom-buttons
nil
[button/button {:on-press display-confirmation
[button/button {:on-press (partial display-confirmation modal?)
:text-style styles/got-it-button-text
:accessibility-label :done-button}
(i18n/label :t/got-it)
nil]]]])))
nil]]]])))
(views/defview screen []
[onboarding-panel false])
(views/defview modal []
[react/view styles/modal
[status-bar/status-bar {:type :modal-wallet}]
[onboarding-panel true]])

View File

@ -194,20 +194,23 @@
;;SEND TRANSACTION
(= method constants/web3-send-transaction)
(let [{:keys [gas gasPrice]} args
transaction (prepare-transaction queued-transaction now)
sending-from-bot-or-dapp? (not (get-in db [:wallet :send-transaction :waiting-signal?]))
new-db (assoc-in db' [:wallet :transactions-unsigned id] transaction)
sending-db {:id id
:method method
:from-chat? (or
sending-from-bot-or-dapp?
(let [{:keys [gas gasPrice]} args
transaction (prepare-transaction queued-transaction now)
sending-from-dapp? (not (get-in db [:wallet :send-transaction :waiting-signal?]))
new-db (assoc-in db' [:wallet :transactions-unsigned id] transaction)
sender-account (:account/account db)
sending-db {:id id
:method method
:from-chat? (or sending-from-dapp? ;;TODO(goranjovic): figure out why we need to
;; have from-chat? flag for dapp txs and get rid of this
(get-in db [:wallet :send-transaction :from-chat?]))}]
(if sending-from-bot-or-dapp?
;;SENDING FROM BOT (CHAT) OR DAPP
(if sending-from-dapp?
;;SENDING FROM DAPP
{:db (assoc-in new-db [:wallet :send-transaction] sending-db) ; we need to completely reset sending state here
:dispatch-n [[:update-wallet]
[:navigate-to-modal :wallet-send-transaction-modal]
[:navigate-to-modal (if (:wallet-set-up-passed? sender-account)
:wallet-send-transaction-modal
:wallet-onboarding-setup-modal)]
(when-not (seq gas)
[:wallet/update-estimated-gas transaction])
(when-not (seq gasPrice)

View File

@ -260,22 +260,20 @@
(defview send-transaction []
(letsubs [transaction [:wallet.send/transaction]
symbol [:wallet.send/symbol]
advanced? [:wallet.send/advanced?]
network [:get-current-account-network]
scroll (atom nil)]
[send-transaction-panel {:modal? false :transaction transaction :scroll scroll :advanced? advanced?
:symbol symbol :network network}]))
:network network}]))
(defview send-transaction-modal []
(letsubs [transaction [:wallet.send/unsigned-transaction]
symbol [:wallet.send/symbol]
advanced? [:wallet.send/advanced?]
network [:get-current-account-network]
scroll (atom nil)]
(if transaction
[send-transaction-panel {:modal? true :transaction transaction :scroll scroll :advanced? advanced?
symbol symbol :network network}]
:network network}]
[react/view wallet.styles/wallet-modal-container
[react/view components.styles/flex
[status-bar/status-bar {:type :modal-wallet}]