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 W3MCoinbaseException('$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));
return;
} on PlatformException catch (e, s) {
// 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 W3MCoinbaseException(errorMessage, e, s);
} catch (e, s) {
onCoinbaseError.broadcast(CoinbaseErrorEvent('Initial handshake error'));
throw W3MCoinbaseException('Initial handshake error', e, s);
}
}