Skip to content

Commit

Permalink
fix: staking delegations static typed correctly (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo authored Nov 13, 2024
1 parent 22b670d commit 137d3ee
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
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.13.25"
version = "1.13.26"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ internal class AccountDelegationsProcessor(
return if (payload != null) {
val modified = mutableListOf<InternalStakingDelegationState>()
for (item in payload.delegationResponses ?: emptyList()) {
val validator = parser.asString(item.validatorAddress)
val delegator = parser.asString(item.delegatorAddress)
val shares = parser.asDecimal(item.shares)
val validator = parser.asString(item.delegation?.validatorAddress)
val delegator = parser.asString(item.delegation?.delegatorAddress)
val shares = parser.asDecimal(item.delegation?.shares)
val amount = parser.asDecimal(item.balance?.amount)
val denom = parser.asString(item.balance?.denom)
if (amount != null && denom != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ data class OnChainDelegationResponse(

@Serializable
data class OnChainDelegationObject(
val delegation: OnChainDelegationInfo? = null,
val balance: OnChainAccountBalanceObject? = null,
)

@Serializable
data class OnChainDelegationInfo(
val delegatorAddress: String? = null,
val validatorAddress: String? = null,
val shares: String? = null,
val balance: OnChainAccountBalanceObject? = null,
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.ionspin.kotlin.bignum.decimal.toBigDecimal
import exchange.dydx.abacus.state.internalstate.InternalAccountBalanceState
import exchange.dydx.abacus.utils.Parser
import indexer.models.chain.OnChainAccountBalanceObject
import indexer.models.chain.OnChainDelegationInfo
import indexer.models.chain.OnChainDelegationObject
import indexer.models.chain.OnChainDelegationResponse
import kotlin.test.Test
Expand All @@ -14,27 +15,33 @@ class AccountDelegationsProcessorTests {
internal val payloadMock: OnChainDelegationResponse = OnChainDelegationResponse(
delegationResponses = listOf(
OnChainDelegationObject(
delegatorAddress = "delegatorAddress",
validatorAddress = "validatorAddress",
shares = null,
delegation = OnChainDelegationInfo(
delegatorAddress = "delegatorAddress",
validatorAddress = "validatorAddress",
shares = null,
),
balance = OnChainAccountBalanceObject(
denom = "denom",
amount = "100.0",
),
),
OnChainDelegationObject(
delegatorAddress = "delegatorAddress",
validatorAddress = "validatorAddress",
shares = null,
delegation = OnChainDelegationInfo(
delegatorAddress = "delegatorAddress",
validatorAddress = "validatorAddress",
shares = null,
),
balance = OnChainAccountBalanceObject(
denom = "denom",
amount = "300.0",
),
),
OnChainDelegationObject(
delegatorAddress = "delegatorAddress",
validatorAddress = "validatorAddress",
shares = null,
delegation = OnChainDelegationInfo(
delegatorAddress = "delegatorAddress",
validatorAddress = "validatorAddress",
shares = null,
),
balance = OnChainAccountBalanceObject(
denom = "denom1",
amount = "200.0",
Expand Down
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.13.25'
spec.version = '1.13.26'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down

0 comments on commit 137d3ee

Please sign in to comment.