diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/parsers/BEP2AddressParser.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/parsers/BEP2AddressParser.kt deleted file mode 100644 index 3b66c631a9..0000000000 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/parsers/BEP2AddressParser.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2024 Dash Core Group. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.dash.wallet.integrations.maya.payments.parsers - -import org.bitcoinj.core.AddressFormatException -import org.bitcoinj.core.Base58 -import org.dash.wallet.common.payments.parsers.AddressParser - -open class BEP2AddressParser(val prefix: String) : AddressParser( - "[$prefix${Base58.ALPHABET.joinToString(separator = "")}]{24}", - null -) { - override fun verifyAddress(address: String) { - if (!address.startsWith(prefix)) { - throw AddressFormatException.InvalidPrefix("$prefix is not allowed for BEP2 $prefix addres") - } - if (address.length != 42) { - throw AddressFormatException.InvalidDataLength( - "length is incorrect for BEP2 $prefix address, ${address.length} != 42" - ) - } - - try { - val decoded = Base58.decode(address.substring(4)) - if (decoded.size != 24) { - throw AddressFormatException.InvalidDataLength( - "length is invalid after decoding base58 for BEP2 $prefix addres, ${decoded.size} != 24" - ) - } - } catch (e: Exception) { - throw AddressFormatException("BEP2 $prefix address is invalid: ${e.message}") - } - } -} diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/parsers/BEP2PaymentIntentParser.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/parsers/BEP2PaymentIntentParser.kt deleted file mode 100644 index 9a6d1d7b3c..0000000000 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/parsers/BEP2PaymentIntentParser.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2024 Dash Core Group. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.dash.wallet.integrations.maya.payments.parsers - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext -import org.bitcoinj.core.AddressFormatException -import org.dash.wallet.common.R -import org.dash.wallet.common.data.PaymentIntent -import org.dash.wallet.common.payments.parsers.PaymentIntentParserException -import org.dash.wallet.common.util.ResourceString -import org.slf4j.LoggerFactory - -open class BEP2PaymentIntentParser(currency: String, prefix: String, asset: String) : - MayaPaymentIntentParser(currency, asset, null) { - - private val log = LoggerFactory.getLogger(BEP2PaymentIntentParser::class.java) - private val addressParser = BEP2AddressParser(prefix) - override suspend fun parse(input: String): PaymentIntent = withContext(Dispatchers.Default) { - if (input.startsWith("$currency:") || input.startsWith("${currency.uppercase()}:")) { - try { - val hexAddress = input.substring(currency.length) - return@withContext createPaymentIntent(hexAddress) - } catch (ex: Exception) { - log.info("got invalid uri: '$input'", ex) - throw PaymentIntentParserException( - ex, - ResourceString( - R.string.error, - listOf(input) - ) - ) - } - } else if (addressParser.exactMatch(input)) { - try { - return@withContext createPaymentIntent(input) - } catch (ex: AddressFormatException) { - log.info("got invalid address", ex) - throw PaymentIntentParserException( - ex, - ResourceString( - R.string.error, - listOf() - ) - ) - } - } - - log.info("cannot classify: '{}'", input) - throw PaymentIntentParserException( - IllegalArgumentException(input), - ResourceString( - R.string.error, - listOf(input) - ) - ) - } -} diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt index 7c15200c93..b9f8f305d9 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt @@ -24,7 +24,6 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController -import androidx.navigation.navGraphViewModels import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch import org.dash.wallet.common.ui.decorators.ListDividerDecorator