Updated on 2026-08-14

This commit is contained in:
Tangem 2023-04-07 20:39:24 +08:00
parent 069605e151
commit 36516c900f
234 changed files with 902 additions and 1618 deletions

View file

@ -10,10 +10,5 @@ interface ReferralRepository {
suspend fun getReferralStatus(walletId: String): ReferralData
/** Starts user referral program */
suspend fun startReferral(
walletId: String,
networkId: String,
tokenId: String,
address: String,
): ReferralData
suspend fun startReferral(walletId: String, networkId: String, tokenId: String, address: String): ReferralData
}

View file

@ -102,8 +102,11 @@ internal class SwapRepositoryImpl @Inject constructor(
}
}
override suspend fun checkTokensSpendAllowance(networkId: String, tokenAddress: String, walletAddress: String):
AggregatedSwapDataModel<String> {
override suspend fun checkTokensSpendAllowance(
networkId: String,
tokenAddress: String,
walletAddress: String,
): AggregatedSwapDataModel<String> {
return withContext(coroutineDispatcher.io) {
try {
val response = oneInchErrorsHandler.handleOneInchResponse(

View file

@ -305,11 +305,7 @@ internal class SwapInteractorImpl @Inject constructor(
return allowance.error == DataError.NoError && allowance.dataModel != ZERO_BALANCE
}
private fun createEmptyAmountState(
networkId: String,
fromToken: Currency,
toToken: Currency,
): SwapState {
private fun createEmptyAmountState(networkId: String, fromToken: Currency, toToken: Currency): SwapState {
val appCurrency = userWalletManager.getUserAppCurrency()
val fromTokenBalance = cache.getBalanceForToken(networkId, derivationPath, fromToken.symbol)
val toTokenBalance = cache.getBalanceForToken(networkId, derivationPath, toToken.symbol)
@ -372,10 +368,7 @@ internal class SwapInteractorImpl @Inject constructor(
}
}
private suspend fun getFormattedFiatFee(
networkId: String,
fee: BigDecimal,
): String {
private suspend fun getFormattedFiatFee(networkId: String, fee: BigDecimal): String {
val appCurrency = userWalletManager.getUserAppCurrency()
val nativeToken = userWalletManager.getNativeTokenForNetwork(networkId)
val rates = repository.getRates(appCurrency.code, listOf(nativeToken.id))

View file

@ -32,11 +32,7 @@ interface SwapRepository {
* @param tokenAddress token you want to exchange
* @param amount number of tokens is allowed. By default infinite
*/
suspend fun dataToApprove(
networkId: String,
tokenAddress: String,
amount: String? = null,
): ApproveModel
suspend fun dataToApprove(networkId: String, tokenAddress: String, amount: String? = null): ApproveModel
/**
* Get the number of tokens that the 1inch router is allowed to spend

View file

@ -37,9 +37,7 @@ class SwapDomainModule {
@Provides
@Singleton
fun provideBlockchainInteractor(
transactionManager: TransactionManager,
): BlockchainInteractor {
fun provideBlockchainInteractor(transactionManager: TransactionManager): BlockchainInteractor {
return BlockchainInteractorImpl(
transactionManager = transactionManager,
)

View file

@ -9,9 +9,11 @@ sealed class DataError {
fun mapErrors(error: String?): DataError {
return if (error == null) {
DataError.NoError
} else when (error) {
INSUFFICIENT_LIQUIDITY_ERROR -> DataError.InsufficientLiquidity
else -> DataError.UnknownError(error)
} else {
when (error) {
INSUFFICIENT_LIQUIDITY_ERROR -> DataError.InsufficientLiquidity
else -> DataError.UnknownError(error)
}
}
}

View file

@ -290,11 +290,7 @@ internal class StateBuilder(val actions: UiActions) {
)
}
fun createErrorTransaction(
uiState: SwapStateHolder,
txState: TxState,
onAlertClick: () -> Unit,
): SwapStateHolder {
fun createErrorTransaction(uiState: SwapStateHolder, txState: TxState, onAlertClick: () -> Unit): SwapStateHolder {
return uiState.copy(
alert = SwapWarning.GenericWarning(
message = null,

View file

@ -293,9 +293,7 @@ private fun FeeItem(feeState: FeeState, currency: String) {
}
@Composable
private fun SwapWarnings(
warnings: List<SwapWarning>,
) {
private fun SwapWarnings(warnings: List<SwapWarning>) {
Column(
modifier = Modifier
.background(color = TangemTheme.colors.background.secondary)

View file

@ -198,10 +198,7 @@ private fun TokenItem(token: TokenToSelect, network: Network, onTokenClick: () -
@Suppress("MagicNumber")
@Composable
private fun TokenIcon(
token: TokenToSelect,
@DrawableRes iconPlaceholder: Int?,
) {
private fun TokenIcon(token: TokenToSelect, @DrawableRes iconPlaceholder: Int?) {
val data = token.iconUrl.ifEmpty {
iconPlaceholder
}
@ -233,9 +230,7 @@ private fun TokenIcon(
}
@Composable
private fun TokenImageShimmer(
modifier: Modifier = Modifier,
) {
private fun TokenImageShimmer(modifier: Modifier = Modifier) {
Box(modifier = modifier.shimmer()) {
Box(
modifier = Modifier

View file

@ -121,11 +121,7 @@ fun TransactionCard(
}
@Composable
private fun Header(
type: TransactionCardType,
balance: String,
modifier: Modifier = Modifier,
) {
private fun Header(type: TransactionCardType, balance: String, modifier: Modifier = Modifier) {
Row(
modifier = modifier
.fillMaxWidth()
@ -383,9 +379,7 @@ private fun makePriceImpactBalanceWarning(value: String, priceImpactPercents: In
}
@Composable
private fun TokenImageShimmer(
modifier: Modifier = Modifier,
) {
private fun TokenImageShimmer(modifier: Modifier = Modifier) {
Box(modifier = modifier.shimmer()) {
Box(
modifier = Modifier

View file

@ -159,11 +159,7 @@ internal class SwapViewModel @Inject constructor(
}
}
private fun loadQuotesTask(
fromToken: Currency,
toToken: Currency,
amount: String,
): PeriodicTask<SwapState> {
private fun loadQuotesTask(fromToken: Currency, toToken: Currency, amount: String): PeriodicTask<SwapState> {
return PeriodicTask(
UPDATE_DELAY,
task = {

View file

@ -20,10 +20,7 @@ import com.tangem.feature.tester.impl.R
@OptIn(ExperimentalFoundationApi::class)
@Composable
internal fun TesterActionsScreen(
state: TesterActionsContentState,
modifier: Modifier = Modifier,
) {
internal fun TesterActionsScreen(state: TesterActionsContentState, modifier: Modifier = Modifier) {
LazyColumn(
modifier = modifier
.fillMaxSize()
@ -48,11 +45,7 @@ internal fun TesterActionsScreen(
}
@Composable
private fun TesterActionItem(
progress: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
private fun TesterActionItem(progress: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier) {
Box(modifier = modifier.padding(all = TangemTheme.dimens.spacing16)) {
PrimaryButton(
modifier = Modifier.fillMaxWidth(),
@ -65,9 +58,7 @@ private fun TesterActionItem(
// region Preview
@Composable
private fun TesterActionsScreenSample(
modifier: Modifier = Modifier,
) {
private fun TesterActionsScreenSample(modifier: Modifier = Modifier) {
Column(
modifier = modifier
.background(TangemTheme.colors.background.primary),