From 9b9182e296a455b255adfbe683f6f9994b7a4d71 Mon Sep 17 00:00:00 2001 From: Artem Date: Fri, 2 Apr 2021 12:23:49 +0300 Subject: [PATCH] Fix: interact --- cmd/api/handlers/operations.go | 7 +++---- cmd/api/handlers/run_code.go | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/api/handlers/operations.go b/cmd/api/handlers/operations.go index 1d30c03f1..5434042a9 100644 --- a/cmd/api/handlers/operations.go +++ b/cmd/api/handlers/operations.go @@ -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 } } @@ -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) { diff --git a/cmd/api/handlers/run_code.go b/cmd/api/handlers/run_code.go index 6db4c76ae..9933f62bd 100644 --- a/cmd/api/handlers/run_code.go +++ b/cmd/api/handlers/run_code.go @@ -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) { @@ -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 {