mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-04 06:33:12 +00:00
Update to latest contractabi
This commit is contained in:
parent
ad95604c18
commit
9611c36c78
@ -1 +1 @@
|
|||||||
nim 1.6.0
|
nim 1.6.2
|
||||||
|
|||||||
@ -7,7 +7,7 @@ requires "nim >= 1.2.6 & < 2.0.0"
|
|||||||
requires "nimcrypto >= 0.5.4 & < 0.6.0"
|
requires "nimcrypto >= 0.5.4 & < 0.6.0"
|
||||||
requires "questionable >= 0.10.1 & < 0.11.0"
|
requires "questionable >= 0.10.1 & < 0.11.0"
|
||||||
requires "upraises >= 0.1.0 & < 0.2.0"
|
requires "upraises >= 0.1.0 & < 0.2.0"
|
||||||
requires "https://github.com/status-im/nim-contract-abi >= 0.3.0 & < 0.4.0"
|
requires "contractabi >= 0.4.1 & < 0.5.0"
|
||||||
requires "secp256k1"
|
requires "secp256k1"
|
||||||
requires "stint"
|
requires "stint"
|
||||||
requires "stew"
|
requires "stew"
|
||||||
|
|||||||
@ -1,23 +1,12 @@
|
|||||||
import std/hashes
|
import std/hashes
|
||||||
import pkg/questionable
|
import pkg/contractabi/address
|
||||||
import pkg/questionable/results
|
|
||||||
import pkg/stew/byteutils
|
|
||||||
|
|
||||||
export questionable
|
export address
|
||||||
|
|
||||||
type EthAddress* = distinct array[20, byte]
|
type EthAddress* = Address
|
||||||
|
|
||||||
func zero*(_: type EthAddress): EthAddress =
|
func zero*(_: type EthAddress): EthAddress =
|
||||||
EthAddress.default
|
EthAddress.default
|
||||||
|
|
||||||
func toArray*(address: EthAddress): array[20, byte] =
|
proc `hash`*(a: EthAddress): Hash =
|
||||||
array[20, byte](address)
|
hash(a.toArray)
|
||||||
|
|
||||||
func `$`*(a: EthAddress): string =
|
|
||||||
a.toArray().toHex()
|
|
||||||
|
|
||||||
func parse*(_: type EthAddress, hex: string): ?EthAddress =
|
|
||||||
EthAddress(array[20, byte].fromHex(hex)).catch.option
|
|
||||||
|
|
||||||
proc `==`*(a, b: EthAddress): bool {.borrow.}
|
|
||||||
proc `hash`*(a: EthAddress): Hash {.borrow.}
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ func initFromJson*(bytes: var seq[byte], node: JsonNode, _: var string) =
|
|||||||
|
|
||||||
func initFromJson*(address: var EthAddress, node: JsonNode, _: var string) =
|
func initFromJson*(address: var EthAddress, node: JsonNode, _: var string) =
|
||||||
node.expectKind(JString)
|
node.expectKind(JString)
|
||||||
without parsed =? EthAddress.parse(node.getStr):
|
without parsed =? EthAddress.init(node.getStr):
|
||||||
raise newException(ValueError, "invalid ethereum address")
|
raise newException(ValueError, "invalid ethereum address")
|
||||||
address = parsed
|
address = parsed
|
||||||
|
|
||||||
|
|||||||
@ -6,10 +6,5 @@ push: {.upraises:[].}
|
|||||||
export basics
|
export basics
|
||||||
export contractabi
|
export contractabi
|
||||||
|
|
||||||
func encode*(encoder: var AbiEncoder, address: EthAddress) =
|
|
||||||
var padded: array[32, byte]
|
|
||||||
padded[12..<32] = address.toArray
|
|
||||||
encoder.write(padded)
|
|
||||||
|
|
||||||
func encode*(encoder: var AbiEncoder, destination: Destination) =
|
func encode*(encoder: var AbiEncoder, destination: Destination) =
|
||||||
encoder.write(destination.toArray)
|
encoder.write(destination.toArray)
|
||||||
|
|||||||
@ -17,7 +17,7 @@ suite "channel definition":
|
|||||||
chainId: 9001.u256,
|
chainId: 9001.u256,
|
||||||
nonce: 1,
|
nonce: 1,
|
||||||
participants: @[
|
participants: @[
|
||||||
!EthAddress.parse("24b905Dcc8A11C0FE57C2592f3D25f0447402C10")
|
!EthAddress.init("24b905Dcc8A11C0FE57C2592f3D25f0447402C10")
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
let expected = !Destination.parse(
|
let expected = !Destination.parse(
|
||||||
|
|||||||
@ -61,7 +61,7 @@ suite "outcome":
|
|||||||
let outcome = Outcome(@[
|
let outcome = Outcome(@[
|
||||||
AssetOutcome(
|
AssetOutcome(
|
||||||
kind: allocationType,
|
kind: allocationType,
|
||||||
assetHolder: !EthAddress.parse(
|
assetHolder: !EthAddress.init(
|
||||||
"1E90B49563da16D2537CA1Ddd9b1285279103D93"
|
"1E90B49563da16D2537CA1Ddd9b1285279103D93"
|
||||||
),
|
),
|
||||||
allocation: Allocation(@[
|
allocation: Allocation(@[
|
||||||
@ -75,7 +75,7 @@ suite "outcome":
|
|||||||
),
|
),
|
||||||
AssetOutcome(
|
AssetOutcome(
|
||||||
kind: guaranteeType,
|
kind: guaranteeType,
|
||||||
assetHolder: !EthAddress.parse(
|
assetHolder: !EthAddress.init(
|
||||||
"1E90B49563da16D2537CA1Ddd9b1285279103D93"
|
"1E90B49563da16D2537CA1Ddd9b1285279103D93"
|
||||||
),
|
),
|
||||||
guarantee: Guarantee(
|
guarantee: Guarantee(
|
||||||
|
|||||||
@ -40,7 +40,7 @@ suite "signature":
|
|||||||
chainId: 0x1.u256,
|
chainId: 0x1.u256,
|
||||||
nonce: 1,
|
nonce: 1,
|
||||||
participants: @[
|
participants: @[
|
||||||
!EthAddress.parse("0x8a64E10FF40Bc9C90EA5750313dB5e036495c10E")
|
!EthAddress.init("0x8a64E10FF40Bc9C90EA5750313dB5e036495c10E")
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
outcome: Outcome(@[]),
|
outcome: Outcome(@[]),
|
||||||
|
|||||||
@ -46,7 +46,7 @@ suite "state":
|
|||||||
chainId: 0x1.u256,
|
chainId: 0x1.u256,
|
||||||
nonce: 1,
|
nonce: 1,
|
||||||
participants: @[
|
participants: @[
|
||||||
!EthAddress.parse("DBE821484648c73C1996Da25f2355342B9803eBD")
|
!EthAddress.init("DBE821484648c73C1996Da25f2355342B9803eBD")
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
outcome: Outcome(@[]),
|
outcome: Outcome(@[]),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user