requestAddChain method
Implementation
@override
Future<void> requestAddChain(ReownAppKitModalNetworkInfo newChain) async {
final topic = _currentSession?.topic ?? '';
final chainId = '${CoreConstants.namespace}:$_currentSelectedChainId';
final newChainId = '${CoreConstants.namespace}:${newChain.chainId}';
_logger.i('[$runtimeType] requesting switch to add chain $newChainId');
try {
await request(
topic: topic,
chainId: chainId,
switchToChainId: newChainId,
request: SessionRequestParams(
method: MethodsConstants.walletAddEthChain,
params: [newChain.toJson()],
),
);
_currentSelectedChainId = newChain.chainId;
await _setSesionAndChainData(_currentSession!);
return;
} catch (e) {
_logger.i('[$runtimeType] requestAddChain error $e');
await _setLocalEthChain(_currentSelectedChainId!);
throw JsonRpcError(code: 5002, message: 'User rejected methods.');
}
}