Skip to content

Commit

Permalink
feature #6843 - wallet redesign - connected ui with send transaction …
Browse files Browse the repository at this point in the history
…backend and other fixes
  • Loading branch information
goranjovic committed Feb 6, 2019
1 parent 4f8fb7e commit 5b27c00
Show file tree
Hide file tree
Showing 28 changed files with 1,577 additions and 2,000 deletions.
5 changes: 3 additions & 2 deletions resources/icons/paste.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 8 additions & 10 deletions src/status_im/accounts/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@

(defn- chat-send? [transaction]
(and (seq transaction)
(not (:in-progress? transaction))
(:from-chat? transaction)))

(fx/defn continue-after-wallet-onboarding [{:keys [db] :as cofx} modal?]
(let [transaction (get-in db [:wallet :send-transaction])]
(if modal?
{:dispatch [:navigate-to-clean :wallet-send-transaction-modal]}
(if-not (chat-send? transaction)
(navigation/navigate-to-clean cofx :wallet nil)
(navigation/navigate-to-cofx cofx :wallet-send-transaction-modal nil)))))
(fx/defn continue-after-wallet-onboarding [{:keys [db] :as cofx} modal? {:keys [flow] :as screen-params}]
(if modal?
{:dispatch [:navigate-to :wallet-send-transaction-modal screen-params]}
(if (= :chat flow)
(navigation/navigate-to-cofx cofx :wallet-txn-overview screen-params)
(navigation/navigate-to-clean cofx :wallet nil))))

(fx/defn confirm-wallet-set-up
[{:keys [db] :as cofx} modal?]
[{:keys [db] :as cofx} modal? screen-params]
(fx/merge cofx
(continue-after-wallet-onboarding modal?)
(continue-after-wallet-onboarding modal? screen-params)
(wallet.settings.models/wallet-autoconfig-tokens)
(accounts.update/account-update {:wallet-set-up-passed? true} {})))

Expand Down
34 changes: 7 additions & 27 deletions src/status_im/chat/commands/impl/transactions.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,6 @@
(when network-mismatch?
[react/text send-network])]])))

;; TODO(goranjovic) - update to include tokens in https://github.com/status-im/status-react/issues/3233
(defn- transaction-details [contact symbol]
(-> contact
(select-keys [:name :address :public-key])
(assoc :symbol symbol
:gas (ethereum/estimate-gas symbol)
:from-chat? true)))

(defn- inject-network-info [parameters {:keys [db]}]
(assoc parameters :network (:chain db)))

Expand Down Expand Up @@ -303,26 +295,14 @@
{:keys [symbol decimals]} (tokens/asset-for all-tokens chain symbol-param)
{:keys [value error]} (wallet.db/parse-amount amount decimals)
next-view-id (if (:wallet-set-up-passed? sender-account)
:wallet-send-transaction-modal
:wallet-txn-overview
:wallet-onboarding-setup)]
(fx/merge cofx
{:db (-> db
(update-in [:wallet :send-transaction]
assoc
:amount (money/formatted->internal value symbol decimals)
:amount-text amount
:amount-error error)
#_(choose-recipient.events/fill-request-details
(transaction-details recipient-contact symbol))
(update-in [:wallet :send-transaction]
dissoc :id :password :wrong-password?))
;; TODO(janherich) - refactor wallet send events, updating gas price
;; is generic thing which shouldn't be defined in wallet.send, then
;; we can include the utility helper without running into circ-dep problem
:update-gas-price {:web3 (:web3 db)
:success-event :wallet/update-gas-price-success
:edit? false}}
(navigation/navigate-to-cofx next-view-id {}))))
(let [transaction {:amount (money/formatted->internal value symbol decimals)
:symbol symbol
:to (:address recipient-contact)}]
(navigation/navigate-to-cofx cofx next-view-id {:transaction transaction
:contact recipient-contact
:flow :chat}))))
protocol/EnhancedParameters
(enhance-send-parameters [_ parameters cofx]
(-> parameters
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@

(handlers/register-handler-fx
:accounts.ui/wallet-set-up-confirmed
(fn [cofx [_ modal?]]
(accounts/confirm-wallet-set-up cofx modal?)))
(fn [cofx [_ modal? screen-params]]
(accounts/confirm-wallet-set-up cofx modal? screen-params)))

;; accounts create module

Expand Down
4 changes: 2 additions & 2 deletions src/status_im/extensions/ethereum.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
(defn- execute-send-transaction [db {:keys [method params on-success on-failure] :as arguments}]
(let [tx-object (assoc (select-keys arguments [:to :gas :gas-price :value :nonce])
:data (when (and method params) (abi-spec/encode method params)))
transaction (prepare-extension-transaction tx-object (:contacts/contacts db) on-success on-failure)]
(models.wallet/open-modal-wallet-for-transaction db transaction tx-object)))
transaction (prepare-extension-transaction tx-object (:contacts/contacts db) on-success on-failure)]
(models.wallet/open-modal-wallet-for-transaction db transaction)))

