Skip to content

Commit f03c788

Browse files
committed
chore: bump eth
* recycle common transaction signature helpers * bump versions
1 parent 30871c7 commit f03c788

2 files changed

Lines changed: 6 additions & 19 deletions

File tree

ethers.nimble

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
version = "2.0.0"
1+
version = "2.1.0"
22
author = "Nim Ethers Authors"
33
description = "library for interacting with Ethereum"
44
license = "MIT"
55

66
requires "nim >= 2.0.14"
7-
requires "chronicles >= 0.10.3 & < 0.11.0"
7+
requires "chronicles >= 0.10.3 & < 0.13.0"
88
requires "chronos >= 4.0.4 & < 4.1.0"
99
requires "contractabi >= 0.7.2 & < 0.8.0"
1010
requires "questionable >= 0.10.2 & < 0.11.0"
1111
requires "json_rpc >= 0.5.0 & < 0.6.0"
1212
requires "serde >= 1.2.1 & < 1.3.0"
1313
requires "stint >= 0.8.1 & < 0.9.0"
1414
requires "stew >= 0.2.0"
15-
requires "eth >= 0.5.0 & < 0.6.0"
15+
requires "eth >= 0.6.0 & < 0.10.0"
1616

1717
task test, "Run the test suite":
1818
# exec "nimble install -d -y"

ethers/signers/wallet/signing.nim

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pkg/eth/keys
22
import pkg/eth/rlp
33
import pkg/eth/common/transaction as eth
4+
import pkg/eth/common/transaction_utils
45
import pkg/eth/common/eth_hash
56
import ../../basics
67
import ../../transaction as ethers
@@ -25,7 +26,7 @@ func toSignableTransaction(transaction: Transaction): SignableTransaction =
2526
raiseWalletError "missing gas limit"
2627

2728
signable.nonce = nonce.truncate(uint64)
28-
signable.chainId = ChainId(chainId.truncate(uint64))
29+
signable.chainId = chainId
2930
signable.gasLimit = GasInt(gasLimit.truncate(uint64))
3031

3132
signable.to = Opt.some(EthAddress(transaction.to))
@@ -47,21 +48,7 @@ func toSignableTransaction(transaction: Transaction): SignableTransaction =
4748

4849
func sign(key: PrivateKey, transaction: SignableTransaction): seq[byte] =
4950
var transaction = transaction
50-
51-
# Temporary V value, used to signal to the hashing function
52-
# that we'd like to use an EIP-155 signature
53-
transaction.V = uint64(transaction.chainId) * 2 + 35
54-
55-
let hash = transaction.txHashNoSignature().data
56-
let signature = key.sign(SkMessage(hash)).toRaw()
57-
58-
transaction.R = UInt256.fromBytesBE(signature[0..<32])
59-
transaction.S = UInt256.fromBytesBE(signature[32..<64])
60-
transaction.V = uint64(signature[64])
61-
62-
if transaction.txType == TxLegacy:
63-
transaction.V += uint64(transaction.chainId) * 2 + 35
64-
51+
transaction.signature = transaction.sign(key, true)
6552
rlp.encode(transaction)
6653

6754
func sign*(key: PrivateKey, transaction: Transaction): seq[byte] =

0 commit comments

Comments
 (0)