mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-25 13:26:17 +00:00
fix: replace TaintedString type deprecated in nim 1.5
This commit is contained in:
parent
8fee1b9bed
commit
83ae6987b8
@ -297,7 +297,7 @@ type
|
|||||||
name: "rln-relay-cred-password" }: string
|
name: "rln-relay-cred-password" }: string
|
||||||
|
|
||||||
# NOTE: Keys are different in nim-libp2p
|
# NOTE: Keys are different in nim-libp2p
|
||||||
proc parseCmdArg*(T: type crypto.PrivateKey, p: TaintedString): T =
|
proc parseCmdArg*(T: type crypto.PrivateKey, p: string): T =
|
||||||
try:
|
try:
|
||||||
let key = SkPrivateKey.init(utils.fromHex(p)).tryGet()
|
let key = SkPrivateKey.init(utils.fromHex(p)).tryGet()
|
||||||
# XXX: Here at the moment
|
# XXX: Here at the moment
|
||||||
@ -305,25 +305,25 @@ proc parseCmdArg*(T: type crypto.PrivateKey, p: TaintedString): T =
|
|||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
raise newException(ConfigurationError, "Invalid private key")
|
raise newException(ConfigurationError, "Invalid private key")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type crypto.PrivateKey, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type crypto.PrivateKey, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type ValidIpAddress, p: TaintedString): T =
|
proc parseCmdArg*(T: type ValidIpAddress, p: string): T =
|
||||||
try:
|
try:
|
||||||
result = ValidIpAddress.init(p)
|
result = ValidIpAddress.init(p)
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
raise newException(ConfigurationError, "Invalid IP address")
|
raise newException(ConfigurationError, "Invalid IP address")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type ValidIpAddress, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type ValidIpAddress, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type Port, p: TaintedString): T =
|
proc parseCmdArg*(T: type Port, p: string): T =
|
||||||
try:
|
try:
|
||||||
result = Port(parseInt(p))
|
result = Port(parseInt(p))
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
raise newException(ConfigurationError, "Invalid Port number")
|
raise newException(ConfigurationError, "Invalid Port number")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type Port, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type Port, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
func defaultListenAddress*(conf: Chat2Conf): ValidIpAddress =
|
func defaultListenAddress*(conf: Chat2Conf): ValidIpAddress =
|
||||||
|
@ -129,33 +129,33 @@ type
|
|||||||
defaultValue: "/toy-chat/2/huilong/proto"
|
defaultValue: "/toy-chat/2/huilong/proto"
|
||||||
name: "content-topic" }: string
|
name: "content-topic" }: string
|
||||||
|
|
||||||
proc parseCmdArg*(T: type keys.KeyPair, p: TaintedString): T =
|
proc parseCmdArg*(T: type keys.KeyPair, p: string): T =
|
||||||
try:
|
try:
|
||||||
let privkey = keys.PrivateKey.fromHex(string(p)).tryGet()
|
let privkey = keys.PrivateKey.fromHex(string(p)).tryGet()
|
||||||
result = privkey.toKeyPair()
|
result = privkey.toKeyPair()
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
raise newException(ConfigurationError, "Invalid private key")
|
raise newException(ConfigurationError, "Invalid private key")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type keys.KeyPair, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type keys.KeyPair, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type crypto.PrivateKey, p: TaintedString): T =
|
proc parseCmdArg*(T: type crypto.PrivateKey, p: string): T =
|
||||||
let key = SkPrivateKey.init(p)
|
let key = SkPrivateKey.init(p)
|
||||||
if key.isOk():
|
if key.isOk():
|
||||||
crypto.PrivateKey(scheme: Secp256k1, skkey: key.get())
|
crypto.PrivateKey(scheme: Secp256k1, skkey: key.get())
|
||||||
else:
|
else:
|
||||||
raise newException(ConfigurationError, "Invalid private key")
|
raise newException(ConfigurationError, "Invalid private key")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type crypto.PrivateKey, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type crypto.PrivateKey, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type ValidIpAddress, p: TaintedString): T =
|
proc parseCmdArg*(T: type ValidIpAddress, p: string): T =
|
||||||
try:
|
try:
|
||||||
result = ValidIpAddress.init(p)
|
result = ValidIpAddress.init(p)
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
raise newException(ConfigurationError, "Invalid IP address")
|
raise newException(ConfigurationError, "Invalid IP address")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type ValidIpAddress, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type ValidIpAddress, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
func defaultListenAddress*(conf: Chat2MatterbridgeConf): ValidIpAddress =
|
func defaultListenAddress*(conf: Chat2MatterbridgeConf): ValidIpAddress =
|
||||||
|
@ -151,33 +151,33 @@ type
|
|||||||
defaultValue: "/waku/2/default-waku/proto"
|
defaultValue: "/waku/2/default-waku/proto"
|
||||||
name: "bridge-pubsub-topic" }: string
|
name: "bridge-pubsub-topic" }: string
|
||||||
|
|
||||||
proc parseCmdArg*(T: type keys.KeyPair, p: TaintedString): T =
|
proc parseCmdArg*(T: type keys.KeyPair, p: string): T =
|
||||||
try:
|
try:
|
||||||
let privkey = keys.PrivateKey.fromHex(string(p)).tryGet()
|
let privkey = keys.PrivateKey.fromHex(string(p)).tryGet()
|
||||||
result = privkey.toKeyPair()
|
result = privkey.toKeyPair()
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
raise newException(ConfigurationError, "Invalid private key")
|
raise newException(ConfigurationError, "Invalid private key")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type keys.KeyPair, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type keys.KeyPair, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type crypto.PrivateKey, p: TaintedString): T =
|
proc parseCmdArg*(T: type crypto.PrivateKey, p: string): T =
|
||||||
let key = SkPrivateKey.init(p)
|
let key = SkPrivateKey.init(p)
|
||||||
if key.isOk():
|
if key.isOk():
|
||||||
crypto.PrivateKey(scheme: Secp256k1, skkey: key.get())
|
crypto.PrivateKey(scheme: Secp256k1, skkey: key.get())
|
||||||
else:
|
else:
|
||||||
raise newException(ConfigurationError, "Invalid private key")
|
raise newException(ConfigurationError, "Invalid private key")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type crypto.PrivateKey, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type crypto.PrivateKey, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type ValidIpAddress, p: TaintedString): T =
|
proc parseCmdArg*(T: type ValidIpAddress, p: string): T =
|
||||||
try:
|
try:
|
||||||
result = ValidIpAddress.init(p)
|
result = ValidIpAddress.init(p)
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
raise newException(ConfigurationError, "Invalid IP address")
|
raise newException(ConfigurationError, "Invalid IP address")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type ValidIpAddress, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type ValidIpAddress, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
func defaultListenAddress*(conf: WakuNodeConf): ValidIpAddress =
|
func defaultListenAddress*(conf: WakuNodeConf): ValidIpAddress =
|
||||||
|
@ -436,7 +436,7 @@ type
|
|||||||
name: "websocket-secure-cert-path"}: string
|
name: "websocket-secure-cert-path"}: string
|
||||||
|
|
||||||
# NOTE: Keys are different in nim-libp2p
|
# NOTE: Keys are different in nim-libp2p
|
||||||
proc parseCmdArg*(T: type crypto.PrivateKey, p: TaintedString): T =
|
proc parseCmdArg*(T: type crypto.PrivateKey, p: string): T =
|
||||||
try:
|
try:
|
||||||
let key = SkPrivateKey.init(utils.fromHex(p)).tryGet()
|
let key = SkPrivateKey.init(utils.fromHex(p)).tryGet()
|
||||||
# XXX: Here at the moment
|
# XXX: Here at the moment
|
||||||
@ -444,25 +444,25 @@ proc parseCmdArg*(T: type crypto.PrivateKey, p: TaintedString): T =
|
|||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
raise newException(ConfigurationError, "Invalid private key")
|
raise newException(ConfigurationError, "Invalid private key")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type crypto.PrivateKey, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type crypto.PrivateKey, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type ValidIpAddress, p: TaintedString): T =
|
proc parseCmdArg*(T: type ValidIpAddress, p: string): T =
|
||||||
try:
|
try:
|
||||||
result = ValidIpAddress.init(p)
|
result = ValidIpAddress.init(p)
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
raise newException(ConfigurationError, "Invalid IP address")
|
raise newException(ConfigurationError, "Invalid IP address")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type ValidIpAddress, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type ValidIpAddress, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type Port, p: TaintedString): T =
|
proc parseCmdArg*(T: type Port, p: string): T =
|
||||||
try:
|
try:
|
||||||
result = Port(parseInt(p))
|
result = Port(parseInt(p))
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
raise newException(ConfigurationError, "Invalid Port number")
|
raise newException(ConfigurationError, "Invalid Port number")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type Port, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type Port, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc defaultListenAddress*(): ValidIpAddress =
|
proc defaultListenAddress*(): ValidIpAddress =
|
||||||
|
@ -45,21 +45,21 @@ type
|
|||||||
defaultValue: KeyPair.random(keys.newRng()[])
|
defaultValue: KeyPair.random(keys.newRng()[])
|
||||||
name: "nodekey" .}: KeyPair
|
name: "nodekey" .}: KeyPair
|
||||||
|
|
||||||
proc parseCmdArg*(T: type KeyPair, p: TaintedString): T =
|
proc parseCmdArg*(T: type KeyPair, p: string): T =
|
||||||
try:
|
try:
|
||||||
let privkey = PrivateKey.fromHex(string(p)).tryGet()
|
let privkey = PrivateKey.fromHex(string(p)).tryGet()
|
||||||
result = privkey.toKeyPair()
|
result = privkey.toKeyPair()
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
raise newException(ConfigurationError, "Invalid private key")
|
raise newException(ConfigurationError, "Invalid private key")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type KeyPair, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type KeyPair, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type IpAddress, p: TaintedString): T =
|
proc parseCmdArg*(T: type IpAddress, p: string): T =
|
||||||
try:
|
try:
|
||||||
result = parseIpAddress(p)
|
result = parseIpAddress(p)
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
raise newException(ConfigurationError, "Invalid IP address")
|
raise newException(ConfigurationError, "Invalid IP address")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type IpAddress, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type IpAddress, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
@ -51,13 +51,13 @@ type
|
|||||||
abbr: "l" .}: LogLevel
|
abbr: "l" .}: LogLevel
|
||||||
|
|
||||||
|
|
||||||
proc parseCmdArg*(T: type chronos.Duration, p: TaintedString): T =
|
proc parseCmdArg*(T: type chronos.Duration, p: string): T =
|
||||||
try:
|
try:
|
||||||
result = chronos.seconds(parseInt(p))
|
result = chronos.seconds(parseInt(p))
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
raise newException(ConfigurationError, "Invalid timeout value")
|
raise newException(ConfigurationError, "Invalid timeout value")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type chronos.Duration, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type chronos.Duration, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
# checks if rawProtocols (skipping version) are supported in nodeProtocols
|
# checks if rawProtocols (skipping version) are supported in nodeProtocols
|
||||||
|
@ -144,21 +144,21 @@ type
|
|||||||
of genNodekey:
|
of genNodekey:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc parseCmdArg*(T: type KeyPair, p: TaintedString): T =
|
proc parseCmdArg*(T: type KeyPair, p: string): T =
|
||||||
try:
|
try:
|
||||||
let privkey = PrivateKey.fromHex(string(p)).tryGet()
|
let privkey = PrivateKey.fromHex(string(p)).tryGet()
|
||||||
result = privkey.toKeyPair()
|
result = privkey.toKeyPair()
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
raise newException(ConfigurationError, "Invalid private key")
|
raise newException(ConfigurationError, "Invalid private key")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type KeyPair, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type KeyPair, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
|
||||||
proc parseCmdArg*(T: type IpAddress, p: TaintedString): T =
|
proc parseCmdArg*(T: type IpAddress, p: string): T =
|
||||||
try:
|
try:
|
||||||
result = parseIpAddress(p)
|
result = parseIpAddress(p)
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
raise newException(ConfigurationError, "Invalid IP address")
|
raise newException(ConfigurationError, "Invalid IP address")
|
||||||
|
|
||||||
proc completeCmdArg*(T: type IpAddress, val: TaintedString): seq[string] =
|
proc completeCmdArg*(T: type IpAddress, val: string): seq[string] =
|
||||||
return @[]
|
return @[]
|
||||||
|
@ -26,7 +26,7 @@ type
|
|||||||
# Helper functions #
|
# Helper functions #
|
||||||
####################
|
####################
|
||||||
|
|
||||||
proc parseBootstrapAddress(address: TaintedString):
|
proc parseBootstrapAddress(address: string):
|
||||||
Result[enr.Record, cstring] =
|
Result[enr.Record, cstring] =
|
||||||
logScope:
|
logScope:
|
||||||
address = string(address)
|
address = string(address)
|
||||||
|
@ -21,7 +21,7 @@ type NodeTaskJsonResult = Result[JsonNode, string]
|
|||||||
const taskPrelude = "npx hardhat --network localhost "
|
const taskPrelude = "npx hardhat --network localhost "
|
||||||
const cmdPrelude = "cd ../swap-contracts-module; " & taskPrelude
|
const cmdPrelude = "cd ../swap-contracts-module; " & taskPrelude
|
||||||
|
|
||||||
# proc execNodeTask(taskStr: string): tuple[output: TaintedString, exitCode: int] =
|
# proc execNodeTask(taskStr: string): tuple[output: string, exitCode: int] =
|
||||||
# let cmdString = $cmdPrelude & $taskStr
|
# let cmdString = $cmdPrelude & $taskStr
|
||||||
# debug "execNodeTask", cmdString
|
# debug "execNodeTask", cmdString
|
||||||
# return osproc.execCmdEx(cmdString)
|
# return osproc.execCmdEx(cmdString)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user