Skip to content

Commit

Permalink
add individual event delegations
Browse files Browse the repository at this point in the history
  • Loading branch information
kruspy committed Oct 20, 2023
1 parent fa29c69 commit c06039d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions x/liquidstakeibc/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,21 @@ func (k *Keeper) DoDelegate(ctx sdk.Context, hc *types.HostChain) {
}

// if everything went well, update the deposit states and set the sequence id
lastEpoch := int64(0) // highest epoch among deposits, used for event emission
for _, deposit := range deposits {
deposit.IbcSequenceId = sequenceID
deposit.State = types.Deposit_DEPOSIT_DELEGATING
k.SetDeposit(ctx, deposit)

lastEpoch = deposit.Epoch
// emit the delegation event for every deposit
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeDoDelegationDeposit,
sdk.NewAttribute(types.AttributeChainID, hc.ChainId),
sdk.NewAttribute(types.AttributeEpoch, strconv.FormatInt(deposit.Epoch, 10)),
sdk.NewAttribute(types.AttributeDelegatedAmount, sdk.NewCoin(hc.HostDenom, deposit.Amount.Amount).String()),
sdk.NewAttribute(types.AttributeIBCSequenceID, sequenceID),
),
)
}

// emit the delegation event
Expand All @@ -100,10 +108,8 @@ func (k *Keeper) DoDelegate(ctx sdk.Context, hc *types.HostChain) {
sdk.NewEvent(
types.EventTypeDoDelegation,
sdk.NewAttribute(types.AttributeChainID, hc.ChainId),
sdk.NewAttribute(types.AttributeEpoch, strconv.FormatInt(lastEpoch, 10)),
sdk.NewAttribute(types.AttributeTotalDelegatedAmount, sdk.NewCoin(hc.HostDenom, totalDepositDelegation).String()),
sdk.NewAttribute(types.AttributeICAMessages, base64.StdEncoding.EncodeToString(encMsgs)),
sdk.NewAttribute(types.AttributeIBCSequenceID, sequenceID),
),
)
}
Expand Down
1 change: 1 addition & 0 deletions x/liquidstakeibc/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
EventTypeValidatorExchangeRateUpdate = "validator_exchange_rate_update"
EventTypeValidatorDelegableStateUpdate = "validator_delegable_state_update"
EventTypeDoDelegation = "send_delegation"
EventTypeDoDelegationDeposit = "send_individual_delegation"
EventTypeClaimedUnbondings = "claimed_unbondings"
EventTypeRedeemTokensForShares = "redeem_lsm_tokens_shares" //nolint:gosec
EventTypeCValueUpdate = "c_value_update"
Expand Down

0 comments on commit c06039d

Please sign in to comment.