Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT SQUASH Meta wallet transaction history #8228

Merged
merged 8 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion STATUS_GO_SHA256
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## DO NOT EDIT THIS FILE BY HAND. USE `scripts/update-status-go.sh <tag>` instead

0cj202bj2rwfrw327gibj8hj8i94ciyp3hkq2hck9l6711qlhpnb
0049i6znvl45hc651bqyzwgmzlv0fp40maggfjsrv13q5avd0g6d
2 changes: 1 addition & 1 deletion STATUS_GO_VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## DO NOT EDIT THIS FILE BY HAND. USE `scripts/update-status-go.sh <tag>` instead

v0.25.0-beta.0
v0.25.0-beta.1
8 changes: 3 additions & 5 deletions src/status_im/accounts/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
(:require [re-frame.core :as re-frame]
[status-im.accounts.update.core :as accounts.update]
[status-im.i18n :as i18n]
[status-im.ui.screens.navigation :as navigation]
[status-im.native-module.core :as native-module]
[status-im.ui.screens.wallet.settings.models :as wallet.settings.models]
[status-im.ui.screens.navigation :as navigation]
[status-im.utils.build :as build]
[status-im.utils.config :as config]
[status-im.utils.utils :as utils]
[status-im.utils.fx :as fx]
[status-im.utils.platform :as platform]
[status-im.utils.build :as build]))
[status-im.utils.utils :as utils]))

(re-frame/reg-fx
::chaos-mode-changed
Expand Down Expand Up @@ -49,7 +48,6 @@
[{:keys [db] :as cofx} modal?]
(fx/merge cofx
(continue-after-wallet-onboarding modal?)
(wallet.settings.models/wallet-autoconfig-tokens)
(accounts.update/account-update {:wallet-set-up-passed? true} {})))

(fx/defn update-dev-server-state
Expand Down
13 changes: 7 additions & 6 deletions src/status_im/accounts/login/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
[status-im.chaos-mode.core :as chaos-mode]
[status-im.data-store.core :as data-store]
[status-im.ethereum.subscriptions :as ethereum.subscriptions]
[status-im.ethereum.transactions.core :as transactions]
[status-im.fleet.core :as fleet]
[status-im.i18n :as i18n]
[status-im.models.transactions :as transactions]
[status-im.models.wallet :as models.wallet]
[status-im.native-module.core :as status]
[status-im.node.core :as node]
[status-im.protocol.core :as protocol]
Expand All @@ -22,6 +21,7 @@
[status-im.utils.security :as security]
[status-im.utils.types :as types]
[status-im.utils.universal-links.core :as universal-links]
[status-im.wallet.core :as wallet]
[taoensso.timbre :as log]))

(def rpc-endpoint "https://goerli.infura.io/v3/f315575765b14720b32382a61a89341a")
Expand Down Expand Up @@ -84,10 +84,11 @@

(fx/defn initialize-wallet [cofx]
(fx/merge cofx
(models.wallet/initialize-tokens)
(ethereum.subscriptions/initialize)
(models.wallet/update-wallet)
(transactions/start-sync)))
(wallet/initialize-tokens)
(wallet/update-balances)
(wallet/update-prices)
(transactions/initialize)
(ethereum.subscriptions/initialize)))

(fx/defn user-login [{:keys [db] :as cofx} create-database?]
(let [{:keys [address password]} (accounts.db/credentials cofx)]
Expand Down
10 changes: 4 additions & 6 deletions src/status_im/accounts/logout/core.cljs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
(ns status-im.accounts.logout.core
(:require [re-frame.core :as re-frame]
[status-im.chaos-mode.core :as chaos-mode]
[status-im.i18n :as i18n]
[status-im.transport.core :as transport]
[status-im.utils.fx :as fx]
[status-im.models.transactions :as transactions]
[status-im.node.core :as node]
[status-im.init.core :as init]
[status-im.chaos-mode.core :as chaos-mode]))
[status-im.node.core :as node]
[status-im.transport.core :as transport]
[status-im.utils.fx :as fx]))

