diff --git a/nitro/ethaddress.nim b/nitro/ethaddress.nim index 1abeca5..8a17709 100644 --- a/nitro/ethaddress.nim +++ b/nitro/ethaddress.nim @@ -8,7 +8,7 @@ type EthAddress* = distinct array[20, byte] proc toArray*(address: EthAddress): array[20, byte] = 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 proc `==`*(a, b: EthAddress): bool {.borrow.} diff --git a/tests/nitro/protocol/testChannel.nim b/tests/nitro/protocol/testChannel.nim index d65d41c..48337df 100644 --- a/tests/nitro/protocol/testChannel.nim +++ b/tests/nitro/protocol/testChannel.nim @@ -23,7 +23,7 @@ suite "channel definition": chainId: 9001.u256, nonce: 1, participants: @[ - EthAddress.fromHex("24b905Dcc8A11C0FE57C2592f3D25f0447402C10").get() + EthAddress.parse("24b905Dcc8A11C0FE57C2592f3D25f0447402C10").get() ] ) let expected = Destination.parse( diff --git a/tests/nitro/protocol/testOutcome.nim b/tests/nitro/protocol/testOutcome.nim index ea0b9ad..ec707fc 100644 --- a/tests/nitro/protocol/testOutcome.nim +++ b/tests/nitro/protocol/testOutcome.nim @@ -1,6 +1,5 @@ import pkg/nitro/protocol/abi import pkg/nimcrypto -import pkg/stew/byteutils import ../basics suite "outcome": @@ -91,7 +90,7 @@ suite "outcome": let outcome = Outcome(@[ AssetOutcome( kind: allocationType, - assetHolder: EthAddress.fromHex( + assetHolder: EthAddress.parse( "1E90B49563da16D2537CA1Ddd9b1285279103D93" ).get(), allocation: Allocation(@[ @@ -105,7 +104,7 @@ suite "outcome": ), AssetOutcome( kind: guaranteeType, - assetHolder: EthAddress.fromHex( + assetHolder: EthAddress.parse( "1E90B49563da16D2537CA1Ddd9b1285279103D93" ).get(), guarantee: Guarantee( diff --git a/tests/nitro/protocol/testSignature.nim b/tests/nitro/protocol/testSignature.nim index 447d67c..838bbbc 100644 --- a/tests/nitro/protocol/testSignature.nim +++ b/tests/nitro/protocol/testSignature.nim @@ -23,7 +23,7 @@ suite "signature": chainId: 0x1.u256, nonce: 1, participants: @[ - EthAddress.fromHex("0x8a64E10FF40Bc9C90EA5750313dB5e036495c10E").get() + EthAddress.parse("0x8a64E10FF40Bc9C90EA5750313dB5e036495c10E").get() ] ), outcome: Outcome(@[]), diff --git a/tests/nitro/protocol/testState.nim b/tests/nitro/protocol/testState.nim index cacb601..25164a1 100644 --- a/tests/nitro/protocol/testState.nim +++ b/tests/nitro/protocol/testState.nim @@ -52,7 +52,7 @@ suite "state": chainId: 0x1.u256, nonce: 1, participants: @[ - EthAddress.fromHex("DBE821484648c73C1996Da25f2355342B9803eBD").get() + EthAddress.parse("DBE821484648c73C1996Da25f2355342B9803eBD").get() ] ), outcome: Outcome(@[]),