Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add on-chain transaction response models #703

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.12.19"
version = "1.12.20"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package indexer.models.chain

import exchange.dydx.abacus.protocols.asTypedObject
import exchange.dydx.abacus.utils.Parser
import kotlinx.serialization.Serializable

// Define the structure of the error message
@Serializable
data class ChainError(
val message: String,
val line: Int? = null,
val column: Int? = null,
val stack: String? = null
) {
companion object {
val unknownError = ChainError(message = "An unknown error occurred", line = null, column = null, stack = null)
}
}

@Serializable
data class OnChainTransactionErrorResponse(
val error: ChainError
) {
companion object {
private val parser = Parser()

fun fromPayload(payload: String?): OnChainTransactionErrorResponse? {
return parser.asTypedObject<OnChainTransactionErrorResponse>(payload)
}
}
}

// Define the structure of the success message
@Serializable
data class ChainEvent(
val type: String,
val attributes: List<ChainEventAttribute>
)

@Serializable
data class ChainEventAttribute(
val key: String,
val value: String
)

@Serializable
data class OnChainTransactionSuccessResponse(
val height: Int? = null,
val hash: String? = null,
val code: Int? = null,
val tx: String,
val txIndex: Int? = null,
val gasUsed: String? = null,
val gasWanted: String? = null,
val events: List<ChainEvent>? = null,
) {
companion object {
private val parser = Parser()

fun fromPayload(payload: String?): OnChainTransactionSuccessResponse? {
return parser.asTypedObject<OnChainTransactionSuccessResponse>(payload)
}
}
}
2 changes: 1 addition & 1 deletion v4_abacus.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'v4_abacus'
spec.version = '1.12.19'
spec.version = '1.12.20'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down