Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace nim's std/nre with nim-regex library #1327

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,13 @@
url = https://github.com/vacp2p/zerokit.git
ignore = dirty
branch = master
[submodule "vendor/nim-regex"]
path = vendor/nim-regex
url = https://github.com/nitely/nim-regex.git
ignore = untracked
branch = master
[submodule "vendor/nim-unicodedb"]
path = vendor/nim-unicodedb
url = https://github.com/nitely/nim-unicodedb.git
ignore = untracked
branch = master
10 changes: 5 additions & 5 deletions apps/wakunode2/config.nim
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import
std/[strutils, nre],
std/strutils,
stew/results,
chronicles,
chronos,
regex,
confutils,
confutils/defs,
confutils/std/net,
Expand Down Expand Up @@ -473,8 +474,7 @@ proc defaultListenAddress*(): ValidIpAddress =
proc defaultPrivateKey*(): PrivateKey =
crypto.PrivateKey.random(Secp256k1, crypto.newRng()[]).value

proc readValue*(r: var TomlReader, val: var crypto.PrivateKey)
{.raises: [Defect, IOError, SerializationError].} =
proc readValue*(r: var TomlReader, val: var crypto.PrivateKey) {.raises: [SerializationError].} =
val = try: parseCmdArg(crypto.PrivateKey, r.readValue(string))
except CatchableError as err:
raise newException(SerializationError, err.msg)
Expand All @@ -487,7 +487,7 @@ let DbUrlRegex = re"^[\w\+]+:\/\/[\w\/\\\.\:\@]+$"
proc validateDbUrl*(val: string): ConfResult[string] =
let val = val.strip()

if val == "" or val.match(DbUrlRegex).isSome():
if val == "" or val.match(DbUrlRegex):
return ok(val)
else:
return err("invalid 'db url' option format: " & val)
Expand All @@ -498,7 +498,7 @@ let StoreMessageRetentionPolicyRegex = re"^\w+:\w$"
proc validateStoreMessageRetentionPolicy*(val: string): ConfResult[string] =
let val = val.strip()

if val == "" or val.match(StoreMessageRetentionPolicyRegex).isSome():
if val == "" or val.match(StoreMessageRetentionPolicyRegex):
return ok(val)
else:
return err("invalid 'store message retention policy' option format: " & val)
1 change: 1 addition & 0 deletions vendor/nim-regex
Submodule nim-regex added at ab9873
1 change: 1 addition & 0 deletions vendor/nim-unicodedb
Submodule nim-unicodedb added at c3c9ae
5 changes: 3 additions & 2 deletions waku.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT or Apache License 2.0"
#bin = @["build/waku"]

### Dependencies
requires "nim >= 1.2.0",
requires "nim >= 1.6.0",
"chronicles",
"confutils",
"chronos",
Expand All @@ -21,7 +21,8 @@ requires "nim >= 1.2.0",
"metrics",
"libp2p", # Only for Waku v2
"web3",
"presto"
"presto",
"regex"

### Helper functions
proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
Expand Down