Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Semenyuk <[email protected]>
  • Loading branch information
alex-semenyuk committed Mar 21, 2024
1 parent 53aee26 commit f4d86a5
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions internal/tezos/deploy_contract_prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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 {
Expand All @@ -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
}

0 comments on commit f4d86a5

Please sign in to comment.