[#11136] Warning to users sending ERC20 directly to smart contract

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2020-09-22 12:34:22 +02:00
parent b32367a9b2
commit 8eed842c62
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
3 changed files with 15 additions and 5 deletions

View File

@ -25,6 +25,7 @@
"eth_getBlockByNumber" {}
"eth_newBlockFilter" {:subscription? true}
"eth_newFilter" {:subscription? true}
"eth_getCode" {}
"eth_syncing" {}
"net_version" {}
"web3_clientVersion" {}

View File

@ -55,7 +55,7 @@
(fx/defn set-recipient
{:events [::recipient-address-resolved]}
[{:keys [db]} raw-recipient id]
[{:keys [db] :as cofx} raw-recipient id]
(when (or (not id) (= id @resolve-last-id))
(reset! resolve-last-id nil)
(let [chain (ethereum/chain-keyword db)
@ -64,9 +64,17 @@
(ethereum/address? recipient)
(let [checksum (eip55/address->checksum recipient)]
(if (eip55/valid-address-checksum? checksum)
{:db (-> db
(assoc-in [:wallet/recipient :searching] false)
(assoc-in [:wallet/recipient :resolved-address] checksum))}
(fx/merge cofx
{:db (-> db
(assoc-in [:wallet/recipient :searching] false)
(assoc-in [:wallet/recipient :resolved-address] checksum))}
(json-rpc/call
{:method "eth_getCode"
:params [checksum "latest"]
:on-success #(when (not= "0x" %)
(utils/show-popup (i18n/label :t/warning)
(i18n/label :t/warning-sending-to-contract-descr)))
:number-of-retries 3}))
{:ui/show-error (i18n/label :t/wallet-invalid-address-checksum {:data recipient})
:db (assoc-in db [:wallet/recipient :searching] false)}))
(and (not (string/blank? recipient)) (ens/valid-eth-name-prefix? recipient))

View File

@ -1273,5 +1273,6 @@
"recent-empty": "Recently used addresses will appear here",
"address-or-ens-name": "Address or ENS name",
"name-optional": "Name (optional)",
"mute": "Mute"
"mute": "Mute",
"warning-sending-to-contract-descr": "The address you entered is a smart contract, sending funds to this address may result in loss of funds. To interact with a DApp, open the DApp in the Status DApp Browser."
}