diff --git a/blockchain/build.gradle b/blockchain/build.gradle index e96afaf62..8033d4784 100644 --- a/blockchain/build.gradle +++ b/blockchain/build.gradle @@ -55,7 +55,7 @@ dependencies { implementation 'com.squareup.retrofit2:converter-moshi:2.6.0' implementation 'com.squareup.moshi:moshi:1.13.0' implementation "com.squareup.moshi:moshi-kotlin:1.13.0" - implementation 'com.squareup.moshi:moshi-adapters:1.9.1' + implementation 'com.squareup.moshi:moshi-adapters:1.13.0' kapt("com.squareup.moshi:moshi-kotlin-codegen:1.13.0") implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3' diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/AptosApi.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/AptosApi.kt index 6fb437edc..07ac21332 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/AptosApi.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/AptosApi.kt @@ -1,10 +1,10 @@ package com.tangem.blockchain.blockchains.aptos.network -import com.tangem.blockchain.blockchains.aptos.network.request.TransactionBody -import com.tangem.blockchain.blockchains.aptos.network.response.AptosResource -import com.tangem.blockchain.blockchains.aptos.network.response.EstimateGasPriceResponse -import com.tangem.blockchain.blockchains.aptos.network.response.SimulateTransactionResponse -import com.tangem.blockchain.blockchains.aptos.network.response.SubmitTransactionResponse +import com.tangem.blockchain.blockchains.aptos.network.request.AptosTransactionBody +import com.tangem.blockchain.blockchains.aptos.network.response.AptosEstimateGasPriceResponse +import com.tangem.blockchain.blockchains.aptos.network.response.AptosResourceBody +import com.tangem.blockchain.blockchains.aptos.network.response.AptosSimulateTransactionBody +import com.tangem.blockchain.blockchains.aptos.network.response.AptosSubmitTransactionResponse import retrofit2.http.* /** @@ -21,11 +21,11 @@ internal interface AptosApi { * * @param address account address * - * @see AptosResource to know more details about kind of resources + * @see AptosResourceBody to know more details about kind of resources */ @Headers("Content-Type: application/json") @GET("v1/accounts/{address}/resources") - suspend fun getAccountResources(@Path("address") address: String): List + suspend fun getAccountResources(@Path("address") address: String): List /** * Gives an estimate of the gas unit price required to get a transaction on chain in a reasonable amount of time. @@ -34,7 +34,7 @@ internal interface AptosApi { */ @Headers("Content-Type: application/json") @GET("v1/estimate_gas_price") - suspend fun estimateGasPrice(): EstimateGasPriceResponse + suspend fun estimateGasPrice(): AptosEstimateGasPriceResponse /** * Simulate transaction's sending. Use it to estimate the maximum gas units for a submitted transaction. @@ -55,15 +55,15 @@ internal interface AptosApi { "estimate_max_gas_amount=true&" + "estimate_prioritized_gas_unit_price=false", ) - suspend fun simulateTransaction(@Body body: TransactionBody): List + suspend fun simulateTransaction(@Body body: AptosTransactionBody): List /** Build raw transaction data [body] and encode in BCS */ @Headers("Content-Type: application/json") @POST("v1/transactions/encode_submission") - suspend fun encodeSubmission(@Body body: TransactionBody): String + suspend fun encodeSubmission(@Body body: AptosTransactionBody): String /** Submit transaction [body] */ @Headers("Content-Type: application/json") @POST("v1/transactions") - suspend fun submitTransaction(@Body body: TransactionBody): SubmitTransactionResponse + suspend fun submitTransaction(@Body body: AptosTransactionBody): AptosSubmitTransactionResponse } diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/request/TransactionBody.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/request/AptosTransactionBody.kt similarity index 96% rename from blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/request/TransactionBody.kt rename to blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/request/AptosTransactionBody.kt index 985851c0c..0329d6c57 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/request/TransactionBody.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/request/AptosTransactionBody.kt @@ -4,7 +4,7 @@ import com.squareup.moshi.Json import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) -internal data class TransactionBody( +internal data class AptosTransactionBody( @Json(name = "expiration_timestamp_secs") val expirationTimestamp: String, @Json(name = "gas_unit_price") val gasUnitPrice: String, @Json(name = "max_gas_amount") val maxGasAmount: String, diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/EstimateGasPriceResponse.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosEstimateGasPriceResponse.kt similarity index 88% rename from blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/EstimateGasPriceResponse.kt rename to blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosEstimateGasPriceResponse.kt index 668db12de..a7bda8904 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/EstimateGasPriceResponse.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosEstimateGasPriceResponse.kt @@ -4,7 +4,7 @@ import com.squareup.moshi.Json import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) -internal data class EstimateGasPriceResponse( +internal data class AptosEstimateGasPriceResponse( @Json(name = "deprioritized_gas_estimate") val minimalGasUnitPrice: Long, @Json(name = "gas_estimate") val normalGasUnitPrice: Long, @Json(name = "prioritized_gas_estimate") val priorityGasUnitPrice: Long, diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosResource.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosResourceBody.kt similarity index 84% rename from blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosResource.kt rename to blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosResourceBody.kt index 72b3a5b32..0d3f5e8aa 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosResource.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosResourceBody.kt @@ -4,12 +4,12 @@ import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory -internal sealed class AptosResource { +internal sealed class AptosResourceBody { @JsonClass(generateAdapter = true) data class AccountResource( @Json(name = "data") val account: AccountData, - ) : AptosResource() { + ) : AptosResourceBody() { @JsonClass(generateAdapter = true) data class AccountData( @@ -20,7 +20,7 @@ internal sealed class AptosResource { @JsonClass(generateAdapter = true) data class CoinResource( @Json(name = "data") val coin: CoinData, - ) : AptosResource() { + ) : AptosResourceBody() { @JsonClass(generateAdapter = true) data class CoinData( @@ -34,13 +34,13 @@ internal sealed class AptosResource { } } - object Unknown : AptosResource() + object Unknown : AptosResourceBody() companion object { - fun createPolymorphicJsonAdapterFactory(): PolymorphicJsonAdapterFactory { + fun createPolymorphicJsonAdapterFactory(): PolymorphicJsonAdapterFactory { return PolymorphicJsonAdapterFactory - .of(AptosResource::class.java, "type") + .of(AptosResourceBody::class.java, "type") .withSubtype(AccountResource::class.java, "0x1::account::Account") .withSubtype(CoinResource::class.java, "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>") .withDefaultValue(Unknown) diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/SimulateTransactionResponse.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosSimulateTransactionBody.kt similarity index 71% rename from blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/SimulateTransactionResponse.kt rename to blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosSimulateTransactionBody.kt index 5419de62a..65d3b9abe 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/SimulateTransactionResponse.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosSimulateTransactionBody.kt @@ -4,8 +4,7 @@ import com.squareup.moshi.Json import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) -internal data class SimulateTransactionResponse( +internal data class AptosSimulateTransactionBody( @Json(name = "gas_used") val usedGasUnit: String, - @Json(name = "sequence_number") val sequenceNumber: String, @Json(name = "success") val isSuccess: Boolean, ) diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/SubmitTransactionResponse.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosSubmitTransactionResponse.kt similarity index 84% rename from blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/SubmitTransactionResponse.kt rename to blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosSubmitTransactionResponse.kt index 569fa438d..4cc76d3fc 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/SubmitTransactionResponse.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/aptos/network/response/AptosSubmitTransactionResponse.kt @@ -4,7 +4,7 @@ import com.squareup.moshi.Json import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) -internal data class SubmitTransactionResponse( +internal data class AptosSubmitTransactionResponse( @Json(name = "hash") val hash: String, @Json(name = "sequence_number") val sequenceNumber: String, ) diff --git a/blockchain/src/main/java/com/tangem/blockchain/network/RetrofitBuilder.kt b/blockchain/src/main/java/com/tangem/blockchain/network/RetrofitBuilder.kt index a56c2fc24..88074baa5 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/network/RetrofitBuilder.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/network/RetrofitBuilder.kt @@ -2,7 +2,7 @@ package com.tangem.blockchain.network import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory -import com.tangem.blockchain.blockchains.aptos.network.response.AptosResource +import com.tangem.blockchain.blockchains.aptos.network.response.AptosResourceBody import okhttp3.Interceptor import okhttp3.OkHttpClient import retrofit2.Retrofit @@ -63,7 +63,7 @@ data class Timeout( internal val moshi: Moshi by lazy { Moshi.Builder() .add(BigDecimal::class.java, BigDecimalAdapter) - .add(AptosResource.createPolymorphicJsonAdapterFactory()) + .add(AptosResourceBody.createPolymorphicJsonAdapterFactory()) .add(KotlinJsonAdapterFactory()) .build() }