Enable Uncurried mode - #49
Conversation
|
Here's the diff of the codegen output.🙌🧠🦜 |
| let convertViemDecodedEvent: Viem.decodedEvent<'a> => Viem.decodedEvent< | ||
| Types.{{contract.name.capitalized}}.{{event.name.capitalized}}.eventArgs, | ||
| > = Obj.magic | ||
| > = X.magic |
There was a problem hiding this comment.
What is X? Is it a new built in module?
There was a problem hiding this comment.
I decided to create the X module with all our custom utility functions which should extend stdlib. The reason why X.magic is needed is because the Obj module is embedded into compiler and doesn't have uncurried support. It's fine in many cases, but I like using Obj.magic with a type annotation like (Obj.magic: unknown => string) and it doesn't work in uncurried.
| @@ -0,0 +1 @@ | |||
| external magic: 'a => 'b = "%identity" | |||
|
|
||
| let makeWithRollBackEventIdentifier = (rollBackEventIdentifier): t => { | ||
| eventSyncState: InMemoryTable.make(~hash=Int.toString), | ||
| eventSyncState: InMemoryTable.make(~hash=v => v->RescriptCore.Int.toString), |
There was a problem hiding this comment.
Should we open RescriptCore globally? Not for this PR though.
There was a problem hiding this comment.
Probably. I tried and it happened to be not as simple as I originally though.
| /** | ||
| This module is to help defer callbacks that are low priority | ||
| to help with unblocking the event loop on large iterations for example. | ||
|
|
||
| The aim is to have an interface like a promise but instead of | ||
| placing callbacks on the micro task queue along with promise | ||
| callbacks it will get placed on the macro task queue where the | ||
| event loop will prioritise promise callback and deprioritise | ||
| callbacks created instantiated with a "Deferred" object | ||
|
|
||
| It uses a setTimeout callback to make the behaviour consistent across | ||
| runtimes (NodeJs, browser etc.) as opposed to setImmediate, nextTick | ||
| which are placed at different orders in the event loop on different | ||
| runtimes | ||
| */ | ||
| type deferredState<'a> = Pending | Resolved('a) | Rejected(exn) | ||
|
|
||
| type resolveCb<'a> = 'a => unit |
There was a problem hiding this comment.
We should maybe run reanalyze. There's probably a lot of other dead code around.
| let fetchArbitraryEvents = (_worker: sourceWorker) => { | ||
| let fetchArbitraryEvents = ( | ||
| _worker: sourceWorker, | ||
| ~fromBlock as _fromBlock, | ||
| ~fromLogIndex as _fromLogIndex, | ||
| ~toBlock as _toBlock, | ||
| ~logger as _logger, | ||
| ~dynamicContracts as _dynamicContracts, | ||
| ) => { |
There was a problem hiding this comment.
This should be deprecated with RawEventsWorker.res. I can't remember if we wanted to reimplement raw events worker. Currently its just broken.
No description provided.