Skip to content

Commit

Permalink
fix lint and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vkjr committed Jul 24, 2024
1 parent ca74030 commit 8a38102
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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}$")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
12 changes: 8 additions & 4 deletions src/utils/address.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand All @@ -116,4 +120,4 @@

(defn extract-address-without-chains-info
[address]
(re-find constants/regx-address-contains address))
(re-find regx-address-contains address))
3 changes: 2 additions & 1 deletion src/utils/address_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))))

0 comments on commit 8a38102

Please sign in to comment.