mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-05 15:13:07 +00:00
Move common imports into a "basics" module
This commit is contained in:
parent
4afe88965c
commit
f7dda63c04
11
nitro/basics.nim
Normal file
11
nitro/basics.nim
Normal file
@ -0,0 +1,11 @@
|
||||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
import pkg/stint
|
||||
import ./uint48
|
||||
import ./ethaddress
|
||||
|
||||
export questionable
|
||||
export results
|
||||
export stint
|
||||
export uint48
|
||||
export ethaddress
|
||||
@ -1,24 +1,14 @@
|
||||
import std/math
|
||||
import pkg/questionable
|
||||
import pkg/stint
|
||||
import pkg/stew/byteutils
|
||||
|
||||
include questionable/errorban
|
||||
|
||||
export stint
|
||||
export questionable
|
||||
|
||||
type
|
||||
UInt48* = range[0'u64..2'u64^48-1]
|
||||
EthAddress* = distinct array[20, byte]
|
||||
type EthAddress* = distinct array[20, byte]
|
||||
|
||||
proc toArray*(address: EthAddress): array[20, byte] =
|
||||
array[20, byte](address)
|
||||
|
||||
proc fromHex*(_: type EthAddress, hex: string): ?EthAddress =
|
||||
try:
|
||||
EthAddress(array[20, byte].fromHex(hex)).some
|
||||
except ValueError:
|
||||
EthAddress.none
|
||||
EthAddress(array[20, byte].fromHex(hex)).catch.toOption
|
||||
|
||||
proc `==`*(a, b: EthAddress): bool {.borrow.}
|
||||
@ -1,10 +1,9 @@
|
||||
import pkg/stew/endians2
|
||||
import pkg/stint
|
||||
import ../types
|
||||
import ../basics
|
||||
|
||||
include questionable/errorban
|
||||
|
||||
export types
|
||||
export basics
|
||||
|
||||
type
|
||||
AbiEncoder* = object
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import pkg/nimcrypto
|
||||
import ../types
|
||||
import ../basics
|
||||
import ./abi
|
||||
|
||||
include questionable/errorban
|
||||
|
||||
export types
|
||||
export basics
|
||||
|
||||
type
|
||||
Channel* = object
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import pkg/nimcrypto
|
||||
import ../types
|
||||
import ../basics
|
||||
import ./abi
|
||||
|
||||
include questionable/errorban
|
||||
|
||||
export types
|
||||
export basics
|
||||
|
||||
type
|
||||
Outcome* = distinct seq[AssetOutcome]
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
import pkg/nimcrypto
|
||||
import pkg/secp256k1
|
||||
import pkg/nimcrypto
|
||||
import pkg/stew/byteutils
|
||||
import ../basics
|
||||
import ./state
|
||||
|
||||
include questionable/errorban
|
||||
|
||||
export questionable
|
||||
export basics
|
||||
export toPublicKey
|
||||
|
||||
type
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import pkg/nimcrypto
|
||||
import ../types
|
||||
import ../basics
|
||||
import ./channel
|
||||
import ./outcome
|
||||
import ./abi
|
||||
|
||||
include questionable/errorban
|
||||
|
||||
export types
|
||||
export basics
|
||||
export channel
|
||||
export outcome
|
||||
|
||||
|
||||
3
nitro/uint48.nim
Normal file
3
nitro/uint48.nim
Normal file
@ -0,0 +1,3 @@
|
||||
import std/math
|
||||
|
||||
type UInt48* = range[0'u64..2'u64^48-1]
|
||||
7
tests/nitro/protocol/basics.nim
Normal file
7
tests/nitro/protocol/basics.nim
Normal file
@ -0,0 +1,7 @@
|
||||
import std/unittest
|
||||
import pkg/nitro
|
||||
import ./examples
|
||||
|
||||
export unittest
|
||||
export nitro
|
||||
export examples
|
||||
@ -1,7 +1,5 @@
|
||||
import std/unittest
|
||||
import ./basics
|
||||
import pkg/nitro/protocol/abi
|
||||
import pkg/stint
|
||||
import ./examples
|
||||
|
||||
suite "ABI encoding":
|
||||
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
import std/unittest
|
||||
import pkg/nitro/protocol/channel
|
||||
import ./basics
|
||||
import pkg/nitro/protocol/abi
|
||||
import pkg/nimcrypto
|
||||
import pkg/stew/byteutils
|
||||
import ./examples
|
||||
|
||||
suite "channel":
|
||||
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
import std/unittest
|
||||
import ./basics
|
||||
import pkg/nitro/protocol/abi
|
||||
import pkg/nimcrypto
|
||||
import pkg/stew/byteutils
|
||||
import pkg/nitro/protocol/abi
|
||||
import pkg/nitro/protocol/outcome
|
||||
import ./examples
|
||||
|
||||
suite "outcome":
|
||||
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
import std/unittest
|
||||
import ./basics
|
||||
import pkg/nimcrypto
|
||||
import pkg/secp256k1
|
||||
import pkg/stew/byteutils
|
||||
import pkg/nitro/protocol/state
|
||||
import pkg/nitro/protocol/signature
|
||||
import ./examples
|
||||
|
||||
suite "signature":
|
||||
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
import std/unittest
|
||||
import ./basics
|
||||
import pkg/nitro/protocol/abi
|
||||
import pkg/nimcrypto
|
||||
import pkg/stew/byteutils
|
||||
import pkg/nitro/protocol/state
|
||||
import pkg/nitro/protocol/abi
|
||||
import ./examples
|
||||
|
||||
suite "state":
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user