diff --git a/src/status_im/ethereum/json_rpc.cljs b/src/status_im/ethereum/json_rpc.cljs index c7b4db5461..0996ebcdd4 100644 --- a/src/status_im/ethereum/json_rpc.cljs +++ b/src/status_im/ethereum/json_rpc.cljs @@ -25,6 +25,7 @@ "eth_getBlockByNumber" {} "eth_newBlockFilter" {:subscription? true} "eth_newFilter" {:subscription? true} + "eth_getCode" {} "eth_syncing" {} "net_version" {} "web3_clientVersion" {} diff --git a/src/status_im/wallet/recipient/core.cljs b/src/status_im/wallet/recipient/core.cljs index 95b42b52ad..f43c126e18 100644 --- a/src/status_im/wallet/recipient/core.cljs +++ b/src/status_im/wallet/recipient/core.cljs @@ -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)) diff --git a/translations/en.json b/translations/en.json index c9bcd1bdde..ab929eacd2 100644 --- a/translations/en.json +++ b/translations/en.json @@ -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." }