registerAccount method

  1. @override
void registerAccount({
  1. required String chainId,
  2. required String accountAddress,
})
override

Register accounts for a given namespace or chainId. Used to construct the Namespaces map for the session proposal. Each account must follow the namespace:chainId:address format or this will throw an error.

Implementation

@override
void registerAccount({
  required String chainId,
  required String accountAddress,
}) {
  final bool isChainId = NamespaceUtils.isValidChainId(chainId);
  if (!isChainId) {
    throw Errors.getSdkError(
      Errors.UNSUPPORTED_CHAINS,
      context:
          'registerAccount, chain $chainId should conform to "CAIP-2" format',
    ).toSignError();
  }
  final String value = _getRegisterKey(chainId, accountAddress);
  SignApiValidatorUtils.isValidAccounts(
    accounts: [value],
    context: 'registerAccount',
  );
  _accounts.add(value);
}