chore: bump eth (#124)

* recycle common transaction signature helpers
* bump versions
This commit is contained in:
Jacek Sieka 2025-12-13 07:32:36 +01:00 committed by GitHub
parent 30871c7b1d
commit 965b8cd752
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 19 deletions

View File

@ -1,10 +1,10 @@
version = "2.0.0"
version = "2.1.0"
author = "Nim Ethers Authors"
description = "library for interacting with Ethereum"
license = "MIT"
requires "nim >= 2.0.14"
requires "chronicles >= 0.10.3 & < 0.11.0"
requires "chronicles >= 0.10.3 & < 0.13.0"
requires "chronos >= 4.0.4 & < 4.1.0"
requires "contractabi >= 0.7.2 & < 0.8.0"
requires "questionable >= 0.10.2 & < 0.11.0"
@ -12,7 +12,7 @@ requires "json_rpc >= 0.5.0 & < 0.6.0"
requires "serde >= 1.2.1 & < 1.3.0"
requires "stint >= 0.8.1 & < 0.9.0"
requires "stew >= 0.2.0"
requires "eth >= 0.5.0 & < 0.6.0"
requires "eth >= 0.6.0 & < 0.10.0"
task test, "Run the test suite":
# exec "nimble install -d -y"

View File

@ -1,6 +1,7 @@
import pkg/eth/keys
import pkg/eth/rlp
import pkg/eth/common/transaction as eth
import pkg/eth/common/transaction_utils
import pkg/eth/common/eth_hash
import ../../basics
import ../../transaction as ethers
@ -25,7 +26,7 @@ func toSignableTransaction(transaction: Transaction): SignableTransaction =
raiseWalletError "missing gas limit"
signable.nonce = nonce.truncate(uint64)
signable.chainId = ChainId(chainId.truncate(uint64))
signable.chainId = chainId
signable.gasLimit = GasInt(gasLimit.truncate(uint64))
signable.to = Opt.some(EthAddress(transaction.to))
@ -47,21 +48,7 @@ func toSignableTransaction(transaction: Transaction): SignableTransaction =
func sign(key: PrivateKey, transaction: SignableTransaction): seq[byte] =
var transaction = transaction
# Temporary V value, used to signal to the hashing function
# that we'd like to use an EIP-155 signature
transaction.V = uint64(transaction.chainId) * 2 + 35
let hash = transaction.txHashNoSignature().data
let signature = key.sign(SkMessage(hash)).toRaw()
transaction.R = UInt256.fromBytesBE(signature[0..<32])
transaction.S = UInt256.fromBytesBE(signature[32..<64])
transaction.V = uint64(signature[64])
if transaction.txType == TxLegacy:
transaction.V += uint64(transaction.chainId) * 2 + 35
transaction.signature = transaction.sign(key, true)
rlp.encode(transaction)
func sign*(key: PrivateKey, transaction: Transaction): seq[byte] =