mirror of
https://github.com/status-im/status-react.git
synced 2025-02-21 07:08:44 +00:00
feat: init
This commit is contained in:
parent
711fd19967
commit
e39fb0b318
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
(defn enabled? [v] (= "1" v))
|
(defn enabled? [v] (= "1" v))
|
||||||
|
|
||||||
(goog-define INFURA_TOKEN "")
|
(goog-define INFURA_TOKEN "1abe540f06ed4245b47d68f28549d5a4")
|
||||||
(goog-define POKT_TOKEN "3ef2018191814b7e1009b8d9")
|
(goog-define POKT_TOKEN "")
|
||||||
(goog-define STATUS_BUILD_PROXY_USER "")
|
(goog-define STATUS_BUILD_PROXY_USER "")
|
||||||
(goog-define STATUS_BUILD_PROXY_PASSWORD "")
|
(goog-define STATUS_BUILD_PROXY_PASSWORD "")
|
||||||
(goog-define OPENSEA_API_KEY "")
|
(goog-define OPENSEA_API_KEY "")
|
||||||
|
@ -85,18 +85,18 @@
|
|||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet-connect/prepare-transaction-success
|
:wallet-connect/prepare-transaction-success
|
||||||
(fn [{:keys [db]} [prepared-tx chain-id]]
|
(fn [{:keys [db]} [prepared-tx chain-id]]
|
||||||
(let [{:keys [tx-args]} prepared-tx
|
(let [{:keys [tx-args tx-details]} prepared-tx
|
||||||
tx (bean/->clj tx-args)
|
tx (-> tx-args
|
||||||
address (-> tx :from string/lower-case)
|
bean/->clj
|
||||||
display-data (transactions/beautify-transaction tx)]
|
(transactions/Transaction. tx-details))]
|
||||||
{:db (update-in db
|
{:db (update-in db
|
||||||
[:wallet-connect/current-request]
|
[:wallet-connect/current-request]
|
||||||
assoc
|
assoc
|
||||||
:address address
|
:raw-data prepared-tx
|
||||||
:raw-data prepared-tx
|
:chain-id chain-id
|
||||||
:transaction tx
|
:address (.sender tx)
|
||||||
:chain-id chain-id
|
:transaction-summary (.summary tx)
|
||||||
:display-data display-data)})))
|
:display-data (.beautify-params tx))})))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet-connect/process-eth-send-transaction
|
:wallet-connect/process-eth-send-transaction
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
(ns status-im.contexts.wallet.wallet-connect.utils.rpc
|
(ns status-im.contexts.wallet.wallet-connect.utils.rpc
|
||||||
(:require [oops.core :as oops]
|
(:require [cljs-bean.core :as bean]
|
||||||
|
[oops.core :as oops]
|
||||||
[promesa.core :as promesa]
|
[promesa.core :as promesa]
|
||||||
[status-im.common.json-rpc.events :as rpc-events]
|
[status-im.common.json-rpc.events :as rpc-events]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
@ -79,3 +80,9 @@
|
|||||||
[chain-id max-fee-per-gas]
|
[chain-id max-fee-per-gas]
|
||||||
(-> (rpc-events/call-async "wallet_getTransactionEstimatedTime" true chain-id max-fee-per-gas)
|
(-> (rpc-events/call-async "wallet_getTransactionEstimatedTime" true chain-id max-fee-per-gas)
|
||||||
(promesa/then transforms/js->clj)))
|
(promesa/then transforms/js->clj)))
|
||||||
|
|
||||||
|
(defn wallet-get-transaction-details
|
||||||
|
[transaction]
|
||||||
|
(->> (transforms/js-stringify transaction 0)
|
||||||
|
(rpc-events/call-async "wallet_getTransactionMetadata" true)
|
||||||
|
(transforms/js->clj)))
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
(ns status-im.contexts.wallet.wallet-connect.utils.transactions
|
(ns status-im.contexts.wallet.wallet-connect.utils.transactions
|
||||||
(:require [cljs-bean.core :as bean]
|
(:require [cljs-bean.core :as bean]
|
||||||
|
[cljs.pprint :as pprint]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[native-module.core :as native-module]
|
[native-module.core :as native-module]
|
||||||
[promesa.core :as promesa]
|
[promesa.core :as promesa]
|
||||||
@ -128,9 +129,11 @@
|
|||||||
(rpc/wallet-build-transaction chain-id))
|
(rpc/wallet-build-transaction chain-id))
|
||||||
estimated-time (rpc/wallet-get-transaction-estimated-time
|
estimated-time (rpc/wallet-get-transaction-estimated-time
|
||||||
chain-id
|
chain-id
|
||||||
(:maxPriorityFeePerGas suggested-fees))]
|
(:maxPriorityFeePerGas suggested-fees))
|
||||||
|
details (rpc/wallet-get-transaction-details tx-args)]
|
||||||
{:tx-args tx-args
|
{:tx-args tx-args
|
||||||
:tx-hash message-to-sign
|
:tx-hash message-to-sign
|
||||||
|
:tx-details details
|
||||||
:suggested-fees suggested-fees
|
:suggested-fees suggested-fees
|
||||||
:estimated-time estimated-time}))
|
:estimated-time estimated-time}))
|
||||||
|
|
||||||
@ -157,3 +160,83 @@
|
|||||||
(= k :MultiTransactionID)
|
(= k :MultiTransactionID)
|
||||||
(= k :Symbol)))
|
(= k :Symbol)))
|
||||||
data))
|
data))
|
||||||
|
|
||||||
|
|
||||||
|
(def tx-args
|
||||||
|
{:version 0
|
||||||
|
:from "0xb18ec1808bd8b84f244c6e34cbedee9b0cd7e1fb"
|
||||||
|
:to "0x744d70fdbe2ba4cf95131626614a1763df805b9e"
|
||||||
|
:gas "0x21563"
|
||||||
|
:gasPrice "0xda9a06de5"
|
||||||
|
:value "0x0"
|
||||||
|
:nonce "0x19"
|
||||||
|
:maxFeePerGas "0xda9a06de5"
|
||||||
|
:maxPriorityFeePerGas "0x5d56b25c"
|
||||||
|
:input "0x"
|
||||||
|
:data
|
||||||
|
"0xa9059cbb00000000000000000000000097654628dd47c2d88fc9b3d0cc38a92e46a32cd4000000000000000000000000000000000000000000000016ca63768fcf860000"
|
||||||
|
:multiTransactionID 0})
|
||||||
|
|
||||||
|
(def tx-met
|
||||||
|
{:FunctionSelector "0xa9059cbb"
|
||||||
|
:FunctionName "transfer"
|
||||||
|
:Recipient "0x97654628dd47c2d88fc9b3d0cc38a92e46a32cd4"
|
||||||
|
:Amount "420412000000000000000"
|
||||||
|
:TokenID "<nil>"})
|
||||||
|
|
||||||
|
(defrecord Transaction [params metadata]
|
||||||
|
Object
|
||||||
|
(beautify-params [this]
|
||||||
|
(-> this :params beautify-transaction))
|
||||||
|
|
||||||
|
(type [this]
|
||||||
|
(condp = (get-in this [:metadata :FunctionName])
|
||||||
|
"" :transaction/eth-transfer
|
||||||
|
"transfer" :transaction/erc-20-transfer
|
||||||
|
"approve" :transaction/approve
|
||||||
|
:else :transaction/unknown))
|
||||||
|
|
||||||
|
(amount [this]
|
||||||
|
(let [metadata-amount (get-in this [:metadata :Amount])
|
||||||
|
params-amount (get-in this [:params :value])]
|
||||||
|
(-> (condp =
|
||||||
|
(.type this)
|
||||||
|
:transaction/erc-20-transfer
|
||||||
|
metadata-amount
|
||||||
|
:transaction/approve
|
||||||
|
metadata-amount
|
||||||
|
:else
|
||||||
|
params-amount)
|
||||||
|
money/bignumber)))
|
||||||
|
|
||||||
|
(sender [this]
|
||||||
|
(-> this :params :from string/lower-case))
|
||||||
|
|
||||||
|
(recipient [this]
|
||||||
|
(let [metadata-recipient (get-in this [:metadata :Recipient])
|
||||||
|
params-recipient (get-in this [:params :to])]
|
||||||
|
(-> (condp =
|
||||||
|
(.type this)
|
||||||
|
:transaction/erc-20-transfer
|
||||||
|
metadata-recipient
|
||||||
|
:transaction/approve
|
||||||
|
metadata-recipient
|
||||||
|
:else
|
||||||
|
params-recipient)
|
||||||
|
string/lower-case)))
|
||||||
|
|
||||||
|
(token-address [this]
|
||||||
|
(when (->> this
|
||||||
|
.type
|
||||||
|
(contains? #{:transaction/erc-20-transfer
|
||||||
|
:transaction/approve}))
|
||||||
|
(-> this :params :to string/lower-case)))
|
||||||
|
|
||||||
|
(summary [this]
|
||||||
|
{:type (.type this)
|
||||||
|
:amount (.amount this)
|
||||||
|
:recipient (.recipient this)
|
||||||
|
:sender (.sender this)
|
||||||
|
:token-address (.token-address this)}))
|
||||||
|
|
||||||
|
(def tx (->Transaction tx-args tx-met))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user