Skip to content

Commit cd50583

Browse files
fix: genesis validation (#319)
1 parent 505516b commit cd50583

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

x/appchain/coordinator/types/msg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (msg *RegisterSubscriberChainRequest) ValidateBasic() error {
4747
if _, _, err := assetstypes.ValidateID(
4848
assetID,
4949
true, // the caller must make them lowercase
50-
true, // TODO: we support only Ethereum assets for now.
50+
false,
5151
); err != nil {
5252
return fmt.Errorf("invalid asset id %s: %s", assetID, err)
5353
}

x/assets/types/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (gs GenesisState) ValidateDeposits(lzIDs map[uint64]struct{}, tokensTotalSt
124124
// validate the stakerID
125125
var stakerClientChainID uint64
126126
var err error
127-
if _, stakerClientChainID, err = ValidateID(stakerID, true, true); err != nil {
127+
if _, stakerClientChainID, err = ValidateID(stakerID, true, false); err != nil {
128128
return errorsmod.Wrapf(
129129
ErrInvalidGenesisData,
130130
"invalid stakerID: %s",

x/operator/types/genesis.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,17 @@ func (gs GenesisState) ValidateOperators() (map[string]struct{}, error) {
6161
"invalid operator address %s: %s", address, err,
6262
)
6363
}
64-
if op.OperatorInfo.EarningsAddr != "" {
65-
_, err := sdk.AccAddressFromBech32(op.OperatorInfo.EarningsAddr)
66-
if err != nil {
67-
return nil, errorsmod.Wrapf(
68-
ErrInvalidGenesisData,
69-
"invalid operator earning address %s: %s", op.OperatorInfo.EarningsAddr, err,
70-
)
71-
}
64+
if op.OperatorInfo.EarningsAddr != address {
65+
return nil, errorsmod.Wrapf(
66+
ErrInvalidGenesisData,
67+
"operator address %s has earnings address %s", address, op.OperatorInfo.EarningsAddr,
68+
)
69+
}
70+
if op.OperatorInfo.ApproveAddr != address {
71+
return nil, errorsmod.Wrapf(
72+
ErrInvalidGenesisData,
73+
"operator address %s has approve address %s", address, op.OperatorInfo.ApproveAddr,
74+
)
7275
}
7376
operators[address] = struct{}{}
7477
if op.OperatorInfo.ClientChainEarningsAddr != nil {

0 commit comments

Comments
 (0)