(fx/defn logout
[{:keys [db] :as cofx}]
(fx/merge cofx
{:keychain/clear-user-password (get-in db [:account/account :address])
:dev-server/stop nil}
(transactions/stop-sync)
(transport/stop-whisper
#(re-frame/dispatch [:accounts.logout/filters-removed]))
(chaos-mode/stop-checking)))
Expand Down
55 changes: 31 additions & 24 deletions src/status_im/chat/commands/impl/transactions.cljs
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
(ns status-im.chat.commands.impl.transactions
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [clojure.string :as string]
[reagent.core :as reagent]
[re-frame.core :as re-frame]
[reagent.core :as reagent]
[status-im.chat.commands.impl.transactions.styles
:as
transactions-styles]
[status-im.chat.commands.protocol :as protocol]
[status-im.chat.commands.impl.transactions.styles :as transactions-styles]
[status-im.contact.db :as db.contact]
[status-im.data-store.messages :as messages-store]
[status-im.ui.components.react :as react]
[status-im.ui.components.icons.vector-icons :as vector-icons]
[status-im.i18n :as i18n]
[status-im.ui.components.animation :as animation]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.icons.vector-icons :as vector-icons]
[status-im.ui.components.list.views :as list]
[status-im.ui.components.animation :as animation]
[status-im.ui.components.react :as react]
[status-im.ui.components.svgimage :as svgimage]
[status-im.i18n :as i18n]
[status-im.contact.db :as db.contact]
[status-im.ui.screens.navigation :as navigation]
[status-im.ui.screens.wallet.choose-recipient.events
:as
choose-recipient.events]
[status-im.ui.screens.wallet.utils :as wallet.utils]
[status-im.utils.datetime :as datetime]
[status-im.utils.ethereum.core :as ethereum]
[status-im.utils.ethereum.tokens :as tokens]
[status-im.utils.datetime :as datetime]
[status-im.utils.fx :as fx]
[status-im.utils.money :as money]
[status-im.utils.platform :as platform]
[status-im.ui.screens.wallet.db :as wallet.db]
[status-im.ui.screens.wallet.choose-recipient.events :as choose-recipient.events]
[status-im.ui.screens.navigation :as navigation]
[status-im.ui.screens.wallet.utils :as wallet.utils]
[status-im.ui.components.chat-icon.screen :as chat-icon]))
[status-im.ui.components.chat-icon.screen :as chat-icon]
[status-im.wallet.db :as wallet.db])
(:require-macros [status-im.utils.views :refer [defview letsubs]]))

;; common `send/request` functionality

Expand Down Expand Up @@ -179,19 +183,22 @@
;; `/send` command

