From f4d86a5d91c523572e145b8150654faab1c21091 Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Thu, 21 Mar 2024 20:03:43 +0500 Subject: [PATCH] Minor fixes Signed-off-by: Alexey Semenyuk --- internal/tezos/deploy_contract_prepare.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/internal/tezos/deploy_contract_prepare.go b/internal/tezos/deploy_contract_prepare.go index 9def61d..216f667 100644 --- a/internal/tezos/deploy_contract_prepare.go +++ b/internal/tezos/deploy_contract_prepare.go @@ -20,7 +20,8 @@ func (c *tezosConnector) DeployContractPrepare(ctx context.Context, req *ffcapi. return nil, ffcapi.ErrorReasonInvalidInputs, i18n.NewError(ctx, "Missing contract", req.Contract) } - sc := asScript(req.Contract.String()) + var sc micheline.Script + _ = json.Unmarshal([]byte(req.Contract.String()), &sc) orig := &codec.Origination{ Script: sc, } @@ -30,11 +31,11 @@ func (c *tezosConnector) DeployContractPrepare(ctx context.Context, req *ffcapi. return nil, ffcapi.ErrorReasonInvalidInputs, i18n.NewError(ctx, msgs.MsgInvalidFromAddress, req.From, err) } - hash, _ := c.client.GetBlockHash(ctx, rpc.Head) + headBlockHash, _ := c.client.GetBlockHash(ctx, rpc.Head) op := codec.NewOp(). WithContents(orig). WithSource(addr). - WithBranch(hash) + WithBranch(headBlockHash) err = c.completeOp(ctx, op, req.From, req.Nonce) if err != nil { @@ -45,16 +46,10 @@ func (c *tezosConnector) DeployContractPrepare(ctx context.Context, req *ffcapi. return nil, reason, err } - log.L(ctx).Infof("Prepared deploy transaction dataLen=%d gas=%s", len(op.Bytes()), req.Gas.Int()) + log.L(ctx).Infof("Prepared deploy transaction dataLen=%d", len(op.Bytes())) return &ffcapi.TransactionPrepareResponse{ Gas: req.Gas, TransactionData: hex.EncodeToString(op.Bytes()), }, "", nil } - -func asScript(s string) micheline.Script { - var sc micheline.Script - _ = json.Unmarshal([]byte(s), &sc) - return sc -}