init method

  1. @override
Future<void> init()
override

The current connection state of the modal. Used by the connect button to render the correct UI. The current state of the modal. The list of wallets from the explorer API. Sets up the explorer and the web3App if they already been initialized.

Implementation

@override
Future<void> init() async {
  if (_isInitialized) {
    return;
  }

  await _web3App!.init();
  await explorerService.init(
    referer: _web3App!.metadata.name.replaceAll(' ', ''),
  );

  _registerListeners();

  if (_web3App!.sessions.getAll().isNotEmpty) {
    _isConnected = true;
    _session = _web3App!.sessions.getAll().first;
    _address = NamespaceUtils.getAccount(
      _session!.namespaces.values.first.accounts.first,
    );
  }

  _isInitialized = true;

  notifyListeners();
}