You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's also possible to leave chainId as is and in config accept number. Enum type can be supplied to number parameter.
Legacy config support
To introduce backward compatibility we can rename current config type to LegacyConfig and introduce new type Config.
typeBackwardsCompatibleConfig=LegacyConfig|Config
New hooks
NetworkConnectorProvider
Provider that will hold a NetworkConnector object.
Object will be updated when networks in config change.
Draft:
exportconstNetworkConnectorContext=createContext<NetworkConnector>(newNetworkConnector({urls:[]}))exportfunctionuseNetworkConnector(){returnuseContext(NetworkConnectorContext)}exportfunctionNetworkConnectorProvider({ children }: {children:ReactNode}){const{networks}=useConfig()constnetworkConnector=useMemo(()=>(newNetworkConnector({urls: networks})),[networks])return<NetworkConnectorContext.Providervalue={{networkConnector}}children={children}/>}
LibrariesProvider
Web3ReactProvider for read only libraries. See docs
Similar to use ethers will use NetworkConnector to change connected ID. Also will contain a hasBlockChanged to tell whether the block changed on currently connected network from the last time this function was called.
ChainStateProvider will have to hold calls and results that are separated between each chainId, also will hold special list of calls that follows the chainId of connected wallet.
Summary
This is proposal for introducing multichain support in useDApp. This will allow to connect to several chains in read-only mode and one in write mode.
In the future multiple write chains might be available, without backward compatibility breaking.
TODO
Config
, what about non-network items)Configuration
Example configuration with mulitchain:
New types:
Flexible
chainId
It's also possible to leave chainId as is and in config accept number. Enum type can be supplied to number parameter.
Legacy config support
To introduce backward compatibility we can rename current config type to
LegacyConfig
and introduce new typeConfig
.New hooks
NetworkConnectorProvider
Provider that will hold a NetworkConnector object.
Object will be updated when networks in config change.
Draft:
LibrariesProvider
Web3ReactProvider for read only libraries.
See docs
Draft:
useLibraries
Similar to use ethers will use NetworkConnector to change connected ID. Also will contain a
hasBlockChanged
to tell whether the block changed on currently connected network from the last time this function was called.Draft:
useContracts
New models
CallOptions
Changes to old models
TransactionOptions
Changes to old hooks
useConfig
Add support for both legacy and new config
Extract multicallAdressess and supportedChains from new Config
useUpdateConfig
ChainStateProvider
ChainStateProvider will have to hold calls and results that are separated between each chainId, also will hold special list of calls that follows the chainId of connected wallet.
Draft:
useChainCalls
read only hooks
Add CallOptions parameters to functions that read state from blockchain
usePromiseTransaction
usePromiseTransaction will set exception state when options.chainId doesn't match wallet chainId
Proposed task list
The text was updated successfully, but these errors were encountered: