Commit Graph

33 Commits

Author SHA1 Message Date
Eric b68bea9909
fix: modify unsubscribe cleanup routine and tests (#84)
* fix: modify unsubscribe cleanup routine

Ignore exceptions (other than CancelledError) if uninstallation of the filter fails. If it's the last step in the subscription cleanup, then filter changes for this filter will no longer be polled so if the filter continues to live on in geth for whatever reason, then it doesn't matter.

This includes a number of fixes:
- `CancelledError` is now caught inside of `getChanges`. This was causing conditions during `subscriptions.close`, where the `CancelledError` would get consumed by the `except CatchableError`, if there was an ongoing `poll` happening at the time of close.
- After creating a new filter inside of `getChanges`, the new filter is polled for changes before returning.
- `getChanges` also does not swallow `CatchableError` by returning an empty array, and instead re-raises the error if it is not `filter not found`.
- The tests were simplified by accessing the private fields of `PollingSubscriptions`. That way, there wasn't a race condition for the `newFilterId` counter inside of the mock.
- The `MockRpcHttpServer` was simplified by keeping track of the active filters only, and invalidation simply removes the filter. The tests then only needed to rely on the fact that the filter id changed in the mapping.
- Because of the above changes, we no longer needed to sleep inside of the tests, so the sleeps were removed, and the polling interval could be changed to 1ms, which not only makes the tests faster, but would further highlight any race conditions if present.

* docs: rpc custom port documentation

---------

Co-authored-by: Adam Uhlíř <adam@uhlir.dev>
2024-10-25 14:58:45 +11:00
Mark Spanbroek e15974eb1f version 0.9.0
This is a breaking change. Contract functions can no
longer be defined to return ?TransactionResponse,
use Confirmable as the return type instead.
2024-05-21 13:27:19 +02:00
Mark Spanbroek 067e0f2eb7 readme: add description of custom errors 2024-05-21 13:19:24 +02:00
Mark Spanbroek d46f5a10d3 version 0.8.0
Replaces version 0.7.2, because it includes
breaking changes
2024-02-27 09:13:36 +01:00
benbierens 7911ac6c57
version 0.7.2 2024-02-26 14:03:48 +01:00
Mark Spanbroek fd16d71ea5 version 0.7.1 2023-12-12 09:28:52 +01:00
Mark Spanbroek 8fff63102a version 0.7.0 2023-09-13 13:54:41 +02:00
Mark Spanbroek 43041e7948 Small fix in Readme 2023-09-13 10:11:18 +02:00
Mark Spanbroek 2ec0313dd3 version 0.6.0
updated contractabi brings in breaking change in nimcrypto
2023-08-29 12:25:39 +02:00
Eric 9f4f762e21
version 0.5.0
Breaking change:
`Filter` has been changed to `EventFilter` to be inline with ethers.js. `Filter` is used for creating subscriptions in `nim-ethers`. All previously-created instances of `Filter` in your consuming application code should be changed to `EventFilter`.
2023-07-24 15:54:18 +10:00
Mark Spanbroek c49311fca2 version 0.4.0 2023-07-05 15:09:31 +02:00
Mark Spanbroek e086b71b42 version 0.3.0 2023-07-04 12:58:48 +02:00
Mark Spanbroek a27c2de41c Close provider by unsubscribing and closing client 2023-07-03 13:09:09 +02:00
Mark Spanbroek ceedf03c82 Subscriptions now also supported with http url 2023-07-03 13:09:09 +02:00
Mark Spanbroek 5a4f786757 version 0.2.5 2023-04-19 10:06:04 +02:00
Adam Uhlíř 3c12a65769
feat: erc20 module (#38)
Co-authored-by: Eric Mastro <github@egonat.me>
2023-03-29 13:41:44 +02:00
Mark Spanbroek e462649aec version 0.2.4 2022-11-10 10:22:24 +01:00
Eric Mastro 8a484299e6 Remove en/decoding advice from readme 2022-09-21 10:27:45 +10:00
Eric Mastro 01d277f801 version 0.2.2 2022-09-21 10:27:45 +10:00
Eric Mastro 0adf56c65b Support distinct types for Event fields
Add support for indexed (and non-indexed) Event fields types that are distinct `ValueType` or `SmallByteArray`. For example,
```nim
type
  DistinctAlias = distinct array[32, byte]
  MyEvent = object of Event
    a {.indexed.}: DistinctAlias
    b: DistinctAlias # also allowed for non-indexed fields

## The below funcs generally need to be included for ABI
## encoding/decoding purposes when implementing distinct types.

func toArray(value: DistinctAlias): array[32, byte] =
  array[32, byte](value)

func encode*(encoder: var AbiEncoder, value: DistinctAlias) =
  encoder.write(value.toArray)

func decode*(decoder: var AbiDecoder,
             T: type DistinctAlias): ?!T =
  let d = ?decoder.read(type array[32, byte])
  success DistinctAlias(d)
```
2022-09-21 10:27:45 +10:00
Mark Spanbroek e8d0fdf1a9 version 0.2.1 2022-08-08 15:14:11 +02:00
Mark Spanbroek 440ca6360b Version 0.2.0
Backwards incompatible because:
- Raises EthersError instead of JsonRpcError
- Nim 1.4.x no longer supported
2022-06-30 10:52:12 +02:00
Mark Spanbroek a626070532 version 0.1.9 2022-06-15 10:54:45 +02:00
Mark Spanbroek 78115cdd4b version 0.1.8 2022-06-08 11:24:38 +02:00
Eric Mastro 270d358b86
version 0.1.7 2022-05-23 11:31:16 +10:00
Mark Spanbroek 0549800af6 version 0.1.6 2022-05-17 19:28:52 +02:00
Mark Spanbroek 8c45babcdf version 0.1.5 2022-04-19 17:57:16 +02:00
Mark Spanbroek a0dca2674d version 0.1.4 2022-04-13 10:10:53 +02:00
Mark Spanbroek ac74b91f11 version 0.1.3 2022-03-29 10:48:00 +02:00
Mark Spanbroek fc8af1117c version 0.1.2 2022-03-17 10:30:42 +01:00
Mark Spanbroek acc4fc25e6 version 0.1.1 2022-03-16 14:20:56 +01:00
Mark Spanbroek 5cc1f4b71d Add documentation about events 2022-02-09 14:50:51 +01:00
Mark Spanbroek 3940233bc9 Add Readme 2022-01-26 17:58:51 +01:00