2022-01-18 13:26:41 +00:00
|
|
|
import ./basics
|
2022-01-20 11:56:18 +00:00
|
|
|
import ./transaction
|
2022-01-24 11:14:31 +00:00
|
|
|
import ./blocktag
|
2022-01-18 13:26:41 +00:00
|
|
|
|
|
|
|
export basics
|
2022-01-20 11:56:18 +00:00
|
|
|
export transaction
|
2022-01-24 11:14:31 +00:00
|
|
|
export blocktag
|
2022-01-18 13:26:41 +00:00
|
|
|
|
2022-01-18 13:51:53 +00:00
|
|
|
push: {.upraises: [].}
|
|
|
|
|
2022-01-18 11:10:20 +00:00
|
|
|
type
|
|
|
|
Provider* = ref object of RootObj
|
2022-02-02 15:56:37 +00:00
|
|
|
Subscription* = ref object of RootObj
|
|
|
|
Filter* = object
|
|
|
|
address*: Address
|
|
|
|
topics*: seq[Topic]
|
|
|
|
Log* = object
|
|
|
|
data*: seq[byte]
|
|
|
|
topics*: seq[Topic]
|
2022-05-17 02:34:22 +00:00
|
|
|
TransactionHash* = array[32, byte]
|
|
|
|
BlockHash* = array[32, byte]
|
|
|
|
TransactionStatus* = enum
|
|
|
|
Failure = 0,
|
|
|
|
Success = 1,
|
|
|
|
Invalid = 2
|
|
|
|
TransactionResponse* = object
|
|
|
|
provider*: Provider
|
|
|
|
hash*: TransactionHash
|
|
|
|
TransactionReceipt* = object
|
|
|
|
sender*: ?Address
|
|
|
|
to*: ?Address
|
|
|
|
contractAddress*: ?Address
|
|
|
|
transactionIndex*: UInt256
|
|
|
|
gasUsed*: UInt256
|
|
|
|
logsBloom*: seq[byte]
|
|
|
|
blockHash*: BlockHash
|
|
|
|
transactionHash*: TransactionHash
|
|
|
|
logs*: seq[Log]
|
|
|
|
blockNumber*: ?UInt256
|
|
|
|
cumulativeGasUsed*: UInt256
|
|
|
|
status*: TransactionStatus
|
2022-02-02 15:56:37 +00:00
|
|
|
LogHandler* = proc(log: Log) {.gcsafe, upraises:[].}
|
2022-05-16 12:51:39 +00:00
|
|
|
BlockHandler* = proc(blck: Block) {.gcsafe, upraises:[].}
|
2022-02-02 15:56:37 +00:00
|
|
|
Topic* = array[32, byte]
|
2022-03-16 13:02:44 +00:00
|
|
|
Block* = object
|
|
|
|
number*: UInt256
|
|
|
|
timestamp*: UInt256
|
|
|
|
hash*: array[32, byte]
|
2022-01-18 13:26:41 +00:00
|
|
|
|
2022-05-17 02:34:22 +00:00
|
|
|
const DEFAULT_CONFIRMATIONS* {.intdefine.} = 12
|
feat: Allow contract transactions to be waited on
Allow waiting for a specified number of confirmations for contract transactions.
This change only requires an optional TransactionResponse return type to be added to the contract function. This allows the transaction hash to be passed to `.wait`.
For example, previously the `mint` method looked like this without a return value:
```
method mint(token: TestToken, holder: Address, amount: UInt256) {.base, contract.}
```
it still works without a return value, but if we want to wait for a 3 confirmations, we can now define it like this:
```
method mint(token: TestToken, holder: Address, amount: UInt256): ?TransactionResponse {.base, contract.}
```
and use like this:
```
let receipt = await token.connect(signer0)
.mint(accounts[1], 100.u256)
.wait(3) # wait for 3 confirmations
```
2022-05-17 04:57:18 +00:00
|
|
|
const RECEIPT_TIMEOUT_BLKS* {.intdefine.} = 50 # in blocks
|
|
|
|
const RECEIPT_POLLING_INTERVAL* {.intdefine.} = 1 # in seconds
|
2022-05-17 02:34:22 +00:00
|
|
|
|
2022-01-18 13:26:41 +00:00
|
|
|
method getBlockNumber*(provider: Provider): Future[UInt256] {.base.} =
|
|
|
|
doAssert false, "not implemented"
|
2022-03-16 13:02:44 +00:00
|
|
|
|
2022-03-17 09:16:13 +00:00
|
|
|
method getBlock*(provider: Provider, tag: BlockTag): Future[?Block] {.base.} =
|
2022-03-16 13:02:44 +00:00
|
|
|
doAssert false, "not implemented"
|
2022-01-20 11:56:18 +00:00
|
|
|
|
2022-04-10 20:21:59 +00:00
|
|
|
method call*(provider: Provider,
|
|
|
|
tx: Transaction,
|
|
|
|
blockTag = BlockTag.latest): Future[seq[byte]] {.base.} =
|
2022-01-20 11:56:18 +00:00
|
|
|
doAssert false, "not implemented"
|
2022-01-24 11:12:52 +00:00
|
|
|
|
|
|
|
method getGasPrice*(provider: Provider): Future[UInt256] {.base.} =
|
|
|
|
doAssert false, "not implemented"
|
2022-01-24 11:14:31 +00:00
|
|
|
|
|
|
|
method getTransactionCount*(provider: Provider,
|
|
|
|
address: Address,
|
|
|
|
blockTag = BlockTag.latest):
|
|
|
|
Future[UInt256] {.base.} =
|
|
|
|
doAssert false, "not implemented"
|
2022-01-24 13:40:47 +00:00
|
|
|
|
|
|
|
method estimateGas*(provider: Provider,
|
|
|
|
transaction: Transaction): Future[UInt256] {.base.} =
|
|
|
|
doAssert false, "not implemented"
|
2022-01-24 16:29:25 +00:00
|
|
|
|
|
|
|
method getChainId*(provider: Provider): Future[UInt256] {.base.} =
|
|
|
|
doAssert false, "not implemented"
|
2022-02-02 15:56:37 +00:00
|
|
|
|
|
|
|
method subscribe*(provider: Provider,
|
|
|
|
filter: Filter,
|
|
|
|
callback: LogHandler):
|
|
|
|
Future[Subscription] {.base.} =
|
|
|
|
doAssert false, "not implemented"
|
|
|
|
|
2022-05-16 12:51:39 +00:00
|
|
|
method subscribe*(provider: Provider,
|
|
|
|
callback: BlockHandler):
|
|
|
|
Future[Subscription] {.base.} =
|
|
|
|
doAssert false, "not implemented"
|
|
|
|
|
2022-02-02 15:56:37 +00:00
|
|
|
method unsubscribe*(subscription: Subscription) {.base, async.} =
|
|
|
|
doAssert false, "not implemented"
|