regenerateNamespacesWithChains static method
To be used by Wallet to regenerate already generatedNamespaces but adding chains
parameter
Example usage on onSessionProposal(SessionProposalEvent? event)
await _web3Wallet!.approveSession( id: event.id, namespaces: NamespaceUtils.regenerateNamespacesWithChains( event.params.generatedNamespaces!, ), sessionProperties: event.params.sessionProperties, );
Implementation
static Map<String, Namespace> regenerateNamespacesWithChains(
Map<String, Namespace> generatedNamespaces,
) {
Map<String, Namespace> regeneratedNamespaces = {};
for (var key in generatedNamespaces.keys) {
final namespace = generatedNamespaces[key]!.copyWith(
chains: getChainsFromAccounts(generatedNamespaces[key]!.accounts),
);
regeneratedNamespaces[key] = namespace;
}
return regeneratedNamespaces;
}