(defview send-status [tx-hash outgoing]
(letsubs [confirmed? [:chats/transaction-confirmed? tx-hash]
tx-exists? [:chats/wallet-transaction-exists? tx-hash]]
[react/touchable-highlight {:on-press #(when tx-exists?
(re-frame/dispatch [:show-transaction-details tx-hash]))}
(letsubs [{:keys [exists? confirmed?]} [:chats/transaction-status tx-hash]]
[react/touchable-highlight {:on-press #(when exists?
(re-frame/dispatch [:wallet.ui/show-transaction-details tx-hash]))}
[react/view transactions-styles/command-send-status-container
[vector-icons/icon (if confirmed? :tiny-icons/tiny-check :tiny-icons/tiny-pending)
{:color (if outgoing colors/blue-light colors/blue)
[vector-icons/icon (if confirmed?
:tiny-icons/tiny-check
:tiny-icons/tiny-pending)
{:color (if outgoing
colors/blue-light
colors/blue)
:container-style (transactions-styles/command-send-status-icon outgoing)}]
[react/view
[react/text {:style (transactions-styles/command-send-status-text outgoing)}
(i18n/label (cond
confirmed? :status-confirmed
tx-exists? :status-pending
exists? :status-pending
:else :status-tx-not-found))]]]]))

(defn transaction-status [{:keys [tx-hash outgoing]}]
Expand Down Expand Up @@ -326,9 +333,9 @@
;; 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}}
:wallet/update-gas-price
{:success-event :wallet/update-gas-price-success
:edit? false}}
(navigation/navigate-to-cofx next-view-id {}))))
protocol/EnhancedParameters
(enhance-send-parameters [_ parameters cofx]
Expand Down
13 changes: 1 addition & 12 deletions src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@

(def system "system")

(def default-wallet-transactions
{:filters
{:type [{:id :inbound :label (i18n/label :t/incoming) :checked? true}
{:id :outbound :label (i18n/label :t/outgoing) :checked? true}
{:id :pending :label (i18n/label :t/pending) :checked? true}
{:id :failed :label (i18n/label :t/failed) :checked? true}]}})

(def mainnet-networks
{"mainnet" {:id "mainnet",
:name "Mainnet",
Expand Down Expand Up @@ -110,11 +103,7 @@
(defn default-account-settings []
{:web3-opt-in? true
:preview-privacy? false
:wallet {:visible-tokens {:testnet #{:STT :HND}
:mainnet #{:SNT}
:rinkeby #{:MOKSHA :KDO}
:xdai #{}
:poa #{}}}})
:wallet {:visible-tokens {}}})

(def currencies
{:aed {:id :aed :code "AED" :display-name (i18n/label :t/currency-display-name-aed) :symbol "د.إ"}
Expand Down
17 changes: 17 additions & 0 deletions src/status_im/ethereum/contracts.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(ns status-im.ethereum.contracts
(:require [status-im.utils.ethereum.core :as ethereum]))

(def contracts
{:status/snt
{:mainnet "0x744d70fdbe2ba4cf95131626614a1763df805b9e"
:testnet "0xc55cf4b03948d7ebc8b9e8bad92643703811d162"}
:status/tribute-to-talk
{:testnet "0x3da3fc53e24707f36c5b4433b442e896c4955f0e"}
:status/stickers
{:testnet "0x39d16CdB56b5a6a89e1A397A13Fe48034694316E"}})

(defn get-address
[db contract]
(let [chain-keyword (-> (get-in db [:account/account :networks (:network db)])
ethereum/network->chain-keyword)]
(get-in contracts [contract chain-keyword])))
74 changes: 74 additions & 0 deletions src/status_im/ethereum/json_rpc.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
(ns status-im.ethereum.json-rpc
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.ethereum.decode :as decode]
[status-im.native-module.core :as status]
[status-im.utils.ethereum.abi-spec :as abi-spec]
[status-im.utils.money :as money]
[status-im.utils.types :as types]
[taoensso.timbre :as log]))

(def json-rpc-api
{"eth_call" {}
"eth_getBalance"
{:on-result money/bignumber}
"eth_estimateGas"
{:on-result money/bignumber}
"eth_gasPrice"
{:on-result money/bignumber}
"eth_getBlockByHash"
{:on-result #(-> (update % :number decode/uint)
(update :timestamp decode/uint))}
"eth_getTransactionByHash" {}
"eth_getTransactionReceipt" {}
"eth_newBlockFilter" {:subscription? true}
"eth_newFilter" {:subscription? true}})

(defn call
[{:keys [method params on-success on-error]}]
(when-let [method-options (json-rpc-api method)]
(let [{:keys [id on-result subscription?]
:or {on-result identity
id 1
params []}} method-options
on-error (or on-error
#(log/warn :json-rpc/error method :params params :error %))]
(if (nil? method)
(log/error :json-rpc/method-not-found method)
(status/call-private-rpc
(types/clj->json {:jsonrpc "2.0"
:id id
:method (if subscription?
"eth_subscribeSignal"
method)
:params (if subscription?
[method params]
params)})
(fn [response]
(if (string/blank? response)
(on-error {:message "Blank response"})
(let [{:keys [error result] :as response2} (types/json->clj response)]
(if error
(on-error error)
(if subscription?
(re-frame/dispatch
[:ethereum.callback/subscription-success
result on-success])
(on-success (on-result result))))))))))))

(defn eth-call
[{:keys [contract method params outputs on-success on-error block]
:or {block "latest"
params []}}]
(call {:method "eth_call"
:params [{:to contract
:data (abi-spec/encode method params)}
(if (int? block)
(abi-spec/number-to-hex block)
block)]
:on-success
(if outputs
#(on-success (abi-spec/decode % outputs))
on-success)
:on-error
on-error}))