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

chore(networkConfig): remove 1 place where manual testing and code searching would be needed to add chains #4857

Merged
merged 20 commits into from
Feb 23, 2024

Conversation

cajubelt
Copy link
Contributor

@cajubelt cajubelt commented Feb 7, 2024

Description

we should try to maintain a status quo where all we have to do in every repo to add a chain is update a "NetworkId" enum and fix all compilation errors that result from it

Test plan

added spot checks for the two affected configs

Related issues

cc https://linear.app/valora/issue/ACT-1060/add-optimism-arbitrum-to-wallet

Backwards compatibility

na

Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.36%. Comparing base (d62d676) to head (1becef0).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4857   +/-   ##
=======================================
  Coverage   85.36%   85.36%           
=======================================
  Files         716      716           
  Lines       29229    29232    +3     
  Branches     5086     5086           
=======================================
+ Hits        24951    24954    +3     
  Misses       4039     4039           
  Partials      239      239           
Files Coverage Δ
src/web3/networkConfig.ts 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d62d676...1becef0. Read the comment docs.

'eip155:421614': Network.Arbitrum,
'eip155:10': Network.Optimism,
'eip155:11155420': Network.Optimism,
export const walletConnectChainIdToNetwork: Record<string, Network> = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I spent a sec trying to code golf this into a single line using a Object.entries(walletConnectChainIdToNetworkId).reduce(...), but then realized that it's prolly less readable than the current approach 😆

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 think you could do Object.fromEntries(Object.entries(walletConnectChainIdToNetworkId).map(([chainId, networkId]) => [networkId, chainId]))) . But i went with the for loop because it seemed more readable

Copy link
Contributor Author

@cajubelt cajubelt Feb 7, 2024

Choose a reason for hiding this comment

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

i may have gotten network id and chain id backwards in my comment^ but whatever

@cajubelt cajubelt changed the title chore(networkConfig): remove 1 place where manual updates would be needed to add chains chore(networkConfig): remove 1 place where manual testing and code searching would be needed to add chains Feb 10, 2024
Copy link
Collaborator

@kathaypacific kathaypacific left a comment

Choose a reason for hiding this comment

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

TY for the catch, looks good. recently Jean was floating the idea of moving away from lodash, we didn't end up discussing at eng sync like we intended but seeing it used here made me remember this.

This comment was marked as outdated.

@MuckT MuckT enabled auto-merge (squash) February 23, 2024 17:30

This comment was marked as duplicate.

This comment was marked as duplicate.

@MuckT MuckT merged commit 6fbe62d into main Feb 23, 2024
16 checks passed
@MuckT MuckT deleted the cajubelt/multichain-static-typing branch February 23, 2024 19:35
shottah pushed a commit to zed-io/kolektivo that referenced this pull request May 15, 2024
…arching would be needed to add chains (valora-inc#4857)

### Description

we should try to maintain a status quo where all we have to do in every
repo to add a chain is update a "NetworkId" enum and fix all compilation
errors that result from it

### Test plan

added spot checks for the two affected configs

### Related issues

cc
https://linear.app/valora/issue/ACT-1060/add-optimism-arbitrum-to-wallet

### Backwards compatibility

na

---------

Co-authored-by: Tom McGuire <Mcgtom10@gmail.com>
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