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

⚡️ Add block refresher #795

Merged
merged 11 commits into from
Jun 3, 2022
Merged

⚡️ Add block refresher #795

merged 11 commits into from
Jun 3, 2022

Conversation

mj426382
Copy link
Contributor

@mj426382 mj426382 commented Jun 2, 2022

closes #783
closes #156

@changeset-bot
Copy link

changeset-bot bot commented Jun 2, 2022

🦋 Changeset detected

Latest commit: 0cd09b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@usedapp/core Patch
@usedapp/coingecko Patch
@usedapp/testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 10:30 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 10:30 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 10:30 Inactive
/**
* Refresh standard calls each time the n-th block is mined.
*/
refresh?: number | string
Copy link
Contributor

Choose a reason for hiding this comment

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

Specify available strings exactly, not string.

() =>
calls.map((call) =>
chainId !== undefined
? encodeCallData(call, chainId, { ...queryParams, refresh: queryParams.refresh ?? refresh })
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it be simplified into { refresh, ...queryParams }?

Copy link
Contributor Author

@mj426382 mj426382 Jun 2, 2022

Choose a reason for hiding this comment

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

No because refresh can be undefined and then we need to use queryParam's refresh.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, then queryParams will override.

@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 12:24 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 12:25 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 12:25 Inactive
await waitForCurrent((val) => val !== undefined)
expect(result.error).to.be.undefined
expect(result.current).to.eq(100)
await sleep(1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about moving the sleep into the mineBlock function, and explain why it is there?

@@ -82,6 +82,7 @@ export function MultiChainStateProvider({ children, multicallAddresses }: Props)

const callsOnThisChain = uniqueCalls.filter((call) => call.chainId === chainId)
if (callsOnThisChain.length === 0) {
dispatchCalls({ type: 'UPDATE_CALLS', calls, blockNumber, chainId })
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment why this is needed here?

@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 14:44 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 14:44 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 14:45 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 14:48 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 14:49 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 2, 2022 14:49 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 3, 2022 09:01 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 3, 2022 09:01 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 3, 2022 09:01 Inactive
@mj426382 mj426382 force-pushed the add-block-refresher branch from 1438389 to 0cd09b0 Compare June 3, 2022 10:22
@github-actions github-actions bot temporarily deployed to pull request June 3, 2022 10:25 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 3, 2022 10:25 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 3, 2022 10:25 Inactive
@@ -81,9 +81,7 @@ export function MultiChainStateProvider({ children, multicallAddresses }: Props)
}

const callsOnThisChain = uniqueCalls.filter((call) => call.chainId === chainId)
if (callsOnThisChain.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i put that on multicall function, to reduce duplicated code

@mj426382 mj426382 merged commit 24e9668 into master Jun 3, 2022
@mj426382 mj426382 deleted the add-block-refresher branch June 3, 2022 11:37
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.

How to stop/limit the number of auto-refresh requests? Add Caching/Limits to Contract Calls
2 participants