getSenderCaip10Account method
Get first CAIP-10 account for the given chain on the approved namespaces This is currenctly a limitation in the SDK as an approved session could have more than 1 account per chain approved and we currently pick the first one in the list risking to pick an empty account (or an account with insufficient funds, for what it matter). There is no way we can know (at least until wallet_pay) which account is the more appropriate (or the only appropriate account) to make the payment if the user decided to approve the session for every account they have in the wallet.
Implementation
String? getSenderCaip10Account(String chainId) {
final ns = NamespaceUtils.getNamespaceFromChain(chainId);
final namespace = namespaces[ns];
final account = namespace?.accounts.firstWhereOrNull((account) {
final accountChain = NamespaceUtils.getChainFromAccount(account);
return accountChain == chainId;
});
return account;
}