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 networkStore and runtime support for networks #1835

Open
wants to merge 64 commits into
base: master
Choose a base branch
from

Conversation

walmat
Copy link
Contributor

@walmat walmat commented Feb 7, 2025

Fixes BX-1740, BX-1742, BX-1741, BX-1739, BX-1675

What changed (plus any additional context for devs)

  • consolidates backend network fetching into backendNetworks and customNetworks
  • Backend driven customNetworks now powers the pre-populated list of custom chains a user can add
  • Bump Zustand from 4.1.5 to 4.5.5 to support new createQueryStore architecture
  • Introduces a new networkStore that merges pre-existing userChains and rainbowChains stores together
  • Fixes a syncing issue with createSelector and createParameterizedSelector
  • Migrates chain accessors to new networkStore store methods
  • Removes references/chains file with static build time accessors
  • Removes (hopefully) all locations where hardcoded new chain additions were needed
  • networkStore now ingests network diffs automatically
    • kicks off a sync process that merges potentially previously added custom chains with newly supported chains
  • Consume ChainBadge urls directly from backend networks now
  • Removes all local badge assets as they are no longer used
  • Removes duplicate slippage defaults and relies now solely on remoteConfig + a fallback default
  • Optimizes native asset fetching to no longer fetch eth prices more than once
  • Tried to capture some unit tests for the networkStore, but there's plenty more test cases to write

Screen recordings / screenshots

// will try and capture a few screenshots tonight

What to test

https://www.notion.so/rainbowdotme/NetworkStore-Detailed-Test-Checklist-19eb001b85b48074a134d0ca093dbb9b

Copy link

linear bot commented Feb 7, 2025

@@ -60,17 +60,20 @@ export const estimateSwapGasLimit = async ({
const provider = getProvider({ chainId });

if (!provider || !quote) {
return getChainGasUnits(chainId).basic.swap;
const chainGasUnits = networkStore.getState().getChainGasUnits(chainId);
Copy link
Member

Choose a reason for hiding this comment

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

can pull this line out to line 61 and delete the duplicate line on 72

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can, but only wanted to grab it when/if we needed to in order to reduce calls to the network store.

@walmat walmat marked this pull request as ready for review February 12, 2025 21:39
balance: { amount: '', display: '' },
chainId: chainId,
chainName: chainsLabel[chainId] as ChainName,
chainName: chainLabel as ChainName,
Copy link
Member

Choose a reason for hiding this comment

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

this looks like an existing issue, but chainName should be from getChainsName instead of getChainsLabel to be consistent

Copy link
Member

Choose a reason for hiding this comment

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

also existing issue: on line 46 it looks like we are including native_asset_ in the uniqueId which seems inconsistent with the way we handle uniqueIds

Copy link
Member

@BrodyHughes BrodyHughes left a comment

Choose a reason for hiding this comment

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

LGTM:

  • token data: ✅
  • swaps: ✅
  • sends: ✅
  • nfts: ✅
  • custom networks: ✅

@@ -358,7 +358,7 @@ it('should be able to open token to buy input and select assets', async () => {
expect(toBuyInputDaiSelected).toBeTruthy();
});

it('should be able to type native amount on sell input', async () => {
it.skip('should be able to type native amount on sell input', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Can you provide any info on this one? I can make a ticket but making sure this was intentional.

Copy link
Member

Choose a reason for hiding this comment

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

so for context: this failure has been happening since my PR was merged (#1830). I think something with the quotes changed and I need to fix it. I recommended skipping this for now so we have an actual working e2e in the meantime.

"anvil": "anvil --fork-url $(./scripts/get-rpc-url.sh mainnet) --fork-block-number 21574102 --block-base-fee-per-gas 5000000000 --block-gas-limit 30000000",
"anvil": "anvil --fork-url $(./scripts/get-rpc-url.sh mainnet) --fork-block-number 21574102 --block-base-fee-per-gas 1000000000 --block-gas-limit 30000000",
Copy link
Member

Choose a reason for hiding this comment

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

Did this have a material effect on e2e?

Copy link
Member

Choose a reason for hiding this comment

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

Yes it did. Bruno actually recommended it a few weeks ago if we saw more of a specific failure type which matthew was seeing. Again, i recommended this and it did fix an issue.

src/core/state/networks/networks.ts Outdated Show resolved Hide resolved
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.

4 participants