Skip to content

Commit

Permalink
fix: genesis validation
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed Feb 26, 2025
1 parent 505516b commit 6dc5f04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion x/appchain/coordinator/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (msg *RegisterSubscriberChainRequest) ValidateBasic() error {
if _, _, err := assetstypes.ValidateID(
assetID,
true, // the caller must make them lowercase
true, // TODO: we support only Ethereum assets for now.
false,
); err != nil {
return fmt.Errorf("invalid asset id %s: %s", assetID, err)
}
Expand Down
2 changes: 1 addition & 1 deletion x/assets/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (gs GenesisState) ValidateDeposits(lzIDs map[uint64]struct{}, tokensTotalSt
// validate the stakerID
var stakerClientChainID uint64
var err error
if _, stakerClientChainID, err = ValidateID(stakerID, true, true); err != nil {
if _, stakerClientChainID, err = ValidateID(stakerID, true, false); err != nil {
return errorsmod.Wrapf(
ErrInvalidGenesisData,
"invalid stakerID: %s",
Expand Down
19 changes: 11 additions & 8 deletions x/operator/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ func (gs GenesisState) ValidateOperators() (map[string]struct{}, error) {
"invalid operator address %s: %s", address, err,
)
}
if op.OperatorInfo.EarningsAddr != "" {
_, err := sdk.AccAddressFromBech32(op.OperatorInfo.EarningsAddr)
if err != nil {
return nil, errorsmod.Wrapf(
ErrInvalidGenesisData,
"invalid operator earning address %s: %s", op.OperatorInfo.EarningsAddr, err,
)
}
if op.OperatorInfo.EarningsAddr != address {
return nil, errorsmod.Wrapf(
ErrInvalidGenesisData,
"operator address %s has earnings address %s", address, op.OperatorInfo.EarningsAddr,
)
}
if op.OperatorInfo.ApproveAddr != address {
return nil, errorsmod.Wrapf(
ErrInvalidGenesisData,
"operator address %s has approve address %s", address, op.OperatorInfo.ApproveAddr,
)
}
operators[address] = struct{}{}
if op.OperatorInfo.ClientChainEarningsAddr != nil {
Expand Down

0 comments on commit 6dc5f04

Please sign in to comment.