Skip to content

Commit

Permalink
Merge pull request #64 from karacurt/fix/binding-output
Browse files Browse the repository at this point in the history
Fix: Enforce alphabetic order to seer methods import
  • Loading branch information
zomglings authored Sep 4, 2024
2 parents 4b059c4 + dd5cb5d commit 96a636e
Show file tree
Hide file tree
Showing 3 changed files with 350 additions and 329 deletions.
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

0 comments on commit 96a636e

Please sign in to comment.