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

chore(precompiles): remove outdated distribution authorization checks #1992

Merged
merged 2 commits into from
Nov 3, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (erc20) [#1984](https://github.com/evmos/evmos/pull/1984) Add tests for ERC20 precompile events.
- (ci) [#1985](https://github.com/evmos/evmos/pull/1985) Add CI action to check for a Changelog entry on PRs to `main`.
- (erc20) [#1983](https://github.com/evmos/evmos/pull/1983) Add ERC-20 Precompile queries.
- (distribution) [#1992](https://github.com/evmos/evmos/pull/1992) Remove outdated check utility for distribution approval.

### Bug Fixes

Expand Down
39 changes: 0 additions & 39 deletions precompiles/authorization/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,45 +107,6 @@ func CheckRevokeArgs(args []interface{}) (common.Address, []string, error) {
return granteeAddr, typeURLs, nil
}

// CheckDistributionApprovalArgs checks the arguments passed to the distribution Approve function.
func CheckDistributionApprovalArgs(args []interface{}, origin common.Address) (common.Address, []string, []string, error) {
if len(args) != 3 {
return common.Address{}, nil, nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, 3, len(args))
}

spenderAddr, ok := args[0].(common.Address)
if !ok || spenderAddr == (common.Address{}) {
return common.Address{}, nil, nil, fmt.Errorf(ErrInvalidGranter, args[0])
}

typeURLs, err := validateMsgTypes(args[1])
if err != nil {
return common.Address{}, nil, nil, err
}

allowedList, ok := args[2].([]string)
if !ok {
return common.Address{}, nil, nil, fmt.Errorf(ErrInvalidMethods, args[2])
}

for i, addr := range allowedList {
// If the address is hex, convert it to bech32
if common.IsHexAddress(addr) {
allowedList[i], err = sdk.Bech32ifyAddressBytes("evmos", common.HexToAddress(addr).Bytes())
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("failed to convert hex address to bech32: %w", err)
}
}
}

// If the origin is not present in the allowedList add it by default
if !slices.Contains(allowedList, origin.String()) {
allowedList = append(allowedList, sdk.AccAddress(origin.Bytes()).String())
}

return spenderAddr, typeURLs, allowedList, nil
}

// CheckAllowanceArgs checks the arguments for the Allowance function.
func CheckAllowanceArgs(args []interface{}) (common.Address, common.Address, string, error) {
if len(args) != 3 {
Expand Down