Skip to content

Commit

Permalink
pr changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-rdx committed Jan 16, 2024
1 parent 221a495 commit 30efd2a
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ suspend fun StateApi.fetchAccountGatewayDetails(
suspend fun StateApi.fetchPools(
poolAddresses: Set<String>,
stateVersion: Long
): List<FetchPoolsResult> {
): List<PoolsResponse> {
if (poolAddresses.isEmpty()) return emptyList()

val poolDetails = mutableMapOf<String, StateEntityDetailsResponseItem>()
Expand All @@ -107,7 +107,7 @@ suspend fun StateApi.fetchPools(
}
}

val result = mutableListOf<FetchPoolsResult>()
val result = mutableListOf<PoolsResponse>()
paginateDetails(
addresses = resourceToPoolComponentAssociation.keys, // Request details for resources
metadataKeys = ExplicitMetadataKey.forAssets,
Expand All @@ -116,15 +116,15 @@ suspend fun StateApi.fetchPools(
resourcesDetails.items.forEach { resourceDetails ->
val poolAddress = resourceToPoolComponentAssociation[resourceDetails.address]
poolDetails[poolAddress]?.let { poolDetails ->
result.add(FetchPoolsResult(poolDetails, resourceDetails, poolWithResources[poolAddress].orEmpty()))
result.add(PoolsResponse(poolDetails, resourceDetails, poolWithResources[poolAddress].orEmpty()))
}
}
}

return result
}

data class FetchPoolsResult(
data class PoolsResponse(
val poolDetails: StateEntityDetailsResponseItem,
val poolUnitDetails: StateEntityDetailsResponseItem,
val poolResourcesDetails: List<FungibleResourcesCollectionItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
import com.babylon.wallet.android.data.gateway.extensions.FetchPoolsResult
import com.babylon.wallet.android.data.gateway.extensions.PoolsResponse
import com.babylon.wallet.android.data.gateway.extensions.toMetadata
import com.babylon.wallet.android.data.gateway.generated.models.StateEntityDetailsResponseItem
import com.babylon.wallet.android.data.repository.cache.database.PoolResourceJoin.Companion.asPoolResourceJoin
Expand Down Expand Up @@ -34,7 +34,7 @@ data class PoolEntity(

companion object {
@Suppress("UnsafeCallOnNullableType")
fun List<FetchPoolsResult>.asPoolsResourcesJoin(
fun List<PoolsResponse>.asPoolsResourcesJoin(
syncInfo: SyncInfo
): List<PoolWithResourcesJoinResult> =
mapNotNull { fetchedPoolDetails ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ sealed interface Transferable {
instructionIndex = predicted.instructionIndex
)

is TransferableResource.StakeClaimNft -> null
is TransferableResource.StakeClaimNft -> GuaranteeAssertion.ForNFT(
instructionIndex = predicted.instructionIndex
)

is TransferableResource.PoolUnitAmount -> GuaranteeAssertion.ForAmount(
amount = transferable.amount * predicted.guaranteeOffset.toBigDecimal(),
instructionIndex = predicted.instructionIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GetPoolUnitDetailsUseCase @Inject constructor(
val poolAddress = poolResource.poolAddress ?: return@then runCatching {
error("Resource $resourceAddress is not associated with a pool")
}
stateRepository.getPools(setOf(poolAddress)).map {
stateRepository.getPools(setOf(poolAddress)).mapCatching {
PoolUnit(
stake = poolResource,
pool = it.first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ suspend fun DetailedManifestClass.PoolContribution.resolve(
getProfileUseCase: GetProfileUseCase,
resources: List<Resource>,
involvedPools: List<Pool>
): PreviewType {
): PreviewType.Transfer.Pool {
val defaultDepositGuarantees = getProfileUseCase.invoke().first().appPreferences.transaction.defaultDepositGuarantee
val accountsWithdrawnFrom = executionSummary.accountWithdraws.keys
val ownedAccountsWithdrawnFrom = getProfileUseCase.accountsOnCurrentNetwork().filter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ suspend fun DetailedManifestClass.PoolRedemption.resolve(
getProfileUseCase: GetProfileUseCase,
resources: List<Resource>,
involvedPools: List<Pool>
): PreviewType {
): PreviewType.Transfer.Pool {
val accountsWithdrawnFrom = executionSummary.accountDeposits.keys
val ownedAccountsWithdrawnFrom = getProfileUseCase.accountsOnCurrentNetwork().filter {
accountsWithdrawnFrom.contains(it.address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ suspend fun DetailedManifestClass.ValidatorStake.resolve(
getProfileUseCase: GetProfileUseCase,
resources: List<Resource>,
involvedValidators: List<ValidatorDetail>
): PreviewType {
): PreviewType.Transfer.Staking {
val fromAccounts = extractWithdrawals(executionSummary, getProfileUseCase, resources)
val toAccounts = extractDeposits(
executionSummary = executionSummary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ suspend fun DetailedManifestClass.ValidatorClaim.resolve(
resources: List<Resource>,
involvedValidators: List<ValidatorDetail>,
stakeClaimsNfts: List<Resource.NonFungibleResource.Item>
): PreviewType {
): PreviewType.Transfer.Staking {
val toAccounts = extractDeposits(executionSummary, getProfileUseCase, resources)
val fromAccounts = extractWithdrawals(
executionSummary = executionSummary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ class TransactionAnalysisDelegate @Inject constructor(
manifestSummary = manifestSummary,
ephemeralNotaryPrivateKey = _state.value.ephemeralNotaryPrivateKey
)
manifest.toPrettyString().let { prettyString ->
logger.d(prettyString)
}
logger.d(manifest.toPrettyString())
return transactionClient.getTransactionPreview(
manifest = manifest,
notaryAndSigners = notaryAndSigners
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ suspend fun DetailedManifestClass.ValidatorUnstake.resolve(
getProfileUseCase: GetProfileUseCase,
resources: List<Resource>,
involvedValidators: List<ValidatorDetail>
): PreviewType {
): PreviewType.Transfer.Staking {
val fromAccounts = extractWithdrawals(executionSummary, getProfileUseCase, resources, involvedValidators)
val toAccounts = extractDeposits(executionSummary, getProfileUseCase, resources, involvedValidators)
val validatorAddressesSet = validatorAddresses.map { it.addressString() }.toSet()
Expand Down

0 comments on commit 30efd2a

Please sign in to comment.