Rename: EthAddress.fromHex() -> EthAddress.parse()

This commit is contained in:
Mark Spanbroek 2021-03-09 14:05:32 +01:00
parent b758751211
commit a8b2cfab5a
5 changed files with 6 additions and 7 deletions

View File

@ -8,7 +8,7 @@ type EthAddress* = distinct array[20, byte]
proc toArray*(address: EthAddress): array[20, byte] = proc toArray*(address: EthAddress): array[20, byte] =
array[20, byte](address) array[20, byte](address)
proc fromHex*(_: type EthAddress, hex: string): ?EthAddress = proc parse*(_: type EthAddress, hex: string): ?EthAddress =
EthAddress(array[20, byte].fromHex(hex)).catch.toOption EthAddress(array[20, byte].fromHex(hex)).catch.toOption
proc `==`*(a, b: EthAddress): bool {.borrow.} proc `==`*(a, b: EthAddress): bool {.borrow.}

View File

@ -23,7 +23,7 @@ suite "channel definition":
chainId: 9001.u256, chainId: 9001.u256,
nonce: 1, nonce: 1,
participants: @[ participants: @[
EthAddress.fromHex("24b905Dcc8A11C0FE57C2592f3D25f0447402C10").get() EthAddress.parse("24b905Dcc8A11C0FE57C2592f3D25f0447402C10").get()
] ]
) )
let expected = Destination.parse( let expected = Destination.parse(

View File

@ -1,6 +1,5 @@
import pkg/nitro/protocol/abi import pkg/nitro/protocol/abi
import pkg/nimcrypto import pkg/nimcrypto
import pkg/stew/byteutils
import ../basics import ../basics
suite "outcome": suite "outcome":
@ -91,7 +90,7 @@ suite "outcome":
let outcome = Outcome(@[ let outcome = Outcome(@[
AssetOutcome( AssetOutcome(
kind: allocationType, kind: allocationType,
assetHolder: EthAddress.fromHex( assetHolder: EthAddress.parse(
"1E90B49563da16D2537CA1Ddd9b1285279103D93" "1E90B49563da16D2537CA1Ddd9b1285279103D93"
).get(), ).get(),
allocation: Allocation(@[ allocation: Allocation(@[
@ -105,7 +104,7 @@ suite "outcome":
), ),
AssetOutcome( AssetOutcome(
kind: guaranteeType, kind: guaranteeType,
assetHolder: EthAddress.fromHex( assetHolder: EthAddress.parse(
"1E90B49563da16D2537CA1Ddd9b1285279103D93" "1E90B49563da16D2537CA1Ddd9b1285279103D93"
).get(), ).get(),
guarantee: Guarantee( guarantee: Guarantee(

View File

@ -23,7 +23,7 @@ suite "signature":
chainId: 0x1.u256, chainId: 0x1.u256,
nonce: 1, nonce: 1,
participants: @[ participants: @[
EthAddress.fromHex("0x8a64E10FF40Bc9C90EA5750313dB5e036495c10E").get() EthAddress.parse("0x8a64E10FF40Bc9C90EA5750313dB5e036495c10E").get()
] ]
), ),
outcome: Outcome(@[]), outcome: Outcome(@[]),

View File

@ -52,7 +52,7 @@ suite "state":
chainId: 0x1.u256, chainId: 0x1.u256,
nonce: 1, nonce: 1,
participants: @[ participants: @[
EthAddress.fromHex("DBE821484648c73C1996Da25f2355342B9803eBD").get() EthAddress.parse("DBE821484648c73C1996Da25f2355342B9803eBD").get()
] ]
), ),
outcome: Outcome(@[]), outcome: Outcome(@[]),