Adds Signer.getGasPrice()
This commit is contained in:
parent
94dcc171af
commit
54c66db827
|
@ -1,7 +1,9 @@
|
|||
import ./ethers/provider
|
||||
import ./ethers/signer
|
||||
import ./ethers/providers/jsonrpc
|
||||
import ./ethers/contract
|
||||
|
||||
export provider
|
||||
export signer
|
||||
export jsonrpc
|
||||
export contract
|
||||
|
|
|
@ -14,3 +14,6 @@ method getBlockNumber*(provider: Provider): Future[UInt256] {.base.} =
|
|||
|
||||
method call*(provider: Provider, tx: Transaction): Future[seq[byte]] {.base.} =
|
||||
doAssert false, "not implemented"
|
||||
|
||||
method getGasPrice*(provider: Provider): Future[UInt256] {.base.} =
|
||||
doAssert false, "not implemented"
|
||||
|
|
|
@ -64,8 +64,15 @@ method call*(provider: JsonRpcProvider,
|
|||
let client = await provider.client
|
||||
return await client.eth_call(tx)
|
||||
|
||||
method getGasPrice*(provider: JsonRpcProvider): Future[UInt256] {.async.} =
|
||||
let client = await provider.client
|
||||
return await client.eth_gasprice()
|
||||
|
||||
# Signer
|
||||
|
||||
method provider*(signer: JsonRpcSigner): Provider =
|
||||
signer.provider
|
||||
|
||||
method getAddress*(signer: JsonRpcSigner): Future[Address] {.async.} =
|
||||
if address =? signer.address:
|
||||
return address
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
proc eth_accounts: seq[Address]
|
||||
proc eth_blockNumber: UInt256
|
||||
proc eth_call(tx: Transaction): seq[byte]
|
||||
proc eth_gasPrice(): UInt256
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
import ./basics
|
||||
import ./provider
|
||||
|
||||
export basics
|
||||
|
||||
type Signer* = ref object of RootObj
|
||||
|
||||
method getAddress*(signer: Signer): Future[Address] {.base, async.} =
|
||||
method provider*(signer: Signer): Provider {.base.} =
|
||||
doAssert false, "not implemented"
|
||||
|
||||
method getAddress*(signer: Signer): Future[Address] {.base.} =
|
||||
doAssert false, "not implemented"
|
||||
|
||||
method getGasPrice*(signer: Signer): Future[UInt256] {.base.} =
|
||||
signer.provider.getGasPrice()
|
||||
|
|
|
@ -16,3 +16,8 @@ suite "JsonRpcSigner":
|
|||
let account = (await provider.listAccounts())[1]
|
||||
let signer = provider.getSigner(account)
|
||||
check (await signer.getAddress()) == account
|
||||
|
||||
test "can retrieve gas price":
|
||||
let signer = provider.getSigner()
|
||||
let gasprice = await signer.getGasPrice()
|
||||
check gasprice > 0.u256
|
||||
|
|
Loading…
Reference in New Issue