mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-03 14:13:09 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ccdeb46e0 | ||
|
|
fdcea5a2aa | ||
|
|
86d5601b4b | ||
|
|
a15660f70f | ||
|
|
309431a482 | ||
|
|
1e7358c7c4 | ||
|
|
f924a32458 | ||
|
|
f3879ed666 | ||
|
|
9cbecdde20 | ||
|
|
e3719433d5 | ||
|
|
89052f638d | ||
|
|
c13aba9942 | ||
|
|
991d56f7d1 | ||
|
|
7047da19b1 |
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@ -8,12 +8,15 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||||
nim: [stable, 1.2.6]
|
nim: [stable, 2.0.14]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v6
|
||||||
- uses: iffy/install-nim@v3
|
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.nim }}
|
submodules: recursive
|
||||||
|
- uses: jiro4989/setup-nim-action@v2
|
||||||
|
with:
|
||||||
|
nim-version: ${{matrix.nim}}
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build
|
- name: Build
|
||||||
run: nimble install -y
|
run: nimble install -y
|
||||||
- name: Test
|
- name: Test
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
|||||||
*
|
*
|
||||||
!*/
|
!*/
|
||||||
!*.*
|
!*.*
|
||||||
|
nimble.develop
|
||||||
|
nimble.paths
|
||||||
|
nimbledeps
|
||||||
|
|||||||
@ -10,3 +10,11 @@ References
|
|||||||
- [statechannels.org](https://statechannels.org/)
|
- [statechannels.org](https://statechannels.org/)
|
||||||
- [Nitro paper](https://magmo.com/nitro-protocol.pdf)
|
- [Nitro paper](https://magmo.com/nitro-protocol.pdf)
|
||||||
- [Nitro smart contracts & Javascript code](https://github.com/statechannels/statechannels/tree/master/packages/nitro-protocol)
|
- [Nitro smart contracts & Javascript code](https://github.com/statechannels/statechannels/tree/master/packages/nitro-protocol)
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
To avoid conflicts with previous versions of `contractabi`, use the following command to install dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nimble install --maximumtaggedversions=2
|
||||||
|
```
|
||||||
5
config.nims
Normal file
5
config.nims
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# begin Nimble config (version 2)
|
||||||
|
--noNimblePath
|
||||||
|
when withDir(thisDir(), system.fileExists("nimble.paths")):
|
||||||
|
include "nimble.paths"
|
||||||
|
# end Nimble config
|
||||||
101
nimble.lock
Normal file
101
nimble.lock
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"packages": {
|
||||||
|
"results": {
|
||||||
|
"version": "0.5.1",
|
||||||
|
"vcsRevision": "df8113dda4c2d74d460a8fa98252b0b771bf1f27",
|
||||||
|
"url": "https://github.com/arnetheduck/nim-results",
|
||||||
|
"downloadMethod": "git",
|
||||||
|
"dependencies": [],
|
||||||
|
"checksums": {
|
||||||
|
"sha1": "a9c011f74bc9ed5c91103917b9f382b12e82a9e7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unittest2": {
|
||||||
|
"version": "0.2.5",
|
||||||
|
"vcsRevision": "26f2ef3ae0ec72a2a75bfe557e02e88f6a31c189",
|
||||||
|
"url": "https://github.com/status-im/nim-unittest2",
|
||||||
|
"downloadMethod": "git",
|
||||||
|
"dependencies": [],
|
||||||
|
"checksums": {
|
||||||
|
"sha1": "02bb3751ba9ddc3c17bfd89f2e41cb6bfb8fc0c9"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"stew": {
|
||||||
|
"version": "0.4.2",
|
||||||
|
"vcsRevision": "b66168735d6f3841c5239c3169d3fe5fe98b1257",
|
||||||
|
"url": "https://github.com/status-im/nim-stew",
|
||||||
|
"downloadMethod": "git",
|
||||||
|
"dependencies": [
|
||||||
|
"results",
|
||||||
|
"unittest2"
|
||||||
|
],
|
||||||
|
"checksums": {
|
||||||
|
"sha1": "928e82cb8d2f554e8f10feb2349ee9c32fee3a8c"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"stint": {
|
||||||
|
"version": "0.8.2",
|
||||||
|
"vcsRevision": "470b7892561b5179ab20bd389a69217d6213fe58",
|
||||||
|
"url": "https://github.com/status-im/nim-stint",
|
||||||
|
"downloadMethod": "git",
|
||||||
|
"dependencies": [
|
||||||
|
"stew",
|
||||||
|
"unittest2"
|
||||||
|
],
|
||||||
|
"checksums": {
|
||||||
|
"sha1": "d8f871fd617e7857192d4609fe003b48942a8ae5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nimcrypto": {
|
||||||
|
"version": "0.6.4",
|
||||||
|
"vcsRevision": "721fb99ee099b632eb86dfad1f0d96ee87583774",
|
||||||
|
"url": "https://github.com/cheatfate/nimcrypto",
|
||||||
|
"downloadMethod": "git",
|
||||||
|
"dependencies": [],
|
||||||
|
"checksums": {
|
||||||
|
"sha1": "f9ab24fa940ed03d0fb09729a7303feb50b7eaec"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"questionable": {
|
||||||
|
"version": "0.10.15",
|
||||||
|
"vcsRevision": "82d90b67bcfb7f2e918b61dace2ff1a4ced60935",
|
||||||
|
"url": "https://github.com/codex-storage/questionable",
|
||||||
|
"downloadMethod": "git",
|
||||||
|
"dependencies": [],
|
||||||
|
"checksums": {
|
||||||
|
"sha1": "3238ff637c7b44d2fa8fcb839a8ded968e389de3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contractabi": {
|
||||||
|
"version": "0.7.3",
|
||||||
|
"vcsRevision": "0a7b4cecce725bcb11ad8648035a92704a8854d3",
|
||||||
|
"url": "https://github.com/status-im/nim-contract-abi",
|
||||||
|
"downloadMethod": "git",
|
||||||
|
"dependencies": [
|
||||||
|
"stint",
|
||||||
|
"stew",
|
||||||
|
"nimcrypto",
|
||||||
|
"questionable"
|
||||||
|
],
|
||||||
|
"checksums": {
|
||||||
|
"sha1": "1bb9af15f02a77b44af02ec94b0e392b1ec88438"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"secp256k1": {
|
||||||
|
"version": "0.6.0.3.2",
|
||||||
|
"vcsRevision": "b526c4b436809aa1cfe650026d796cf7b8328b91",
|
||||||
|
"url": "https://github.com/status-im/nim-secp256k1",
|
||||||
|
"downloadMethod": "git",
|
||||||
|
"dependencies": [
|
||||||
|
"stew",
|
||||||
|
"results",
|
||||||
|
"nimcrypto"
|
||||||
|
],
|
||||||
|
"checksums": {
|
||||||
|
"sha1": "e6e50bd4a29cb473b070eb5359d87d8946d96075"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tasks": {}
|
||||||
|
}
|
||||||
17
nitro.nimble
17
nitro.nimble
@ -1,13 +1,12 @@
|
|||||||
version = "0.5.1"
|
version = "0.6.1"
|
||||||
author = "Nim Nitro developers"
|
author = "Nim Nitro developers"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "Nitro state channels"
|
description = "Nitro state channels"
|
||||||
|
|
||||||
requires "nim >= 1.2.6 & < 2.0.0"
|
requires "nim >= 2.0.14 & < 3.0.0"
|
||||||
requires "nimcrypto >= 0.5.4 & < 0.6.0"
|
requires "nimcrypto >= 0.6.0 & < 0.7.0"
|
||||||
requires "questionable >= 0.10.1 & < 0.11.0"
|
requires "questionable >= 0.10.10 & < 0.11.0"
|
||||||
requires "upraises >= 0.1.0 & < 0.2.0"
|
requires "contractabi >= 0.7.1 & < 0.8.0"
|
||||||
requires "contractabi >= 0.4.1 & < 0.5.0"
|
requires "secp256k1 >= 0.6.0 & < 0.7.0"
|
||||||
requires "secp256k1"
|
requires "stint >= 0.8.0 & < 0.9.0"
|
||||||
requires "stint"
|
requires "stew >= 0.2.0"
|
||||||
requires "stew"
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
import pkg/upraises
|
|
||||||
import pkg/stint
|
import pkg/stint
|
||||||
import ./basics/uint48
|
import ./basics/uint48
|
||||||
import ./basics/ethaddress
|
import ./basics/ethaddress
|
||||||
@ -8,7 +7,6 @@ import ./basics/destination
|
|||||||
|
|
||||||
export questionable
|
export questionable
|
||||||
export results
|
export results
|
||||||
export upraises
|
|
||||||
export stint
|
export stint
|
||||||
export uint48
|
export uint48
|
||||||
export ethaddress
|
export ethaddress
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import std/hashes
|
import std/hashes
|
||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
import pkg/upraises
|
|
||||||
import pkg/stew/byteutils
|
import pkg/stew/byteutils
|
||||||
import ./ethaddress
|
import ./ethaddress
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
type Destination* = distinct array[32, byte]
|
type Destination* = distinct array[32, byte]
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import ./wallet/signedstate
|
|||||||
|
|
||||||
export signedstate
|
export signedstate
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
func `%`(value: Outcome | Allocation): JsonNode =
|
func `%`(value: Outcome | Allocation): JsonNode =
|
||||||
type Base = distinctBase(typeof value)
|
type Base = distinctBase(typeof value)
|
||||||
@ -37,7 +37,7 @@ func toJson*(payment: SignedState): string =
|
|||||||
|
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
push: {.upraises: [ValueError].}
|
{.push raises: [ValueError].}
|
||||||
|
|
||||||
func expectKind(node: JsonNode, kind: JsonNodeKind) =
|
func expectKind(node: JsonNode, kind: JsonNodeKind) =
|
||||||
if node.kind != kind:
|
if node.kind != kind:
|
||||||
@ -74,7 +74,7 @@ func initFromJson*(signature: var Signature, node: JsonNode, _: var string) =
|
|||||||
|
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
push: {.upraises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
proc fromJson*(_: type SignedState, json: string): ?SignedState =
|
proc fromJson*(_: type SignedState, json: string): ?SignedState =
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import ./basics
|
|||||||
export basics
|
export basics
|
||||||
export toPublicKey
|
export toPublicKey
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
type
|
type
|
||||||
EthPrivateKey* = SkSecretKey
|
EthPrivateKey* = SkSecretKey
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import pkg/contractabi
|
import pkg/contractabi
|
||||||
import ../basics
|
import ../basics
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
export basics
|
export basics
|
||||||
export contractabi
|
export contractabi
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import pkg/nimcrypto
|
|||||||
import ../basics
|
import ../basics
|
||||||
import ./abi
|
import ./abi
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
export basics
|
export basics
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import pkg/nimcrypto
|
|||||||
import ../basics
|
import ../basics
|
||||||
import ./abi
|
import ./abi
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
export basics
|
export basics
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import pkg/secp256k1
|
import pkg/secp256k1
|
||||||
import pkg/nimcrypto
|
import pkg/nimcrypto/keccak
|
||||||
import pkg/stew/byteutils
|
import pkg/stew/byteutils
|
||||||
import ../basics
|
import ../basics
|
||||||
import ../keys
|
import ../keys
|
||||||
import ./state
|
import ./state
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
export basics
|
export basics
|
||||||
export keys
|
export keys
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import ./channel
|
|||||||
import ./outcome
|
import ./outcome
|
||||||
import ./abi
|
import ./abi
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
export basics
|
export basics
|
||||||
export channel
|
export channel
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import std/sequtils
|
|||||||
import ../basics
|
import ../basics
|
||||||
import ../protocol
|
import ../protocol
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
export tables
|
export tables
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import std/sets
|
|||||||
import std/hashes
|
import std/hashes
|
||||||
import ../basics
|
import ../basics
|
||||||
|
|
||||||
push: {.upraises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
type
|
type
|
||||||
Nonces* = object
|
Nonces* = object
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import ../basics
|
import ../basics
|
||||||
import ../protocol
|
import ../protocol
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
type
|
type
|
||||||
SignedState* = object
|
SignedState* = object
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import ./balances
|
|||||||
import ./nonces
|
import ./nonces
|
||||||
import ./deref
|
import ./deref
|
||||||
|
|
||||||
push: {.upraises:[].}
|
{.push raises: [].}
|
||||||
|
|
||||||
export basics
|
export basics
|
||||||
export keys
|
export keys
|
||||||
|
|||||||
@ -19,10 +19,10 @@ proc example*[T](_: type seq[T], len = 0..5): seq[T] =
|
|||||||
newSeqWith(chosenlen, T.example)
|
newSeqWith(chosenlen, T.example)
|
||||||
|
|
||||||
proc example*(_: type UInt256): UInt256 =
|
proc example*(_: type UInt256): UInt256 =
|
||||||
UInt256.fromBytes(array[32, byte].example)
|
UInt256.fromBytesBE(array[32, byte].example)
|
||||||
|
|
||||||
proc example*(_: type UInt128): UInt128 =
|
proc example*(_: type UInt128): UInt128 =
|
||||||
UInt128.fromBytes(array[16, byte].example)
|
UInt128.fromBytesBE(array[16, byte].example)
|
||||||
|
|
||||||
proc example*(_: type EthAddress): EthAddress =
|
proc example*(_: type EthAddress): EthAddress =
|
||||||
EthAddress(array[20, byte].example)
|
EthAddress(array[20, byte].example)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import pkg/nitro/wallet/nonces
|
|||||||
suite "nonces":
|
suite "nonces":
|
||||||
|
|
||||||
let chainId = UInt256.example
|
let chainId = UInt256.example
|
||||||
let participants = seq[EthAddress].example
|
let participants = seq[EthAddress].example(1..5)
|
||||||
|
|
||||||
var nonces: Nonces
|
var nonces: Nonces
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ suite "nonces":
|
|||||||
check nonces.getNonce(chainId, participants) == 102
|
check nonces.getNonce(chainId, participants) == 102
|
||||||
|
|
||||||
test "nonces are different when participants differ":
|
test "nonces are different when participants differ":
|
||||||
let otherParticipants = seq[EthAddress].example
|
let otherParticipants = seq[EthAddress].example(1..5)
|
||||||
nonces.incNonce(0, chainId, participants)
|
nonces.incNonce(0, chainId, participants)
|
||||||
check nonces.getNonce(chainId, otherParticipants) == 0
|
check nonces.getNonce(chainId, otherParticipants) == 0
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user