Skip to content

Commit

Permalink
fix some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
trestinlsd committed Dec 12, 2024
1 parent 00eeed8 commit 70cd42e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
12 changes: 10 additions & 2 deletions precompiles/avs/avs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterAVS() {
sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(),
sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(),
}
exoWhiteAddresses := []string{
sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(),
sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(),
}
assetID := suite.AssetIDs
minStakeAmount, taskAddr := uint64(3), "0xDF907c29719154eb9872f021d21CAE6E5025d7aB"
avsUnbondingPeriod, minSelfDelegation := uint64(3), uint64(3)
Expand All @@ -108,7 +112,7 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterAVS() {
common.HexToAddress(slashAddress),
common.HexToAddress(rewardAddress),
avsOwnerAddress,
avsOwnerAddress,
exoWhiteAddresses,
assetID,
avsUnbondingPeriod,
minSelfDelegation,
Expand Down Expand Up @@ -350,6 +354,10 @@ func (suite *AVSManagerPrecompileSuite) TestUpdateAVS() {
sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(),
sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(),
}
exoWhiteAddresses := []string{
sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(),
sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(),
}
assetID := suite.AssetIDs
minStakeAmount, taskAddr := uint64(3), "0x3e108c058e8066DA635321Dc3018294cA82ddEdf"
avsUnbondingPeriod, minSelfDelegation := uint64(3), uint64(3)
Expand All @@ -365,7 +373,7 @@ func (suite *AVSManagerPrecompileSuite) TestUpdateAVS() {
common.HexToAddress(slashAddress),
common.HexToAddress(rewardAddress),
avsOwnerAddress,
avsOwnerAddress,
exoWhiteAddresses,
assetID,
avsUnbondingPeriod,
minSelfDelegation,
Expand Down
2 changes: 1 addition & 1 deletion precompiles/avs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (p Precompile) GetAVSParamsFromInputs(_ sdk.Context, args []interface{}) (*
if err != nil {
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 7, "[]string", whitelistAddress)
}
exoAddresses[i] = accAddr.String()
exoWhiteAddresses[i] = accAddr.String()
}
avsParams.WhitelistAddress = exoWhiteAddresses
// string, since it is the address_id representation
Expand Down
8 changes: 6 additions & 2 deletions x/avs/keeper/avs.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ func (k *Keeper) GetAllChainIDInfos(ctx sdk.Context) ([]types.ChainIDInfo, error
return ret, nil
}

// IsWhitelisted check if operator is in the whitelist
// IsWhitelisted checks if an operator is in the AVS whitelist.
// If the whitelist is empty, any operator is considered whitelisted.
// Returns true if the operator is whitelisted, false otherwise.
// Returns an error if the AVS address is invalid, the operator address is invalid,
// or if the operator is not in the whitelist.
func (k *Keeper) IsWhitelisted(ctx sdk.Context, avsAddr, operatorAddr string) (bool, error) {
avsInfo, err := k.GetAVSInfo(ctx, avsAddr)
if err != nil {
Expand All @@ -241,7 +245,7 @@ func (k *Keeper) IsWhitelisted(ctx sdk.Context, avsAddr, operatorAddr string) (b
return true, nil
}
if !slices.Contains(avsInfo.Info.WhitelistAddress, operatorAddr) {
return false, errorsmod.Wrap(err, "not in the whitelist address of supported operators")
return false, errorsmod.Wrap(err, fmt.Sprintf("operator %s not in whitelist", operatorAddr))
}
return true, nil
}
2 changes: 1 addition & 1 deletion x/operator/keeper/opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (k *Keeper) OptIn(
return types.ErrNoSuchAvs.Wrapf("AVS not found %s", avsAddr)
}
// check if operator is in the whitelist
if isWhite, err := k.avsKeeper.IsWhitelisted(ctx, avsAddr, operatorAddress.String()); !isWhite {
if _, err := k.avsKeeper.IsWhitelisted(ctx, avsAddr, operatorAddress.String()); err != nil {
return err
}
// check optedIn info
Expand Down

0 comments on commit 70cd42e

Please sign in to comment.