From 6e9292c1e12568a9ae0ee348b3b564eb94732a66 Mon Sep 17 00:00:00 2001 From: Andrey Shovkoplyas Date: Mon, 3 Feb 2020 09:28:49 +0100 Subject: [PATCH] remove event duplication Signed-off-by: yenda --- src/status_im/wallet/core.cljs | 43 +++++++++------------------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index 695b75c1ec..3ebe512826 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -505,47 +505,26 @@ [to-norm amount-hex])})}))))) (fx/defn sign-transaction-button-clicked - {:events [:wallet.ui/sign-transaction-button-clicked]} + {:events [:wallet.ui/sign-transaction-button-clicked]} [{:keys [db] :as cofx} {:keys [to amount from token gas gasPrice]}] (let [{:keys [symbol address]} token - amount-hex (str "0x" (abi-spec/number-to-hex amount)) - to-norm (ethereum/normalized-hex (if (string? to) to (:address to))) - from-address (:address from)] - (fx/merge cofx - {:db (dissoc db :wallet/prepare-transaction)} - (fn [cofx] - (signing/sign cofx {:tx-obj (if (= symbol :ETH) - {:to to-norm - :from from-address - :value amount-hex} - {:to (ethereum/normalized-hex address) - :from from-address - :data (abi-spec/encode - "transfer(address,uint256)" - [to-norm amount-hex]) - ;;Note: data from qr (eip681) - :gas gas - :gasPrice gasPrice})}))))) - -(fx/defn sign-transaction-button-clicked-from-command - {:events [:wallet.ui/sign-transaction-button-clicked]} - [{:keys [db] :as cofx} {:keys [to amount from token gas gasPrice]}] - (let [{:keys [symbol address]} token - amount-hex (str "0x" (abi-spec/number-to-hex amount)) - to-norm (ethereum/normalized-hex (if (string? to) to (:address to))) + amount-hex (str "0x" (abi-spec/number-to-hex amount)) + to-norm (ethereum/normalized-hex (if (string? to) to (:address to))) from-address (:address from)] (fx/merge cofx {:db (dissoc db :wallet/prepare-transaction)} (signing/sign - {:tx-obj (merge {:from from-address} + {:tx-obj (merge {:from from-address + ;;gas and gasPrice from qr (eip681) + :gas gas + :gasPrice gasPrice} (if (= symbol :ETH) {:to to-norm :value amount-hex} - {:to (ethereum/normalized-hex address) - :from from-address - :data (abi-spec/encode - "transfer(address,uint256)" - [to-norm amount-hex])}))})))) + {:to (ethereum/normalized-hex address) + :data (abi-spec/encode + "transfer(address,uint256)" + [to-norm amount-hex])}))})))) (fx/defn set-and-validate-amount-request {:events [:wallet.request/set-and-validate-amount]}