From 577e02b8a25198d6897c1f4871b5fd8e1f859e5a Mon Sep 17 00:00:00 2001 From: Ben Bierens <39762930+benbierens@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:58:54 +0100 Subject: [PATCH] enables stylecheck (#36) * enables stylecheck * applies style check * Applying style check * uses alias to fix ambiguity --- config.nims | 3 +++ ethers/events.nim | 2 +- ethers/providers/jsonrpc.nim | 2 +- ethers/wallet.nim | 10 +++++----- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/config.nims b/config.nims index 7c9db32..e01d099 100644 --- a/config.nims +++ b/config.nims @@ -1,3 +1,6 @@ +--styleCheck:usages +--styleCheck:error + # begin Nimble config (version 1) when fileExists("nimble.paths"): include "nimble.paths" diff --git a/ethers/events.nim b/ethers/events.nim index b3f2d39..1fa7cf0 100644 --- a/ethers/events.nim +++ b/ethers/events.nim @@ -37,7 +37,7 @@ func fitsInIndexedField(T: type): bool {.compileTime.} = solidityType(T) in supportedTypes func decode*[E: Event](_: type E, data: seq[byte], topics: seq[Topic]): ?!E = - var event = ?Abidecoder.decode(data, E) + var event = ?AbiDecoder.decode(data, E) var i = 1 for field in event.fields: if field.hasCustomPragma(indexed): diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index 5627790..942ea2a 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -129,7 +129,7 @@ method call*(provider: JsonRpcProvider, method getGasPrice*(provider: JsonRpcProvider): Future[UInt256] {.async.} = convertError: let client = await provider.client - return await client.eth_gasprice() + return await client.eth_gasPrice() method getTransactionCount*(provider: JsonRpcProvider, address: Address, diff --git a/ethers/wallet.nim b/ethers/wallet.nim index 9cbf774..9b86217 100644 --- a/ethers/wallet.nim +++ b/ethers/wallet.nim @@ -3,7 +3,7 @@ import eth/rlp import eth/common import eth/common/transaction as ct import ./provider -import ./transaction +import ./transaction as tx import ./signer export keys @@ -64,7 +64,7 @@ proc signTransaction(tr: var SignableTransaction, pk: PrivateKey) = let r = toRaw(s) let v = r[64] - tr.R = fromBytesBe(UInt256, r.toOpenArray(0, 31)) + tr.R = fromBytesBE(UInt256, r.toOpenArray(0, 31)) tr.S = fromBytesBE(UInt256, r.toOpenArray(32, 63)) case tr.txType: @@ -76,7 +76,7 @@ proc signTransaction(tr: var SignableTransaction, pk: PrivateKey) = else: raise newException(WalletError, "Transaction type not supported") -proc signTransaction*(wallet: Wallet, tx: transaction.Transaction): Future[seq[byte]] {.async.} = +proc signTransaction*(wallet: Wallet, tx: tx.Transaction): Future[seq[byte]] {.async.} = if sender =? tx.sender and sender != wallet.address: raise newException(WalletError, "from address mismatch") @@ -101,10 +101,10 @@ proc signTransaction*(wallet: Wallet, tx: transaction.Transaction): Future[seq[b s.to = some EthAddress(tx.to) s.payload = tx.data signTransaction(s, wallet.privateKey) - + return rlp.encode(s) -method sendTransaction*(wallet: Wallet, tx: transaction.Transaction): Future[TransactionResponse] {.async.} = +method sendTransaction*(wallet: Wallet, tx: tx.Transaction): Future[TransactionResponse] {.async.} = let rawTX = await signTransaction(wallet, tx) return await provider(wallet).sendTransaction(rawTX)