mirror of
https://github.com/status-im/status-react.git
synced 2025-01-09 18:46:19 +00:00
fix pending transactions
Signed-off-by: yenda <eric@status.im>
This commit is contained in:
parent
48d3087f81
commit
1cac8f1161
@ -48,7 +48,7 @@
|
|||||||
chain (ethereum/chain-keyword db)
|
chain (ethereum/chain-keyword db)
|
||||||
chain-tokens (into {} (map (juxt :address identity)
|
chain-tokens (into {} (map (juxt :address identity)
|
||||||
(tokens/tokens-for all-tokens chain)))]
|
(tokens/tokens-for all-tokens chain)))]
|
||||||
{:db (update-in db [:wallet :transactions]
|
{:db (update-in db [:wallet :accounts]
|
||||||
wallet/remove-transactions-since-block block-number)
|
wallet/remove-transactions-since-block block-number)
|
||||||
::transactions/get-transfers {:chain-tokens chain-tokens
|
::transactions/get-transfers {:chain-tokens chain-tokens
|
||||||
:from-block block-number}}))
|
:from-block block-number}}))
|
||||||
|
@ -113,8 +113,12 @@
|
|||||||
(fx/defn check-watched-transactions
|
(fx/defn check-watched-transactions
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [watched-transactions
|
(let [watched-transactions
|
||||||
(select-keys (get-in db [:wallet :transactions])
|
(reduce-kv (fn [acc _ {:keys [transactions]}]
|
||||||
(keys (get db :ethereum/watched-transactions)))]
|
(merge acc
|
||||||
|
(select-keys transactions
|
||||||
|
(keys (get db :ethereum/watched-transactions)))))
|
||||||
|
{}
|
||||||
|
(get-in db [:wallet :accounts]))]
|
||||||
(apply fx/merge
|
(apply fx/merge
|
||||||
cofx
|
cofx
|
||||||
(map (fn [[_ transaction]]
|
(map (fn [[_ transaction]]
|
||||||
@ -151,12 +155,6 @@
|
|||||||
transfers)))))]
|
transfers)))))]
|
||||||
(apply fx/merge cofx effects)))
|
(apply fx/merge cofx effects)))
|
||||||
|
|
||||||
(fx/defn handle-token-history
|
|
||||||
[{:keys [db]} transactions]
|
|
||||||
{:db (update-in db
|
|
||||||
[:wallet :transactions]
|
|
||||||
merge transactions)})
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
::get-transfers
|
::get-transfers
|
||||||
(fn [{:keys [chain-tokens from-block to-block historical?]
|
(fn [{:keys [chain-tokens from-block to-block historical?]
|
||||||
|
@ -1430,16 +1430,6 @@
|
|||||||
(fn [cofx [_ id handler]]
|
(fn [cofx [_ id handler]]
|
||||||
(ethereum.subscriptions/register-subscription cofx id handler)))
|
(ethereum.subscriptions/register-subscription cofx id handler)))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:ethereum.transactions.callback/etherscan-error
|
|
||||||
(fn [cofx [event error]]
|
|
||||||
(log/info event error)))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:ethereum.transactions.callback/fetch-token-history-success
|
|
||||||
(fn [cofx [_ transactions]]
|
|
||||||
(ethereum.transactions/handle-token-history cofx transactions)))
|
|
||||||
|
|
||||||
;; wallet events
|
;; wallet events
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
|
@ -96,11 +96,10 @@
|
|||||||
:cb #(re-frame/dispatch [:signing/transaction-completed % tx-obj-to-send])}})))))
|
:cb #(re-frame/dispatch [:signing/transaction-completed % tx-obj-to-send])}})))))
|
||||||
|
|
||||||
(fx/defn prepare-unconfirmed-transaction
|
(fx/defn prepare-unconfirmed-transaction
|
||||||
[{:keys [db now]} hash {:keys [value gasPrice gas data to from]} symbol]
|
[{:keys [db now]} hash {:keys [value gasPrice gas data to from]} symbol amount]
|
||||||
(let [all-tokens (:wallet/all-tokens db)
|
(let [all-tokens (:wallet/all-tokens db)
|
||||||
chain (:chain db)
|
token (tokens/symbol->token all-tokens (ethereum/chain-keyword db) symbol)]
|
||||||
token (tokens/symbol->token all-tokens (keyword chain) symbol)]
|
{:db (assoc-in db [:wallet :accounts from :transactions hash]
|
||||||
{:db (assoc-in db [:wallet :transactions hash]
|
|
||||||
{:timestamp (str now)
|
{:timestamp (str now)
|
||||||
:to to
|
:to to
|
||||||
:from from
|
:from from
|
||||||
@ -109,7 +108,9 @@
|
|||||||
:data data
|
:data data
|
||||||
:token token
|
:token token
|
||||||
:symbol symbol
|
:symbol symbol
|
||||||
:value (money/to-fixed (money/bignumber value))
|
:value (if token
|
||||||
|
(money/unit->token amount (:decimals token))
|
||||||
|
(money/to-fixed (money/bignumber value)))
|
||||||
:gas-price (money/to-fixed (money/bignumber gasPrice))
|
:gas-price (money/to-fixed (money/bignumber gasPrice))
|
||||||
:gas-limit (money/to-fixed (money/bignumber gas))})}))
|
:gas-limit (money/to-fixed (money/bignumber gas))})}))
|
||||||
|
|
||||||
@ -204,11 +205,11 @@
|
|||||||
|
|
||||||
(fx/defn transaction-result
|
(fx/defn transaction-result
|
||||||
[{:keys [db] :as cofx} result tx-obj]
|
[{:keys [db] :as cofx} result tx-obj]
|
||||||
(let [{:keys [on-result symbol]} (get db :signing/tx)]
|
(let [{:keys [on-result symbol amount]} (get db :signing/tx)]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (dissoc db :signing/tx :signing/in-progress? :signing/sign)
|
{:db (dissoc db :signing/tx :signing/in-progress? :signing/sign)
|
||||||
:signing/show-transaction-result nil}
|
:signing/show-transaction-result nil}
|
||||||
(prepare-unconfirmed-transaction result tx-obj symbol)
|
(prepare-unconfirmed-transaction result tx-obj symbol amount)
|
||||||
(check-queue)
|
(check-queue)
|
||||||
#(when on-result
|
#(when on-result
|
||||||
{:dispatch (conj on-result result)}))))
|
{:dispatch (conj on-result result)}))))
|
||||||
|
@ -71,8 +71,15 @@
|
|||||||
0))
|
0))
|
||||||
|
|
||||||
(defn remove-transactions-since-block
|
(defn remove-transactions-since-block
|
||||||
[transactions block]
|
[accounts block]
|
||||||
(into empty-transaction-map
|
(reduce-kv (fn [acc account-address {:keys [transactions] :as account}]
|
||||||
(drop-while (fn [[k v]]
|
(assoc acc account-address
|
||||||
(>= (int (:block v)) block))
|
(update account
|
||||||
transactions)))
|
:transactions
|
||||||
|
(fn [transactions]
|
||||||
|
(into empty-transaction-map
|
||||||
|
(drop-while (fn [[k v]]
|
||||||
|
(>= (int (:block v)) block))
|
||||||
|
transactions))))))
|
||||||
|
{}
|
||||||
|
accounts))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user