show onboarding for transaction from chat [#4456]
This commit is contained in:
parent
68eb36f7b1
commit
83afbd515a
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -46,16 +47,16 @@
|
|||
(handlers/register-handler-fx
|
||||
:create-account
|
||||
(fn [{{:accounts/keys [create] :as db} :db} _]
|
||||
{:db (update db :accounts/create assoc :step :account-creating :error nil)
|
||||
{:db (update db :accounts/create assoc :step :account-creating :error nil)
|
||||
::create-account (:password create)}))
|
||||
|
||||
(defn add-account
|
||||
"Takes db and new account, creates map of effects describing adding account to database and realm"
|
||||
[{:keys [network] :networks/keys [networks] :as db} {:keys [address] :as account}]
|
||||
(let [enriched-account (assoc account
|
||||
:network network
|
||||
:network network
|
||||
:networks networks
|
||||
:address address)]
|
||||
:address address)]
|
||||
{:db (assoc-in db [:accounts/accounts address] enriched-account)
|
||||
:data-store/base-tx [(accounts-store/save-account-tx enriched-account)]}))
|
||||
|
||||
|
@ -92,8 +93,8 @@
|
|||
(map (fn [{:keys [address] :as account}]
|
||||
[address account]))
|
||||
(into {}))
|
||||
;;workaround for realm bug, migrating account v4
|
||||
events (mapv #(when (empty? (:networks %)) [:account-update-networks (:address %)]) (vals accounts))]
|
||||
;;workaround for realm bug, migrating account v4
|
||||
events (mapv #(when (empty? (:networks %)) [:account-update-networks (:address %)]) (vals accounts))]
|
||||
(merge
|
||||
{:db (assoc db :accounts/accounts accounts)}
|
||||
(when-not (empty? events)
|
||||
|
@ -103,7 +104,7 @@
|
|||
:account-update-networks
|
||||
(fn [{{:accounts/keys [accounts] :networks/keys [networks] :as db} :db} [_ id]]
|
||||
(let [current-account (get accounts id)
|
||||
new-account (assoc current-account :networks networks)]
|
||||
new-account (assoc current-account :networks networks)]
|
||||
{:db (assoc-in db [:accounts/accounts id] new-account)
|
||||
:data-store/base-tx [(accounts-store/save-account-tx new-account)]})))
|
||||
|
||||
|
@ -112,18 +113,18 @@
|
|||
([settings success-event {{:keys [account/account] :as db} :db :as cofx}]
|
||||
(let [new-account (assoc account :settings settings)]
|
||||
{:db (assoc db :account/account new-account)
|
||||
:data-store/base-tx [{:transaction (accounts-store/save-account-tx new-account)
|
||||
:data-store/base-tx [{:transaction (accounts-store/save-account-tx new-account)
|
||||
:success-event success-event}]})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:send-account-update-if-needed
|
||||
(fn [{:keys [db now] :as cofx} _]
|
||||
(let [{:keys [last-updated]} (:account/account db)
|
||||
needs-update? (> (- now last-updated) time/week)]
|
||||
needs-update? (> (- now last-updated) time/week)]
|
||||
(log/info "Need to send account-update: " needs-update?)
|
||||
(when needs-update?
|
||||
;; TODO(janherich): this is very strange and misleading, need to figure out why it'd necessary to update
|
||||
;; account with network update when last update was more then week ago
|
||||
;; TODO(janherich): this is very strange and misleading, need to figure out why it'd necessary to update
|
||||
;; account with network update when last update was more then week ago
|
||||
(accounts.utils/account-update nil cofx)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
@ -137,7 +138,7 @@
|
|||
(handlers/register-handler-fx
|
||||
:account-finalized
|
||||
(fn [{db :db} [_ show-welcome?]]
|
||||
{:db (assoc db :accounts/create {:show-welcome? show-welcome?})
|
||||
{:db (assoc db :accounts/create {:show-welcome? show-welcome?})
|
||||
:dispatch-n [[:navigate-to-clean :home]
|
||||
[:request-notifications]]}))
|
||||
|
||||
|
@ -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}))))
|
|
@ -90,23 +90,26 @@
|
|||
(fn [cofx [_ view-id]]
|
||||
(replace-view view-id cofx)))
|
||||
|
||||
(defn navigate-back [{:keys [navigation-stack view-id modal] :as db}]
|
||||
(cond
|
||||
modal (assoc db :modal nil
|
||||
:was-modal? true)
|
||||
(>= 1 (count navigation-stack)) db
|
||||
|
||||
:else
|
||||
(let [[previous-view-id :as navigation-stack'] (pop navigation-stack)
|
||||
first-in-stack (first navigation-stack)]
|
||||
(if (= view-id first-in-stack)
|
||||
(-> db
|
||||
(assoc :view-id previous-view-id)
|
||||
(assoc :navigation-stack navigation-stack'))
|
||||
(assoc db :view-id first-in-stack)))))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:navigate-back
|
||||
(re-frame/enrich -preload-data!)
|
||||
(fn [{:keys [navigation-stack view-id modal] :as db} _]
|
||||
(cond
|
||||
modal (assoc db :modal nil
|
||||
:was-modal? true)
|
||||
(>= 1 (count navigation-stack)) db
|
||||
|
||||
:else
|
||||
(let [[previous-view-id :as navigation-stack'] (pop navigation-stack)
|
||||
first-in-stack (first navigation-stack)]
|
||||
(if (= view-id first-in-stack)
|
||||
(-> db
|
||||
(assoc :view-id previous-view-id)
|
||||
(assoc :navigation-stack navigation-stack'))
|
||||
(assoc db :view-id first-in-stack))))))
|
||||
(fn [db _]
|
||||
(navigate-back db)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-to-clean
|
||||
|
|
|
@ -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)
|
||||
|
@ -48,21 +49,21 @@
|
|||
(reg-fx
|
||||
:get-balance
|
||||
(fn [{:keys [web3 account-id success-event error-event]}]
|
||||
(get-balance {:web3 web3
|
||||
:account-id account-id
|
||||
:on-success #(re-frame/dispatch [success-event %])
|
||||
:on-error #(re-frame/dispatch [error-event %])})))
|
||||
(get-balance {:web3 web3
|
||||
:account-id account-id
|
||||
:on-success #(re-frame/dispatch [success-event %])
|
||||
:on-error #(re-frame/dispatch [error-event %])})))
|
||||
|
||||
(reg-fx
|
||||
:get-tokens-balance
|
||||
(fn [{:keys [web3 symbols chain account-id success-event error-event]}]
|
||||
(doseq [symbol symbols]
|
||||
(let [contract (:address (tokens/symbol->token chain symbol))]
|
||||
(get-token-balance {:web3 web3
|
||||
:contract contract
|
||||
:account-id account-id
|
||||
:on-success #(re-frame/dispatch [success-event symbol %])
|
||||
:on-error #(re-frame/dispatch [error-event %])})))))
|
||||
(get-token-balance {:web3 web3
|
||||
:contract contract
|
||||
:account-id account-id
|
||||
:on-success #(re-frame/dispatch [success-event symbol %])
|
||||
:on-error #(re-frame/dispatch [error-event %])})))))
|
||||
|
||||
(reg-fx
|
||||
:get-transactions
|
||||
|
@ -109,25 +110,25 @@
|
|||
currency-id (or (get-in settings [:wallet :currency]) :usd)
|
||||
currency (get constants/currencies currency-id)]
|
||||
(when (not= network-status :offline)
|
||||
{:get-balance {:web3 web3
|
||||
:account-id address
|
||||
:success-event :update-balance-success
|
||||
:error-event :update-balance-fail}
|
||||
{:get-balance {:web3 web3
|
||||
:account-id address
|
||||
:success-event :update-balance-success
|
||||
:error-event :update-balance-fail}
|
||||
:get-tokens-balance {:web3 web3
|
||||
:account-id address
|
||||
:symbols symbols
|
||||
:chain chain
|
||||
:success-event :update-token-balance-success
|
||||
:error-event :update-token-balance-fail}
|
||||
:get-prices {:from (if mainnet? (conj symbols "ETH") ["ETH"])
|
||||
:to [(:code currency)]
|
||||
:success-event :update-prices-success
|
||||
:error-event :update-prices-fail}
|
||||
:db (-> db
|
||||
(clear-error-message :prices-update)
|
||||
(clear-error-message :balance-update)
|
||||
(assoc-in [:wallet :balance-loading?] true)
|
||||
(assoc :prices-loading? true))}))))
|
||||
:get-prices {:from (if mainnet? (conj symbols "ETH") ["ETH"])
|
||||
:to [(:code currency)]
|
||||
:success-event :update-prices-success
|
||||
:error-event :update-prices-fail}
|
||||
:db (-> db
|
||||
(clear-error-message :prices-update)
|
||||
(clear-error-message :balance-update)
|
||||
(assoc-in [:wallet :balance-loading?] true)
|
||||
(assoc :prices-loading? true))}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-transactions
|
||||
|
@ -226,7 +227,7 @@
|
|||
(handlers/register-handler-fx
|
||||
:show-transaction-details
|
||||
(fn [{:keys [db]} [_ hash]]
|
||||
{:db (assoc-in db [:wallet :current-transaction] hash)
|
||||
{:db (assoc-in db [:wallet :current-transaction] hash)
|
||||
:dispatch [:navigate-to :wallet-transaction-details]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
@ -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))}))
|
|
@ -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)
|
||||
|
|
|
@ -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.',
|
||||
|
|
|
@ -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'])
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -259,11 +259,17 @@ 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()
|
||||
self.send_message_button.click_until_presence_of_element(send_transaction.sign_transaction_button)
|
||||
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)
|
||||
|
||||
def delete_chat(self, chat_name: str, errors: list):
|
||||
|
|
Loading…
Reference in New Issue