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

Save network state in query parameters #1295

Closed
3 of 5 tasks
chrstph-dvx opened this issue Nov 16, 2023 · 1 comment
Closed
3 of 5 tasks

Save network state in query parameters #1295

chrstph-dvx opened this issue Nov 16, 2023 · 1 comment
Assignees

Comments

@chrstph-dvx
Copy link
Contributor

chrstph-dvx commented Nov 16, 2023

Objective

The idea is to use query parameters as a store for network information rather than relying on connected wallet.

Motivation

Using query parameters as the single source of truth for network information has multiple advantages:

  • Allow change of network in the UI directly
  • Allow server-side rendering as we don't rely on client side information anymore
  • Enable users to interact with the bridge without having to connect their wallet
  • Abstract notions of L1/L2/L3 into from and to

Architecture changes

User should be prompted to switch network only when they are about to move funds.
Query param should be the source of truth over the currently connected network in the wallet.

Adding

from,to query parameters - Query parameters for source and destination chain.

Both parameter are string rather than chainId to be more user friendly. They are also sanitized and defaulted to valid chains if at least one of the value is not valid.

useNetworks() - Long term replacement for useNetworksRelationship returning source and destination chains.

type UseNetworksState = {
  from: Chain
  fromProvider: StaticJsonRpcProvider
  to: Chain
  toProvider: StaticJsonRpcProvider
}
type UseNetworksSetState = (params: { fromId: ChainId; toId?: ChainId }) => void
function useNetworks(): [UseNetworksState, UseNetworksSetState] {}

useNetworksRelationship - Temporary hook until we replace it with useNetworks. API is closer to current useNetworksAndSigners, returning parent and child chains.

type UseNetworksRelationshipState = {
  childProvider: StaticJsonRpcProvider
  childChain: Chain
  parentChain: Chain
  parentProvider: StaticJsonRpcProvider
}
export function useNetworksRelationship({
  fromProvider,
  from,
  toProvider,
  to
}: UseNetworksState): UseNetworksRelationshipState {}

Deprecating

useNetworksAndSigners hook - replaced by useNetworks hook
l2ChainId query param - replaced by child chain

Timeline

Tasks

Preview Give feedback
  1. chrstph-dvx
  2. chrstph-dvx
  3. chrstph-dvx
@fionnachan
Copy link
Member

most are done, remaining task "Enable non-connected user to interact with the bridge" is tracked on Linear

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

No branches or pull requests

2 participants