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: genesis validation #319

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading