Skip to content

Enable Uncurried mode - #49

Merged
DZakh merged 2 commits into
mainfrom
dz/uncurried
Jul 2, 2024
Merged

DZakh merged 2 commits into
mainfrom
dz/uncurried

Conversation

@DZakh

@DZakh DZakh commented Jun 27, 2024

Copy link
Copy Markdown
Member

No description provided.

@DZakh
DZakh requested a review from JasoonS June 27, 2024 13:58
@github-actions

Copy link
Copy Markdown

Here's the diff of the codegen output.🙌🧠🦜

@DZakh
DZakh changed the base branch from dz/bigint-clean-up to main June 30, 2024 14:22
@DZakh
DZakh requested a review from JonoPrest June 30, 2024 21:53
let convertViemDecodedEvent: Viem.decodedEvent<'a> => Viem.decodedEvent<
Types.{{contract.name.capitalized}}.{{event.name.capitalized}}.eventArgs,
> = Obj.magic
> = X.magic

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is X? Is it a new built in module?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see it here 😄


let makeWithRollBackEventIdentifier = (rollBackEventIdentifier): t => {
eventSyncState: InMemoryTable.make(~hash=Int.toString),
eventSyncState: InMemoryTable.make(~hash=v => v->RescriptCore.Int.toString),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we open RescriptCore globally? Not for this PR though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I tried and it happened to be not as simple as I originally though.

Comment on lines -1 to -18
/**
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should maybe run reanalyze. There's probably a lot of other dead code around.

Comment on lines -5 to +12
let fetchArbitraryEvents = (_worker: sourceWorker) => {
let fetchArbitraryEvents = (
_worker: sourceWorker,
~fromBlock as _fromBlock,
~fromLogIndex as _fromLogIndex,
~toBlock as _toBlock,
~logger as _logger,
~dynamicContracts as _dynamicContracts,
) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be deprecated with RawEventsWorker.res. I can't remember if we wanted to reimplement raw events worker. Currently its just broken.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep it as it is.

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! Thank you so much for doing this @DZakh. Sorry if it was a bit of a grind but I think its very valuable 🙏🏼

@DZakh
DZakh merged commit 1aff7c1 into main Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants