diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/decimal/DecimalAddressService.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/decimal/DecimalAddressService.kt new file mode 100644 index 000000000..457f2439b --- /dev/null +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/decimal/DecimalAddressService.kt @@ -0,0 +1,91 @@ +package com.tangem.blockchain.blockchains.decimal + +import com.tangem.blockchain.blockchains.binance.client.encoding.Crypto +import com.tangem.blockchain.common.address.AddressService +import com.tangem.blockchain.common.address.AddressType +import com.tangem.common.card.EllipticCurve +import com.tangem.common.extensions.hexToBytes +import com.tangem.common.extensions.toDecompressedPublicKey +import org.bitcoinj.core.Bech32 +import org.kethereum.crypto.toAddress +import org.kethereum.erc55.hasValidERC55ChecksumOrNoChecksum +import org.kethereum.erc55.withERC55Checksum +import org.kethereum.model.Address +import org.kethereum.model.PublicKey +import org.komputing.khex.extensions.toHexString +import com.tangem.blockchain.common.address.Address as SdkAddress + +internal class DecimalAddressService : AddressService() { + + override fun makeAddress(walletPublicKey: ByteArray, curve: EllipticCurve?): String { + return makeErcAddress(walletPublicKey) + } + + override fun makeAddresses( + walletPublicKey: ByteArray, + curve: EllipticCurve?, + ): Set { + val ercAddress = makeErcAddress(walletPublicKey) + + return setOf( + SdkAddress(ercAddress), + SdkAddress( + convertErcAddressToDscAddress(ercAddress), + AddressType.Legacy, + ) + ) + } + + private fun makeErcAddress(walletPublicKey: ByteArray): String { + val decompressedPublicKey = walletPublicKey + .toDecompressedPublicKey() + .sliceArray(1..64) + + return PublicKey(decompressedPublicKey) + .toAddress() + .withERC55Checksum() + .hex + } + + override fun validate(address: String): Boolean { + val addressToValidate = when { + address.startsWith(ADDRESS_PREFIX) || address.startsWith(LEGACY_ADDRESS_PREFIX) -> { + convertDscAddressToErcAddress(address) ?: return false + } + + else -> address + } + + return Address(addressToValidate).hasValidERC55ChecksumOrNoChecksum() + } + + companion object { + private const val ADDRESS_PREFIX = "d0" + private const val LEGACY_ADDRESS_PREFIX = "dx" + private const val ERC55_ADDRESS_PREFIX = "0x" + + fun convertDscAddressToErcAddress(addressHex: String): String? { + if (addressHex.startsWith(ERC55_ADDRESS_PREFIX)) { + return addressHex + } + + val (prefix, addressBytes) = Bech32.decode(addressHex).let { it.hrp to it.data } + if (prefix == null || addressBytes == null) return null + + val convertedAddressBytes = Crypto.convertBits(addressBytes, 0, addressBytes.size, 5, 8, false) + + return convertedAddressBytes.toHexString() + } + + fun convertErcAddressToDscAddress(addressHex: String): String { + if (addressHex.startsWith(ADDRESS_PREFIX) || addressHex.startsWith(LEGACY_ADDRESS_PREFIX)) { + return addressHex + } + + val addressBytes = addressHex.hexToBytes() + val converted = Crypto.convertBits(addressBytes, 0, addressBytes.size, 8, 5, false) + + return Bech32.encode(ADDRESS_PREFIX, converted) + } + } +} diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/decimal/DecimalWalletManager.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/decimal/DecimalWalletManager.kt new file mode 100644 index 000000000..95db45e90 --- /dev/null +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/decimal/DecimalWalletManager.kt @@ -0,0 +1,60 @@ +package com.tangem.blockchain.blockchains.decimal + +import com.tangem.blockchain.blockchains.ethereum.CompiledEthereumTransaction +import com.tangem.blockchain.blockchains.ethereum.EthereumTransactionBuilder +import com.tangem.blockchain.blockchains.ethereum.EthereumWalletManager +import com.tangem.blockchain.blockchains.ethereum.network.EthereumNetworkProvider +import com.tangem.blockchain.common.Amount +import com.tangem.blockchain.common.TransactionData +import com.tangem.blockchain.common.TransactionSigner +import com.tangem.blockchain.common.Wallet +import com.tangem.blockchain.common.transaction.TransactionFee +import com.tangem.blockchain.extensions.Result +import com.tangem.blockchain.extensions.SimpleResult +import java.math.BigInteger + +internal class DecimalWalletManager( + wallet: Wallet, + transactionBuilder: EthereumTransactionBuilder, + networkProvider: EthereumNetworkProvider, +) : EthereumWalletManager(wallet, transactionBuilder, networkProvider) { + + override suspend fun getFee(amount: Amount, destination: String): Result { + return super.getFee(amount, convertAddress(destination)) + } + + override suspend fun getFee(amount: Amount, destination: String, data: String): Result { + return super.getFee(amount, convertAddress(destination), data) + } + + override suspend fun getFeeInternal(amount: Amount, destination: String, data: String?): Result { + return super.getFeeInternal(amount, convertAddress(destination), data) + } + + override suspend fun getGasLimit(amount: Amount, destination: String): Result { + return super.getGasLimit(amount, convertAddress(destination)) + } + + override suspend fun getGasLimit(amount: Amount, destination: String, data: String): Result { + return super.getGasLimit(amount, convertAddress(destination), data) + } + + override suspend fun send(transactionData: TransactionData, signer: TransactionSigner): SimpleResult { + return super.send(convertTransactionDataAddress(transactionData), signer) + } + + override suspend fun sign( + transactionData: TransactionData, + signer: TransactionSigner, + ): Result> { + return super.sign(convertTransactionDataAddress(transactionData), signer) + } + + private fun convertTransactionDataAddress(transactionData: TransactionData) = transactionData.copy( + destinationAddress = convertAddress(transactionData.destinationAddress), + ) + + private fun convertAddress(destinationAddress: String): String { + return DecimalAddressService.convertDscAddressToErcAddress(destinationAddress) ?: destinationAddress + } +} diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumJsonRpcProvidersExt.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumJsonRpcProvidersExt.kt index 46ccc79b6..563b4f732 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumJsonRpcProvidersExt.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumJsonRpcProvidersExt.kt @@ -161,13 +161,28 @@ internal fun Blockchain.getEthereumJsonRpcProviders( EthereumJsonRpcProvider(baseUrl = "https://api.kainosbp.com", postfixUrl = "evm"), EthereumJsonRpcProvider(baseUrl = "https://telos-evm.rpc.thirdweb.com/") ) + Blockchain.TelosTestnet -> listOf( EthereumJsonRpcProvider(baseUrl = "https://telos-evm-testnet.rpc.thirdweb.com/"), ) + Blockchain.OctaSpace -> listOf( EthereumJsonRpcProvider(baseUrl = "https://rpc.octa.space"), EthereumJsonRpcProvider(baseUrl = "https://octaspace.rpc.thirdweb.com"), ) + + Blockchain.Decimal -> listOf( + EthereumJsonRpcProvider(baseUrl = "https://node.decimalchain.com/web3/"), + EthereumJsonRpcProvider(baseUrl = "https://node1-mainnet.decimalchain.com/web3/"), + EthereumJsonRpcProvider(baseUrl = "https://node2-mainnet.decimalchain.com/web3/"), + EthereumJsonRpcProvider(baseUrl = "https://node3-mainnet.decimalchain.com/web3/"), + EthereumJsonRpcProvider(baseUrl = "https://node4-mainnet.decimalchain.com/web3/"), + ) + + Blockchain.DecimalTestnet -> listOf( + EthereumJsonRpcProvider(baseUrl = "https://testnet-val.decimalchain.com/web3/") + ) + else -> throw IllegalStateException("$this isn't supported") } diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumTransactionBuilder.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumTransactionBuilder.kt index 137d1fc41..1b3b3b6b9 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumTransactionBuilder.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumTransactionBuilder.kt @@ -144,4 +144,6 @@ enum class Chain( Cronos(25, Blockchain.Cronos), OctaSpace(800001, Blockchain.OctaSpace), OctaSpaceTestnet(800002, Blockchain.OctaSpaceTestnet), + Decimal(75, Blockchain.Decimal), + DecimalTestnet(202020, Blockchain.DecimalTestnet) } diff --git a/blockchain/src/main/java/com/tangem/blockchain/common/Blockchain.kt b/blockchain/src/main/java/com/tangem/blockchain/common/Blockchain.kt index a5db120a1..9b6e8d091 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/common/Blockchain.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/common/Blockchain.kt @@ -5,6 +5,7 @@ import com.tangem.blockchain.blockchains.bitcoin.BitcoinAddressService import com.tangem.blockchain.blockchains.bitcoincash.BitcoinCashAddressService import com.tangem.blockchain.blockchains.cardano.CardanoAddressServiceFacade import com.tangem.blockchain.blockchains.chia.ChiaAddressService +import com.tangem.blockchain.blockchains.decimal.DecimalAddressService import com.tangem.blockchain.blockchains.ethereum.Chain import com.tangem.blockchain.blockchains.ethereum.EthereumAddressService import com.tangem.blockchain.blockchains.kaspa.KaspaAddressService @@ -96,6 +97,8 @@ enum class Blockchain( OctaSpaceTestnet("octaspace/test", "OCTA", "OctaSpace Testnet"), Chia("chia", "XCH", "Chia Network"), ChiaTestnet("chia/test", "TXCH", "Chia Network Testnet"), + Decimal("decimal", "DEL", "Decimal Smart Chain"), + DecimalTestnet("decimal/test", "tDEL", "Decimal Smart Chain Testnet"), ; private val externalLinkProvider: ExternalLinkProvider by lazy { ExternalLinkProviderFactory.makeProvider(this) } @@ -104,6 +107,7 @@ enum class Blockchain( Unknown -> 0 Near, NearTestnet, -> 5 + Cardano, XRP, Tezos, @@ -113,6 +117,7 @@ enum class Blockchain( -> 6 Stellar, StellarTestnet -> 7 + Bitcoin, BitcoinTestnet, BitcoinCash, BitcoinCashTestnet, Binance, BinanceTestnet, @@ -129,6 +134,7 @@ enum class Blockchain( -> 9 Polkadot -> 10 + PolkadotTestnet, Kusama, AlephZero, AlephZeroTestnet, Chia, ChiaTestnet, -> 12 @@ -148,6 +154,7 @@ enum class Blockchain( Cronos, Telos, TelosTestnet, OctaSpace, OctaSpaceTestnet, + Decimal, DecimalTestnet, -> 18 } @@ -175,7 +182,6 @@ enum class Blockchain( Dash, Ravencoin, RavencoinTestnet, -> BitcoinAddressService(this) - BitcoinCash, BitcoinCashTestnet -> BitcoinCashAddressService(this) Arbitrum, ArbitrumTestnet, Ethereum, EthereumTestnet, @@ -194,6 +200,7 @@ enum class Blockchain( OctaSpace, OctaSpaceTestnet, -> EthereumAddressService() + Decimal, DecimalTestnet -> DecimalAddressService() RSK -> RskAddressService() Cardano -> CardanoAddressServiceFacade() XRP -> XrpAddressService() @@ -205,7 +212,6 @@ enum class Blockchain( Tezos -> TezosAddressService() TON, TONTestnet, Cosmos, CosmosTestnet, TerraV1, TerraV2, Near, NearTestnet, -> TrustWalletAddressService(blockchain = this) - Tron, TronTestnet -> TronAddressService() Kaspa -> KaspaAddressService() Chia, ChiaTestnet -> ChiaAddressService(this) @@ -269,6 +275,7 @@ enum class Blockchain( OctaSpace, OctaSpaceTestnet -> OctaSpaceTestnet Chia, ChiaTestnet -> ChiaTestnet Near, NearTestnet -> NearTestnet + Decimal, DecimalTestnet -> DecimalTestnet else -> null } } @@ -313,6 +320,7 @@ enum class Blockchain( TerraV1, TerraV2, Cronos, OctaSpace, OctaSpaceTestnet, + Decimal, DecimalTestnet, -> listOf(EllipticCurve.Secp256k1) Stellar, StellarTestnet, @@ -357,6 +365,8 @@ enum class Blockchain( Cronos -> Chain.Cronos.id OctaSpace -> Chain.OctaSpace.id OctaSpaceTestnet -> Chain.OctaSpaceTestnet.id + Decimal -> Chain.Decimal.id + DecimalTestnet -> Chain.DecimalTestnet.id else -> null } } diff --git a/blockchain/src/main/java/com/tangem/blockchain/common/WalletManagerFactory.kt b/blockchain/src/main/java/com/tangem/blockchain/common/WalletManagerFactory.kt index bf544df56..3f680b74c 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/common/WalletManagerFactory.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/common/WalletManagerFactory.kt @@ -4,8 +4,6 @@ import com.tangem.blockchain.common.assembly.WalletManagerAssembly import com.tangem.blockchain.common.assembly.WalletManagerAssemblyInput import com.tangem.blockchain.common.assembly.impl.* import com.tangem.common.card.EllipticCurve -import com.tangem.crypto.hdWallet.DerivationPath -import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey class WalletManagerFactory(private val config: BlockchainSdkConfig = BlockchainSdkConfig()) { @@ -153,6 +151,10 @@ class WalletManagerFactory(private val config: BlockchainSdkConfig = BlockchainS EthereumLikeWalletManagerAssembly } + Blockchain.Decimal, Blockchain.DecimalTestnet -> { + DecimalWalletManagerAssembly + } + Blockchain.Optimism, Blockchain.OptimismTestnet -> { OptimismWalletManagerAssembly } diff --git a/blockchain/src/main/java/com/tangem/blockchain/common/assembly/impl/DecimalWalletManagerAssembly.kt b/blockchain/src/main/java/com/tangem/blockchain/common/assembly/impl/DecimalWalletManagerAssembly.kt new file mode 100644 index 000000000..39f65221a --- /dev/null +++ b/blockchain/src/main/java/com/tangem/blockchain/common/assembly/impl/DecimalWalletManagerAssembly.kt @@ -0,0 +1,26 @@ +package com.tangem.blockchain.common.assembly.impl + +import com.tangem.blockchain.blockchains.decimal.DecimalWalletManager +import com.tangem.blockchain.blockchains.ethereum.EthereumTransactionBuilder +import com.tangem.blockchain.blockchains.ethereum.getEthereumJsonRpcProviders +import com.tangem.blockchain.blockchains.ethereum.network.EthereumNetworkService +import com.tangem.blockchain.common.assembly.WalletManagerAssembly +import com.tangem.blockchain.common.assembly.WalletManagerAssemblyInput + +internal object DecimalWalletManagerAssembly : WalletManagerAssembly() { + + override fun make(input: WalletManagerAssemblyInput): DecimalWalletManager { + return with(input.wallet) { + DecimalWalletManager( + wallet = this, + transactionBuilder = EthereumTransactionBuilder( + walletPublicKey = publicKey.blockchainKey, + blockchain = blockchain + ), + networkProvider = EthereumNetworkService( + jsonRpcProviders = blockchain.getEthereumJsonRpcProviders(input.config), + ) + ) + } + } +} diff --git a/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV1.kt b/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV1.kt index 7d2813cb3..fac92c27f 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV1.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV1.kt @@ -58,10 +58,12 @@ object DerivationConfigV1 : DerivationConfig() { Blockchain.Ethereum, Blockchain.EthereumPow, Blockchain.EthereumFair, - Blockchain.OctaSpace + Blockchain.OctaSpace, + Blockchain.Decimal, -> { mapOf(AddressType.Default to DerivationPath("m/44'/60'/0'/0/0")) } + Blockchain.EthereumClassic -> { mapOf(AddressType.Default to DerivationPath("m/44'/61'/0'/0/0")) } @@ -174,9 +176,10 @@ object DerivationConfigV1 : DerivationConfig() { Blockchain.AlephZeroTestnet, Blockchain.OctaSpaceTestnet, Blockchain.NearTestnet, + Blockchain.DecimalTestnet, -> { mapOf(AddressType.Default to DerivationPath("m/44'/1'/0'/0/0")) } } } -} \ No newline at end of file +} diff --git a/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV2.kt b/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV2.kt index 2450e576f..08be807cc 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV2.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV2.kt @@ -71,9 +71,12 @@ object DerivationConfigV2 : DerivationConfig() { Blockchain.Kava, Blockchain.Cronos, Blockchain.Telos, - Blockchain.OctaSpace -> { + Blockchain.OctaSpace, + Blockchain.Decimal, + -> { mapOf(AddressType.Default to DerivationPath("m/44'/60'/0'/0/0")) } + Blockchain.Binance -> { mapOf(AddressType.Default to DerivationPath("m/44'/714'/0'/0/0")) } @@ -148,10 +151,11 @@ object DerivationConfigV2 : DerivationConfig() { Blockchain.TelosTestnet, Blockchain.AlephZeroTestnet, Blockchain.OctaSpaceTestnet, - Blockchain.NearTestnet + Blockchain.NearTestnet, + Blockchain.DecimalTestnet, -> { mapOf(AddressType.Default to DerivationPath("m/44'/1'/0'/0/0")) } } } -} \ No newline at end of file +} diff --git a/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV3.kt b/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV3.kt index e3c924536..b30cfeb91 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV3.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/common/derivation/DerivationConfigV3.kt @@ -28,7 +28,6 @@ object DerivationConfigV3 : DerivationConfig() { Blockchain.Bitcoin -> { mapOf(AddressType.Default to DerivationPath("m/84'/0'/0'/0/0")) } - Blockchain.Litecoin -> { mapOf(AddressType.Default to DerivationPath("m/84'/2'/0'/0/0")) } @@ -44,7 +43,6 @@ object DerivationConfigV3 : DerivationConfig() { Blockchain.Cardano -> { mapOf(AddressType.Default to DerivationPath("m/1852'/1815'/0'/0/0")) } - Blockchain.BitcoinCash -> { mapOf( AddressType.Default to DerivationPath("m/44'/145'/0'/0/0"), @@ -67,9 +65,11 @@ object DerivationConfigV3 : DerivationConfig() { Blockchain.Cronos, Blockchain.Telos, Blockchain.OctaSpace, + Blockchain.Decimal, -> { mapOf(AddressType.Default to DerivationPath("m/44'/60'/0'/0/0")) } + Blockchain.EthereumClassic -> { mapOf(AddressType.Default to DerivationPath("m/44'/61'/0'/0/0")) } @@ -147,10 +147,11 @@ object DerivationConfigV3 : DerivationConfig() { Blockchain.TelosTestnet, Blockchain.AlephZeroTestnet, Blockchain.OctaSpaceTestnet, - Blockchain.NearTestnet + Blockchain.NearTestnet, + Blockchain.DecimalTestnet, -> { mapOf(AddressType.Default to DerivationPath("m/44'/1'/0'/0/0")) } } } -} \ No newline at end of file +} diff --git a/blockchain/src/main/java/com/tangem/blockchain/externallinkprovider/ExternalLinkProviderFactory.kt b/blockchain/src/main/java/com/tangem/blockchain/externallinkprovider/ExternalLinkProviderFactory.kt index 7b5342d73..bce8f678c 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/externallinkprovider/ExternalLinkProviderFactory.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/externallinkprovider/ExternalLinkProviderFactory.kt @@ -51,6 +51,7 @@ internal object ExternalLinkProviderFactory { Blockchain.OctaSpace -> OctaSpaceExternalLinkProvider() Blockchain.OctaSpaceTestnet -> throw Exception("unsupported blockchain") Blockchain.Chia, Blockchain.ChiaTestnet -> ChiaExternalLinkProvider(isTestnet) + Blockchain.Decimal, Blockchain.DecimalTestnet -> DecimalExternalLinkProvider(isTestnet) } } } diff --git a/blockchain/src/main/java/com/tangem/blockchain/externallinkprovider/providers/DecimalExternalLinkProvider.kt b/blockchain/src/main/java/com/tangem/blockchain/externallinkprovider/providers/DecimalExternalLinkProvider.kt new file mode 100644 index 000000000..87a29e8d2 --- /dev/null +++ b/blockchain/src/main/java/com/tangem/blockchain/externallinkprovider/providers/DecimalExternalLinkProvider.kt @@ -0,0 +1,25 @@ +package com.tangem.blockchain.externallinkprovider.providers + +import com.tangem.blockchain.blockchains.decimal.DecimalAddressService +import com.tangem.blockchain.externallinkprovider.ExternalLinkProvider + +internal class DecimalExternalLinkProvider(isTestnet: Boolean) : ExternalLinkProvider { + + override val explorerBaseUrl: String = if (isTestnet) { + "https://testnet.explorer.decimalchain.com/" + } else { + "https://explorer.decimalchain.com/" + } + + override val testNetTopUpUrl: String = "https://testnet.console.decimalchain.com/wallet/" + + override fun explorerUrl(walletAddress: String, contractAddress: String?): String { + val address = DecimalAddressService.convertErcAddressToDscAddress(walletAddress) + + return explorerBaseUrl + "address/$address" + } + + override fun explorerTransactionUrl(transactionHash: String): String { + return explorerBaseUrl + "transactions/$transactionHash" + } +} diff --git a/blockchain/src/test/java/com/tangem/blockchain/blockchains/decimal/DecimalAddressTest.kt b/blockchain/src/test/java/com/tangem/blockchain/blockchains/decimal/DecimalAddressTest.kt new file mode 100644 index 000000000..eebff205e --- /dev/null +++ b/blockchain/src/test/java/com/tangem/blockchain/blockchains/decimal/DecimalAddressTest.kt @@ -0,0 +1,35 @@ +package com.tangem.blockchain.blockchains.decimal + +import com.google.common.truth.Truth +import com.tangem.common.extensions.hexToBytes +import org.junit.Test + +internal class DecimalAddressTest { + + private val addressService = DecimalAddressService() + + @Test + fun makeAddressFromCorrectPublicKey() { + val walletPublicKey = + "04BAEC8CD3BA50FDFE1E8CF2B04B58E17041245341CD1F1C6B3A496B48956DB4C896A6848BCF8FCFC33B88341507DD25E5F4609386C68086C74CF472B86E5C3820".hexToBytes() + val expectedAddress = "0xc63763572D45171e4C25cA0818b44E5Dd7F5c15B" + + Truth.assertThat(addressService.makeAddress(walletPublicKey)).isEqualTo(expectedAddress) + } + + @Test + fun validateCorrectAddress() { + val address = "0xc63763572d45171e4c25ca0818b44e5dd7f5c15b" + + Truth.assertThat(addressService.validate(address)).isTrue() + } + + @Test + fun validateCorrectAddressWithChecksum() { + val ercAddress = "0xc63763572D45171e4C25cA0818b44E5Dd7F5c15B" + val dscAddress = "d01ccmkx4edg5t3unp9egyp3dzwthtlts2m320gh9" + + Truth.assertThat(addressService.validate(ercAddress)).isTrue() + Truth.assertThat(addressService.validate(dscAddress)).isTrue() + } +}