mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-01-02 13:43:06 +00:00
chore: bump eth (#124)
* recycle common transaction signature helpers * bump versions
This commit is contained in:
parent
30871c7b1d
commit
965b8cd752
@ -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"
|
||||
|
||||
@ -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] =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user