From f03c788d1dccc417bc4d82dc5f63528f6e21e0ca Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Fri, 12 Dec 2025 18:32:19 +0100 Subject: [PATCH] chore: bump eth * recycle common transaction signature helpers * bump versions --- ethers.nimble | 6 +++--- ethers/signers/wallet/signing.nim | 19 +++---------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/ethers.nimble b/ethers.nimble index d1489f8..6879ce2 100644 --- a/ethers.nimble +++ b/ethers.nimble @@ -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" diff --git a/ethers/signers/wallet/signing.nim b/ethers/signers/wallet/signing.nim index 7a05146..9226695 100644 --- a/ethers/signers/wallet/signing.nim +++ b/ethers/signers/wallet/signing.nim @@ -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] =