setDefaultChain method

  1. @override
void setDefaultChain({
  1. Web3ModalChains? web3modalChain,
  2. Map<String, RequiredNamespace>? requiredNamespaces,
})
override

Sets the default chain to use for the session. web3modalChain or requiredNamespaces must be provided, if both are null this function will do nothing.

Implementation

@override
void setDefaultChain({
  Web3ModalChains? web3modalChain,
  Map<String, RequiredNamespace>? requiredNamespaces,
}) {
  _checkInitialized();

  if (web3modalChain != null) {
    switch (web3modalChain) {
      case Web3ModalChains.ethereum:
        _requiredNamespaces = NamespaceConstants.ethereum;
        break;
      case Web3ModalChains.polygon:
        _requiredNamespaces = NamespaceConstants.polygon;
        break;
    }
  }

  if (requiredNamespaces != null) {
    _requiredNamespaces = requiredNamespaces;
  }

  notifyListeners();
}