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

Ibc parsing errors #534

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.provenance.explorer.domain.entities

import com.google.protobuf.Any
import cosmos.base.abci.v1beta1.Abci
import ibc.core.channel.v1.QueryOuterClass
import io.provenance.explorer.OBJECT_MAPPER
import io.provenance.explorer.config.ResourceNotFoundException
Expand Down Expand Up @@ -126,7 +125,6 @@ object IbcLedgerTable : IntIdTable(name = "ibc_ledger") {
val toAddress = varchar("to_address", 256)
val passThroughAddrId = integer("pass_through_address_id")
val passThroughAddr = varchar("pass_through_address", 128)
val logs = jsonb<IbcLedgerTable, Abci.ABCIMessageLog>("logs", OBJECT_MAPPER)
val blockHeight = integer("block_height")
val txHashId = integer("tx_hash_id")
val txHash = varchar("tx_hash", 64)
Expand Down Expand Up @@ -163,7 +161,6 @@ class IbcLedgerRecord(id: EntityID<Int>) : IntEntity(id) {
match?.toAddress ?: ledger.toAddress,
match?.passThroughAddrId ?: ledger.passThroughAddress!!.id.value,
match?.passThroughAddr ?: ledger.passThroughAddress!!.accountAddress,
match?.logs ?: ledger.logs,
match?.blockHeight ?: txData.blockHeight,
match?.txHashId ?: -1,
match?.txHash ?: txData.txHash,
Expand Down Expand Up @@ -309,7 +306,6 @@ class IbcLedgerRecord(id: EntityID<Int>) : IntEntity(id) {
var toAddress by IbcLedgerTable.toAddress
var passThroughAddrId by IbcLedgerTable.passThroughAddrId
var passThroughAddr by IbcLedgerTable.passThroughAddr
var logs by IbcLedgerTable.logs
var blockHeight by IbcLedgerTable.blockHeight
var txHashId by IbcLedgerTable.txHashId
var txHash by IbcLedgerTable.txHash
Expand All @@ -329,7 +325,6 @@ object IbcLedgerAckTable : IntIdTable(name = "ibc_ledger_ack") {
val txHashId = integer("tx_hash_id")
val txHash = varchar("tx_hash", 64)
val txTimestamp = datetime("tx_timestamp")
val logs = jsonb<IbcLedgerAckTable, Abci.ABCIMessageLog>("logs", OBJECT_MAPPER)
val changesEffected = bool("changes_effected").default(false)
}

Expand All @@ -345,7 +340,6 @@ class IbcLedgerAckRecord(id: EntityID<Int>) : IntEntity(id) {
-1,
txInfo.txHash,
txInfo.txTimestamp,
ledger.logs,
ledger.changesEffected
).toProcedureObject()
}
Expand All @@ -356,7 +350,6 @@ class IbcLedgerAckRecord(id: EntityID<Int>) : IntEntity(id) {
var txHashId by IbcLedgerAckTable.txHashId
var txHash by IbcLedgerAckTable.txHash
var txTimestamp by IbcLedgerAckTable.txTimestamp
var logs by IbcLedgerAckTable.logs
var changesEffected by IbcLedgerAckTable.changesEffected
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.provenance.explorer.domain.models.explorer

import cosmos.base.abci.v1beta1.Abci
import io.provenance.explorer.domain.entities.AccountRecord
import io.provenance.explorer.domain.entities.IbcAckType
import io.provenance.explorer.domain.entities.IbcChannelRecord
Expand All @@ -10,7 +9,6 @@ import java.math.BigDecimal
data class LedgerInfo(
var channel: IbcChannelRecord? = null,
var denom: String = "",
var logs: Abci.ABCIMessageLog? = null,
var denomTrace: String = "",
var balanceIn: String? = null,
var balanceOut: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package io.provenance.explorer.grpc.extensions

import cosmos.base.abci.v1beta1.Abci
import cosmos.tx.v1beta1.ServiceOuterClass

fun ServiceOuterClass.GetTxResponse.mapEventAttrValues(idx: Int, event: String, attrList: List<String>): Map<String, String> {
return if (this.txResponse.logsList == null || this.txResponse.logsList.size <= idx) {
return if (this.txResponse.logsList == null || this.txResponse.logsList.size == 0) {
mapEventAttrValuesByMsgIndex(idx, event, attrList)
} else {
mapEventAttrValuesFromLogs(idx, event, attrList)
Expand Down Expand Up @@ -39,3 +40,26 @@ fun ServiceOuterClass.GetTxResponse.mapTxEventAttrValues(eventType: String, attr
}.mapIndexed { idx, event ->
idx to event.attributesList.first { it.key == attrKey }.value
}.toMap()

fun ServiceOuterClass.GetTxResponse.eventsAtIndex(index: Int): List<Abci.StringEvent> {
return if (this.txResponse.logsList == null || this.txResponse.logsList.size == 0) {
txResponse.eventsList.filter { event ->
event.attributesList.any { attribute ->
attribute.key == "msg_index" && attribute.value == index.toString()
}
}.map { event ->
val convertedAttributes = event.attributesList.map { attribute ->
Abci.Attribute.newBuilder()
.setKey(attribute.key)
.setValue(attribute.value)
.build()
}
Abci.StringEvent.newBuilder()
.setType(event.type)
.addAllAttributes(convertedAttributes)
.build()
}
} else {
this.txResponse.logsList[index].eventsList
}
}
Loading
Loading