From 521b0c3e431a5fac10724973bf39fdf52d39a9ec Mon Sep 17 00:00:00 2001 From: Rui Date: Mon, 1 Apr 2024 16:13:36 -0700 Subject: [PATCH 1/2] Bump Abacus --- .idea/.name | 1 + .../exchange/dydx/trading/DydxApplication.kt | 5 ---- v4/build.gradle | 2 +- .../status/DydxTransferStatusViewModel.kt | 1 + .../utils/DydxTransferInstanceStore.kt | 1 + .../dydxstatemanager/AbacusStateManager.kt | 6 ++--- .../transfers/DydxTransferState.kt | 1 + .../protocolImplementations/AbacusRestImp.kt | 24 ++++++++++++------- 8 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 .idea/.name diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 00000000..7202a21e --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +native-android \ No newline at end of file diff --git a/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt b/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt index edcc8aff..54e838ab 100644 --- a/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt +++ b/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt @@ -3,9 +3,7 @@ package exchange.dydx.trading import android.app.Application import com.facebook.stetho.Stetho import dagger.hilt.android.HiltAndroidApp -import exchange.dydx.abacus.jvm.AbacusAndroid import exchange.dydx.platformui.designSystem.theme.ThemeSettings -import exchange.dydx.trading.common.AppConfig import exchange.dydx.trading.common.logger.DydxLogger import timber.log.Timber import javax.inject.Inject @@ -26,9 +24,6 @@ class DydxApplication : Application() { logger.woodTree(this), ) Stetho.initializeWithDefaults(this) - if (AppConfig.ABACUS_LOGGING >= 0) { - AbacusAndroid.enableDebug("dydx#AbacusCore", AppConfig.ABACUS_LOGGING) - } } } } diff --git a/v4/build.gradle b/v4/build.gradle index 08b0620e..ff46017e 100644 --- a/v4/build.gradle +++ b/v4/build.gradle @@ -89,7 +89,7 @@ ext { compileSdkVersion = 34 // App dependencies - abacusVersion = '1.4.14' + abacusVersion = '1.6.23' carteraVersion = '0.1.12' kollectionsVersion = '2.0.16' diff --git a/v4/feature/transfer/src/main/java/exchange/dydx/trading/feature/transfer/status/DydxTransferStatusViewModel.kt b/v4/feature/transfer/src/main/java/exchange/dydx/trading/feature/transfer/status/DydxTransferStatusViewModel.kt index c31be2a6..d6ed2813 100644 --- a/v4/feature/transfer/src/main/java/exchange/dydx/trading/feature/transfer/status/DydxTransferStatusViewModel.kt +++ b/v4/feature/transfer/src/main/java/exchange/dydx/trading/feature/transfer/status/DydxTransferStatusViewModel.kt @@ -96,6 +96,7 @@ class DydxTransferStatusViewModel @Inject constructor( fromChainId = transfer.fromChainId, toChainId = transfer.toChainId, isCctp = transfer.isCctp ?: false, + requestId = transfer.requestId, ) } } diff --git a/v4/feature/transfer/src/main/java/exchange/dydx/trading/feature/transfer/utils/DydxTransferInstanceStore.kt b/v4/feature/transfer/src/main/java/exchange/dydx/trading/feature/transfer/utils/DydxTransferInstanceStore.kt index f47dac52..a845f513 100644 --- a/v4/feature/transfer/src/main/java/exchange/dydx/trading/feature/transfer/utils/DydxTransferInstanceStore.kt +++ b/v4/feature/transfer/src/main/java/exchange/dydx/trading/feature/transfer/utils/DydxTransferInstanceStore.kt @@ -37,6 +37,7 @@ class DydxTransferInstanceStore( usdcSize = parser.asDouble(transferInput.size?.usdcSize), size = parser.asDouble(transferInput.size?.size), isCctp = transferInput.isCctp, + requestId = transferInput.requestPayload?.requestId, ) abacusStateManager.addTransferInstance(transfer) } diff --git a/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/AbacusStateManager.kt b/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/AbacusStateManager.kt index 28fae74a..17ee47c3 100644 --- a/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/AbacusStateManager.kt +++ b/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/AbacusStateManager.kt @@ -93,7 +93,7 @@ interface AbacusStateManagerProtocol { fun addTransferInstance(transfer: DydxTransferInstance) fun removeTransferInstance(transfer: DydxTransferInstance) - fun transferStatus(hash: String, fromChainId: String?, toChainId: String?, isCctp: Boolean) + fun transferStatus(hash: String, fromChainId: String?, toChainId: String?, isCctp: Boolean, requestId: String?) fun screen(address: String, callback: ((Restriction) -> Unit)) fun commitCCTPWithdraw(callback: (Boolean, ParsingError?, Any?) -> Unit) @@ -339,8 +339,8 @@ class AbacusStateManager @Inject constructor( transferStateManager.remove(transfer) } - override fun transferStatus(hash: String, fromChainId: String?, toChainId: String?, isCctp: Boolean) { - asyncStateManager.transferStatus(hash, fromChainId, toChainId, isCctp) + override fun transferStatus(hash: String, fromChainId: String?, toChainId: String?, isCctp: Boolean, requestId: String?) { + asyncStateManager.transferStatus(hash, fromChainId, toChainId, isCctp, requestId) } override fun screen(address: String, callback: ((Restriction) -> Unit)) { diff --git a/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/clientState/transfers/DydxTransferState.kt b/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/clientState/transfers/DydxTransferState.kt index 483bb934..ed96b60d 100644 --- a/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/clientState/transfers/DydxTransferState.kt +++ b/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/clientState/transfers/DydxTransferState.kt @@ -79,6 +79,7 @@ data class DydxTransferInstance( val usdcSize: Double? = null, val size: Double? = null, val isCctp: Boolean? = null, + val requestId: String? = null, ) { enum class TransferType { DEPOSIT, WITHDRAWAL, TRANSFER_OUT diff --git a/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/protocolImplementations/AbacusRestImp.kt b/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/protocolImplementations/AbacusRestImp.kt index 1fa4f61c..bbfb9f65 100644 --- a/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/protocolImplementations/AbacusRestImp.kt +++ b/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/protocolImplementations/AbacusRestImp.kt @@ -2,8 +2,12 @@ package exchange.dydx.dydxstatemanager.protocolImplementations import android.os.AsyncTask import android.util.Log +import exchange.dydx.abacus.protocols.RestCallback import exchange.dydx.abacus.protocols.RestProtocol import exchange.dydx.abacus.utils.IMap +import exchange.dydx.abacus.utils.filterNotNull +import exchange.dydx.abacus.utils.toJsonElement +import exchange.dydx.abacus.utils.toJsonPrettyPrint import okhttp3.CacheControl import okhttp3.Callback import okhttp3.MediaType.Companion.toMediaTypeOrNull @@ -28,7 +32,7 @@ class AbacusRestImp : RestProtocol { override fun delete( url: String, headers: IMap?, - callback: (response: String?, httpCode: Int) -> Unit, + callback: RestCallback, ) { processRest(url, headers, null, "DELETE", callback) } @@ -36,7 +40,7 @@ class AbacusRestImp : RestProtocol { override fun get( url: String, headers: IMap?, - callback: (response: String?, httpCode: Int) -> Unit, + callback: RestCallback, ) { processRest(url, headers, null, "GET", callback) } @@ -45,7 +49,7 @@ class AbacusRestImp : RestProtocol { url: String, headers: IMap?, body: String?, - callback: (response: String?, httpCode: Int) -> Unit, + callback: RestCallback, ) { processRest(url, headers, body, "POST", callback) } @@ -54,7 +58,7 @@ class AbacusRestImp : RestProtocol { url: String, headers: IMap?, body: String?, - callback: (response: String?, httpCode: Int) -> Unit, + callback: RestCallback, ) { processRest(url, headers, body, "PUT", callback) } @@ -64,7 +68,7 @@ class AbacusRestImp : RestProtocol { headers: IMap?, body: String?, verb: String, - callback: (String?, Int) -> Unit, + callback: RestCallback, ) { var requestBuilder = Request.Builder() .url(url) @@ -87,21 +91,25 @@ class AbacusRestImp : RestProtocol { run(request, callback) } - private fun run(request: Request, callback: (String?, Int) -> Unit) { + private fun run(request: Request, callback: RestCallback) { beginBackgroundTask() // Log.d(TAG, "AbacusRestImp Requesting ${request.url}") client.newCall(request).enqueue(object : Callback { override fun onFailure(call: okhttp3.Call, e: IOException) { Log.e(TAG, "AbacusRestImp Request Failed ${request.url}, ${e.message}") endBackgroundTask() - callback(null, 0) + callback(null, 0, null) } override fun onResponse(call: okhttp3.Call, response: Response) { endBackgroundTask() val code = response.code val body = response.body?.string() - callback(body, code) + val headerMap: Map = response.headers.names().associateWith { + response.headers.values(it)?.firstOrNull() + }.filterNotNull() + val headerJsonString = headerMap.toJsonPrettyPrint() + callback(body, code, headerJsonString) } }) } From 5e5cc595f3fe36049a34ea3c2ba35a5ff713c1a3 Mon Sep 17 00:00:00 2001 From: Rui Date: Mon, 1 Apr 2024 16:19:40 -0700 Subject: [PATCH 2/2] Revert --- .../protocolImplementations/AbacusRestImp.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/protocolImplementations/AbacusRestImp.kt b/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/protocolImplementations/AbacusRestImp.kt index 72cac024..6a42fed2 100644 --- a/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/protocolImplementations/AbacusRestImp.kt +++ b/v4/integration/dydxStateManager/src/main/java/exchange/dydx/dydxstatemanager/protocolImplementations/AbacusRestImp.kt @@ -5,8 +5,7 @@ import android.util.Log import exchange.dydx.abacus.protocols.RestCallback import exchange.dydx.abacus.protocols.RestProtocol import exchange.dydx.abacus.utils.IMap -import exchange.dydx.abacus.utils.filterNotNull -import exchange.dydx.abacus.utils.toJsonPrettyPrint +import exchange.dydx.abacus.utils.toJson import okhttp3.CacheControl import okhttp3.Callback import okhttp3.MediaType.Companion.toMediaTypeOrNull @@ -114,11 +113,8 @@ class AbacusRestImp @Inject constructor() : RestProtocol { endBackgroundTask() val code = response.code val body = response.body?.string() - val headerMap: Map = response.headers.names().associateWith { - response.headers.values(it)?.firstOrNull() - }.filterNotNull() - val headerJsonString = headerMap.toJsonPrettyPrint() - callback(body, code, headerJsonString) + val headersJsonString = response.headers.toMap().toJson() + callback(body, code, headersJsonString) } }) }