Commit Graph

48 Commits

Author SHA1 Message Date
Mark Spanbroek c72cdc5573 [wallet] cleanup 2022-08-08 15:07:41 +02:00
Mark Spanbroek 0483e1676a [provider] Rename sendRawTransaction -> sendTransaction
To be consistent with ethers.js
2022-08-08 15:07:41 +02:00
Jackie cd5165efd0 Fix issues with teardown in wallet tests 2022-08-08 12:40:36 +02:00
Jackie b72fbb0ed9 small fixes 2022-08-08 12:40:36 +02:00
Jackie 39005a09be Add TODOs 2022-08-08 12:40:36 +02:00
Jackie d6c9151103 Add new test for wallet 2022-08-08 12:40:36 +02:00
Jackie 1d89be9d42 Add first tests for wallet 2022-08-08 12:40:36 +02:00
Mark Spanbroek e9aaea4a5a Fix intermittent test failure
Test would fail with an error when transaction hash
happens to start with 0b; it would then try to to parse
the hash as a binary number.
2022-07-13 09:04:48 +02:00
Mark Spanbroek 083af80dcc Introduce separate type for transaction overrides 2022-07-13 09:04:48 +02:00
Mark Spanbroek a7d1944406 Allow for custom transaction properties 2022-07-13 09:04:48 +02:00
Mark Spanbroek 94f5f35a10 Drop support for Nim 1.4.x
Only support stable Nim versions 1.2.x and 1.6.x.
2022-06-30 10:52:12 +02:00
Mark Spanbroek 95c5282b8a Raise EthersError when JSON-RPC fails 2022-06-30 10:52:12 +02:00
Mark Spanbroek 00b511cc9b Allow enums to be used as function parameters 2022-06-15 10:52:35 +02:00
Mark Spanbroek 9ef6c08072 Handle multiple return types on a contract call 2022-06-14 16:27:43 +02:00
Mark Spanbroek e61c70f5ba Fix: handle dynamically sized return values
Dynamically sized return values such as strings and
sequences were not decoded as part of a tuple, leading
to a difference in byte representation.
2022-06-08 11:23:01 +02:00
Mark Spanbroek 801bf19157 Remove calls to Option.get 2022-05-25 09:28:15 +02:00
Mark Spanbroek 2653610b6b Raise EthersError instead of JsonRpcProviderError 2022-05-25 09:28:15 +02:00
Eric Mastro e6c9b59cfb chore: add tests for all contract method return types
Add tests for non-constant contract method return types:
1. `void`
2. `?TransactionResponse` or `Option[TransactionRepsonse]`
3. `Confirmable`
2022-05-25 09:13:44 +02:00
Mark Spanbroek 649dc8efd0 Allow types that are equivalent to Confirmable
Allows ?TransactionResponse, Option[TransactionResponse] etc
to be used instead of Confirmable.
2022-05-25 09:13:44 +02:00
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
Eric Mastro 2f97a03fe2 feat: Can wait for transaction confirmations
Allows specified number of transaction confirmations to be awaited before a transaction is considered finalised. Polls for a transaction receipt then listens for new blocks and calculates the number of blocks between the receipt and the new block.

Notes
1. Only works with websockets currently
2. Replaced transaction not supported yet
2022-05-23 11:27:26 +10:00
Mark Spanbroek bbf133725f Subscribe to new blocks 2022-05-17 09:08:02 +02:00
Mark Spanbroek e3d5ce5122 Fix decoding of events with dynamic arguments
Such as byte sequences or strings.
2022-04-13 10:10:53 +02:00
Mark Spanbroek c49a9cbae9 Decode indexed event parameters bytes1 up to bytes32 2022-03-29 10:48:00 +02:00
Mark Spanbroek ce435f8791 Add Provider.getBlock()
Only returns hash, number and timestamp for now.
2022-03-16 14:20:00 +01:00
Mark Spanbroek ff5a35aac0 Define and subscribe to solidity events 2022-02-09 14:50:51 +01:00
Mark Spanbroek 21f98c4086 Event decoding from data and topics 2022-02-09 14:50:51 +01:00
Mark Spanbroek 062b367f32 Ensure that tests run on Nim 1.2.x 2022-01-26 17:58:51 +01:00
Mark Spanbroek 9eee20e49d Add Contract.connect() 2022-01-26 12:23:30 +01:00
Mark Spanbroek 1e767b2107 Add Signer.signMessage() 2022-01-26 11:21:28 +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 6bd3e27e38 Add Signer.populateTransaction() 2022-01-25 10:25:09 +01:00
Mark Spanbroek 4acc6ef45c Add Signer.getChainId() 2022-01-24 17:29:25 +01:00
Mark Spanbroek 7e32f5ee51 Add Signer.estimateGas() 2022-01-24 14:40:47 +01:00
Mark Spanbroek 30bea4759c Adds Signer.getTransactionCount() 2022-01-24 12:14:31 +01:00
Mark Spanbroek 54c66db827 Adds Signer.getGasPrice() 2022-01-24 12:12:52 +01:00
Mark Spanbroek 94dcc171af Introduces JsonRpcSigner 2022-01-20 14:39:37 +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
Mark Spanbroek b965599a47 Use Address implementation from contractabi 2022-01-20 12:55:14 +01:00
Mark Spanbroek 7bc102a421 Provider.getBlockNumber() 2022-01-18 14:26:41 +01:00
Mark Spanbroek bd20199f87 Send raw messages to the provider 2022-01-18 14:24:46 +01:00
Mark Spanbroek 05366c4a49 Introduce JsonRpcProvider 2022-01-18 12:10:20 +01:00
Mark Spanbroek fe688bde79 Introduce Address type 2022-01-18 12:09:20 +01:00
Mark Spanbroek 898bf8f16f Project setup 2022-01-17 17:04:14 +01:00