mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-28 14:39:38 +00:00
c7deeaea9b
* New versions Fix issues with Monero.com * Add sending for Solana tokens exchanges * Add default keyword for P2WPKH [skip ci] * chore: Switch solana commitment to confirmed to reduced blockhash expiration (#1313) * Modify test workflow to send arm64-v8a build only * Fix workflow build path * Remove unnecessary reverse of txId * Show case sensitive evm wallet address * Revert default Cake Theme add custom package id for test builds * Fix workflow script * Fix workflow * hash branch name * hash branch name * Update versions * Add user image to Nostr Add fetching address from text for tokens * Fix test app package id * fix: Solana message improvement (#1316) --------- Co-authored-by: Adegoke David <64401859+Blazebrain@users.noreply.github.com>
142 lines
3.5 KiB
Dart
142 lines
3.5 KiB
Dart
import 'package:cake_wallet/entities/openalias_record.dart';
|
|
import 'package:cake_wallet/entities/yat_record.dart';
|
|
|
|
enum ParseFrom {
|
|
unstoppableDomains,
|
|
openAlias,
|
|
yatRecord,
|
|
fio,
|
|
notParsed,
|
|
twitter,
|
|
ens,
|
|
contact,
|
|
mastodon,
|
|
nostr
|
|
}
|
|
|
|
class ParsedAddress {
|
|
ParsedAddress({
|
|
required this.addresses,
|
|
this.name = '',
|
|
this.description = '',
|
|
this.profileImageUrl = '',
|
|
this.profileName = '',
|
|
this.parseFrom = ParseFrom.notParsed,
|
|
});
|
|
|
|
factory ParsedAddress.fetchEmojiAddress({
|
|
List<YatRecord>? addresses,
|
|
required String name,
|
|
}) {
|
|
if (addresses?.isEmpty ?? true) {
|
|
return ParsedAddress(addresses: [name], parseFrom: ParseFrom.yatRecord);
|
|
}
|
|
return ParsedAddress(
|
|
addresses: addresses!.map((e) => e.address).toList(),
|
|
name: name,
|
|
parseFrom: ParseFrom.yatRecord,
|
|
);
|
|
}
|
|
|
|
factory ParsedAddress.fetchUnstoppableDomainAddress({
|
|
String? address,
|
|
required String name,
|
|
}) {
|
|
if (address?.isEmpty ?? true) {
|
|
return ParsedAddress(addresses: [name]);
|
|
}
|
|
return ParsedAddress(
|
|
addresses: [address!],
|
|
name: name,
|
|
parseFrom: ParseFrom.unstoppableDomains,
|
|
);
|
|
}
|
|
|
|
factory ParsedAddress.fetchOpenAliasAddress(
|
|
{required OpenaliasRecord record, required String name}) {
|
|
if (record.address.isEmpty) {
|
|
return ParsedAddress(addresses: [name]);
|
|
}
|
|
return ParsedAddress(
|
|
addresses: [record.address],
|
|
name: record.name,
|
|
description: record.description,
|
|
parseFrom: ParseFrom.openAlias,
|
|
);
|
|
}
|
|
|
|
factory ParsedAddress.fetchFioAddress({required String address, required String name}) {
|
|
return ParsedAddress(
|
|
addresses: [address],
|
|
name: name,
|
|
parseFrom: ParseFrom.fio,
|
|
);
|
|
}
|
|
|
|
factory ParsedAddress.fetchTwitterAddress(
|
|
{required String address,
|
|
required String name,
|
|
required String profileImageUrl,
|
|
required String profileName,
|
|
String? description}) {
|
|
return ParsedAddress(
|
|
addresses: [address],
|
|
name: name,
|
|
description: description ?? '',
|
|
profileImageUrl: profileImageUrl,
|
|
profileName: profileName,
|
|
parseFrom: ParseFrom.twitter,
|
|
);
|
|
}
|
|
|
|
factory ParsedAddress.fetchMastodonAddress(
|
|
{required String address,
|
|
required String name,
|
|
required String profileImageUrl,
|
|
required String profileName}) {
|
|
return ParsedAddress(
|
|
addresses: [address],
|
|
name: name,
|
|
parseFrom: ParseFrom.mastodon,
|
|
profileImageUrl: profileImageUrl,
|
|
profileName: profileName,
|
|
);
|
|
}
|
|
|
|
factory ParsedAddress.fetchContactAddress({required String address, required String name}) {
|
|
return ParsedAddress(
|
|
addresses: [address],
|
|
name: name,
|
|
parseFrom: ParseFrom.contact,
|
|
);
|
|
}
|
|
|
|
factory ParsedAddress.fetchEnsAddress({required String address, required String name}) {
|
|
return ParsedAddress(
|
|
addresses: [address],
|
|
name: name,
|
|
parseFrom: ParseFrom.ens,
|
|
);
|
|
}
|
|
|
|
factory ParsedAddress.nostrAddress(
|
|
{required String address,
|
|
required String name,
|
|
required String profileImageUrl,
|
|
required String profileName}) {
|
|
return ParsedAddress(
|
|
addresses: [address],
|
|
name: name,
|
|
parseFrom: ParseFrom.nostr,
|
|
profileImageUrl: profileImageUrl,
|
|
profileName: profileName,
|
|
);
|
|
}
|
|
|
|
final List<String> addresses;
|
|
final String name;
|
|
final String description;
|
|
final String profileImageUrl;
|
|
final String profileName;
|
|
final ParseFrom parseFrom;
|
|
}
|