Skip to content

Commit

Permalink
Fix: interact
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Apr 2, 2021
1 parent 29a55bf commit 9b9182e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions cmd/api/handlers/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (ctx *Context) prepareOperation(operation operation.Operation, bmd []bigmap
}

if bcd.IsContract(op.Destination) && operation.IsCall() && !tezerrors.HasParametersError(op.Errors) {
if err := ctx.setParameters(operation.Parameters, script, &op); err != nil {
if err := setParameters([]byte(operation.Parameters), script, &op); err != nil {
return op, err
}
}
Expand Down Expand Up @@ -309,14 +309,13 @@ func (ctx *Context) PrepareOperations(ops []operation.Operation, withStorageDiff
return resp, nil
}

func (ctx *Context) setParameters(data string, script *ast.Script, op *Operation) error {
func setParameters(data []byte, script *ast.Script, op *Operation) error {
parameter, err := script.ParameterType()
if err != nil {
return err
}
params := types.NewParameters([]byte(data))
op.Entrypoint = params.Entrypoint

params := types.NewParameters(data)
tree, err := parameter.FromParameters(params)
if err != nil {
if tezerrors.HasGasExhaustedError(op.Errors) {
Expand Down
4 changes: 2 additions & 2 deletions cmd/api/handlers/run_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (ctx *Context) RunCode(c *gin.Context) {
if ctx.handleError(c, err, 0) {
return
}
if err := ctx.setParameters(string(input), script, &main); ctx.handleError(c, err, 0) {
if err := setParameters(input, script, &main); ctx.handleError(c, err, 0) {
return
}
if err := ctx.setSimulateStorageDiff(response, script, &main); ctx.handleError(c, err, 0) {
Expand Down Expand Up @@ -241,7 +241,7 @@ func (ctx *Context) parseAppliedRunCode(response noderpc.RunCodeResponse, script
op.Protocol = main.Protocol
op.Level = main.Level
op.Internal = true
if err := ctx.setParameters(string(response.Operations[i].Parameters), script, &op); err != nil {
if err := setParameters(response.Operations[i].Parameters, script, &op); err != nil {
return nil, err
}
if err := ctx.setSimulateStorageDiff(response, script, &op); err != nil {
Expand Down

0 comments on commit 9b9182e

Please sign in to comment.