Skip to content

Commit

Permalink
feat: add err reason event for process attestation (#259)
Browse files Browse the repository at this point in the history
Co-authored-by: fx0x55 <[email protected]>
  • Loading branch information
zakir-code and fx0x55 authored Mar 8, 2024
1 parent 3b86e3b commit 2d36979
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions x/crosschain/keeper/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,19 @@ func (k Keeper) TryAttestation(ctx sdk.Context, att *types.Attestation, claim ty
k.SetAttestation(ctx, claim.GetEventNonce(), claim.ClaimHash(), att)

err := k.processAttestation(ctx, claim)
ctx.EventManager().EmitEvent(sdk.NewEvent(
event := sdk.NewEvent(
types.EventTypeContractEvent,
sdk.NewAttribute(sdk.AttributeKeyModule, k.moduleName),
sdk.NewAttribute(types.AttributeKeyClaimType, claim.GetType().String()),
sdk.NewAttribute(types.AttributeKeyEventNonce, fmt.Sprint(claim.GetEventNonce())),
sdk.NewAttribute(types.AttributeKeyClaimHash, fmt.Sprint(hex.EncodeToString(claim.ClaimHash()))),
sdk.NewAttribute(types.AttributeKeyBlockHeight, fmt.Sprint(claim.GetBlockHeight())),
sdk.NewAttribute(types.AttributeKeyStateSuccess, fmt.Sprint(err == nil)),
))
)
if err != nil {
event.AppendAttributes(sdk.NewAttribute(types.AttributeKeyErrReason, err.Error()))
}
ctx.EventManager().EmitEvent(event)

k.pruneAttestations(ctx)
break
Expand Down
1 change: 1 addition & 0 deletions x/crosschain/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (

AttributeKeyBlockHeight = "block_height"
AttributeKeyStateSuccess = "state_success"
AttributeKeyErrReason = "err_reason"

EventTypeOracleSetUpdate = "oracle_set_update"
AttributeKeyOracleSetNonce = "oracle_set_nonce"
Expand Down

0 comments on commit 2d36979

Please sign in to comment.