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 16:20:03 +02:00 committed by GitHub
parent c6cb48096d
commit 150becb679
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 401 additions and 30 deletions

View file

@ -38,9 +38,9 @@ class AddressValidator extends TextValidator {
'|[0-9a-zA-Z]{105}|addr1[0-9a-zA-Z]{98}';
case CryptoCurrency.btc:
pattern =
'${P2pkhAddress.regex.pattern}|${P2shAddress.regex.pattern}|${RegExp(r'(bc|tb)1q[ac-hj-np-z02-9]{25,39}}').pattern}|${P2trAddress.regex.pattern}|${P2wshAddress.regex.pattern}|${SilentPaymentAddress.regex.pattern}';
'${P2pkhAddress.regex.pattern}|${P2shAddress.regex.pattern}|${P2wpkhAddress.regex.pattern}|${P2trAddress.regex.pattern}|${P2wshAddress.regex.pattern}|${SilentPaymentAddress.regex.pattern}';
case CryptoCurrency.ltc:
pattern = '^${RegExp(r'ltc1q[ac-hj-np-z02-9]{25,39}').pattern}\$|^${MwebAddress.regex.pattern}\$';
pattern = '${P2wpkhAddress.regex.pattern}|${MwebAddress.regex.pattern}';
case CryptoCurrency.nano:
pattern = '[0-9a-zA-Z_]+';
case CryptoCurrency.banano:
@ -335,10 +335,6 @@ class AddressValidator extends TextValidator {
}
}
if (pattern != null) {
return "$BEFORE_REGEX($pattern)$AFTER_REGEX";
}
return null;
return pattern != null ? "($pattern)" : null;
}
}