Updated on 2026-08-14
This commit is contained in:
parent
b01b575e63
commit
f81e51f4c4
2 changed files with 81 additions and 9 deletions
|
|
@ -0,0 +1,74 @@
|
|||
package com.tangem.data.transaction
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.transaction.GaslessTransactionRepository
|
||||
import com.tangem.domain.transaction.models.Eip7702Authorization
|
||||
import com.tangem.domain.transaction.models.GaslessSignedTransactionResult
|
||||
import com.tangem.domain.transaction.models.GaslessTransactionData
|
||||
import java.math.BigInteger
|
||||
|
||||
class MockedGaslessTransactionRepository(
|
||||
private val responseCryptoCurrenciesFactory: ResponseCryptoCurrenciesFactory,
|
||||
) : GaslessTransactionRepository {
|
||||
|
||||
override fun isNetworkSupported(network: Network): Boolean {
|
||||
val blockchain = Blockchain.fromNetworkId(network.backendId) ?: return false
|
||||
return SUPPORTED_BLOCKCHAINS.contains(blockchain)
|
||||
}
|
||||
|
||||
override suspend fun getSupportedTokens(network: Network): Set<CryptoCurrency> {
|
||||
val usdcPolygon = responseCryptoCurrenciesFactory.createToken(
|
||||
blockchain = Blockchain.Polygon,
|
||||
sdkToken = Token(
|
||||
contractAddress = "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
|
||||
name = "USD Coin",
|
||||
symbol = "USDC",
|
||||
decimals = 6,
|
||||
),
|
||||
network = network,
|
||||
)
|
||||
return setOf(usdcPolygon)
|
||||
}
|
||||
|
||||
override fun getTokenFeeReceiverAddress(): String {
|
||||
return TOKEN_RECEIVER_ADDRESS
|
||||
}
|
||||
|
||||
override suspend fun sendGaslessTransaction(
|
||||
gaslessTransactionData: GaslessTransactionData,
|
||||
signature: String,
|
||||
userAddress: String,
|
||||
network: Network,
|
||||
eip7702Auth: Eip7702Authorization?,
|
||||
): GaslessSignedTransactionResult = GaslessSignedTransactionResult(
|
||||
signedTransaction = "0x000",
|
||||
gasLimit = 100000.toBigInteger(),
|
||||
maxFeePerGas = 21000.toBigInteger(),
|
||||
maxPriorityFeePerGas = 21000.toBigInteger(),
|
||||
)
|
||||
|
||||
override fun getBaseGasForTransaction(): BigInteger {
|
||||
return BASE_GAS_FOR_TRANSACTION
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
const val TOKEN_RECEIVER_ADDRESS = "0x"
|
||||
|
||||
val BASE_GAS_FOR_TRANSACTION: BigInteger = BigInteger("100000")
|
||||
val SUPPORTED_BLOCKCHAINS = arrayOf(
|
||||
Blockchain.Ethereum,
|
||||
Blockchain.BSC,
|
||||
Blockchain.Base,
|
||||
Blockchain.Polygon,
|
||||
Blockchain.Arbitrum,
|
||||
Blockchain.XDC,
|
||||
Blockchain.Optimism,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,11 +2,10 @@ package com.tangem.data.transaction.di
|
|||
|
||||
import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
|
||||
import com.tangem.data.transaction.DefaultFeeRepository
|
||||
import com.tangem.data.transaction.DefaultGaslessTransactionRepository
|
||||
import com.tangem.data.transaction.DefaultTransactionRepository
|
||||
import com.tangem.data.transaction.DefaultWalletAddressServiceRepository
|
||||
import com.tangem.data.transaction.MockedGaslessTransactionRepository
|
||||
import com.tangem.data.transaction.error.DefaultFeeErrorResolver
|
||||
import com.tangem.datasource.api.gasless.GaslessTxServiceApi
|
||||
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
||||
import com.tangem.datasource.local.walletmanager.WalletManagersStore
|
||||
import com.tangem.domain.demo.models.DemoConfig
|
||||
|
|
@ -73,14 +72,13 @@ internal object TransactionDataModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
fun provideGaslessTransactionRepository(
|
||||
gaslessTxServiceApi: GaslessTxServiceApi,
|
||||
coroutineDispatcherProvider: CoroutineDispatcherProvider,
|
||||
responseCryptoCurrenciesFactory: ResponseCryptoCurrenciesFactory,
|
||||
): GaslessTransactionRepository {
|
||||
return DefaultGaslessTransactionRepository(
|
||||
gaslessTxServiceApi,
|
||||
coroutineDispatcherProvider,
|
||||
responseCryptoCurrenciesFactory,
|
||||
)
|
||||
return MockedGaslessTransactionRepository(responseCryptoCurrenciesFactory)
|
||||
// return DefaultGaslessTransactionRepository(
|
||||
// gaslessTxServiceApi,
|
||||
// coroutineDispatcherProvider,
|
||||
// responseCryptoCurrenciesFactory,
|
||||
// )
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue