Updated on 2026-08-14
This commit is contained in:
parent
e182d88ebe
commit
73ba136063
13 changed files with 274 additions and 100 deletions
|
|
@ -34,14 +34,11 @@ class TransactionManagerImpl(
|
|||
) : TransactionManager {
|
||||
|
||||
override suspend fun sendApproveTransaction(
|
||||
networkId: String,
|
||||
feeAmount: BigDecimal,
|
||||
gasLimit: Int,
|
||||
destinationAddress: String,
|
||||
dataToSign: String,
|
||||
txData: ApproveTxData,
|
||||
derivationPath: String?,
|
||||
analyticsData: AnalyticsData,
|
||||
): SendTxResult {
|
||||
val blockchain = requireNotNull(Blockchain.fromNetworkId(networkId)) { "blockchain not found" }
|
||||
val blockchain = requireNotNull(Blockchain.fromNetworkId(txData.networkId)) { "blockchain not found" }
|
||||
val walletManager = getActualWalletManager(blockchain, derivationPath)
|
||||
walletManager.update()
|
||||
val amount = Amount(value = BigDecimal.ZERO, blockchain = blockchain)
|
||||
|
|
@ -49,40 +46,55 @@ class TransactionManagerImpl(
|
|||
walletManager = walletManager,
|
||||
amount = amount,
|
||||
blockchain = blockchain,
|
||||
feeAmount = feeAmount,
|
||||
gasLimit = gasLimit,
|
||||
destinationAddress = destinationAddress,
|
||||
dataToSign = dataToSign,
|
||||
feeAmount = txData.feeAmount,
|
||||
gasLimit = txData.gasLimit,
|
||||
destinationAddress = txData.destinationAddress,
|
||||
dataToSign = txData.dataToSign,
|
||||
successEvent = AnalyticsParam.TxSentFrom.Approve(
|
||||
blockchain = blockchain.fullName,
|
||||
token = analyticsData.tokenSymbol,
|
||||
feeType = AnalyticsParam.FeeType.fromString(analyticsData.feeType),
|
||||
permissionType = analyticsData.permissionType ?: "",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun sendTransaction(
|
||||
networkId: String,
|
||||
amountToSend: BigDecimal,
|
||||
feeAmount: BigDecimal,
|
||||
gasLimit: Int,
|
||||
destinationAddress: String,
|
||||
dataToSign: String,
|
||||
txData: SwapTxData,
|
||||
isSwap: Boolean,
|
||||
currencyToSend: Currency,
|
||||
derivationPath: String?,
|
||||
analyticsData: AnalyticsData,
|
||||
): SendTxResult {
|
||||
val blockchain = requireNotNull(Blockchain.fromNetworkId(networkId)) { "blockchain not found" }
|
||||
val blockchain = requireNotNull(Blockchain.fromNetworkId(txData.networkId)) { "blockchain not found" }
|
||||
val walletManager = getActualWalletManager(blockchain, derivationPath)
|
||||
walletManager.update()
|
||||
val amount = if (isSwap) {
|
||||
createAmountForSwap(amountToSend, currencyToSend, blockchain)
|
||||
createAmountForSwap(txData.amountToSend, txData.currencyToSend, blockchain)
|
||||
} else {
|
||||
createAmount(amountToSend, currencyToSend, blockchain)
|
||||
createAmount(txData.amountToSend, txData.currencyToSend, blockchain)
|
||||
}
|
||||
val successEvent = if (isSwap) {
|
||||
AnalyticsParam.TxSentFrom.Swap(
|
||||
blockchain = blockchain.fullName,
|
||||
token = analyticsData.tokenSymbol,
|
||||
feeType = AnalyticsParam.FeeType.fromString(analyticsData.feeType),
|
||||
)
|
||||
} else {
|
||||
AnalyticsParam.TxSentFrom.Send(
|
||||
blockchain = blockchain.fullName,
|
||||
token = analyticsData.tokenSymbol,
|
||||
feeType = AnalyticsParam.FeeType.fromString(analyticsData.feeType),
|
||||
)
|
||||
}
|
||||
return sendTransactionInternal(
|
||||
walletManager = walletManager,
|
||||
amount = amount,
|
||||
blockchain = blockchain,
|
||||
feeAmount = feeAmount,
|
||||
gasLimit = gasLimit,
|
||||
destinationAddress = destinationAddress,
|
||||
dataToSign = dataToSign,
|
||||
feeAmount = txData.feeAmount,
|
||||
gasLimit = txData.gasLimit,
|
||||
destinationAddress = txData.destinationAddress,
|
||||
dataToSign = txData.dataToSign,
|
||||
successEvent = successEvent,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +107,7 @@ class TransactionManagerImpl(
|
|||
gasLimit: Int,
|
||||
destinationAddress: String,
|
||||
dataToSign: String,
|
||||
successEvent: AnalyticsParam.TxSentFrom,
|
||||
): SendTxResult {
|
||||
val txData = walletManager.createTransaction(
|
||||
amount = amount,
|
||||
|
|
@ -110,7 +123,10 @@ class TransactionManagerImpl(
|
|||
FirebaseCrashlytics.getInstance().recordException(ex)
|
||||
return SendTxResult.UnknownError(ex)
|
||||
}
|
||||
return handleSendResult(sendResult)
|
||||
return handleSendResult(
|
||||
result = sendResult,
|
||||
successEvent = successEvent,
|
||||
)
|
||||
}
|
||||
|
||||
override fun getExplorerTransactionLink(networkId: String, txAddress: String): String {
|
||||
|
|
@ -319,10 +335,10 @@ class TransactionManagerImpl(
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleSendResult(result: SimpleResult): SendTxResult {
|
||||
private fun handleSendResult(result: SimpleResult, successEvent: AnalyticsParam.TxSentFrom): SendTxResult {
|
||||
when (result) {
|
||||
is SimpleResult.Success -> {
|
||||
analytics.send(Basic.TransactionSent(AnalyticsParam.TxSentFrom.Swap))
|
||||
analytics.send(Basic.TransactionSent(sentFrom = successEvent))
|
||||
return SendTxResult.Success
|
||||
}
|
||||
is SimpleResult.Failure -> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue