Updated on 2026-08-14
This commit is contained in:
parent
30b52bc194
commit
fe21d8801c
7 changed files with 25 additions and 8 deletions
|
|
@ -65,6 +65,9 @@ data class FeeData(
|
|||
|
||||
@Json(name = "baseGas")
|
||||
val baseGas: String,
|
||||
|
||||
@Json(name = "feeReceiver")
|
||||
val feeReceiver: String,
|
||||
)
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class DefaultGaslessTransactionRepository(
|
|||
private val supportedTokensState = MutableStateFlow<Map<Network.ID, Set<CryptoCurrency>>>(hashMapOf())
|
||||
private val allFeeRecipientAddress = mutableSetOf<String>()
|
||||
private val addressesMutex = Mutex()
|
||||
private var feeReceiverAddress: String? = null
|
||||
|
||||
private val gaslessTransactionRequestBuilder = GaslessTransactionRequestBuilder()
|
||||
private val signedTransactionResultConverter = GaslessSignedTransactionResultConverter()
|
||||
|
|
@ -77,11 +78,18 @@ class DefaultGaslessTransactionRepository(
|
|||
|
||||
override suspend fun getTokenFeeReceiverAddress(): String {
|
||||
return withContext(coroutineDispatcherProvider.io) {
|
||||
val response = gaslessTxServiceApi.getFeeRecipient().getOrThrow()
|
||||
if (response.isSuccess) {
|
||||
response.result.address
|
||||
} else {
|
||||
error("Gasless service returned unsuccessful response")
|
||||
addressesMutex.withLock {
|
||||
val feeReceiver = feeReceiverAddress
|
||||
if (feeReceiver != null) {
|
||||
return@withContext feeReceiver
|
||||
}
|
||||
val response = gaslessTxServiceApi.getFeeRecipient().getOrThrow()
|
||||
if (response.isSuccess) {
|
||||
feeReceiverAddress = response.result.address
|
||||
response.result.address
|
||||
} else {
|
||||
error("Gasless service returned unsuccessful response")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class GaslessTxDataToGaslessRequestConverter : Converter<GaslessTransactionData,
|
|||
coinPriceInToken = fee.coinPriceInToken.toString(),
|
||||
feeTransferGasLimit = fee.feeTransferGasLimit.toString(),
|
||||
baseGas = fee.baseGas.toString(),
|
||||
feeReceiver = fee.feeReceiver,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +56,7 @@ data class GaslessTransactionData(
|
|||
* @property coinPriceInToken price of native coin in fee token units
|
||||
* @property feeTransferGasLimit gas limit for fee token transfer
|
||||
* @property baseGas base gas cost (currently constant BASE_GAS, may vary in future)
|
||||
* @property feeReceiver address receiving the fee payment
|
||||
*/
|
||||
data class Fee(
|
||||
val feeToken: String,
|
||||
|
|
@ -63,5 +64,6 @@ data class GaslessTransactionData(
|
|||
val coinPriceInToken: BigInteger,
|
||||
val feeTransferGasLimit: BigInteger,
|
||||
val baseGas: BigInteger,
|
||||
val feeReceiver: String,
|
||||
)
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ class CreateAndSendGaslessTransactionUseCase(
|
|||
}
|
||||
}
|
||||
|
||||
private fun createGaslessTransactionData(
|
||||
private suspend fun createGaslessTransactionData(
|
||||
transactionData: TransactionData.Uncompiled,
|
||||
txFee: TransactionFeeExtended,
|
||||
tokenFeeStatus: CryptoCurrencyStatus,
|
||||
|
|
@ -272,7 +272,7 @@ class CreateAndSendGaslessTransactionUseCase(
|
|||
)
|
||||
}
|
||||
|
||||
private fun buildFee(
|
||||
private suspend fun buildFee(
|
||||
txFee: TransactionFeeExtended,
|
||||
tokenFeeStatus: CryptoCurrencyStatus,
|
||||
): GaslessTransactionData.Fee {
|
||||
|
|
@ -288,6 +288,7 @@ class CreateAndSendGaslessTransactionUseCase(
|
|||
coinPriceInToken = feeInTokenCurrency.coinPriceInToken,
|
||||
feeTransferGasLimit = feeInTokenCurrency.feeTransferGasLimit,
|
||||
baseGas = feeInTokenCurrency.baseGas,
|
||||
feeReceiver = gaslessTransactionRepository.getTokenFeeReceiverAddress(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ object Eip712TypedDataBuilder {
|
|||
put(typeProperty("coinPriceInToken", "uint256"))
|
||||
put(typeProperty("feeTransferGasLimit", "uint256"))
|
||||
put(typeProperty("baseGas", "uint256"))
|
||||
put(typeProperty("feeReceiver", "address"))
|
||||
})
|
||||
put("GaslessTransaction", JSONArray().apply {
|
||||
put(typeProperty("transaction", "Transaction"))
|
||||
|
|
@ -117,6 +118,7 @@ object Eip712TypedDataBuilder {
|
|||
put("coinPriceInToken", gaslessTransaction.fee.coinPriceInToken.toString())
|
||||
put("feeTransferGasLimit", gaslessTransaction.fee.feeTransferGasLimit.toString())
|
||||
put("baseGas", gaslessTransaction.fee.baseGas.toString())
|
||||
put("feeReceiver", gaslessTransaction.fee.feeReceiver)
|
||||
})
|
||||
put("nonce", gaslessTransaction.nonce.toString())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# https://github.com/tangem/tangem-sdk-android/
|
||||
# https://github.com/tangem/vico
|
||||
|
||||
tangemBlockchainSdk = "develop-1387"
|
||||
tangemBlockchainSdk = "develop-1391"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "develop-573"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue