Skip to content

Commit

Permalink
add constants for events names
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Sep 11, 2024
1 parent 2b6f63f commit ead6173
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions precompiles/staking/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ import (
"github.com/zeta-chain/node/precompiles/logs"
)

const (
StakeEventName = "Stake"
UnstakeEventName = "Unstake"
MoveStakeEventName = "MoveStake"
)

func (c *Contract) AddStakeLog(
ctx sdk.Context,
stateDB vm.StateDB,
staker common.Address,
validator string,
amount *big.Int,
) error {
event := c.Abi().Events["Stake"]
event := c.Abi().Events[StakeEventName]

valAddr, err := sdk.ValAddressFromBech32(validator)
if err != nil {
Expand Down Expand Up @@ -48,7 +54,7 @@ func (c *Contract) AddUnstakeLog(
validator string,
amount *big.Int,
) error {
event := c.Abi().Events["Unstake"]
event := c.Abi().Events[UnstakeEventName]
valAddr, err := sdk.ValAddressFromBech32(validator)
if err != nil {
return err

Check warning on line 60 in precompiles/staking/logs.go

View check run for this annotation

Codecov / codecov/patch

precompiles/staking/logs.go#L60

Added line #L60 was not covered by tests
Expand Down Expand Up @@ -79,7 +85,7 @@ func (c *Contract) AddMoveStakeLog(
validatorDst string,
amount *big.Int,
) error {
event := c.Abi().Events["MoveStake"]
event := c.Abi().Events[MoveStakeEventName]
validatorSrcAddr, err := sdk.ValAddressFromBech32(validatorSrc)
if err != nil {
return err

Check warning on line 91 in precompiles/staking/logs.go

View check run for this annotation

Codecov / codecov/patch

precompiles/staking/logs.go#L91

Added line #L91 was not covered by tests
Expand Down

0 comments on commit ead6173

Please sign in to comment.