Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow fetch functions to pass headers #2004

Merged
merged 6 commits into from
Feb 5, 2025
Merged

Conversation

kadirchan
Copy link
Contributor

This PR opened for issue #1983

Two exposed method implemented to set default headers to be passed both Mina and Archive GraphQL nodes for fetch operations. Named setMinaDefaultHeaders, setArchiveDefaultHeaders same as stated in issue.

Also one new internal method to decide header to be sent to the server, after classify them between archive or not.

In addition optional per request header option parameters added to following methods:
fetchAccount
fetchLastBlock
fetchCurrentSlot
fetchTransactionStatus
sendZkapp
fetchEvents
fetchActions
fetchGenesisConstants
So that developers can decide between default header usage and one time only usage, and they can overwrite default headers with this usage.

Also unit-tests implemented by using mocking fetch.

@kadirchan
Copy link
Contributor Author

I also hesitated to add this to methods checkZkAppTransaction, markAccountToBeFetched etc., so I skipped them for now.

Copy link
Contributor

@45930 45930 left a comment

Choose a reason for hiding this comment

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

I think you should get rid of the isArchiveUrl conditional logic as it's not needed.

I also left a proposal to bake these headers into the Mina.Network function, for convenience. That's not necessary, but I think it could be nice.

I love the tests you added! Overall this looks great!

@45930
Copy link
Contributor

45930 commented Feb 4, 2025

@dfstio , did you take a look at this implementation? Do you think it addresses your needs?

@kadirchan
Copy link
Contributor Author

kadirchan commented Feb 4, 2025

I changed fetch functions again as I understand, removed isArchive and added setting headers feature in Mina.Netwok and tested it same way. But there is some other methods that we can add per request header option like Mina.sendTransaction, Mina.fetchEvents, Mina.fetchActions, Mina.waitForFunding etc. should I add this option for them too @45930 ?

@45930
Copy link
Contributor

45930 commented Feb 4, 2025

@kadirchan

But there is some other methods that we can add per request header option like Mina.sendTransaction, Mina.fetchEvents, Mina.fetchActions, Mina.waitForFunding etc.

IMO yes let's add these as well. At least fetchActions and fetchEvents, because I think the archive node will make more use of this than the mina node.

Copy link
Contributor

@45930 45930 left a comment

Choose a reason for hiding this comment

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

This looks really good! I think it's ready to approve if you add a changelog entry, and I will wait to review those final changes from the Mina module you talked about.

@kadirchan
Copy link
Contributor Author

Finally added to Mina.fetchActions, Mina.fetchEvents (also added for faucet and waitForFunding just in case ). Due to sendTransaction is not directly exposed for devs I didn't add for it but it still uses the default one which is enough imo.

@45930 45930 merged commit c824001 into o1-labs:main Feb 5, 2025
28 of 31 checks passed
@45930
Copy link
Contributor

45930 commented Feb 5, 2025

Thanks @kadirchan !

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