show onboarding for transaction from chat [#4456]

This commit is contained in:
Andrey Shovkoplyas 2018-05-30 18:41:00 +03:00 committed by Roman Volosovskyi
parent 68eb36f7b1
commit 83afbd515a
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
10 changed files with 110 additions and 63 deletions

View File

@ -12,11 +12,14 @@
:gas (ethereum/estimate-gas :ETH)
:from-chat? true)))
(defn send-shortcut-fx [db contact params]
(defn send-shortcut-fx [{:account/keys [account] :as db} contact params]
(merge {:db (-> db
(send.events/set-and-validate-amount-db (:amount params) :ETH 18)
(choose-recipient.events/fill-request-details (transaction-details contact))
(navigation/navigate-to :wallet-send-transaction-chat))}
(navigation/navigate-to
(if (:wallet-set-up-passed? account)
:wallet-send-transaction-chat
:wallet-onboarding-setup)))}
(send.events/update-gas-price db false)))
(def shortcuts

View File

@ -18,7 +18,8 @@
status-im.ui.screens.accounts.create.navigation
[status-im.chat.models :as chat.models]
[status-im.ui.screens.accounts.utils :as accounts.utils]
[status-im.data-store.accounts :as accounts-store]))
[status-im.data-store.accounts :as accounts-store]
[status-im.ui.screens.navigation :as navigation]))
;;;; COFX
@ -161,7 +162,17 @@
(fn [cofx [_ dev-mode]]
(accounts.utils/account-update {:dev-mode? dev-mode} cofx)))
(defn wallet-set-up-passed [db cofx]
(let [transaction (seq (get-in db [:wallet :send-transaction]))]
(merge
{:db (navigation/navigate-back db)}
(when transaction
{:dispatch [:navigate-to :wallet-send-transaction-chat]}))))
(handlers/register-handler-fx
:wallet-set-up-passed
(fn [cofx]
(accounts.utils/account-update {:wallet-set-up-passed? true} cofx)))
(fn [{:keys [db] :as cofx}]
(handlers-macro/merge-fx
cofx
(wallet-set-up-passed db)
(accounts.utils/account-update {:wallet-set-up-passed? true}))))

View File

@ -90,10 +90,7 @@
(fn [cofx [_ view-id]]
(replace-view view-id cofx)))
(handlers/register-handler-db
:navigate-back
(re-frame/enrich -preload-data!)
(fn [{:keys [navigation-stack view-id modal] :as db} _]
(defn navigate-back [{:keys [navigation-stack view-id modal] :as db}]
(cond
modal (assoc db :modal nil
:was-modal? true)
@ -106,7 +103,13 @@
(-> db
(assoc :view-id previous-view-id)
(assoc :navigation-stack navigation-stack'))
(assoc db :view-id first-in-stack))))))
(assoc db :view-id first-in-stack)))))
(handlers/register-handler-db
:navigate-back
(re-frame/enrich -preload-data!)
(fn [db _]
(navigate-back db)))
(handlers/register-handler-fx
:navigate-to-clean

View File

@ -11,7 +11,8 @@
[taoensso.timbre :as log]
status-im.ui.screens.wallet.request.events
[status-im.utils.money :as money]
[status-im.constants :as constants]))
[status-im.constants :as constants]
[status-im.ui.screens.navigation :as navigation]))
(defn get-balance [{:keys [web3 account-id on-success on-error]}]
(if (and web3 account-id)
@ -258,3 +259,10 @@
:wallet/show-error
(fn []
{:show-error (i18n/label :t/wallet-error)}))
(handlers/register-handler-fx
:wallet-setup-navigate-back
(fn [{:keys [db]}]
{:db (-> db
(assoc-in [:wallet :send-transaction] {})
(navigation/navigate-back))}))

View File

@ -10,7 +10,8 @@
[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.utils.utils :as utils]
[status-im.ui.components.toolbar.actions :as actions]))
(defn signing-word [word]
[react/view styles/signing-word
@ -23,14 +24,16 @@
(utils/show-question
(i18n/label :t/wallet-set-up-confirm-title)
(i18n/label :t/wallet-set-up-confirm-description)
#(do (re-frame/dispatch [:wallet-set-up-passed])
(re-frame/dispatch [:navigate-back]))))
#(re-frame/dispatch [:wallet-set-up-passed])))
(views/defview screen []
(views/letsubs [{:keys [signing-phrase]} [:get-current-account]]
(let [signing-words (string/split signing-phrase #" ")]
[comp/simple-screen {:avoid-keyboard? true}
[comp/toolbar (i18n/label :t/wallet-set-up-title)]
[comp/toolbar
{}
(actions/back-white #(re-frame/dispatch [:wallet-setup-navigate-back]))
(i18n/label :t/wallet-set-up-title)]
[react/view components.styles/flex
[react/view {:style styles/setup-image-container}
[react/image {:source (:wallet-setup resources/ui)

View File

@ -1,4 +1,5 @@
RERUN_ERRORS = [
"can't receive further commands",
'Original error: Error: ESOCKETTIMEDOUT',
"The server didn't respond in time.",
'An unknown server-side error occurred while processing the command.',

View File

@ -27,6 +27,10 @@ class TestChatManagementMultiple(MultipleDeviceTestCase):
device_1_home_view = device_1_sign_in_view.get_home_view()
device_2_home_view = device_2_sign_in_view.get_home_view()
for home in device_1_home_view, device_2_home_view:
wallet = home.wallet_button.click()
wallet.set_up_wallet()
wallet.home_button.click()
# Device 1: Start new 1-1 chat
device_1_home_view.add_contact(self.senders['h_user']['public_key'])

View File

@ -51,6 +51,11 @@ class TestTransaction(SingleDeviceTestCase):
chat_view.commands_button.click()
chat_view.send_command.click()
chat_view.send_as_keyevent(transaction_amount)
wallet_view = chat_view.get_wallet_view()
chat_view.send_message_button.click_until_presence_of_element(wallet_view.sign_in_phrase)
wallet_view.done_button.click()
wallet_view.yes_button.click()
send_transaction_view = chat_view.get_send_transaction_view()
chat_view.send_message_button.click_until_presence_of_element(send_transaction_view.sign_transaction_button)
send_transaction_view.sign_transaction_button.click_until_presence_of_element(
@ -276,11 +281,10 @@ class TestTransactions(MultipleDeviceTestCase):
device_1_chat.send_as_keyevent(amount)
device_1_chat.send_message_button.click()
request_button = device_2_chat.element_by_text_part('Requesting %s ETH' % amount, 'button')
device_2_chat.send_eth_to_request(request_button, sender['password'])
device_2_chat.send_eth_to_request(request_button, sender['password'], wallet_set_up=True)
self.network_api.find_transaction_by_unique_amount(recipient['address'], amount)
device_2_chat.back_button.click()
device_2_wallet = device_2_home.wallet_button.click()
device_2_wallet.set_up_wallet()
transactions_view = device_2_wallet.transactions_button.click()
transactions_view.transactions_table.find_transaction(amount=amount)
@ -317,5 +321,5 @@ class TestTransactions(MultipleDeviceTestCase):
one_to_one_chat_device_2.wait_for_visibility_of_element(120)
one_to_one_chat_device_2.click()
request_button = device_2_chat.element_by_text_part('Requesting %s ETH' % amount, 'button')
device_2_chat.send_eth_to_request(request_button, sender['password'])
device_2_chat.send_eth_to_request(request_button, sender['password'], wallet_set_up=True)
self.network_api.find_transaction_by_unique_amount(recipient['address'], amount)

View File

@ -278,6 +278,10 @@ class BaseView(object):
from views.profile_view import ProfileView
return ProfileView(self.driver)
def get_wallet_view(self):
from views.wallet_view import WalletView
return WalletView(self.driver)
def get_unique_amount(self):
return '0.0%s' % datetime.now().strftime('%-m%-d%-H%-M%-S').strip('0')

View File

@ -259,10 +259,16 @@ class ChatView(BaseView):
errors.append("Message '%s' was received but username is '%s' instead of %s" %
(message, element.text, username))
def send_eth_to_request(self, request, sender_password):
def send_eth_to_request(self, request, sender_password, wallet_set_up=False):
gas_popup = self.element_by_text_part('Specify amount')
request.click_until_presence_of_element(gas_popup)
send_transaction = self.get_send_transaction_view()
if wallet_set_up:
wallet_view = self.get_wallet_view()
self.send_message_button.click_until_presence_of_element(wallet_view.sign_in_phrase)
wallet_view.done_button.click()
wallet_view.yes_button.click()
else:
self.send_message_button.click_until_presence_of_element(send_transaction.sign_transaction_button)
send_transaction.sign_transaction(sender_password)