Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9f8d4c524 | ||
|
|
78ed7f5805 | ||
|
|
80ae1b4734 | ||
|
|
3ace91fa86 | ||
|
|
e39fb0b318 |
@@ -10,8 +10,8 @@
|
||||
|
||||
(defn enabled? [v] (= "1" v))
|
||||
|
||||
(goog-define INFURA_TOKEN "")
|
||||
(goog-define POKT_TOKEN "3ef2018191814b7e1009b8d9")
|
||||
(goog-define INFURA_TOKEN "1abe540f06ed4245b47d68f28549d5a4")
|
||||
(goog-define POKT_TOKEN "")
|
||||
(goog-define STATUS_BUILD_PROXY_USER "")
|
||||
(goog-define STATUS_BUILD_PROXY_PASSWORD "")
|
||||
(goog-define OPENSEA_API_KEY "")
|
||||
|
||||
@@ -279,8 +279,6 @@
|
||||
#{wallet-connect-personal-sign-method
|
||||
wallet-connect-eth-sign-method
|
||||
wallet-connect-eth-send-transaction-method
|
||||
;; NOTE: disabled, as we have no clear use cases for it and other wallets don't support it
|
||||
;; wallet-connect-eth-sign-transaction-method
|
||||
wallet-connect-eth-sign-typed-method
|
||||
wallet-connect-eth-sign-typed-v4-method})
|
||||
(def ^:const wallet-connect-supported-events #{"accountsChanged" "chainChanged"})
|
||||
|
||||
@@ -84,17 +84,6 @@
|
||||
(promesa/then on-success)
|
||||
(promesa/catch on-error))))
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.wallet-connect/sign-transaction
|
||||
(fn [{:keys [password address chain-id tx-hash tx-args on-success on-error]}]
|
||||
(-> (transactions/sign-transaction (security/safe-unmask-data password)
|
||||
address
|
||||
tx-hash
|
||||
tx-args
|
||||
chain-id)
|
||||
(promesa/then (partial rf/call-continuation on-success))
|
||||
(promesa/catch (partial rf/call-continuation on-error)))))
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.wallet-connect/send-transaction
|
||||
(fn [{:keys [password address chain-id tx-hash tx-args on-success on-error]}]
|
||||
|
||||
@@ -44,9 +44,6 @@
|
||||
constants/wallet-connect-eth-sign-method
|
||||
[:dispatch [:wallet-connect/process-eth-sign]]
|
||||
|
||||
constants/wallet-connect-eth-sign-transaction-method
|
||||
[:dispatch [:wallet-connect/process-eth-sign-transaction]]
|
||||
|
||||
constants/wallet-connect-eth-sign-typed-method
|
||||
[:dispatch [:wallet-connect/process-sign-typed]]
|
||||
|
||||
@@ -84,60 +81,42 @@
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/prepare-transaction-success
|
||||
(fn [{:keys [db]} [prepared-tx chain-id]]
|
||||
(fn [{:keys [db]} [prepared-tx]]
|
||||
(let [{:keys [tx-args]} prepared-tx
|
||||
tx (bean/->clj tx-args)
|
||||
address (-> tx :from string/lower-case)
|
||||
display-data (transactions/beautify-transaction tx)]
|
||||
tx (-> tx-args
|
||||
bean/->clj)]
|
||||
{:db (update-in db
|
||||
[:wallet-connect/current-request]
|
||||
assoc
|
||||
:address address
|
||||
:raw-data prepared-tx
|
||||
:transaction tx
|
||||
:chain-id chain-id
|
||||
:display-data display-data)})))
|
||||
:address (transactions/get-sender tx)
|
||||
:display-data (transactions/beautify-transaction tx))})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/process-eth-send-transaction
|
||||
(fn [{:keys [db]} [{:keys [on-success]}]]
|
||||
(let [event (data-store/get-db-current-request-event db)
|
||||
tx (-> event data-store/get-request-params first)
|
||||
chain-id (-> event
|
||||
(get-in [:params :chainId])
|
||||
networks/eip155->chain-id)]
|
||||
chain-id (data-store/get-chain-id event)]
|
||||
(when tx
|
||||
{:fx [[:effects.wallet-connect/prepare-transaction
|
||||
{:tx tx
|
||||
:chain-id chain-id
|
||||
:on-success (fn [data]
|
||||
(rf/dispatch [:wallet-connect/prepare-transaction-success data chain-id])
|
||||
(rf/dispatch [:wallet-connect/prepare-transaction-success data])
|
||||
(when on-success
|
||||
(rf/call-continuation on-success)))
|
||||
:on-error #(rf/dispatch [:wallet-connect/on-processing-error %])}]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/process-eth-sign-transaction
|
||||
(fn [{:keys [db]}]
|
||||
(let [event (data-store/get-db-current-request-event db)
|
||||
tx (-> event data-store/get-request-params first)
|
||||
chain-id (-> event
|
||||
(get-in [:params :chainId])
|
||||
networks/eip155->chain-id)]
|
||||
{:fx [[:effects.wallet-connect/prepare-transaction
|
||||
{:tx tx
|
||||
:chain-id chain-id
|
||||
:on-success #(rf/dispatch [:wallet-connect/prepare-transaction-success % chain-id])
|
||||
:on-error #(rf/dispatch [:wallet-connect/on-processing-error %])}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/process-sign-typed
|
||||
(fn [{:keys [db]}]
|
||||
(try
|
||||
(let [[address raw-data] (data-store/get-db-current-request-params db)
|
||||
session-chain-id (-> (data-store/get-db-current-request-event db)
|
||||
(get-in [:params :chainId])
|
||||
networks/eip155->chain-id)
|
||||
session-chain-id (-> db
|
||||
(data-store/get-db-current-request-event)
|
||||
(data-store/get-chain-id))
|
||||
typed-data (-> raw-data
|
||||
transforms/js-parse
|
||||
transforms/js->clj)
|
||||
|
||||
@@ -33,9 +33,6 @@
|
||||
constants/wallet-connect-eth-send-transaction-method
|
||||
[:dispatch [:wallet-connect/respond-send-transaction-data password]]
|
||||
|
||||
constants/wallet-connect-eth-sign-transaction-method
|
||||
[:dispatch [:wallet-connect/respond-sign-transaction-data password]]
|
||||
|
||||
constants/wallet-connect-eth-sign-typed-method
|
||||
[:dispatch [:wallet-connect/respond-sign-typed-data password :v1]]
|
||||
|
||||
@@ -58,7 +55,7 @@
|
||||
:wallet-connect/respond-sign-typed-data
|
||||
(fn [{:keys [db]} [password typed-data-version]]
|
||||
(let [{:keys [address raw-data event]} (get db :wallet-connect/current-request)
|
||||
chain-id (get-in event [:params :chainId])]
|
||||
chain-id (data-store/get-chain-id event)]
|
||||
{:fx [[:effects.wallet-connect/sign-typed-data
|
||||
{:password password
|
||||
:address address
|
||||
@@ -71,8 +68,9 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/respond-send-transaction-data
|
||||
(fn [{:keys [db]} [password]]
|
||||
(let [{:keys [chain-id raw-data address]} (get db :wallet-connect/current-request)
|
||||
{:keys [tx-hash tx-args]} raw-data]
|
||||
(let [{:keys [raw-data address event]} (get db :wallet-connect/current-request)
|
||||
{:keys [tx-hash tx-args]} raw-data
|
||||
chain-id (data-store/get-chain-id event)]
|
||||
{:fx [[:effects.wallet-connect/send-transaction
|
||||
{:password password
|
||||
:address address
|
||||
@@ -82,20 +80,6 @@
|
||||
:on-error [:wallet-connect/on-sign-error]
|
||||
:on-success [:wallet-connect/finish-session-request]}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/respond-sign-transaction-data
|
||||
(fn [{:keys [db]} [password]]
|
||||
(let [{:keys [chain-id raw-data address]} (get db :wallet-connect/current-request)
|
||||
{:keys [tx-hash tx-args]} raw-data]
|
||||
{:fx [[:effects.wallet-connect/sign-transaction
|
||||
{:password password
|
||||
:address address
|
||||
:chain-id chain-id
|
||||
:tx-hash tx-hash
|
||||
:tx-params tx-args
|
||||
:on-error [:wallet-connect/on-sign-error]
|
||||
:on-success [:wallet-connect/finish-session-request]}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/on-sign-error
|
||||
(fn [{:keys [db]} [error]]
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.page-nav.view :as page-nav]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.style :as style]
|
||||
[status-im.contexts.wallet.wallet-connect.utils.transactions :as transaction-utils]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
@@ -73,9 +74,9 @@
|
||||
(set! (.-current refetch-interval-ref)
|
||||
(js/setInterval refetch-transaction constants/wallet-connect-transaction-refresh-interval-ms))))
|
||||
|
||||
(rn/use-unmount (fn []
|
||||
(clear-interval)
|
||||
(rf/dispatch [:wallet-connect/on-request-modal-dismissed])))
|
||||
(hot-reload/use-safe-unmount (fn []
|
||||
(clear-interval)
|
||||
(rf/dispatch [:wallet-connect/on-request-modal-dismissed])))
|
||||
|
||||
[rn/view {:style (style/container bottom)}
|
||||
[quo/gradient-cover {:customization-color customization-color}]
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.sign-transaction.view
|
||||
(:require [quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.data-block.view :as data-block]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.fees-data-item.view :as
|
||||
fees-data-item]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.footer.view :as footer]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.header.view :as header]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.page-nav.view :as page-nav]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.common.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [bottom (safe-area/get-bottom)
|
||||
{:keys [customization-color]
|
||||
:as account} (rf/sub [:wallet-connect/current-request-account-details])
|
||||
dapp (rf/sub [:wallet-connect/current-request-dapp])
|
||||
network (rf/sub [:wallet-connect/current-request-network])
|
||||
{:keys [max-fees-fiat-formatted
|
||||
error-state]} (rf/sub [:wallet-connect/current-request-transaction-information])]
|
||||
(rn/use-unmount #(rf/dispatch [:wallet-connect/on-request-modal-dismissed]))
|
||||
[rn/view {:style (style/container bottom)}
|
||||
[quo/gradient-cover {:customization-color customization-color}]
|
||||
[page-nav/view
|
||||
{:accessibility-label :wallet-connect-sign-message-close}]
|
||||
[rn/view {:flex 1}
|
||||
[rn/view {:style style/data-content-container}
|
||||
[header/view
|
||||
{:label (i18n/label :t/wallet-connect-sign-transaction-header)
|
||||
:dapp dapp
|
||||
:account account}]
|
||||
[data-block/view]]
|
||||
[footer/view
|
||||
{:warning-label (i18n/label :t/wallet-connect-sign-warning)
|
||||
:slide-button-text (i18n/label :t/slide-to-sign)
|
||||
:error-text (when error-state
|
||||
(i18n/label (condp = error-state
|
||||
:not-enough-assets-to-pay-gas-fees
|
||||
:t/not-enough-assets-to-pay-gas-fees
|
||||
|
||||
:not-enough-assets
|
||||
:t/not-enough-assets)))}
|
||||
[quo/data-item
|
||||
{:status :default
|
||||
:card? false
|
||||
:container-style style/data-item
|
||||
:title (i18n/label :t/network)
|
||||
:subtitle-type :network
|
||||
:network-image (:source network)
|
||||
:subtitle (:full-name network)}]
|
||||
[fees-data-item/view
|
||||
{:fees max-fees-fiat-formatted
|
||||
:fees-error error-state}]]]]))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.wallet-connect.utils.networks :as networks]
|
||||
utils.string
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
@@ -30,8 +31,7 @@
|
||||
constants/wallet-connect-eth-sign-typed-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-sign-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-sign-typed-v4-method :screen/wallet-connect.sign-message
|
||||
constants/wallet-connect-eth-send-transaction-method :screen/wallet-connect.send-transaction
|
||||
constants/wallet-connect-eth-sign-transaction-method :screen/wallet-connect.sign-transaction})
|
||||
constants/wallet-connect-eth-send-transaction-method :screen/wallet-connect.send-transaction})
|
||||
|
||||
(defn extract-native-call-signature
|
||||
[data]
|
||||
@@ -80,3 +80,9 @@
|
||||
:wallet-connect/sessions
|
||||
count
|
||||
inc))
|
||||
|
||||
(defn get-chain-id
|
||||
[event]
|
||||
(-> event
|
||||
(get-in [:params :chainId])
|
||||
networks/eip155->chain-id))
|
||||
|
||||
@@ -12,15 +12,6 @@
|
||||
{:message-to-sign (oops/oget res :messageToSign)
|
||||
:tx-args (oops/oget res :txArgs)}))
|
||||
|
||||
(defn wallet-build-raw-transaction
|
||||
[chain-id tx-args signature]
|
||||
(-> (rpc-events/call-async "wallet_buildRawTransaction"
|
||||
true
|
||||
chain-id
|
||||
(transforms/js-stringify tx-args 0)
|
||||
signature)
|
||||
(promesa/then #(oops/oget % "rawTx"))))
|
||||
|
||||
(defn wallet-send-transaction-with-signature
|
||||
[chain-id tx-args signature]
|
||||
(rpc-events/call-async "wallet_sendTransactionWithSignature"
|
||||
|
||||
@@ -7,14 +7,15 @@
|
||||
[status-im.contexts.wallet.wallet-connect.utils.data-store :as
|
||||
data-store]
|
||||
[status-im.contexts.wallet.wallet-connect.utils.rpc :as rpc]
|
||||
[utils.address :as address]
|
||||
[utils.hex :as hex]
|
||||
[utils.money :as money]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(defn transaction-request?
|
||||
[event]
|
||||
(->> (data-store/get-request-method event)
|
||||
(contains? #{constants/wallet-connect-eth-send-transaction-method
|
||||
constants/wallet-connect-eth-sign-transaction-method})))
|
||||
(contains? #{constants/wallet-connect-eth-send-transaction-method})))
|
||||
|
||||
;; NOTE: Currently we don't allow the user to configure the tx priority as we don't
|
||||
;; show the estimated time, but when we implement it, we should allow to change it
|
||||
@@ -115,40 +116,34 @@
|
||||
(dissoc :gasLimit)
|
||||
(tx->eip1559-tx suggested-fees tx-priority)))
|
||||
|
||||
(defn transaction-estimations
|
||||
[chain-id]
|
||||
(promesa/let [suggested-fees (rpc/wallet-get-suggested-fees chain-id)
|
||||
estimated-time (->> suggested-fees
|
||||
:maxPriorityFeePerGas
|
||||
(rpc/wallet-get-transaction-estimated-time chain-id))]
|
||||
{:suggested-fees suggested-fees
|
||||
:estimated-time estimated-time}))
|
||||
|
||||
(defn prepare-transaction
|
||||
"Formats and builds the incoming transaction, adding the missing properties and returning the final
|
||||
transaction, along with the transaction hash and the suggested fees"
|
||||
[tx chain-id tx-priority]
|
||||
(promesa/let [suggested-fees (rpc/wallet-get-suggested-fees chain-id)
|
||||
{:keys [tx-args message-to-sign]} (->>
|
||||
(prepare-transaction-fees tx
|
||||
tx-priority
|
||||
suggested-fees)
|
||||
prepare-transaction-for-rpc
|
||||
(rpc/wallet-build-transaction chain-id))
|
||||
estimated-time (rpc/wallet-get-transaction-estimated-time
|
||||
chain-id
|
||||
(:maxPriorityFeePerGas suggested-fees))]
|
||||
(promesa/let [{:keys [suggested-fees] :as estimations} (transaction-estimations chain-id)
|
||||
{:keys [tx-args message-to-sign]} (->> suggested-fees
|
||||
(prepare-transaction-fees tx
|
||||
tx-priority)
|
||||
prepare-transaction-for-rpc
|
||||
(rpc/wallet-build-transaction chain-id))]
|
||||
{:tx-args tx-args
|
||||
:tx-hash message-to-sign
|
||||
:suggested-fees suggested-fees
|
||||
:estimated-time estimated-time}))
|
||||
|
||||
(defn sign-transaction
|
||||
[password address tx-hash tx-args chain-id]
|
||||
(promesa/let
|
||||
[signature (rpc/wallet-sign-message tx-hash address password)
|
||||
raw-tx (rpc/wallet-build-raw-transaction chain-id tx-args signature)]
|
||||
raw-tx))
|
||||
:tx-estimations estimations}))
|
||||
|
||||
(defn send-transaction
|
||||
[password address tx-hash tx-args chain-id]
|
||||
(promesa/let
|
||||
[signature (rpc/wallet-sign-message tx-hash address password)
|
||||
tx (rpc/wallet-send-transaction-with-signature chain-id
|
||||
tx-args
|
||||
signature)]
|
||||
tx))
|
||||
(promesa/->> password
|
||||
(rpc/wallet-sign-message tx-hash address)
|
||||
(rpc/wallet-send-transaction-with-signature chain-id tx-args)))
|
||||
|
||||
(defn transactions->display-array
|
||||
[data]
|
||||
@@ -157,3 +152,135 @@
|
||||
(= k :MultiTransactionID)
|
||||
(= k :Symbol)))
|
||||
data))
|
||||
|
||||
(defrecord Transaction
|
||||
[version from to gas gasPrice value nonce maxFeePerGas
|
||||
maxPriorityFeePerGas input data multiTransactionID])
|
||||
|
||||
(defn create-transaction
|
||||
[tx]
|
||||
;; TODO add malli check schema
|
||||
(map->Transaction tx))
|
||||
|
||||
(defn- non-empty-hex
|
||||
[hex-string]
|
||||
(let [normalized (hex/normalize-hex hex-string)]
|
||||
(when-not (string/blank? normalized)
|
||||
hex-string)))
|
||||
|
||||
(defn get-data
|
||||
[^Transaction tx]
|
||||
(let [{:keys [input data]} tx]
|
||||
(or (non-empty-hex input)
|
||||
(non-empty-hex data))))
|
||||
|
||||
(def function-selector-to-type
|
||||
{constants/method-id-transfer :transaction/erc-20-transfer
|
||||
constants/method-id-approve :transaction/erc-20-approve})
|
||||
|
||||
(defn get-type
|
||||
[^Transaction tx]
|
||||
(let [tx-data (get-data tx)
|
||||
eth-transfer? (nil? tx-data)
|
||||
contract-type (when-not eth-transfer?
|
||||
(-> tx-data (subs 0 10) function-selector-to-type))]
|
||||
(cond
|
||||
eth-transfer? :transaction/eth-transfer
|
||||
(keyword? contract-type) contract-type
|
||||
:else :transaction/unknown)))
|
||||
|
||||
(defn get-sender
|
||||
[^Transaction tx]
|
||||
(-> tx :from string/lower-case))
|
||||
|
||||
(defn- subs-bytes
|
||||
[hex-data start-bytes end-bytes]
|
||||
(when (-> hex-data count (/ 2) (>= end-bytes))
|
||||
(-> hex-data
|
||||
hex/normalize-hex
|
||||
(subs (* start-bytes 2)
|
||||
(* end-bytes 2)))))
|
||||
|
||||
(defn- decode-erc-20-transfer
|
||||
"Decode ERC20 transfer data, which has the following function signature:
|
||||
`approve(spender, amount)`"
|
||||
[tx-data]
|
||||
(when (>= (count tx-data) 138)
|
||||
(let [selector (subs-bytes tx-data 0 4) ;; Function selector (first 4 bytes)
|
||||
recipient-hex (subs-bytes tx-data 16 36) ;; Recipient address (next 32 bytes)
|
||||
amount-hex (subs-bytes tx-data 36 68)] ;; Amount (next 32 bytes)
|
||||
{:selector selector
|
||||
:recipient (address/normalized-hex recipient-hex)
|
||||
:amount (money/from-hex amount-hex)})))
|
||||
|
||||
(defn- decode-erc-20-approve
|
||||
"Decode ERC20 transfer data, which has the following function signature:
|
||||
`approve(spender, amount)`"
|
||||
[tx-data]
|
||||
(when (>= (count tx-data) 138)
|
||||
(let [selector (subs-bytes tx-data 0 4) ;; Function selector (first 4 bytes)
|
||||
spender-hex (subs-bytes tx-data 16 36) ;; Spender address (next 32 bytes)
|
||||
amount-hex (subs-bytes tx-data 36 68)] ;; Amount (next 32 bytes)
|
||||
{:selector selector
|
||||
:spender (address/normalized-hex spender-hex)
|
||||
:amount (money/from-hex amount-hex)})))
|
||||
|
||||
(defn get-recipient
|
||||
"Get the transaction recipient, depending on the transaction type"
|
||||
[^Transaction tx]
|
||||
(let [default (:to tx)]
|
||||
(condp = (get-type tx)
|
||||
:transaction/eth-transfer default
|
||||
:transaction/erc-20-transfer (-> tx
|
||||
get-data
|
||||
decode-erc-20-transfer
|
||||
:recipient
|
||||
(or default))
|
||||
:transaction/erc-20-approve (-> tx
|
||||
get-data
|
||||
decode-erc-20-approve
|
||||
:spender
|
||||
(or default))
|
||||
default)))
|
||||
|
||||
(defn get-amount
|
||||
[^Transaction tx]
|
||||
(let [default (-> tx :value money/from-hex)]
|
||||
(condp = (get-type tx)
|
||||
:transaction/eth-transfer default
|
||||
:transaction/erc-20-transfer (-> tx get-data decode-erc-20-transfer :amount)
|
||||
:transaction/erc-20-approve (-> tx get-data decode-erc-20-approve :amount)
|
||||
default)))
|
||||
|
||||
(->
|
||||
(decode-erc-20-transfer
|
||||
"0xa9059cbb00000000000000000000000097654628dd47c2d88fc9b3d0cc38a92e46a32cd400000000000000000000000000000000000000000000000a0af513f7628a8000"))
|
||||
|
||||
(def tt
|
||||
{:version 0
|
||||
:from "0xb18ec1808bd8b84f244c6e34cbedee9b0cd7e1fb"
|
||||
:to "0x744d70fdbe2ba4cf95131626614a1763df805b9e"
|
||||
:gas "0x21e76"
|
||||
:gasPrice "0x8b491f4cf"
|
||||
:value "0x0"
|
||||
:nonce "0x1b"
|
||||
:maxFeePerGas "0x8b491f4cf"
|
||||
:maxPriorityFeePerGas "0x3b9aca00"
|
||||
:input "0x"
|
||||
:data
|
||||
"0xa9059cbb00000000000000000000000097654628dd47c2d88fc9b3d0cc38a92e46a32cd400000000000000000000000000000000000000000000000a0af513f7628a8000"
|
||||
:multiTransactionID 0})
|
||||
|
||||
(get-amount tt)
|
||||
(-> tt
|
||||
decode-erc-20-transfer)
|
||||
|
||||
(get-type tt)
|
||||
|
||||
|
||||
(defn get-contract-address
|
||||
[^Transaction tx]
|
||||
(condp = (get-type tx)
|
||||
:transaction/erc-20-transfer (:to tx)
|
||||
:transaction/erc-20-approve (:to tx)
|
||||
nil))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.utils.typed-data
|
||||
(:require [clojure.string :as string]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.wallet-connect.utils.networks :as networks]
|
||||
[status-im.contexts.wallet.wallet-connect.utils.rpc :as rpc]
|
||||
[utils.number :as number]))
|
||||
|
||||
@@ -85,9 +84,8 @@
|
||||
data-chain-id)))
|
||||
|
||||
(defn sign
|
||||
[password address data chain-id-eip155 version]
|
||||
(let [legacy? (= version :v1)
|
||||
chain-id (networks/eip155->chain-id chain-id-eip155)]
|
||||
[password address data chain-id version]
|
||||
(let [legacy? (= version :v1)]
|
||||
(rpc/wallet-safe-sign-typed-data data
|
||||
address
|
||||
password
|
||||
|
||||
@@ -136,8 +136,6 @@
|
||||
[status-im.contexts.wallet.wallet-connect.modals.session-proposal.view :as
|
||||
wallet-connect-session-proposal]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.sign-message.view :as wallet-connect-sign-message]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.sign-transaction.view :as
|
||||
wallet-connect-sign-transaction]
|
||||
[status-im.navigation.options :as options]
|
||||
[status-im.navigation.transitions :as transitions]))
|
||||
|
||||
@@ -563,10 +561,6 @@
|
||||
:options {:sheet? true}
|
||||
:component wallet-connect-sign-message/view}
|
||||
|
||||
{:name :screen/wallet-connect.sign-transaction
|
||||
:options {:sheet? true}
|
||||
:component wallet-connect-sign-transaction/view}
|
||||
|
||||
{:name :screen/wallet-connect.send-transaction
|
||||
:options {:sheet? true}
|
||||
:component wallet-connect-send-transaction/view}
|
||||
|
||||
@@ -46,9 +46,7 @@
|
||||
:wallet-connect/chain-id
|
||||
:<- [:wallet-connect/current-request]
|
||||
(fn [request]
|
||||
(-> request
|
||||
(get-in [:event :params :chainId])
|
||||
(networks/eip155->chain-id))))
|
||||
(-> request :event data-store/get-chain-id)))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/current-request-network
|
||||
|
||||
@@ -6,22 +6,23 @@
|
||||
[utils.string]))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/transaction-args
|
||||
:wallet-connect/transaction
|
||||
:<- [:wallet-connect/current-request]
|
||||
(fn [{:keys [event transaction]}]
|
||||
(when (transactions/transaction-request? event)
|
||||
transaction)))
|
||||
(transactions/create-transaction transaction))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/transaction-suggested-fees
|
||||
:<- [:wallet-connect/current-request]
|
||||
(fn [{:keys [event raw-data]}]
|
||||
(when (transactions/transaction-request? event)
|
||||
(-> raw-data :tx-estimations :suggested-fees)
|
||||
(:suggested-fees raw-data))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/transaction-max-fees-wei
|
||||
:<- [:wallet-connect/transaction-args]
|
||||
:<- [:wallet-connect/transaction]
|
||||
:<- [:wallet-connect/transaction-suggested-fees]
|
||||
(fn [[transaction suggested-fees]]
|
||||
(when transaction
|
||||
@@ -48,7 +49,7 @@
|
||||
:wallet-connect/current-request-transaction-information
|
||||
:<- [:wallet-connect/chain-id]
|
||||
:<- [:wallet-connect/transaction-max-fees-wei]
|
||||
:<- [:wallet-connect/transaction-args]
|
||||
:<- [:wallet-connect/transaction]
|
||||
:<- [:wallet-connect/account-eth-token]
|
||||
:<- [:profile/currency]
|
||||
:<- [:profile/currency-symbol]
|
||||
@@ -68,11 +69,7 @@
|
||||
tx-value (money/bignumber (:value transaction))
|
||||
total-transaction-value (money/add max-fees-wei tx-value)
|
||||
estimated-time-formatted (wallet-utils/estimated-time-format (:estimated-time transaction))]
|
||||
{:total-transaction-value total-transaction-value
|
||||
:balance balance
|
||||
:estimated-time estimated-time-formatted
|
||||
:max-fees max-fees-wei
|
||||
:max-fees-fiat-value max-fees-fiat
|
||||
{:estimated-time estimated-time-formatted
|
||||
:max-fees-fiat-formatted max-fees-fiat-formatted
|
||||
:error-state (cond
|
||||
(not (money/sufficient-funds? tx-value balance))
|
||||
@@ -81,3 +78,48 @@
|
||||
(not (money/sufficient-funds? total-transaction-value
|
||||
balance))
|
||||
:not-enough-assets-to-pay-gas-fees)}))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/transaction-type
|
||||
:<- [:wallet-connect/transaction]
|
||||
transactions/get-type)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/transaction-recipient
|
||||
:<- [:wallet-connect/transaction]
|
||||
transactions/get-recipient)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/transaction-amount
|
||||
:<- [:wallet-connect/transaction]
|
||||
transactions/get-amount)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/transaction-contract
|
||||
:<- [:wallet-connect/transaction]
|
||||
:<- [:wallet-connect/transaction-type]
|
||||
:<- [:wallet/tokens]
|
||||
(fn [[transaction type tokens]]
|
||||
(->> tokens
|
||||
:by-address
|
||||
(some #(when (= (:address %) (transactions/get-contract-address transaction)) %)))
|
||||
|
||||
))
|
||||
|
||||
(comment
|
||||
(->> [#_[:wallet-connect/transaction]
|
||||
#_[:wallet-connect/transaction-type]
|
||||
#_[:wallet-connect/transaction-recipient]
|
||||
#_[:wallet-connect/transaction-amount]
|
||||
[:wallet-connect/transaction-contract]
|
||||
#_[:wallet/tokens]
|
||||
]
|
||||
(map (comp deref rf/subscribe)))
|
||||
|
||||
;; => ({:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e",
|
||||
;; :decimals 18, :key "1-0x744d70fdbe2ba4cf95131626614a1763df805b9e", :community-id nil,
|
||||
;; :symbol "SNT", :sources ["Uniswap Labs Default Token List" "Status Token List"], :name
|
||||
;; "Status Network Token", :type :erc20, :verified? true, :chain-id 1,
|
||||
;; :image nil})
|
||||
|
||||
)
|
||||
|
||||
@@ -2745,8 +2745,6 @@
|
||||
"wallet-connect-send-transaction-warning": "Send transactions only if you trust the dApp",
|
||||
"wallet-connect-sign-message-header": "wants you to sign the message with",
|
||||
"wallet-connect-sign-message-warning": "Sign messages only if you trust the dApp",
|
||||
"wallet-connect-sign-transaction-header": "wants you to sign this transaction with",
|
||||
"wallet-connect-sign-transaction-warning": "Sign transactions only if you trust the dApp",
|
||||
"wallet-connect-sign-warning": "Sign only if you trust the dApp",
|
||||
"wallet-connect-typed-data-wrong-chain-id-warning": "Wrong network in the request data. Expected '{{expected-chain}}', but got '{{wrong-chain}}'",
|
||||
"wallet-connect-version-not-supported": "WalletConnect version {{version}} is not supported",
|
||||
|
||||
Reference in New Issue
Block a user