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

fix(events): align event processing with smart contract changes #400

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 2 additions & 3 deletions client/x/evmstaking/keeper/delegator_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (k Keeper) ProcessSetRewardAddress(ctx context.Context, ev *bindings.IPToke
return nil
}

func (k Keeper) ProcessAddOperator(ctx context.Context, ev *bindings.IPTokenStakingAddOperator) (err error) {
func (k Keeper) ProcessSetOperator(ctx context.Context, ev *bindings.IPTokenStakingSetOperator) (err error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
cachedCtx, writeCache := sdkCtx.CacheContext()

Expand Down Expand Up @@ -134,7 +134,7 @@ func (k Keeper) ProcessAddOperator(ctx context.Context, ev *bindings.IPTokenStak
return nil
}

func (k Keeper) ProcessRemoveOperator(ctx context.Context, ev *bindings.IPTokenStakingRemoveOperator) (err error) {
func (k Keeper) ProcessUnsetOperator(ctx context.Context, ev *bindings.IPTokenStakingUnsetOperator) (err error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
cachedCtx, writeCache := sdkCtx.CacheContext()

Expand All @@ -148,7 +148,6 @@ func (k Keeper) ProcessRemoveOperator(ctx context.Context, ev *bindings.IPTokenS
types.EventTypeRemoveOperatorFailure,
sdk.NewAttribute(types.AttributeKeyBlockHeight, strconv.FormatInt(sdkCtx.BlockHeight(), 10)),
sdk.NewAttribute(types.AttributeKeyDelegatorUncmpPubKey, hex.EncodeToString(ev.UncmpPubkey)),
sdk.NewAttribute(types.AttributeKeyOperatorAddress, ev.Operator.Hex()),
ezreal1997 marked this conversation as resolved.
Show resolved Hide resolved
sdk.NewAttribute(types.AttributeKeyStatusCode, errors.UnwrapErrCode(err).String()),
sdk.NewAttribute(types.AttributeKeyTxHash, hex.EncodeToString(ev.Raw.TxHash.Bytes())),
),
Expand Down
20 changes: 10 additions & 10 deletions client/x/evmstaking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,24 @@ func (k Keeper) ProcessStakingEvents(ctx context.Context, height uint64, logs []
clog.Error(ctx, "Failed to process set reward address", err)
continue
}
case types.AddOperator.ID:
ev, err := k.ipTokenStakingContract.ParseAddOperator(ethlog)
case types.SetOperator.ID:
ev, err := k.ipTokenStakingContract.ParseSetOperator(ethlog)
if err != nil {
clog.Error(ctx, "Failed to parse SetRewardAddress log", err)
clog.Error(ctx, "Failed to parse SetOperator log", err)
continue
}
if err = k.ProcessAddOperator(ctx, ev); err != nil {
clog.Error(ctx, "Failed to process add operator", err)
if err = k.ProcessSetOperator(ctx, ev); err != nil {
clog.Error(ctx, "Failed to process set operator", err)
continue
}
case types.RemoveOperator.ID:
ev, err := k.ipTokenStakingContract.ParseRemoveOperator(ethlog)
case types.UnsetOperator.ID:
ev, err := k.ipTokenStakingContract.ParseUnsetOperator(ethlog)
if err != nil {
clog.Error(ctx, "Failed to parse SetRewardAddress log", err)
clog.Error(ctx, "Failed to parse UnsetOperator log", err)
continue
}
if err = k.ProcessRemoveOperator(ctx, ev); err != nil {
clog.Error(ctx, "Failed to process add operator", err)
if err = k.ProcessUnsetOperator(ctx, ev); err != nil {
clog.Error(ctx, "Failed to process unset operator", err)
continue
}
case types.CreateValidatorEvent.ID:
Expand Down
4 changes: 2 additions & 2 deletions client/x/evmstaking/types/staking_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ var (
UpdateValidatorCommission = mustGetEvent(ipTokenStakingABI, "UpdateValidatorCommssion")
SetWithdrawalAddress = mustGetEvent(ipTokenStakingABI, "SetWithdrawalAddress")
SetRewardAddress = mustGetEvent(ipTokenStakingABI, "SetRewardAddress")
AddOperator = mustGetEvent(ipTokenStakingABI, "AddOperator")
RemoveOperator = mustGetEvent(ipTokenStakingABI, "RemoveOperator")
SetOperator = mustGetEvent(ipTokenStakingABI, "SetOperator")
UnsetOperator = mustGetEvent(ipTokenStakingABI, "UnsetOperator")
CreateValidatorEvent = mustGetEvent(ipTokenStakingABI, "CreateValidator")
DepositEvent = mustGetEvent(ipTokenStakingABI, "Deposit")
RedelegateEvent = mustGetEvent(ipTokenStakingABI, "Redelegate")
Expand Down
Loading