mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
feat: add optional parameter to customize address extraction pattern
This commit is contained in:
parent
e5d0194f11
commit
3af22422a8
2 changed files with 5 additions and 3 deletions
|
@ -284,7 +284,7 @@ class AddressValidator extends TextValidator {
|
|||
static String get silentPaymentAddressPattern => SilentPaymentAddress.regex.pattern;
|
||||
static String get mWebAddressPattern => MwebAddress.regex.pattern;
|
||||
|
||||
static String? getAddressFromStringPattern(CryptoCurrency type) {
|
||||
static String? getAddressFromStringPattern(CryptoCurrency type, [bool requireJustAddress = true]) {
|
||||
String? pattern = null;
|
||||
|
||||
switch (type) {
|
||||
|
@ -336,7 +336,9 @@ class AddressValidator extends TextValidator {
|
|||
}
|
||||
|
||||
if (pattern != null) {
|
||||
return "$BEFORE_REGEX($pattern)$AFTER_REGEX";
|
||||
if (requireJustAddress)
|
||||
return "$BEFORE_REGEX($pattern)$AFTER_REGEX";
|
||||
return "($pattern)";
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -166,7 +166,7 @@ class AddressResolver {
|
|||
];
|
||||
|
||||
static String? extractAddressByType({required String raw, required CryptoCurrency type}) {
|
||||
final addressPattern = AddressValidator.getAddressFromStringPattern(type);
|
||||
final addressPattern = AddressValidator.getAddressFromStringPattern(type, false);
|
||||
|
||||
if (addressPattern == null) {
|
||||
throw Exception('Unexpected token: $type for getAddressFromStringPattern');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue