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: Enforce alphabetic order to seer methods import #64

Merged
merged 3 commits into from
Sep 4, 2024
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
23 changes: 20 additions & 3 deletions evm/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"go/printer"
"go/token"
"regexp"
"sort"
"strconv"
"strings"
"text/template"
Expand Down Expand Up @@ -616,7 +617,7 @@ func DeriveMethodReturnValues(parameters []ABIBoundParameter) ([]MethodReturnVal
}

// Produces a CLI specification for the structure with the given name, provided the AST nodes representing
// the deployment method, the tranasaction methods, and the view methods for the corresponding smart contract.
// the deployment method, the transaction methods, and the view methods for the corresponding smart contract.
//
// The value of the deployMethod argument is used to determine if the deployment functionality will be
// added to the CLI. If deployMethod is nil, then a deployment command is not generated. This is signified
Expand Down Expand Up @@ -656,7 +657,15 @@ func ParseCLISpecification(structName string, deployMethod *ast.FuncDecl, viewMe

result.ViewHandlers = make([]HandlerDefinition, len(viewMethods))
currentViewHandler := 0
for methodName, methodNode := range viewMethods {

viewMethodNames := make([]string, 0, len(viewMethods))
for viewMethodName := range viewMethods {
viewMethodNames = append(viewMethodNames, viewMethodName)
}
sort.Strings(viewMethodNames)

for _, methodName := range viewMethodNames {
methodNode := viewMethods[methodName]
parameters := make([]ABIBoundParameter, len(methodNode.Type.Params.List))

// Every view method, when bound to Go, will retrun an error as its last return value.
Expand Down Expand Up @@ -701,7 +710,15 @@ func ParseCLISpecification(structName string, deployMethod *ast.FuncDecl, viewMe

result.TransactHandlers = make([]HandlerDefinition, len(transactMethods))
currentTransactHandler := 0
for methodName, methodNode := range transactMethods {

transactMethodNames := make([]string, 0, len(transactMethods))
for transactMethodName := range transactMethods {
transactMethodNames = append(transactMethodNames, transactMethodName)
}
sort.Strings(transactMethodNames)

for _, methodName := range transactMethodNames {
methodNode := transactMethods[methodName]
parameters := make([]ABIBoundParameter, len(methodNode.Type.Params.List))
for i, arg := range methodNode.Type.Params.List {
parameter, parameterErr := ParseBoundParameter(arg)
Expand Down
Loading
Loading