(handlers/register-handler-fx
:extensions/ethereum-send-transaction
Expand Down
29 changes: 12 additions & 17 deletions src/status_im/models/wallet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@
(assoc :nonce nonce))))

;; SEND TRANSACTION -> RPC TRANSACTION
(defn prepare-send-transaction [from {:keys [amount to gas gas-price data nonce]}]
(defn prepare-send-transaction [from {:keys [amount to gas gas-price optimal-gas optimal-gas-price data nonce]}]
(cond-> {:from (ethereum/normalized-address from)
:to (ethereum/normalized-address to)
:value (ethereum/int->hex amount)
:gas (ethereum/int->hex gas)
:gasPrice (ethereum/int->hex gas-price)}
:gas (ethereum/int->hex (or gas optimal-gas))
:gasPrice (ethereum/int->hex (or gas-price optimal-gas-price))}
data
(assoc :data data)
nonce
Expand Down Expand Up @@ -145,9 +145,8 @@
(when on-error
{:dispatch (conj on-error "transaction was cancelled by user")}))))

(defn prepare-unconfirmed-transaction [db now hash]
(let [transaction (get-in db [:wallet :send-transaction])
all-tokens (:wallet/all-tokens db)]
(defn prepare-unconfirmed-transaction [db now transaction hash]
(let [all-tokens (:wallet/all-tokens db)]
(let [chain (:chain db)
token (tokens/symbol->token all-tokens (keyword chain) (:symbol transaction))]
(-> transaction
Expand Down Expand Up @@ -237,18 +236,14 @@
(assoc-in [:wallet :balance-loading?] true)
(assoc :prices-loading? true))})))

(defn open-modal-wallet-for-transaction [db transaction tx-object]
(let [{:keys [gas gas-price]} transaction
(defn open-modal-wallet-for-transaction [db transaction]
(let [{:keys [gas]} transaction
{:keys [wallet-set-up-passed?]} (:account/account db)]
{:db (-> db
(assoc-in [:wallet :send-transaction] transaction)
(assoc-in [:wallet :send-transaction :original-gas] gas))
{:db db
:dispatch-n [[:update-wallet]
(when-not gas
[:wallet/update-estimated-gas tx-object])
(when-not gas-price
[:wallet/update-gas-price])
[:navigate-to
(if wallet-set-up-passed?
:wallet-send-modal-stack
:wallet-send-modal-stack-with-onboarding)]]}))
:wallet-send-transaction-modal
:wallet-onboarding-setup-modal)
{:transaction (assoc transaction :original-gas gas)
:flow :dapp}]]}))
2 changes: 2 additions & 0 deletions src/status_im/ui/components/colors.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@

;; ACCENT BLUE
(def blue "#4360df") ;; Accent blue, used as main wallet color, and ios home add button

;; LIGHT BLUE
(def blue-light "#ECEFFC") ;; Light Blue
(def blue-shadow "#8FA2EA")
(def gray-background blue-light) ;; TODO (andrey) should be refactored later by Dmitry

;; RED
Expand Down
7 changes: 4 additions & 3 deletions src/status_im/ui/components/tooltip/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
:background-color colors/gray
:border-radius 8})

(defn tooltip-text [font-size]
{:color colors/red
:font-size font-size})
(defn tooltip-text [font-size text-color]
{:color (or text-color colors/red)
:font-size font-size
:text-align :center})

(def bottom-tooltip-text
{:color colors/white
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/ui/components/tooltip/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
[status-im.ui.components.colors :as colors]
[reagent.core :as reagent]))

