fix: pinning nim-eth dependency (#77)
Co-authored-by: Eric <5089238+emizzle@users.noreply.github.com>
This commit is contained in:
parent
e15974eb1f
commit
53e596e75a
|
@ -7,7 +7,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
nim: [1.6.16, stable]
|
nim: [1.6.20, stable]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
|
@ -4,3 +4,4 @@
|
||||||
nimble.develop
|
nimble.develop
|
||||||
nimble.paths
|
nimble.paths
|
||||||
.idea
|
.idea
|
||||||
|
.nimble
|
||||||
|
|
|
@ -12,7 +12,7 @@ requires "json_rpc >= 0.4.0 & < 0.5.0"
|
||||||
requires "serde >= 1.2.1 & < 1.3.0"
|
requires "serde >= 1.2.1 & < 1.3.0"
|
||||||
requires "stint"
|
requires "stint"
|
||||||
requires "stew"
|
requires "stew"
|
||||||
requires "eth"
|
requires "eth#c482b4c5b658a77cc96b49d4a397aa6d98472ac7"
|
||||||
|
|
||||||
task test, "Run the test suite":
|
task test, "Run the test suite":
|
||||||
exec "nimble install -d -y"
|
exec "nimble install -d -y"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import std/strformat
|
import std/strformat
|
||||||
import std/strutils
|
import std/strutils
|
||||||
import pkg/chronicles except fromJson, `%`, `%*`, toJson
|
import pkg/chronicles except fromJson, `%`, `%*`, toJson
|
||||||
import pkg/json_rpc/jsonmarshal
|
import pkg/json_rpc/jsonmarshal except toJson
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
import pkg/serde
|
import pkg/serde
|
||||||
import pkg/stew/byteutils
|
import pkg/stew/byteutils
|
||||||
|
@ -10,7 +10,7 @@ import ../../transaction
|
||||||
import ../../blocktag
|
import ../../blocktag
|
||||||
import ../../provider
|
import ../../provider
|
||||||
|
|
||||||
export jsonmarshal
|
export jsonmarshal except toJson
|
||||||
export serde
|
export serde
|
||||||
export chronicles except fromJson, `%`, `%*`, toJson
|
export chronicles except fromJson, `%`, `%*`, toJson
|
||||||
|
|
||||||
|
@ -90,12 +90,13 @@ func fromJson*(_: type BlockTag, json: JsonNode): ?!BlockTag =
|
||||||
"' to BlockTag: must be one of 'earliest', 'latest', 'pending'")
|
"' to BlockTag: must be one of 'earliest', 'latest', 'pending'")
|
||||||
|
|
||||||
# TransactionStatus | TransactionType
|
# TransactionStatus | TransactionType
|
||||||
|
type TransactionEnums = TransactionStatus | TransactionType
|
||||||
|
|
||||||
func `%`*(e: TransactionStatus | TransactionType): JsonNode =
|
func `%`*(e: TransactionEnums): JsonNode =
|
||||||
% ("0x" & e.int8.toHex(1))
|
% ("0x" & e.int8.toHex(1))
|
||||||
|
|
||||||
proc fromJson*[E: TransactionStatus | TransactionType](
|
proc fromJson*(
|
||||||
T: type E,
|
T: type TransactionEnums,
|
||||||
json: JsonNode
|
json: JsonNode
|
||||||
): ?!T =
|
): ?!T =
|
||||||
expectJsonKind(string, JString, json)
|
expectJsonKind(string, JString, json)
|
||||||
|
|
|
@ -40,7 +40,7 @@ suite "JSON Conversions":
|
||||||
}
|
}
|
||||||
|
|
||||||
without blk =? Block.fromJson(blkJson["result"]):
|
without blk =? Block.fromJson(blkJson["result"]):
|
||||||
fail
|
unittest.fail
|
||||||
check blk.hash.isNone
|
check blk.hash.isNone
|
||||||
|
|
||||||
test "missing block number in TransactionReceipt isNone":
|
test "missing block number in TransactionReceipt isNone":
|
||||||
|
@ -71,12 +71,12 @@ suite "JSON Conversions":
|
||||||
}
|
}
|
||||||
|
|
||||||
without receipt1 =? TransactionReceipt.fromJson(json):
|
without receipt1 =? TransactionReceipt.fromJson(json):
|
||||||
fail
|
unittest.fail
|
||||||
check receipt1.blockNumber.isNone
|
check receipt1.blockNumber.isNone
|
||||||
|
|
||||||
json["blockNumber"] = newJString("")
|
json["blockNumber"] = newJString("")
|
||||||
without receipt2 =? TransactionReceipt.fromJson(json):
|
without receipt2 =? TransactionReceipt.fromJson(json):
|
||||||
fail
|
unittest.fail
|
||||||
check receipt2.blockNumber.isNone
|
check receipt2.blockNumber.isNone
|
||||||
|
|
||||||
test "missing block hash in TransactionReceipt isNone":
|
test "missing block hash in TransactionReceipt isNone":
|
||||||
|
@ -107,7 +107,7 @@ suite "JSON Conversions":
|
||||||
}
|
}
|
||||||
|
|
||||||
without receipt =? TransactionReceipt.fromJson(json):
|
without receipt =? TransactionReceipt.fromJson(json):
|
||||||
fail
|
unittest.fail
|
||||||
check receipt.blockHash.isNone
|
check receipt.blockHash.isNone
|
||||||
|
|
||||||
test "correctly deserializes PastTransaction":
|
test "correctly deserializes PastTransaction":
|
||||||
|
@ -131,7 +131,7 @@ suite "JSON Conversions":
|
||||||
}
|
}
|
||||||
|
|
||||||
without tx =? PastTransaction.fromJson(json):
|
without tx =? PastTransaction.fromJson(json):
|
||||||
fail
|
unittest.fail
|
||||||
check tx.blockHash == BlockHash.fromHex("0x595bffbe897e025ea2df3213c4cc52c3f3d69bc04b49011d558f1b0e70038922")
|
check tx.blockHash == BlockHash.fromHex("0x595bffbe897e025ea2df3213c4cc52c3f3d69bc04b49011d558f1b0e70038922")
|
||||||
check tx.blockNumber == 0x22e.u256
|
check tx.blockNumber == 0x22e.u256
|
||||||
check tx.sender == Address.init("0xe00b677c29ff8d8fe6068530e2bc36158c54dd34").get
|
check tx.sender == Address.init("0xe00b677c29ff8d8fe6068530e2bc36158c54dd34").get
|
||||||
|
@ -210,7 +210,7 @@ suite "JSON Conversions":
|
||||||
}
|
}
|
||||||
|
|
||||||
without past =? PastTransaction.fromJson(json):
|
without past =? PastTransaction.fromJson(json):
|
||||||
fail
|
unittest.fail
|
||||||
check %past.toTransaction == %*{
|
check %past.toTransaction == %*{
|
||||||
"to": !Address.init("0x92f09aa59dccb892a9f5406ddd9c0b98f02ea57e"),
|
"to": !Address.init("0x92f09aa59dccb892a9f5406ddd9c0b98f02ea57e"),
|
||||||
"data": hexToSeqByte("0x6368a471d26ff5c7f835c1a8203235e88846ce1a196d6e79df0eaedd1b8ed3deec2ae5c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000012a00000000000000000000000000000000000000000000000000000000000000"),
|
"data": hexToSeqByte("0x6368a471d26ff5c7f835c1a8203235e88846ce1a196d6e79df0eaedd1b8ed3deec2ae5c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000012a00000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
@ -232,3 +232,23 @@ suite "JSON Conversions":
|
||||||
let res = BlockTag.fromJson(newJString(""))
|
let res = BlockTag.fromJson(newJString(""))
|
||||||
check res.error of SerializationError
|
check res.error of SerializationError
|
||||||
check res.error.msg == "Failed to convert '\"\"' to BlockTag: must be one of 'earliest', 'latest', 'pending'"
|
check res.error.msg == "Failed to convert '\"\"' to BlockTag: must be one of 'earliest', 'latest', 'pending'"
|
||||||
|
|
||||||
|
test "correctly deserializes TransactionType":
|
||||||
|
check !TransactionType.fromJson(newJString("0x0")) == TransactionType.Legacy
|
||||||
|
check !TransactionType.fromJson(newJString("0x1")) == TransactionType.AccessList
|
||||||
|
check !TransactionType.fromJson(newJString("0x2")) == TransactionType.Dynamic
|
||||||
|
|
||||||
|
test "correctly serializes TransactionType":
|
||||||
|
check TransactionType.Legacy.toJson == "\"0x0\""
|
||||||
|
check TransactionType.AccessList.toJson == "\"0x1\""
|
||||||
|
check TransactionType.Dynamic.toJson == "\"0x2\""
|
||||||
|
|
||||||
|
test "correctly deserializes TransactionStatus":
|
||||||
|
check !TransactionStatus.fromJson(newJString("0x0")) == TransactionStatus.Failure
|
||||||
|
check !TransactionStatus.fromJson(newJString("0x1")) == TransactionStatus.Success
|
||||||
|
check !TransactionStatus.fromJson(newJString("0x2")) == TransactionStatus.Invalid
|
||||||
|
|
||||||
|
test "correctly serializes TransactionStatus":
|
||||||
|
check TransactionStatus.Failure.toJson == "\"0x0\""
|
||||||
|
check TransactionStatus.Success.toJson == "\"0x1\""
|
||||||
|
check TransactionStatus.Invalid.toJson == "\"0x2\""
|
||||||
|
|
Loading…
Reference in New Issue