Skip to content

Commit 2ebcc0b

Browse files
authored
fix (#786)
1 parent 1393a46 commit 2ebcc0b

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

x/vm/types/params.go

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"math/big"
66
"slices"
77

8-
"github.com/ethereum/go-ethereum/common"
98
"github.com/ethereum/go-ethereum/core/vm"
109
"github.com/ethereum/go-ethereum/params"
1110

@@ -121,16 +120,6 @@ func (p Params) EIPs() []int {
121120
return eips
122121
}
123122

124-
// GetActiveStaticPrecompilesAddrs is a util function that the Active Precompiles
125-
// as a slice of addresses.
126-
func (p Params) GetActiveStaticPrecompilesAddrs() []common.Address {
127-
precompiles := make([]common.Address, len(p.ActiveStaticPrecompiles))
128-
for i, precompile := range p.ActiveStaticPrecompiles {
129-
precompiles[i] = common.HexToAddress(precompile)
130-
}
131-
return precompiles
132-
}
133-
134123
// IsEVMChannel returns true if the channel provided is in the list of
135124
// EVM channels
136125
func (p Params) IsEVMChannel(channel string) bool {
@@ -151,12 +140,7 @@ func (act AccessControlType) Validate() error {
151140
return validateAllowlistAddresses(act.AccessControlList)
152141
}
153142

154-
func validateAccessType(i interface{}) error {
155-
accessType, ok := i.(AccessType)
156-
if !ok {
157-
return fmt.Errorf("invalid access type type: %T", i)
158-
}
159-
143+
func validateAccessType(accessType AccessType) error {
160144
switch accessType {
161145
case AccessTypePermissionless, AccessTypeRestricted, AccessTypePermissioned:
162146
return nil
@@ -165,12 +149,7 @@ func validateAccessType(i interface{}) error {
165149
}
166150
}
167151

168-
func validateAllowlistAddresses(i interface{}) error {
169-
addresses, ok := i.([]string)
170-
if !ok {
171-
return fmt.Errorf("invalid whitelist addresses type: %T", i)
172-
}
173-
152+
func validateAllowlistAddresses(addresses []string) error {
174153
for _, address := range addresses {
175154
if err := utils.ValidateAddress(address); err != nil {
176155
return fmt.Errorf("invalid whitelist address: %s", address)
@@ -179,12 +158,7 @@ func validateAllowlistAddresses(i interface{}) error {
179158
return nil
180159
}
181160

182-
func validateEIPs(i interface{}) error {
183-
eips, ok := i.([]int64)
184-
if !ok {
185-
return fmt.Errorf("invalid EIP slice type: %T", i)
186-
}
187-
161+
func validateEIPs(eips []int64) error {
188162
uniqueEIPs := make(map[int64]struct{})
189163

190164
for _, eip := range eips {
@@ -203,12 +177,7 @@ func validateEIPs(i interface{}) error {
203177
}
204178

205179
// ValidatePrecompiles checks if the precompile addresses are valid and unique.
206-
func ValidatePrecompiles(i interface{}) error {
207-
precompiles, ok := i.([]string)
208-
if !ok {
209-
return fmt.Errorf("invalid precompile slice type: %T", i)
210-
}
211-
180+
func ValidatePrecompiles(precompiles []string) error {
212181
seenPrecompiles := make(map[string]struct{})
213182
for _, precompile := range precompiles {
214183
if _, ok := seenPrecompiles[precompile]; ok {

x/vm/types/params_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ func TestParamsEIPs(t *testing.T) {
8484
}
8585

8686
func TestParamsValidatePriv(t *testing.T) {
87-
require.Error(t, validateEIPs(""))
8887
require.NoError(t, validateEIPs([]int64{1884}))
8988
require.ErrorContains(t, validateEIPs([]int64{1884, 1884, 1885}), "duplicate EIP: 1884")
9089
require.NoError(t, validateChannels([]string{"channel-0"}))

x/vm/types/permissions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func getCanCreateFn(accessControl *AccessControl, signer common.Address) callerF
9595
return func(_ common.Address) bool { return false }
9696
}
9797

98-
// CanCreate implements the PermissionPolicy interface.
98+
// CanCall implements the PermissionPolicy interface.
9999
// It allows calls if access type is set to everybody.
100100
// Otherwise, it checks if:
101101
// - The signer is allowed to do so.

0 commit comments

Comments
 (0)