(views/defview tooltip [label & [{:keys [bottom-value color font-size] :or {bottom-value -30 color :white font-size 15}}]]
(views/defview tooltip [label & [{:keys [bottom-value color text-color font-size] :or {bottom-value -30 color :white font-size 15}}]]
(views/letsubs [bottom-anim-value (animation/create-value bottom-value)
opacity-value (animation/create-value 0)]
{:component-did-mount (animations/animate-tooltip bottom-value bottom-anim-value opacity-value 10)}
[react/view styles/tooltip-container
[react/animated-view {:style (styles/tooltip-animated bottom-anim-value opacity-value)}
[react/view (styles/tooltip-text-container color)
[react/text {:style (styles/tooltip-text font-size)} label]]
[react/text {:style (styles/tooltip-text font-size text-color)} label]]
[vector-icons/icon :icons/tooltip-triangle {:color color :style styles/tooltip-triangle}]]]))

(views/defview bottom-tooltip-info [label on-close]
Expand Down
31 changes: 7 additions & 24 deletions src/status_im/ui/screens/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
[status-im.ui.screens.wallet.main.views :as wallet.main]
[status-im.ui.screens.wallet.collectibles.views :refer [collectibles-list]]
[status-im.ui.screens.wallet.send.views :as send.views :refer [send-transaction send-transaction-modal]]
[status-im.ui.screens.wallet.send.views.amount :as send.views.amount]
[status-im.ui.screens.wallet.sign-message.views :as sign-message]
[status-im.ui.screens.wallet.choose-recipient.views :refer [choose-recipient]]
[status-im.ui.screens.wallet.request.views :refer [wallet-request-contacts-list request-transaction send-transaction-request]]
[status-im.ui.screens.wallet.components.views :as wallet.components]
[status-im.ui.screens.wallet.onboarding.views :as wallet.onboarding]
[status-im.ui.screens.wallet.transaction-fee.views :as wallet.transaction-fee]
[status-im.ui.screens.wallet.settings.views :as wallet-settings]
[status-im.ui.screens.wallet.transactions.views :as wallet-transactions]
[status-im.ui.screens.wallet.transaction-sent.views :refer [transaction-sent transaction-sent-modal]]
Expand Down Expand Up @@ -201,10 +201,7 @@
[:modal send-transaction-modal]

:wallet-transaction-sent
[:modal transaction-sent-modal]

:wallet-transaction-fee
[:modal wallet.transaction-fee/transaction-fee]}
[:modal transaction-sent-modal]}
:config
{:headerMode "none"
:initialRouteName "wallet-send-transaction-modal"}}
Expand All @@ -218,10 +215,7 @@
[:modal send-transaction-modal]

:wallet-transaction-sent
[:modal transaction-sent-modal]

:wallet-transaction-fee
[:modal wallet.transaction-fee/transaction-fee]}
[:modal transaction-sent-modal]}
:config
{:headerMode "none"
:initialRouteName "wallet-onboarding-setup-modal"}}
Expand All @@ -247,8 +241,8 @@
:wallet-transaction-sent transaction-sent
:recipient-qr-code recipient-qr-code
:wallet-choose-amount send.views/choose-amount-token
:wallet-choose-asset send.views/choose-asset
:wallet-txn-overview send.views/txn-overview
:wallet-choose-asset send.views.amount/choose-asset
:wallet-txn-overview send.views/transaction-overview
:wallet-send-assets wallet.components/send-assets}
:config {:headerMode "none"}}

Expand All @@ -275,10 +269,7 @@
[:modal send-transaction-modal]

:wallet-transaction-sent
[:modal transaction-sent-modal]

:wallet-transaction-fee
[:modal wallet.transaction-fee/transaction-fee]})
[:modal transaction-sent-modal]})
{:headerMode "none"
:initialRouteName "wallet-send-transaction-modal"})}

Expand All @@ -291,22 +282,14 @@
[:modal send-transaction-modal]

:wallet-transaction-sent
[:modal transaction-sent-modal]

:wallet-transaction-fee
[:modal wallet.transaction-fee/transaction-fee]})
[:modal transaction-sent-modal]})
{:headerMode "none"
:initialRouteName "wallet-send-modal-stack-with-onboarding"})}

:wallet-settings-assets
{:screen (nav-reagent/stack-screen
(wrap-modal :wallet-settings-assets wallet-settings/manage-assets))}

:wallet-transaction-fee
{:screen (nav-reagent/stack-screen
(wrap-modal :wallet-transaction-fee
wallet.transaction-fee/transaction-fee))}

:wallet-transactions-filter
{:screen (nav-reagent/stack-screen
(wrap-modal :wallet-transactions-filter
Expand Down
Loading

0 comments on commit 5b27c00

Please sign in to comment.