Skip to content

Commit

Permalink
feature #6843 - wallet redesign - choose address or contact screens
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Hauman authored and goranjovic committed Feb 21, 2019
1 parent b8d4f29 commit b01091a
Show file tree
Hide file tree
Showing 10 changed files with 1,063 additions and 8 deletions.
4 changes: 4 additions & 0 deletions resources/icons/change.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 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.
4 changes: 4 additions & 0 deletions resources/icons/sliders.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions resources/icons/time.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/status_im/ui/screens/routing/screens.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
[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.send.views :as send.views]
[status-im.ui.screens.wallet.transactions.views :as wallet-transactions]
[status-im.ui.screens.wallet.transaction-sent.views :as transaction-sent]
[status-im.ui.screens.contacts-list.views :as contacts-list]
Expand Down Expand Up @@ -104,6 +105,8 @@
:recent-recipients wallet.components/recent-recipients
: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-send-assets wallet.components/send-assets
:wallet-request-transaction request/request-transaction
:wallet-send-transaction-request request/send-transaction-request
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/wallet/send/animations.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
:duration 500})
(animation/timing bottom-value {:toValue 53
:easing (.bezier (animation/easing) 0.685, 0.000, 0.025, 1.185)
:duration 500})])))
:duration 500})])))
58 changes: 57 additions & 1 deletion src/status_im/ui/screens/wallet/send/events.cljs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
(ns status-im.ui.screens.wallet.send.events
(:require [re-frame.core :as re-frame]
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.chat.commands.sending :as commands-sending]
[status-im.chat.models.message :as models.message]
[status-im.chat.models :as chat.models]
[status-im.constants :as constants]
[status-im.contact.db :as contact.db]
[status-im.i18n :as i18n]
[status-im.models.transactions :as wallet.transactions]
[status-im.models.wallet :as models.wallet]
[status-im.native-module.core :as status]
[status-im.ui.screens.navigation :as navigation]
[status-im.ui.screens.wallet.db :as wallet.db]
[status-im.utils.ethereum.ens :as ens]
[status-im.utils.ethereum.eip681 :as eip681]
[status-im.utils.ethereum.core :as ethereum]
[status-im.utils.ethereum.erc20 :as erc20]
[status-im.utils.ethereum.tokens :as tokens]
Expand Down Expand Up @@ -52,6 +56,58 @@
(utils/set-timeout #(utils/show-popup (i18n/label :t/transaction-failed) message) 1000)))

;;;; Handlers
;; HANDLE QR CODE

#_(defn- qr-data->send-tx-data [{:keys [address name value symbol gas gasPrice public-key from-chat?]}]
{:pre [(not (nil? address))]}
(cond-> {:to address :public-key public-key}
value (assoc :amount value)
symbol (assoc :symbol symbol)
gas (assoc :gas (money/bignumber gas))
from-chat? (assoc :from-chat? from-chat?)
gasPrice (assoc :gas-price (money/bignumber gasPrice))))

#_(defn extract-qr-code-details [chain-id qr-uri]
{:pre [(integer? chain-id) (string? qr-uri)]}
;; i don't like fetching all tokens here
(let [{:keys [:wallet/all-tokens]} @re-frame.db/app-db
qr-uri (string/trim qr-uri)
;chain-id (ethereum/chain-keyword->chain-id chain)
]
(or (let [m (eip681/parse-uri qr-uri)]
(merge m (eip681/extract-request-details m all-tokens)))
(when (ethereum/address? qr-uri)
{:address qr-uri :chain-id chain-id}))))

#_(defn qr-data->transaction-data [qr-data]
{:pre [(map? qr-data)]}
;; i don't like fetching all tokens here
(let [{:keys [:contacts/contacts]} @re-frame.db/app-db
{:keys [to] :as tx-details} (qr-data->send-tx-data qr-data)
contact-name (:name (contact.db/find-contact-by-address contacts to))]
(cond-> tx-details
contact-name (assoc :to-name name))))

;; CHOOSEN RECIPIENT
(defn eth-name->address [chain recipient callback]
(if (ens/is-valid-eth-name? recipient)
(ens/get-addr (get @re-frame.db/app-db :web3)
(get ens/ens-registries chain)
recipient
callback)
(callback recipient)))

(defn chosen-recipient [chain recipient success-callback error-callback]
{:pre [(keyword? chain) (string? recipient)]}
(eth-name->address chain recipient
#(if (ethereum/address? %)
(success-callback %)
(error-callback %))))

(handlers/register-handler-fx
:wallet/transaction-to-success
(fn [{:keys [db]} [_ recipient-address]]
{:db (assoc-in db [:wallet :send-transaction :to] recipient-address)}))

;; SEND TRANSACTION
(handlers/register-handler-fx
Expand Down
15 changes: 15 additions & 0 deletions src/status_im/ui/screens/wallet/send/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,18 @@

(defstyle gas-input-error-tooltip
{:android {:bottom-value -38}})

;; ----------------------------------------------------------------------
;; Choose Address View
;; ----------------------------------------------------------------------

(def centered {:justify-content :center
:align-items :center})

(def choose-recipient-text-input
{:color colors/white
:font-size 30
:font-weight :bold
:line-height 39
:min-width 236
:margin-horizontal 24})
Loading

0 comments on commit b01091a

Please sign in to comment.