crypto: lazy_static removed, light parser for address URI added (#2250)

The `lazy_static` package does not work well in `no-std`: it requires
`spin_no_std` feature, which also will propagate into `std` if enabled.
This is not what we want.

This PR provides simple address uri parser which allows to get rid of
_regex_ which was used to parse the address uri, what in turns allows to
remove lazy_static.

Three regular expressions
(`SS58_REGEX`,`SECRET_PHRASE_REGEX`,`JUNCTION_REGEX`) were replaced with
the parser which unifies all of them.

The new parser does not support Unicode, it is ASCII only.

Related to: #2044

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Koute <koute@users.noreply.github.com>
Co-authored-by: command-bot <>
This commit is contained in:
Michal Kucharczyk
2023-11-17 14:43:37 +01:00
committed by GitHub
parent 3ab2bc9ff3
commit 5007e2dd5c
10 changed files with 601 additions and 67 deletions
+2 -4
View File
@@ -26,10 +26,8 @@ bs58 = { version = "0.5.0", default-features = false, optional = true }
rand = { version = "0.8.5", features = ["small_rng"], optional = true }
substrate-bip39 = { version = "0.4.4", optional = true }
bip39 = { version = "2.0.0", default-features = false }
regex = { version = "1.6.0", optional = true }
zeroize = { version = "1.4.3", default-features = false }
secrecy = { version = "0.8.0", default-features = false }
lazy_static = { version = "1.4.0", default-features = false, optional = true }
parking_lot = { version = "0.12.1", optional = true }
ss58-registry = { version = "1.34.0", default-features = false }
sp-std = { path = "../std", default-features = false}
@@ -63,6 +61,8 @@ bandersnatch_vrfs = { git = "https://github.com/w3f/ring-vrf", rev = "cbc342e",
[dev-dependencies]
criterion = "0.4.0"
serde_json = "1.0.108"
lazy_static = "1.4.0"
regex = "1.6.0"
sp-core-hashing-proc-macro = { path = "hashing/proc-macro" }
[[bench]]
@@ -92,7 +92,6 @@ std = [
"hash256-std-hasher/std",
"impl-serde/std",
"itertools",
"lazy_static",
"libsecp256k1/std",
"log/std",
"merlin/std",
@@ -102,7 +101,6 @@ std = [
"primitive-types/serde",
"primitive-types/std",
"rand",
"regex",
"scale-info/std",
"schnorrkel/std",
"secp256k1/global-context",