9 Commits

Author SHA1 Message Date
Eric Mastro
c5c9534876 Refactor based on PR comments
- `TransactionReceipt.blockHash` is optional
- Block.number is optional (in case node doesn’t return this in the event)
- Refactor confirmations waiting such that there is no polling for a receipt at the start
- Make BlockHandler and SubscriptionHandler async
- change casing of constants
- change return type checking of contract method to check for `Confirmable` instead of `?TransactionRepsonse`
- Reduce miner sleep to 10ms
- Change `wait` and `Waitable` to `confirm` and `Confirmable` to avoid conflict with chrono’s `.wait`.
- Update params on `.confirm` so that the compiler can restrict values of the `int` to `Positive` and `Natural`.
- Add `Block` and `TransactionReceipt` conversion tests to test for missing block number and block hash.
- Add tests for confirmation calculations and determining if a tx has been mined from its receipt.
- Assume that blockNumber returned from node will be null or empty string, in which case we can parse as 0 and test for that condition.
2022-05-23 11:27:26 +10:00
Eric Mastro
a3e888128c 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-23 11:27:26 +10:00
Mark Spanbroek
ff5a35aac0 Define and subscribe to solidity events 2022-02-09 14:50:51 +01:00
Mark Spanbroek
9eee20e49d Add Contract.connect() 2022-01-26 12:23:30 +01:00
Mark Spanbroek
e833c08303 Additional tests for contract macro 2022-01-26 10:38:17 +01:00
Mark Spanbroek
e4224a1241 Allow calls to non-constant functions 2022-01-25 17:29:01 +01:00
Mark Spanbroek
b639e367c0 Reset EVM in between tests 2022-01-25 15:08:35 +01:00
Mark Spanbroek
2140084d97 Allow contract procs to be exported 2022-01-20 14:00:28 +01:00
Mark Spanbroek
04ff046553 Introduce Contract abstraction 2022-01-20 12:56:18 +01:00