@@ -27,6 +27,7 @@ import (
2727 "github.com/onflow/cadence"
2828 jsoncdc "github.com/onflow/cadence/encoding/json"
2929 "github.com/onflow/cadence/runtime"
30+ "github.com/onflow/cadence/runtime/ast"
3031 "github.com/onflow/cadence/runtime/cmd"
3132 "github.com/onflow/cadence/runtime/common"
3233 "github.com/onflow/cadence/runtime/sema"
@@ -120,20 +121,32 @@ func ParseArguments(args []string, argsJSON string) (scriptArgs []cadence.Value,
120121 return
121122}
122123
123- func ParseArgumentsWithoutType (code []byte , args []string ) (scriptArgs []cadence.Value , err error ) {
124+ func ParseArgumentsWithoutType (fileName string , code []byte , args []string ) (scriptArgs []cadence.Value , err error ) {
124125
125126 var resultArgs []cadence.Value = make ([]cadence.Value , 0 )
126127
127128 codes := map [common.LocationID ]string {}
128- location := common .StringLocation ("" )
129+ location := common .StringLocation (fileName )
129130 program , must := cmd .PrepareProgram (string (code ), location , codes )
130131 checker , _ := cmd .PrepareChecker (program , location , codes , nil , must )
131132
132- err = checker .Check ()
133- var parameterList []* sema.Parameter = checker .EntryPointParameters ()
133+ var parameterList []* ast.Parameter
134134
135- //return on checker error or no entry
136- if err != nil || parameterList == nil {
135+ transactionDeclaration := program .SoleTransactionDeclaration ()
136+ if transactionDeclaration != nil {
137+ if transactionDeclaration .ParameterList != nil {
138+ parameterList = transactionDeclaration .ParameterList .Parameters
139+ }
140+ }
141+
142+ functionDeclaration := sema .FunctionEntryPointDeclaration (program )
143+ if functionDeclaration != nil {
144+ if functionDeclaration .ParameterList != nil {
145+ parameterList = functionDeclaration .ParameterList .Parameters
146+ }
147+ }
148+
149+ if parameterList == nil {
137150 return resultArgs , nil
138151 }
139152
@@ -142,7 +155,8 @@ func ParseArgumentsWithoutType(code []byte, args []string) (scriptArgs []cadence
142155 }
143156
144157 for index , argumentString := range args {
145- semaType := parameterList [index ].TypeAnnotation .Type
158+ astType := parameterList [index ].TypeAnnotation .Type
159+ semaType := checker .ConvertType (astType )
146160
147161 switch semaType {
148162 case sema .StringType :
0 commit comments