CW-1073 Implement Monero wallet definition URI scheme (#2323)

* feat: add optional parameter to customize address extraction pattern

* refactor: add parameter to control address extraction surrounding whitespace validation

* fix: ensure proper handling of unmounted context in address extraction logic

* test: add comprehensive unit tests for AddressResolver and AddressValidator classes
This commit is contained in:
Konstantin Ullrich
2025-06-18 17:20:03 +03:00
committed by GitHub
parent c6cb48096d
commit 150becb679
6 changed files with 401 additions and 30 deletions
+8 -2
View File
@@ -165,13 +165,19 @@ class AddressResolver {
"zone"
];
static String? extractAddressByType({required String raw, required CryptoCurrency type}) {
final addressPattern = AddressValidator.getAddressFromStringPattern(type);
static String? extractAddressByType(
{required String raw,
required CryptoCurrency type,
bool requireSurroundingWhitespaces = true}) {
var addressPattern = AddressValidator.getAddressFromStringPattern(type);
if (addressPattern == null) {
throw Exception('Unexpected token: $type for getAddressFromStringPattern');
}
if (requireSurroundingWhitespaces)
addressPattern = "$BEFORE_REGEX$addressPattern$AFTER_REGEX";
final match = RegExp(addressPattern, multiLine: true).firstMatch(raw);
return match?.group(0)?.replaceAllMapped(RegExp('[^0-9a-zA-Z]|bitcoincash:|nano_|ban_'),
(Match match) {