From 52e3d31574ce1bc6aa5f128452430541dd2b3210 Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Thu, 11 Jul 2024 13:23:48 +0100 Subject: [PATCH 01/12] wip, small renamings --- src/status_im/common/router.cljs | 14 +++++++++----- src/status_im/contexts/shell/qr_reader/view.cljs | 12 ++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/status_im/common/router.cljs b/src/status_im/common/router.cljs index 06e8cbaaae4..244a8c51034 100644 --- a/src/status_im/common/router.cljs +++ b/src/status_im/common/router.cljs @@ -24,7 +24,7 @@ (def web-prefixes ["https://" "http://" "https://www." "http://www."]) -(def web2-domain "status.app") +(def status-web2-domain "status.app") (def user-path "u#") (def user-with-data-path "u/") @@ -32,13 +32,17 @@ (def community-with-data-path "c/") (def channel-path "cc/") -(def web-urls (map #(str % web2-domain "/") web-prefixes)) +(def status-web-urls (map #(str % status-web2-domain "/") web-prefixes)) -(defn path-urls +(defn prepend-status-urls [path] - (map #(str % path) web-urls)) + (map #(str % path) status-web-urls)) -(def handled-schemes (set (into uri-schemes web-urls))) + +(comment + []) + +(def handled-schemes (set (into uri-schemes status-web-urls))) (def group-chat-extractor {[#"(.*)" :params] {"" :group-chat diff --git a/src/status_im/contexts/shell/qr_reader/view.cljs b/src/status_im/contexts/shell/qr_reader/view.cljs index cf967d0b19c..cc1ed6610f6 100644 --- a/src/status_im/contexts/shell/qr_reader/view.cljs +++ b/src/status_im/contexts/shell/qr_reader/view.cljs @@ -19,9 +19,9 @@ :theme :dark :text (i18n/label :t/invalid-qr)}) -(defn- text-for-url-path? +(defn- is-text-a-status-url-for-path? [text path] - (some #(string/starts-with? text %) (router/path-urls path))) + (some #(string/starts-with? text %) (router/prepend-status-urls path))) (defn- extract-id [scanned-text] @@ -71,15 +71,15 @@ [:wallet-connect/on-scan-connection scanned-text] 300)) -(defn on-qr-code-scanned +(defn- on-qr-code-scanned [scanned-text] (cond (or - (text-for-url-path? scanned-text router/community-with-data-path) - (text-for-url-path? scanned-text router/channel-path)) + (is-text-a-status-url-for-path? scanned-text router/community-with-data-path) + (is-text-a-status-url-for-path? scanned-text router/channel-path)) (debounce/debounce-and-dispatch [:universal-links/handle-url scanned-text] 300) - (text-for-url-path? scanned-text router/user-with-data-path) + (is-text-a-status-url-for-path? scanned-text router/user-with-data-path) (let [address (extract-id scanned-text)] (load-and-show-profile address)) From 34c9e3a88298efd6cf2b92fd9c633f2fa17bd933 Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Thu, 18 Jul 2024 19:16:15 +0100 Subject: [PATCH 02/12] Added metamask regex --- src/status_im/common/router.cljs | 3 ++ src/status_im/constants.cljs | 1 + .../contexts/shell/qr_reader/view.cljs | 4 +- .../contexts/wallet/common/utils/address.cljs | 20 ++++++++++ .../wallet/common/utils/address_test.cljs | 40 +++++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 src/status_im/contexts/wallet/common/utils/address.cljs create mode 100644 src/status_im/contexts/wallet/common/utils/address_test.cljs diff --git a/src/status_im/common/router.cljs b/src/status_im/common/router.cljs index 244a8c51034..5b06826791c 100644 --- a/src/status_im/common/router.cljs +++ b/src/status_im/common/router.cljs @@ -40,6 +40,9 @@ (comment + "ethereum:0xeD620C9dC11401b63B35Dfe8e93F2b11DB0F6F9e@0xa4b1" + "ethereum:0xeD620C9dC11401b63B35Dfe8e93F2b11DB0F6F9e@0xa" + "ethereum:0xeD620C9dC11401b63B35Dfe8e93F2b11DB0F6F9e@0x1" []) (def handled-schemes (set (into uri-schemes status-web-urls))) diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 22c45ff76d8..7cc01fcc2a3 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -261,6 +261,7 @@ (def regx-deep-link #"((^ethereum:.*)|(^status-app://[\x00-\x7F]+$))") (def regx-ens #"^(?=.{5,255}$)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$") (def regx-multichain-address #"^(?:(?:eth:|arb1:|oeth:)(?=:|))*0x[0-9a-fA-F]{40}$") +(def regx-metamask-address #"^ethereum:(0x[0-9a-fA-F]{40})@(0x1|0xa|0xa4b1)$") (def regx-address-contains #"(?i)0x[a-fA-F0-9]{40}") (def regx-starts-with-uuid #"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}") diff --git a/src/status_im/contexts/shell/qr_reader/view.cljs b/src/status_im/contexts/shell/qr_reader/view.cljs index cc1ed6610f6..911755b6140 100644 --- a/src/status_im/contexts/shell/qr_reader/view.cljs +++ b/src/status_im/contexts/shell/qr_reader/view.cljs @@ -92,8 +92,8 @@ (debounce/debounce-and-dispatch [:generic-scanner/scan-success scanned-text] 300) (debounce/debounce-and-dispatch [:navigate-change-tab :wallet-stack] 300)) - (eip681-address? scanned-text) - (do + #_(eip681-address? scanned-text) + #_(do (debounce/debounce-and-dispatch [:wallet-legacy/request-uri-parsed (eip681/parse-uri scanned-text)] 300) diff --git a/src/status_im/contexts/wallet/common/utils/address.cljs b/src/status_im/contexts/wallet/common/utils/address.cljs new file mode 100644 index 00000000000..28b3ca51727 --- /dev/null +++ b/src/status_im/contexts/wallet/common/utils/address.cljs @@ -0,0 +1,20 @@ +(ns status-im.contexts.wallet.common.utils.address + (:require + [status-im.constants :as constants])) + + +(defn eip-155-suffix->eip-3770-prefix + [eip-155-suffix] + (case eip-155-suffix + "0x1" "eth:" + "0xa4b1" "arb1:" + "0xa" "oeth:" + nil)) + +(defn is-metamask-address? + [address] + (re-matches constants/regx-metamask-address address)) + +(defn metamask-address->status-address + [metamask-address] + metamask-address) diff --git a/src/status_im/contexts/wallet/common/utils/address_test.cljs b/src/status_im/contexts/wallet/common/utils/address_test.cljs new file mode 100644 index 00000000000..0768dfb3501 --- /dev/null +++ b/src/status_im/contexts/wallet/common/utils/address_test.cljs @@ -0,0 +1,40 @@ +(ns status-im.contexts.wallet.common.utils.address-test + (:require + [cljs.test :refer-macros [are deftest is testing]] + [status-im.contexts.wallet.common.utils.address :as utils] + [status-im.constants :as constants])) + +"ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" +"oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2" + +(re-matches constants/regx-multichain-address "oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2") + +(re-matches constants/regx-metamask-address "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1") +(re-find constants/regx-metamask-address "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1") + + +#_(deftest network->chain-id-test + (testing "network->chain-id function" + (is (= (utils/network->chain-id {:network :mainnet :testnet-enabled? false :goerli-enabled? false}) + constants/ethereum-mainnet-chain-id)) + (is (= (utils/network->chain-id {:network :eth :testnet-enabled? true :goerli-enabled? false}) + constants/ethereum-sepolia-chain-id)) + (is (= (utils/network->chain-id {:network "optimism" :testnet-enabled? true :goerli-enabled? false}) + constants/optimism-sepolia-chain-id)) + (is (= (utils/network->chain-id {:network "oeth" :testnet-enabled? false :goerli-enabled? true}) + constants/optimism-mainnet-chain-id)) + (is (= (utils/network->chain-id {:network :oeth :testnet-enabled? true :goerli-enabled? true}) + constants/optimism-goerli-chain-id)) + (is (= (utils/network->chain-id {:network :arb1 :testnet-enabled? false :goerli-enabled? false}) + constants/arbitrum-mainnet-chain-id)) + (is (= (utils/network->chain-id {:network :arbitrum :testnet-enabled? true :goerli-enabled? false}) + constants/arbitrum-sepolia-chain-id)))) + +#_(deftest short-names->network-preference-prefix-test + (are [expected short-names] + (= expected (utils/short-names->network-preference-prefix short-names)) + "eth:" ["eth"] + "eth:oeth:" ["eth" "oeth"] + "eth:oeth:arb1:" ["eth" "oeth" "arb1"])) + + From 4cc9580d8940cede1e8605500909ff730a23def6 Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Sun, 21 Jul 2024 18:12:59 +0100 Subject: [PATCH 03/12] Added tests for metamask conversion --- .../contexts/wallet/common/utils/address.cljs | 8 +- .../wallet/common/utils/address_test.cljs | 81 ++++++++++--------- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/status_im/contexts/wallet/common/utils/address.cljs b/src/status_im/contexts/wallet/common/utils/address.cljs index 28b3ca51727..e801a450bb0 100644 --- a/src/status_im/contexts/wallet/common/utils/address.cljs +++ b/src/status_im/contexts/wallet/common/utils/address.cljs @@ -2,7 +2,6 @@ (:require [status-im.constants :as constants])) - (defn eip-155-suffix->eip-3770-prefix [eip-155-suffix] (case eip-155-suffix @@ -13,8 +12,11 @@ (defn is-metamask-address? [address] - (re-matches constants/regx-metamask-address address)) + (re-find constants/regx-metamask-address address)) (defn metamask-address->status-address [metamask-address] - metamask-address) + (when-let [[_ address metamask-network-suffix] (is-metamask-address? metamask-address)] + (when-let [status-network-prefix (eip-155-suffix->eip-3770-prefix metamask-network-suffix)] + (str status-network-prefix address)))) + diff --git a/src/status_im/contexts/wallet/common/utils/address_test.cljs b/src/status_im/contexts/wallet/common/utils/address_test.cljs index 0768dfb3501..3ce7d744248 100644 --- a/src/status_im/contexts/wallet/common/utils/address_test.cljs +++ b/src/status_im/contexts/wallet/common/utils/address_test.cljs @@ -1,40 +1,47 @@ (ns status-im.contexts.wallet.common.utils.address-test (:require - [cljs.test :refer-macros [are deftest is testing]] - [status-im.contexts.wallet.common.utils.address :as utils] - [status-im.constants :as constants])) - -"ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" -"oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2" - -(re-matches constants/regx-multichain-address "oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2") - -(re-matches constants/regx-metamask-address "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1") -(re-find constants/regx-metamask-address "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1") - - -#_(deftest network->chain-id-test - (testing "network->chain-id function" - (is (= (utils/network->chain-id {:network :mainnet :testnet-enabled? false :goerli-enabled? false}) - constants/ethereum-mainnet-chain-id)) - (is (= (utils/network->chain-id {:network :eth :testnet-enabled? true :goerli-enabled? false}) - constants/ethereum-sepolia-chain-id)) - (is (= (utils/network->chain-id {:network "optimism" :testnet-enabled? true :goerli-enabled? false}) - constants/optimism-sepolia-chain-id)) - (is (= (utils/network->chain-id {:network "oeth" :testnet-enabled? false :goerli-enabled? true}) - constants/optimism-mainnet-chain-id)) - (is (= (utils/network->chain-id {:network :oeth :testnet-enabled? true :goerli-enabled? true}) - constants/optimism-goerli-chain-id)) - (is (= (utils/network->chain-id {:network :arb1 :testnet-enabled? false :goerli-enabled? false}) - constants/arbitrum-mainnet-chain-id)) - (is (= (utils/network->chain-id {:network :arbitrum :testnet-enabled? true :goerli-enabled? false}) - constants/arbitrum-sepolia-chain-id)))) - -#_(deftest short-names->network-preference-prefix-test - (are [expected short-names] - (= expected (utils/short-names->network-preference-prefix short-names)) - "eth:" ["eth"] - "eth:oeth:" ["eth" "oeth"] - "eth:oeth:arb1:" ["eth" "oeth" "arb1"])) - + [cljs.test :refer-macros [deftest is testing run-tests]] + [status-im.contexts.wallet.common.utils.address :as utils])) + +(def valid-metamask-addresses + ["ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa"]) + +(def invalid-metamask-addresses + ["ethe:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" + ":0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" + "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1d" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd20xa4b1" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"]) + +(def metamask-to-status + [{:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" :status "eth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" :status "arb1:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" :status "oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + {:metamask "ethe:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" :status nil} + {:metamask ":0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" :status nil} + {:metamask "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" :status nil} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1d" :status nil} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd20xa4b1" :status nil} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" :status nil} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2" :status nil}]) + +(deftest is-metamask-address?-test + (testing "Check valid metamask addresses" + (dorun + (for [address valid-metamask-addresses] + (is (utils/is-metamask-address? address))))) + (testing "Check invalid metamask addresses" + (dorun + (for [address invalid-metamask-addresses] + (is (not (utils/is-metamask-address? address))))))) + +(deftest metamask-address->status-address-test + (testing "Check metamask to status address conversion is valid" + (dorun + (for [[metamask-address status-address] metamask-to-status] + (is (= status-address (utils/metamask-address->status-address metamask-address))))))) From ad2e5cb885ad20bc213e56dd19fa382cb02bb99d Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Mon, 22 Jul 2024 14:21:14 +0100 Subject: [PATCH 04/12] Add metamask address to shell scanner and wallet address scanner --- src/status_im/common/router.cljs | 6 --- src/status_im/constants.cljs | 3 +- .../add_address_to_save/view.cljs | 2 +- .../contexts/shell/qr_reader/view.cljs | 12 ++++-- .../add_address_to_watch/view.cljs | 2 +- .../wallet/common/scan_account/view.cljs | 38 ++++++++----------- .../contexts/wallet/common/utils/address.cljs | 20 ++++++++++ .../contexts/wallet/common/validation.cljs | 3 +- .../wallet/send/select_address/view.cljs | 4 +- 9 files changed, 52 insertions(+), 38 deletions(-) diff --git a/src/status_im/common/router.cljs b/src/status_im/common/router.cljs index 5b06826791c..05892374b88 100644 --- a/src/status_im/common/router.cljs +++ b/src/status_im/common/router.cljs @@ -39,12 +39,6 @@ (map #(str % path) status-web-urls)) -(comment - "ethereum:0xeD620C9dC11401b63B35Dfe8e93F2b11DB0F6F9e@0xa4b1" - "ethereum:0xeD620C9dC11401b63B35Dfe8e93F2b11DB0F6F9e@0xa" - "ethereum:0xeD620C9dC11401b63B35Dfe8e93F2b11DB0F6F9e@0x1" - []) - (def handled-schemes (set (into uri-schemes status-web-urls))) (def group-chat-extractor diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 7cc01fcc2a3..7da8c6a32d6 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -260,7 +260,8 @@ (def regx-community-universal-link #"((^https?://status.app/)|(^status-app://))c/([\x00-\x7F]+)$") (def regx-deep-link #"((^ethereum:.*)|(^status-app://[\x00-\x7F]+$))") (def regx-ens #"^(?=.{5,255}$)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$") -(def regx-multichain-address #"^(?:(?:eth:|arb1:|oeth:)(?=:|))*0x[0-9a-fA-F]{40}$") +;; EIP-3770 is a format used by Status and described here: https://eips.ethereum.org/EIPS/eip-3770 +(def regx-eip-3770-address #"^(?:(?:eth:|arb1:|oeth:)(?=:|))*0x[0-9a-fA-F]{40}$") (def regx-metamask-address #"^ethereum:(0x[0-9a-fA-F]{40})@(0x1|0xa|0xa4b1)$") (def regx-address-contains #"(?i)0x[a-fA-F0-9]{40}") diff --git a/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs b/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs index 4631ac7052e..012a7d1e7f7 100644 --- a/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs +++ b/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs @@ -31,7 +31,7 @@ :own-account (not - (or (validation/eth-address? user-input) + (or (validation/eip-3770-address? user-input) (validation/ens-name? user-input))) :invalid-address-or-ens))) diff --git a/src/status_im/contexts/shell/qr_reader/view.cljs b/src/status_im/contexts/shell/qr_reader/view.cljs index 911755b6140..5b6c120deb5 100644 --- a/src/status_im/contexts/shell/qr_reader/view.cljs +++ b/src/status_im/contexts/shell/qr_reader/view.cljs @@ -7,6 +7,7 @@ [status-im.common.validation.general :as validators] [status-im.contexts.communities.events] [status-im.contexts.wallet.common.validation :as wallet-validation] + [status-im.contexts.wallet.common.utils.address :as wallet-address] [status-im.contexts.wallet.wallet-connect.utils :as wc-utils] [status-im.feature-flags :as ff] [utils.debounce :as debounce] @@ -30,7 +31,7 @@ (defn eth-address? [scanned-text] - (wallet-validation/eth-address? scanned-text)) + (wallet-validation/eip-3770-address? scanned-text)) (defn eip681-address? [scanned-text] @@ -92,8 +93,13 @@ (debounce/debounce-and-dispatch [:generic-scanner/scan-success scanned-text] 300) (debounce/debounce-and-dispatch [:navigate-change-tab :wallet-stack] 300)) - #_(eip681-address? scanned-text) - #_(do + (wallet-address/is-metamask-address? scanned-text) + (when-let [status-address (wallet-address/metamask-address->status-address scanned-text)] + (debounce/debounce-and-dispatch [:generic-scanner/scan-success status-address] 300) + (debounce/debounce-and-dispatch [:navigate-change-tab :wallet-stack] 300)) + + (eip681-address? scanned-text) + (do (debounce/debounce-and-dispatch [:wallet-legacy/request-uri-parsed (eip681/parse-uri scanned-text)] 300) diff --git a/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs b/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs index ca464a0ffd9..9ed7e2879f1 100644 --- a/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs +++ b/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs @@ -20,7 +20,7 @@ (or (nil? user-input) (= user-input "")) nil (contains? known-addresses user-input) (i18n/label :t/address-already-in-use) (not - (or (validation/eth-address? user-input) + (or (validation/eip-3770-address? user-input) (validation/ens-name? user-input))) (i18n/label :t/invalid-address))) (defn- extract-address diff --git a/src/status_im/contexts/wallet/common/scan_account/view.cljs b/src/status_im/contexts/wallet/common/scan_account/view.cljs index 966c6d0adef..4949da35ac7 100644 --- a/src/status_im/contexts/wallet/common/scan_account/view.cljs +++ b/src/status_im/contexts/wallet/common/scan_account/view.cljs @@ -1,27 +1,19 @@ (ns status-im.contexts.wallet.common.scan-account.view (:require - [clojure.string :as string] - [status-im.common.scan-qr-code.view :as scan-qr-code] - [status-im.constants :as constants] - [utils.debounce :as debounce] - [utils.i18n :as i18n] - [utils.re-frame :as rf])) + [status-im.common.scan-qr-code.view :as scan-qr-code] + [status-im.constants :as constants] + [status-im.contexts.wallet.common.utils.address :as utils-address] + [utils.debounce :as debounce] + [utils.i18n :as i18n] + [utils.re-frame :as rf])) -(def ^:private supported-networks #{:eth :arb1 :oeth}) - -(defn- contains-supported-address? - [s] - (let [address? (boolean (re-find constants/regx-address-contains s)) - networks (when address? - (as-> s $ - (string/split $ ":") - (butlast $))) - supported? (every? supported-networks (map keyword networks))] - (and address? supported?))) - -(defn- extract-address - [scanned-text] - (first (re-seq constants/regx-multichain-address scanned-text))) +(comment + (def ma "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1") + (def sa "arb1:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2") + (utils-address/supported-address? ma) + (utils-address/supported-address? sa) + (utils-address/supported-address->status-address sa) + (utils-address/supported-address->status-address ma)) (defn view [] @@ -30,9 +22,9 @@ {:title (i18n/label :t/scan-qr) :subtitle (i18n/label :t/scan-an-address-qr-code) :error-message (i18n/label :t/oops-this-qr-does-not-contain-an-address) - :validate-fn #(contains-supported-address? %) + :validate-fn #(utils-address/supported-address? %) :on-success-scan (fn [result] - (let [address (extract-address result)] + (let [address (utils-address/supported-address->status-address result)] (when on-result (on-result address)) (debounce/debounce-and-dispatch [:wallet/scan-address-success address] diff --git a/src/status_im/contexts/wallet/common/utils/address.cljs b/src/status_im/contexts/wallet/common/utils/address.cljs index e801a450bb0..77951275062 100644 --- a/src/status_im/contexts/wallet/common/utils/address.cljs +++ b/src/status_im/contexts/wallet/common/utils/address.cljs @@ -14,9 +14,29 @@ [address] (re-find constants/regx-metamask-address address)) +(defn eip-3770-address? + [s] + (re-find constants/regx-eip-3770-address s)) + +(defn supported-address? + [s] + (boolean (or (eip-3770-address? s) + (is-metamask-address? s)))) + (defn metamask-address->status-address [metamask-address] (when-let [[_ address metamask-network-suffix] (is-metamask-address? metamask-address)] (when-let [status-network-prefix (eip-155-suffix->eip-3770-prefix metamask-network-suffix)] (str status-network-prefix address)))) +(defn supported-address->status-address + [address] + (cond + (eip-3770-address? address) + address + + (is-metamask-address? address) + (metamask-address->status-address address) + + :else + nil)) diff --git a/src/status_im/contexts/wallet/common/validation.cljs b/src/status_im/contexts/wallet/common/validation.cljs index 532c2d61ba5..3e88bab1199 100644 --- a/src/status_im/contexts/wallet/common/validation.cljs +++ b/src/status_im/contexts/wallet/common/validation.cljs @@ -2,7 +2,8 @@ (:require [status-im.constants :as constants])) (defn ens-name? [s] (boolean (re-find constants/regx-ens s))) -(defn eth-address? [s] (re-find constants/regx-multichain-address s)) +;; TODO: get rid of this +(defn eip-3770-address? [s] (re-find constants/regx-eip-3770-address s)) (defn private-key? [s] (or (re-find constants/regx-private-key-hex s) diff --git a/src/status_im/contexts/wallet/send/select_address/view.cljs b/src/status_im/contexts/wallet/send/select_address/view.cljs index b16770b34e1..034556cc350 100644 --- a/src/status_im/contexts/wallet/send/select_address/view.cljs +++ b/src/status_im/contexts/wallet/send/select_address/view.cljs @@ -34,7 +34,7 @@ (debounce/debounce-and-dispatch (cond (<= (count address) 0) [:wallet/address-validation-failed address] - (validation/eth-address? address) [:wallet/address-validation-success address] + (validation/eip-3770-address? address) [:wallet/address-validation-success address] :else [:wallet/address-validation-failed address]) 300)) @@ -58,7 +58,7 @@ {:on-result on-result}])) :ens-regex constants/regx-ens :scanned-value (or (when recipient-plain-address? send-address) scanned-address) - :address-regex constants/regx-multichain-address + :address-regex constants/regx-eip-3770-address :on-detect-address (fn [address] (when (or (= current-screen-id :screen/wallet.select-address) (= current-screen-id :screen/wallet.scan-address)) From e393431f4fb5cf76ffd3a9c465d4362a4f8f7fbc Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Mon, 22 Jul 2024 17:11:28 +0100 Subject: [PATCH 05/12] unify address functions usage --- .../add_address_to_save/view.cljs | 29 ++++++++++--------- .../contexts/shell/qr_reader/view.cljs | 18 +++--------- .../add_address_to_watch/view.cljs | 18 +++++------- .../wallet/common/scan_account/view.cljs | 11 ++++--- .../contexts/wallet/common/utils/address.cljs | 10 +++++-- .../wallet/common/utils/address_test.cljs | 13 +++++---- .../contexts/wallet/common/validation.cljs | 2 -- .../wallet/send/select_address/view.cljs | 8 ++--- 8 files changed, 51 insertions(+), 58 deletions(-) diff --git a/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs b/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs index 012a7d1e7f7..388a0497b89 100644 --- a/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs +++ b/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs @@ -1,17 +1,18 @@ (ns status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.view (:require - [clojure.string :as string] - [quo.core :as quo] - [react-native.clipboard :as clipboard] - [react-native.core :as rn] - [react-native.safe-area :as safe-area] - [status-im.common.floating-button-page.view :as floating-button-page] - [status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style] - [status-im.contexts.wallet.common.utils :as utils] - [status-im.contexts.wallet.common.validation :as validation] - [utils.debounce :as debounce] - [utils.i18n :as i18n] - [utils.re-frame :as rf])) + [clojure.string :as string] + [quo.core :as quo] + [react-native.clipboard :as clipboard] + [react-native.core :as rn] + [react-native.safe-area :as safe-area] + [status-im.common.floating-button-page.view :as floating-button-page] + [status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style] + [status-im.contexts.wallet.common.utils :as utils] + [status-im.contexts.wallet.common.utils.address :as utils-address] + [status-im.contexts.wallet.common.validation :as validation] + [utils.debounce :as debounce] + [utils.i18n :as i18n] + [utils.re-frame :as rf])) (defn- navigate-back [] @@ -31,8 +32,8 @@ :own-account (not - (or (validation/eip-3770-address? user-input) - (validation/ens-name? user-input))) + (or (utils-address/eip-3770-address? user-input) + (validation/ens-name? user-input))) :invalid-address-or-ens))) (defn- address-input diff --git a/src/status_im/contexts/shell/qr_reader/view.cljs b/src/status_im/contexts/shell/qr_reader/view.cljs index 5b6c120deb5..132631111a4 100644 --- a/src/status_im/contexts/shell/qr_reader/view.cljs +++ b/src/status_im/contexts/shell/qr_reader/view.cljs @@ -6,8 +6,7 @@ [status-im.common.scan-qr-code.view :as scan-qr-code] [status-im.common.validation.general :as validators] [status-im.contexts.communities.events] - [status-im.contexts.wallet.common.validation :as wallet-validation] - [status-im.contexts.wallet.common.utils.address :as wallet-address] + [status-im.contexts.wallet.common.utils.address :as utils-address] [status-im.contexts.wallet.wallet-connect.utils :as wc-utils] [status-im.feature-flags :as ff] [utils.debounce :as debounce] @@ -29,10 +28,6 @@ (let [index (string/index-of scanned-text "#")] (subs scanned-text (inc index)))) -(defn eth-address? - [scanned-text] - (wallet-validation/eip-3770-address? scanned-text)) - (defn eip681-address? [scanned-text] (-> scanned-text @@ -88,14 +83,9 @@ (validators/valid-compressed-key? scanned-text)) (load-and-show-profile scanned-text) - (eth-address? scanned-text) - (do - (debounce/debounce-and-dispatch [:generic-scanner/scan-success scanned-text] 300) - (debounce/debounce-and-dispatch [:navigate-change-tab :wallet-stack] 300)) - - (wallet-address/is-metamask-address? scanned-text) - (when-let [status-address (wallet-address/metamask-address->status-address scanned-text)] - (debounce/debounce-and-dispatch [:generic-scanner/scan-success status-address] 300) + (utils-address/supported-address? scanned-text) + (when-let [address (utils-address/supported-address->status-address scanned-text)] + (debounce/debounce-and-dispatch [:generic-scanner/scan-success address] 300) (debounce/debounce-and-dispatch [:navigate-change-tab :wallet-stack] 300)) (eip681-address? scanned-text) diff --git a/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs b/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs index 9ed7e2879f1..7463e873f12 100644 --- a/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs +++ b/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs @@ -6,8 +6,8 @@ [react-native.core :as rn] [reagent.core :as reagent] [status-im.common.floating-button-page.view :as floating-button-page] - [status-im.constants :as constants] [status-im.contexts.wallet.add-account.add-address-to-watch.style :as style] + [status-im.contexts.wallet.common.utils.address :as utils-address] [status-im.contexts.wallet.common.validation :as validation] [status-im.subs.wallet.add-account.address-to-watch] [utils.debounce :as debounce] @@ -20,13 +20,9 @@ (or (nil? user-input) (= user-input "")) nil (contains? known-addresses user-input) (i18n/label :t/address-already-in-use) (not - (or (validation/eip-3770-address? user-input) + (or (utils-address/supported-address? user-input) (validation/ens-name? user-input))) (i18n/label :t/invalid-address))) -(defn- extract-address - [scanned-text] - (re-find constants/regx-address-contains scanned-text)) - (defn- address-input [{:keys [input-value validation-msg validate clear-input]}] (let [scanned-address (rf/sub [:wallet/scanned-address]) @@ -141,10 +137,12 @@ (= activity-state :scanning) (not validated-address)) :on-press (fn [] - (rf/dispatch [:navigate-to - :screen/wallet.confirm-address-to-watch - {:address (extract-address - validated-address)}]) + (rf/dispatch + [:navigate-to + :screen/wallet.confirm-address-to-watch + {:address + (utils-address/extract-address-without-chains-info + validated-address)}]) (clear-input)) :container-style {:z-index 2}} (i18n/label :t/continue)]} diff --git a/src/status_im/contexts/wallet/common/scan_account/view.cljs b/src/status_im/contexts/wallet/common/scan_account/view.cljs index 4949da35ac7..1e552b46905 100644 --- a/src/status_im/contexts/wallet/common/scan_account/view.cljs +++ b/src/status_im/contexts/wallet/common/scan_account/view.cljs @@ -1,11 +1,10 @@ (ns status-im.contexts.wallet.common.scan-account.view (:require - [status-im.common.scan-qr-code.view :as scan-qr-code] - [status-im.constants :as constants] - [status-im.contexts.wallet.common.utils.address :as utils-address] - [utils.debounce :as debounce] - [utils.i18n :as i18n] - [utils.re-frame :as rf])) + [status-im.common.scan-qr-code.view :as scan-qr-code] + [status-im.contexts.wallet.common.utils.address :as utils-address] + [utils.debounce :as debounce] + [utils.i18n :as i18n] + [utils.re-frame :as rf])) (comment (def ma "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1") diff --git a/src/status_im/contexts/wallet/common/utils/address.cljs b/src/status_im/contexts/wallet/common/utils/address.cljs index 77951275062..c345bc4236d 100644 --- a/src/status_im/contexts/wallet/common/utils/address.cljs +++ b/src/status_im/contexts/wallet/common/utils/address.cljs @@ -1,13 +1,13 @@ (ns status-im.contexts.wallet.common.utils.address (:require - [status-im.constants :as constants])) + [status-im.constants :as constants])) (defn eip-155-suffix->eip-3770-prefix [eip-155-suffix] (case eip-155-suffix - "0x1" "eth:" + "0x1" "eth:" "0xa4b1" "arb1:" - "0xa" "oeth:" + "0xa" "oeth:" nil)) (defn is-metamask-address? @@ -40,3 +40,7 @@ :else nil)) + +(defn extract-address-without-chains-info + [address] + (re-find constants/regx-address-contains address)) diff --git a/src/status_im/contexts/wallet/common/utils/address_test.cljs b/src/status_im/contexts/wallet/common/utils/address_test.cljs index 3ce7d744248..b8c860ebc05 100644 --- a/src/status_im/contexts/wallet/common/utils/address_test.cljs +++ b/src/status_im/contexts/wallet/common/utils/address_test.cljs @@ -1,7 +1,7 @@ (ns status-im.contexts.wallet.common.utils.address-test (:require - [cljs.test :refer-macros [deftest is testing run-tests]] - [status-im.contexts.wallet.common.utils.address :as utils])) + [cljs.test :refer-macros [deftest is testing run-tests]] + [status-im.contexts.wallet.common.utils.address :as utils])) (def valid-metamask-addresses ["ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" @@ -18,9 +18,12 @@ "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"]) (def metamask-to-status - [{:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" :status "eth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" :status "arb1:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" :status "oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + [{:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" + :status "eth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" + :status "arb1:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" + :status "oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} {:metamask "ethe:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" :status nil} {:metamask ":0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" :status nil} {:metamask "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" :status nil} diff --git a/src/status_im/contexts/wallet/common/validation.cljs b/src/status_im/contexts/wallet/common/validation.cljs index 3e88bab1199..3e640f4f52b 100644 --- a/src/status_im/contexts/wallet/common/validation.cljs +++ b/src/status_im/contexts/wallet/common/validation.cljs @@ -2,8 +2,6 @@ (:require [status-im.constants :as constants])) (defn ens-name? [s] (boolean (re-find constants/regx-ens s))) -;; TODO: get rid of this -(defn eip-3770-address? [s] (re-find constants/regx-eip-3770-address s)) (defn private-key? [s] (or (re-find constants/regx-private-key-hex s) diff --git a/src/status_im/contexts/wallet/send/select_address/view.cljs b/src/status_im/contexts/wallet/send/select_address/view.cljs index 034556cc350..392957977c1 100644 --- a/src/status_im/contexts/wallet/send/select_address/view.cljs +++ b/src/status_im/contexts/wallet/send/select_address/view.cljs @@ -11,8 +11,8 @@ [status-im.constants :as constants] [status-im.contexts.wallet.common.account-switcher.view :as account-switcher] [status-im.contexts.wallet.common.utils :as utils] + [status-im.contexts.wallet.common.utils.address :as utils-address] [status-im.contexts.wallet.common.utils.networks :as network-utils] - [status-im.contexts.wallet.common.validation :as validation] [status-im.contexts.wallet.item-types :as types] [status-im.contexts.wallet.send.select-address.style :as style] [status-im.contexts.wallet.send.select-address.tabs.view :as tabs] @@ -33,9 +33,9 @@ [address] (debounce/debounce-and-dispatch (cond - (<= (count address) 0) [:wallet/address-validation-failed address] - (validation/eip-3770-address? address) [:wallet/address-validation-success address] - :else [:wallet/address-validation-failed address]) + (<= (count address) 0) [:wallet/address-validation-failed address] + (utils-address/eip-3770-address? address) [:wallet/address-validation-success address] + :else [:wallet/address-validation-failed address]) 300)) (defn- address-input From ea9f897f680b545e10e14212f3e74e3291a89f5c Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Mon, 22 Jul 2024 17:20:29 +0100 Subject: [PATCH 06/12] address-related functions moved to a dedicated namespace --- .../add_address_to_save/view.cljs | 2 +- .../contexts/shell/qr_reader/view.cljs | 2 +- .../add_address_to_watch/view.cljs | 2 +- .../wallet/common/scan_account/view.cljs | 2 +- .../contexts/wallet/common/utils/address.cljs | 46 ----------------- .../wallet/common/utils/address_test.cljs | 50 ------------------- .../wallet/send/select_address/view.cljs | 2 +- src/utils/address.cljs | 44 ++++++++++++++++ src/utils/address_test.cljs | 45 +++++++++++++++++ 9 files changed, 94 insertions(+), 101 deletions(-) delete mode 100644 src/status_im/contexts/wallet/common/utils/address.cljs delete mode 100644 src/status_im/contexts/wallet/common/utils/address_test.cljs diff --git a/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs b/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs index 388a0497b89..16d711c0ead 100644 --- a/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs +++ b/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs @@ -8,8 +8,8 @@ [status-im.common.floating-button-page.view :as floating-button-page] [status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style] [status-im.contexts.wallet.common.utils :as utils] - [status-im.contexts.wallet.common.utils.address :as utils-address] [status-im.contexts.wallet.common.validation :as validation] + [utils.address :as utils-address] [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf])) diff --git a/src/status_im/contexts/shell/qr_reader/view.cljs b/src/status_im/contexts/shell/qr_reader/view.cljs index 132631111a4..39a7a2d29cd 100644 --- a/src/status_im/contexts/shell/qr_reader/view.cljs +++ b/src/status_im/contexts/shell/qr_reader/view.cljs @@ -6,9 +6,9 @@ [status-im.common.scan-qr-code.view :as scan-qr-code] [status-im.common.validation.general :as validators] [status-im.contexts.communities.events] - [status-im.contexts.wallet.common.utils.address :as utils-address] [status-im.contexts.wallet.wallet-connect.utils :as wc-utils] [status-im.feature-flags :as ff] + [utils.address :as utils-address] [utils.debounce :as debounce] [utils.ethereum.eip.eip681 :as eip681] [utils.i18n :as i18n] diff --git a/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs b/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs index 7463e873f12..ff9b67bfb14 100644 --- a/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs +++ b/src/status_im/contexts/wallet/add_account/add_address_to_watch/view.cljs @@ -7,9 +7,9 @@ [reagent.core :as reagent] [status-im.common.floating-button-page.view :as floating-button-page] [status-im.contexts.wallet.add-account.add-address-to-watch.style :as style] - [status-im.contexts.wallet.common.utils.address :as utils-address] [status-im.contexts.wallet.common.validation :as validation] [status-im.subs.wallet.add-account.address-to-watch] + [utils.address :as utils-address] [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf])) diff --git a/src/status_im/contexts/wallet/common/scan_account/view.cljs b/src/status_im/contexts/wallet/common/scan_account/view.cljs index 1e552b46905..a33a5f4a496 100644 --- a/src/status_im/contexts/wallet/common/scan_account/view.cljs +++ b/src/status_im/contexts/wallet/common/scan_account/view.cljs @@ -1,7 +1,7 @@ (ns status-im.contexts.wallet.common.scan-account.view (:require [status-im.common.scan-qr-code.view :as scan-qr-code] - [status-im.contexts.wallet.common.utils.address :as utils-address] + [utils.address :as utils-address] [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf])) diff --git a/src/status_im/contexts/wallet/common/utils/address.cljs b/src/status_im/contexts/wallet/common/utils/address.cljs deleted file mode 100644 index c345bc4236d..00000000000 --- a/src/status_im/contexts/wallet/common/utils/address.cljs +++ /dev/null @@ -1,46 +0,0 @@ -(ns status-im.contexts.wallet.common.utils.address - (:require - [status-im.constants :as constants])) - -(defn eip-155-suffix->eip-3770-prefix - [eip-155-suffix] - (case eip-155-suffix - "0x1" "eth:" - "0xa4b1" "arb1:" - "0xa" "oeth:" - nil)) - -(defn is-metamask-address? - [address] - (re-find constants/regx-metamask-address address)) - -(defn eip-3770-address? - [s] - (re-find constants/regx-eip-3770-address s)) - -(defn supported-address? - [s] - (boolean (or (eip-3770-address? s) - (is-metamask-address? s)))) - -(defn metamask-address->status-address - [metamask-address] - (when-let [[_ address metamask-network-suffix] (is-metamask-address? metamask-address)] - (when-let [status-network-prefix (eip-155-suffix->eip-3770-prefix metamask-network-suffix)] - (str status-network-prefix address)))) - -(defn supported-address->status-address - [address] - (cond - (eip-3770-address? address) - address - - (is-metamask-address? address) - (metamask-address->status-address address) - - :else - nil)) - -(defn extract-address-without-chains-info - [address] - (re-find constants/regx-address-contains address)) diff --git a/src/status_im/contexts/wallet/common/utils/address_test.cljs b/src/status_im/contexts/wallet/common/utils/address_test.cljs deleted file mode 100644 index b8c860ebc05..00000000000 --- a/src/status_im/contexts/wallet/common/utils/address_test.cljs +++ /dev/null @@ -1,50 +0,0 @@ -(ns status-im.contexts.wallet.common.utils.address-test - (:require - [cljs.test :refer-macros [deftest is testing run-tests]] - [status-im.contexts.wallet.common.utils.address :as utils])) - -(def valid-metamask-addresses - ["ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" - "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" - "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa"]) - -(def invalid-metamask-addresses - ["ethe:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" - ":0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" - "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" - "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1d" - "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd20xa4b1" - "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" - "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"]) - -(def metamask-to-status - [{:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" - :status "eth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" - :status "arb1:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" - :status "oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} - {:metamask "ethe:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" :status nil} - {:metamask ":0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" :status nil} - {:metamask "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" :status nil} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1d" :status nil} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd20xa4b1" :status nil} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" :status nil} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2" :status nil}]) - -(deftest is-metamask-address?-test - (testing "Check valid metamask addresses" - (dorun - (for [address valid-metamask-addresses] - (is (utils/is-metamask-address? address))))) - (testing "Check invalid metamask addresses" - (dorun - (for [address invalid-metamask-addresses] - (is (not (utils/is-metamask-address? address))))))) - -(deftest metamask-address->status-address-test - (testing "Check metamask to status address conversion is valid" - (dorun - (for [[metamask-address status-address] metamask-to-status] - (is (= status-address (utils/metamask-address->status-address metamask-address))))))) - diff --git a/src/status_im/contexts/wallet/send/select_address/view.cljs b/src/status_im/contexts/wallet/send/select_address/view.cljs index 392957977c1..2eafb7bee90 100644 --- a/src/status_im/contexts/wallet/send/select_address/view.cljs +++ b/src/status_im/contexts/wallet/send/select_address/view.cljs @@ -11,13 +11,13 @@ [status-im.constants :as constants] [status-im.contexts.wallet.common.account-switcher.view :as account-switcher] [status-im.contexts.wallet.common.utils :as utils] - [status-im.contexts.wallet.common.utils.address :as utils-address] [status-im.contexts.wallet.common.utils.networks :as network-utils] [status-im.contexts.wallet.item-types :as types] [status-im.contexts.wallet.send.select-address.style :as style] [status-im.contexts.wallet.send.select-address.tabs.view :as tabs] [status-im.feature-flags :as ff] [status-im.setup.hot-reload :as hot-reload] + [utils.address :as utils-address] [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf])) diff --git a/src/utils/address.cljs b/src/utils/address.cljs index f19f412b2fb..933be2cfa75 100644 --- a/src/utils/address.cljs +++ b/src/utils/address.cljs @@ -2,6 +2,7 @@ (:require [clojure.string :as string] [native-module.core :as native-module] + [status-im.constants :as constants] [utils.ethereum.eip.eip55 :as eip55])) (def hex-prefix "0x") @@ -77,3 +78,46 @@ [value] (when value (str (subs value 0 5) "..." (subs value (- (count value) 3) (count value))))) + +(defn eip-155-suffix->eip-3770-prefix + [eip-155-suffix] + (case eip-155-suffix + "0x1" "eth:" + "0xa4b1" "arb1:" + "0xa" "oeth:" + nil)) + +(defn is-metamask-address? + [address] + (re-find constants/regx-metamask-address address)) + +(defn eip-3770-address? + [s] + (re-find constants/regx-eip-3770-address s)) + +(defn supported-address? + [s] + (boolean (or (eip-3770-address? s) + (is-metamask-address? s)))) + +(defn metamask-address->status-address + [metamask-address] + (when-let [[_ address metamask-network-suffix] (is-metamask-address? metamask-address)] + (when-let [status-network-prefix (eip-155-suffix->eip-3770-prefix metamask-network-suffix)] + (str status-network-prefix address)))) + +(defn supported-address->status-address + [address] + (cond + (eip-3770-address? address) + address + + (is-metamask-address? address) + (metamask-address->status-address address) + + :else + nil)) + +(defn extract-address-without-chains-info + [address] + (re-find constants/regx-address-contains address)) diff --git a/src/utils/address_test.cljs b/src/utils/address_test.cljs index 56725c03ded..3e999142e71 100644 --- a/src/utils/address_test.cljs +++ b/src/utils/address_test.cljs @@ -39,3 +39,48 @@ (testing "Ensure the function returns nil when given nil" (is (nil? (utils.address/get-abbreviated-profile-url nil))))) + +(def valid-metamask-addresses + ["ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa"]) + +(def invalid-metamask-addresses + ["ethe:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" + ":0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" + "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1d" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd20xa4b1" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"]) + +(def metamask-to-status + [{:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" + :status "eth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" + :status "arb1:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" + :status "oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + {:metamask "ethe:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" :status nil} + {:metamask ":0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" :status nil} + {:metamask "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" :status nil} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1d" :status nil} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd20xa4b1" :status nil} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" :status nil} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2" :status nil}]) + +(deftest is-metamask-address?-test + (testing "Check valid metamask addresses" + (dorun + (for [address valid-metamask-addresses] + (is (utils.address/is-metamask-address? address))))) + (testing "Check invalid metamask addresses" + (dorun + (for [address invalid-metamask-addresses] + (is (not (utils.address/is-metamask-address? address))))))) + +(deftest metamask-address->status-address-test + (testing "Check metamask to status address conversion is valid" + (dorun + (for [[metamask-address status-address] metamask-to-status] + (is (= status-address (utils.address/metamask-address->status-address metamask-address))))))) From d40aa5c8855771199414ee5824a1f5dc7cda2252 Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Tue, 23 Jul 2024 12:06:25 +0100 Subject: [PATCH 07/12] minor fixes --- .../contexts/wallet/common/scan_account/view.cljs | 8 -------- src/utils/address.cljs | 6 +----- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/status_im/contexts/wallet/common/scan_account/view.cljs b/src/status_im/contexts/wallet/common/scan_account/view.cljs index a33a5f4a496..907850a28e5 100644 --- a/src/status_im/contexts/wallet/common/scan_account/view.cljs +++ b/src/status_im/contexts/wallet/common/scan_account/view.cljs @@ -6,14 +6,6 @@ [utils.i18n :as i18n] [utils.re-frame :as rf])) -(comment - (def ma "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1") - (def sa "arb1:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2") - (utils-address/supported-address? ma) - (utils-address/supported-address? sa) - (utils-address/supported-address->status-address sa) - (utils-address/supported-address->status-address ma)) - (defn view [] (let [{:keys [on-result]} (rf/sub [:get-screen-params])] diff --git a/src/utils/address.cljs b/src/utils/address.cljs index 933be2cfa75..65efeccf24b 100644 --- a/src/utils/address.cljs +++ b/src/utils/address.cljs @@ -14,11 +14,6 @@ hex (str hex-prefix hex)))) -(defn naked-address - [s] - (when s - (string/replace s hex-prefix ""))) - (defn address? [address] (native-module/address? address)) @@ -92,6 +87,7 @@ (re-find constants/regx-metamask-address address)) (defn eip-3770-address? + "Checks if address follows EIP-3770 format which is default for Status" [s] (re-find constants/regx-eip-3770-address s)) From 81c6f18c95ffce2689936c395d0c031db142fe90 Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Wed, 24 Jul 2024 14:07:59 +0100 Subject: [PATCH 08/12] fix lint and tests --- src/status_im/constants.cljs | 4 ---- .../contexts/wallet/send/select_address/view.cljs | 2 +- src/utils/address.cljs | 12 ++++++++---- src/utils/address_test.cljs | 3 ++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 7da8c6a32d6..23cd9911f21 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -260,11 +260,7 @@ (def regx-community-universal-link #"((^https?://status.app/)|(^status-app://))c/([\x00-\x7F]+)$") (def regx-deep-link #"((^ethereum:.*)|(^status-app://[\x00-\x7F]+$))") (def regx-ens #"^(?=.{5,255}$)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$") -;; EIP-3770 is a format used by Status and described here: https://eips.ethereum.org/EIPS/eip-3770 -(def regx-eip-3770-address #"^(?:(?:eth:|arb1:|oeth:)(?=:|))*0x[0-9a-fA-F]{40}$") -(def regx-metamask-address #"^ethereum:(0x[0-9a-fA-F]{40})@(0x1|0xa|0xa4b1)$") -(def regx-address-contains #"(?i)0x[a-fA-F0-9]{40}") (def regx-starts-with-uuid #"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}") (def regx-full-or-partial-address #"^0x[a-fA-F0-9]{1,40}$") diff --git a/src/status_im/contexts/wallet/send/select_address/view.cljs b/src/status_im/contexts/wallet/send/select_address/view.cljs index 2eafb7bee90..4c2e91579fd 100644 --- a/src/status_im/contexts/wallet/send/select_address/view.cljs +++ b/src/status_im/contexts/wallet/send/select_address/view.cljs @@ -58,7 +58,7 @@ {:on-result on-result}])) :ens-regex constants/regx-ens :scanned-value (or (when recipient-plain-address? send-address) scanned-address) - :address-regex constants/regx-eip-3770-address + :address-regex utils-address/regx-eip-3770-address :on-detect-address (fn [address] (when (or (= current-screen-id :screen/wallet.select-address) (= current-screen-id :screen/wallet.scan-address)) diff --git a/src/utils/address.cljs b/src/utils/address.cljs index 65efeccf24b..9656ad5baa4 100644 --- a/src/utils/address.cljs +++ b/src/utils/address.cljs @@ -2,10 +2,14 @@ (:require [clojure.string :as string] [native-module.core :as native-module] - [status-im.constants :as constants] [utils.ethereum.eip.eip55 :as eip55])) + (def hex-prefix "0x") +;; EIP-3770 is a format used by Status and described here: https://eips.ethereum.org/EIPS/eip-3770 +(def regx-eip-3770-address #"^(?:(?:eth:|arb1:|oeth:)(?=:|))*0x[0-9a-fA-F]{40}$") +(def regx-metamask-address #"^ethereum:(0x[0-9a-fA-F]{40})@(0x1|0xa|0xa4b1)$") +(def regx-address-contains #"(?i)0x[a-fA-F0-9]{40}") (defn normalized-hex [hex] @@ -84,12 +88,12 @@ (defn is-metamask-address? [address] - (re-find constants/regx-metamask-address address)) + (re-find regx-metamask-address address)) (defn eip-3770-address? "Checks if address follows EIP-3770 format which is default for Status" [s] - (re-find constants/regx-eip-3770-address s)) + (re-find regx-eip-3770-address s)) (defn supported-address? [s] @@ -116,4 +120,4 @@ (defn extract-address-without-chains-info [address] - (re-find constants/regx-address-contains address)) + (re-find regx-address-contains address)) diff --git a/src/utils/address_test.cljs b/src/utils/address_test.cljs index 3e999142e71..40438aadf84 100644 --- a/src/utils/address_test.cljs +++ b/src/utils/address_test.cljs @@ -82,5 +82,6 @@ (deftest metamask-address->status-address-test (testing "Check metamask to status address conversion is valid" (dorun - (for [[metamask-address status-address] metamask-to-status] + (for [{metamask-address :metamask + status-address :status} metamask-to-status] (is (= status-address (utils.address/metamask-address->status-address metamask-address))))))) From caaad21d426816d4be3c981199361ab6c89a553d Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Tue, 30 Jul 2024 16:25:01 +0100 Subject: [PATCH 09/12] review notes fixes --- .../contexts/shell/qr_reader/view.cljs | 8 ++++---- src/utils/address.cljs | 17 +++++++++-------- src/utils/address_test.cljs | 6 +++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/status_im/contexts/shell/qr_reader/view.cljs b/src/status_im/contexts/shell/qr_reader/view.cljs index 39a7a2d29cd..63ef09dd204 100644 --- a/src/status_im/contexts/shell/qr_reader/view.cljs +++ b/src/status_im/contexts/shell/qr_reader/view.cljs @@ -19,7 +19,7 @@ :theme :dark :text (i18n/label :t/invalid-qr)}) -(defn- is-text-a-status-url-for-path? +(defn- text-a-status-url-for-path? [text path] (some #(string/starts-with? text %) (router/prepend-status-urls path))) @@ -71,11 +71,11 @@ [scanned-text] (cond (or - (is-text-a-status-url-for-path? scanned-text router/community-with-data-path) - (is-text-a-status-url-for-path? scanned-text router/channel-path)) + (text-a-status-url-for-path? scanned-text router/community-with-data-path) + (text-a-status-url-for-path? scanned-text router/channel-path)) (debounce/debounce-and-dispatch [:universal-links/handle-url scanned-text] 300) - (is-text-a-status-url-for-path? scanned-text router/user-with-data-path) + (text-a-status-url-for-path? scanned-text router/user-with-data-path) (let [address (extract-id scanned-text)] (load-and-show-profile address)) diff --git a/src/utils/address.cljs b/src/utils/address.cljs index 9656ad5baa4..008ed8ab41e 100644 --- a/src/utils/address.cljs +++ b/src/utils/address.cljs @@ -86,10 +86,14 @@ "0xa" "oeth:" nil)) -(defn is-metamask-address? +(defn split-metamask-address [address] (re-find regx-metamask-address address)) +(defn metamask-address? + [address] + (boolean (split-metamask-address address))) + (defn eip-3770-address? "Checks if address follows EIP-3770 format which is default for Status" [s] @@ -98,11 +102,11 @@ (defn supported-address? [s] (boolean (or (eip-3770-address? s) - (is-metamask-address? s)))) + (metamask-address? s)))) (defn metamask-address->status-address [metamask-address] - (when-let [[_ address metamask-network-suffix] (is-metamask-address? metamask-address)] + (when-let [[_ address metamask-network-suffix] (split-metamask-address metamask-address)] (when-let [status-network-prefix (eip-155-suffix->eip-3770-prefix metamask-network-suffix)] (str status-network-prefix address)))) @@ -112,11 +116,8 @@ (eip-3770-address? address) address - (is-metamask-address? address) - (metamask-address->status-address address) - - :else - nil)) + (metamask-address? address) + (metamask-address->status-address address))) (defn extract-address-without-chains-info [address] diff --git a/src/utils/address_test.cljs b/src/utils/address_test.cljs index 40438aadf84..c36a742960a 100644 --- a/src/utils/address_test.cljs +++ b/src/utils/address_test.cljs @@ -69,15 +69,15 @@ {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" :status nil} {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2" :status nil}]) -(deftest is-metamask-address?-test +(deftest metamask-address?-test (testing "Check valid metamask addresses" (dorun (for [address valid-metamask-addresses] - (is (utils.address/is-metamask-address? address))))) + (is (utils.address/metamask-address? address))))) (testing "Check invalid metamask addresses" (dorun (for [address invalid-metamask-addresses] - (is (not (utils.address/is-metamask-address? address))))))) + (is (not (utils.address/metamask-address? address))))))) (deftest metamask-address->status-address-test (testing "Check metamask to status address conversion is valid" From 8ce864e900b0b4e0c5a506b81976e5041c61b240 Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Tue, 30 Jul 2024 16:35:15 +0100 Subject: [PATCH 10/12] return back function --- src/utils/address.cljs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/address.cljs b/src/utils/address.cljs index 008ed8ab41e..f67f0af98f7 100644 --- a/src/utils/address.cljs +++ b/src/utils/address.cljs @@ -18,6 +18,11 @@ hex (str hex-prefix hex)))) +(defn naked-address + [s] + (when s + (string/replace s hex-prefix ""))) + (defn address? [address] (native-module/address? address)) From 4d66b09f5ffbd4930934c21d37fa7ace838c32ea Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Wed, 28 Aug 2024 14:22:50 +0100 Subject: [PATCH 11/12] lint fix --- .../add_address_to_save/view.cljs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs b/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs index 16d711c0ead..fd6f79192e3 100644 --- a/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs +++ b/src/status_im/contexts/settings/wallet/saved_addresses/add_address_to_save/view.cljs @@ -1,18 +1,18 @@ (ns status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.view (:require - [clojure.string :as string] - [quo.core :as quo] - [react-native.clipboard :as clipboard] - [react-native.core :as rn] - [react-native.safe-area :as safe-area] - [status-im.common.floating-button-page.view :as floating-button-page] - [status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style] - [status-im.contexts.wallet.common.utils :as utils] - [status-im.contexts.wallet.common.validation :as validation] - [utils.address :as utils-address] - [utils.debounce :as debounce] - [utils.i18n :as i18n] - [utils.re-frame :as rf])) + [clojure.string :as string] + [quo.core :as quo] + [react-native.clipboard :as clipboard] + [react-native.core :as rn] + [react-native.safe-area :as safe-area] + [status-im.common.floating-button-page.view :as floating-button-page] + [status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style] + [status-im.contexts.wallet.common.utils :as utils] + [status-im.contexts.wallet.common.validation :as validation] + [utils.address :as utils-address] + [utils.debounce :as debounce] + [utils.i18n :as i18n] + [utils.re-frame :as rf])) (defn- navigate-back [] @@ -33,7 +33,7 @@ (not (or (utils-address/eip-3770-address? user-input) - (validation/ens-name? user-input))) + (validation/ens-name? user-input))) :invalid-address-or-ens))) (defn- address-input From 9fb32551f88d67119bfae0b5147646c76359b3ec Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Thu, 29 Aug 2024 12:17:15 +0100 Subject: [PATCH 12/12] Support metamask addresses without suffix, prefixed `:ethereum` --- src/utils/address.cljs | 7 ++++--- src/utils/address_test.cljs | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/utils/address.cljs b/src/utils/address.cljs index f67f0af98f7..1b964751fcc 100644 --- a/src/utils/address.cljs +++ b/src/utils/address.cljs @@ -8,7 +8,7 @@ (def hex-prefix "0x") ;; EIP-3770 is a format used by Status and described here: https://eips.ethereum.org/EIPS/eip-3770 (def regx-eip-3770-address #"^(?:(?:eth:|arb1:|oeth:)(?=:|))*0x[0-9a-fA-F]{40}$") -(def regx-metamask-address #"^ethereum:(0x[0-9a-fA-F]{40})@(0x1|0xa|0xa4b1)$") +(def regx-metamask-address #"^ethereum:(0x[0-9a-fA-F]{40})(?:@(0x1|0xa|0xa4b1))?$") (def regx-address-contains #"(?i)0x[a-fA-F0-9]{40}") (defn normalized-hex @@ -112,8 +112,9 @@ (defn metamask-address->status-address [metamask-address] (when-let [[_ address metamask-network-suffix] (split-metamask-address metamask-address)] - (when-let [status-network-prefix (eip-155-suffix->eip-3770-prefix metamask-network-suffix)] - (str status-network-prefix address)))) + (if-let [status-network-prefix (eip-155-suffix->eip-3770-prefix metamask-network-suffix)] + (str status-network-prefix address) + address))) (defn supported-address->status-address [address] diff --git a/src/utils/address_test.cljs b/src/utils/address_test.cljs index c36a742960a..3dd434747a2 100644 --- a/src/utils/address_test.cljs +++ b/src/utils/address_test.cljs @@ -43,7 +43,8 @@ (def valid-metamask-addresses ["ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" - "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa"]) + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"]) (def invalid-metamask-addresses ["ethe:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" @@ -51,8 +52,7 @@ "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1d" "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd20xa4b1" - "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" - "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"]) + "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa"]) (def metamask-to-status [{:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" @@ -61,13 +61,14 @@ :status "arb1:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" :status "oeth:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2" + :status "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2"} {:metamask "ethe:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1" :status nil} {:metamask ":0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa4b1" :status nil} {:metamask "0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0xa" :status nil} {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2@0x1d" :status nil} {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd20xa4b1" :status nil} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" :status nil} - {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2" :status nil}]) + {:metamask "ethereum:0x38cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd2:0xa" :status nil}]) (deftest metamask-address?-test (testing "Check valid metamask addresses"