getAccount method
Future<void>
getAccount(
)
override
Implementation
@override
Future<void> getAccount() async {
await _checkInstalled();
try {
final results = await CoinbaseWalletSDK.shared.initiateHandshake([
const RequestAccounts(),
]);
final result = results.first;
if (result.error != null) {
final errorCode = result.error?.code;
final errorMessage = result.error!.message;
onCoinbaseError.broadcast(CoinbaseErrorEvent(errorMessage));
throw CoinbaseServiceException('$errorMessage ($errorCode)');
}
final data = CoinbaseData.fromJson(result.account!.toJson()).copytWith(
peer: metadata.copyWith(
publicKey: await peerPublicKey,
),
self: ConnectionMetadata(
metadata: _metadata,
publicKey: await ownPublicKey,
),
);
onCoinbaseConnect.broadcast(CoinbaseConnectEvent(data));
_core.logger.i('[$runtimeType] getAccount ${data.toJson()}');
return;
} on PlatformException catch (e, s) {
_core.logger.e('[$runtimeType] getAccount PlatformException $e');
// Currently Coinbase SDK is not differentiate between User rejection or any other kind of error in iOS
final errorMessage = (e.message ?? '').toLowerCase();
onCoinbaseError.broadcast(CoinbaseErrorEvent(errorMessage));
throw CoinbaseServiceException(errorMessage, e, s);
} catch (e, s) {
_core.logger.e('[$runtimeType] getAccount $e');
onCoinbaseError.broadcast(CoinbaseErrorEvent('Initial handshake error'));
throw CoinbaseServiceException('Initial handshake error', e, s);
}
}