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 19, 2019
1 parent e2972c0 commit 56036a6
Show file tree
Hide file tree
Showing 34 changed files with 1,619 additions and 2,013 deletions.
File renamed without changes
File renamed without changes
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 @@ -236,14 +236,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 @@ -307,26 +299,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 @@ -188,8 +188,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
2 changes: 2 additions & 0 deletions src/status_im/ui/components/icons/vector_icons.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@
:main-icons/send (components.svg/slurp-svg "./resources/icons/main/send.svg")
:main-icons/settings (components.svg/slurp-svg "./resources/icons/main/settings.svg")
:main-icons/share (components.svg/slurp-svg "./resources/icons/main/share.svg")
:main-icons/sliders (components.svg/slurp-svg "./resources/icons/main/sliders.svg")
:main-icons/stickers (components.svg/slurp-svg "./resources/icons/main/stickers.svg")
:main-icons/text (components.svg/slurp-svg "./resources/icons/main/text.svg")
:main-icons/time (components.svg/slurp-svg "./resources/icons/main/time.svg")
:main-icons/tribute-to-talk (components.svg/slurp-svg "./resources/icons/main/tribute_to_talk.svg")
:main-icons/two-arrows (components.svg/slurp-svg "./resources/icons/main/two_arrows.svg")
:main-icons/user-profile (components.svg/slurp-svg "./resources/icons/main/user_profile.svg")
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
10 changes: 5 additions & 5 deletions src/status_im/ui/screens/routing/screens.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
[status-im.ui.screens.wallet.send.views :as send]
[status-im.ui.screens.wallet.request.views :as request]
[status-im.ui.screens.wallet.components.views :as wallet.components]
[status-im.ui.screens.wallet.send.views.amount :as wallet.send.amount]
[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.sign-message.views :as wallet.sign-message]
[status-im.ui.screens.wallet.settings.views :as wallet-settings]
[status-im.ui.screens.wallet.send.views :as send.views]
[status-im.ui.screens.wallet.transactions.views :as wallet-transactions]
Expand Down Expand Up @@ -93,20 +94,19 @@
:show-extension-modal [:modal extensions.add/show-extension-modal]
:wallet-send-transaction-modal [:modal send/send-transaction-modal]
:wallet-transaction-sent-modal [:modal transaction-sent/transaction-sent-modal]
:wallet-transaction-fee [:modal wallet.transaction-fee/transaction-fee]
:wallet-onboarding-setup-modal [:modal wallet.onboarding/modal]
:wallet-sign-message-modal [:modal send/sign-message-modal]
:wallet-sign-message-modal [:modal wallet.sign-message/sign-message-modal]
:wallet (main-tabs/get-main-tab :wallet)
:collectibles-list collectibles/collectibles-list
:wallet-onboarding-setup wallet.onboarding/screen
:wallet-send-transaction-chat send/send-transaction
:contact-code wallet.components/contact-code
:wallet-send-transaction send/send-transaction
:recent-recipients request/wallet-request-contacts-list
:wallet-transaction-sent transaction-sent/transaction-sent
:recipient-qr-code wallet.components/recipient-qr-code
:wallet-choose-amount send.views/choose-amount-token
:wallet-choose-asset send.views/choose-asset
:wallet-txn-overview send.views/transaction-overview
:wallet-choose-asset wallet.send.amount/choose-asset
:wallet-send-assets wallet.components/send-assets
:wallet-request-transaction request/request-transaction
:wallet-send-transaction-request request/send-transaction-request
Expand Down
3 changes: 3 additions & 0 deletions src/status_im/ui/screens/routing/wallet_stack.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
{:name :send-transaction-stack
:screens [:wallet-send-transaction
:recent-recipients
:wallet-choose-amount
:wallet-txn-overview
:wallet-choose-asset
:wallet-transaction-sent
:recipient-qr-code
:wallet-send-assets]}
Expand Down
Loading

0 comments on commit 56036a6

Please sign in to comment.