Skip to content

Commit

Permalink
Return error or multi errors
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Semenyuk <[email protected]>
  • Loading branch information
alex-semenyuk committed Oct 10, 2023
1 parent dcd9916 commit 5a8195a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/tezos/get_receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tezos
import (
"context"
"encoding/json"
"errors"

"blockwatch.cc/tzgo/micheline"
"blockwatch.cc/tzgo/rpc"
Expand All @@ -24,7 +25,6 @@ type receiptExtraInfo struct {
Counter *fftypes.FFBigInt `json:"counter"`
Fee *fftypes.FFBigInt `json:"fee"`
Status *string `json:"status"`
ErrorMessage *string `json:"errorMessage"`
Storage *fftypes.JSONAny `json:"storage"`
}

Expand Down Expand Up @@ -100,20 +100,22 @@ func (c *tezosConnector) TransactionReceipt(ctx context.Context, req *ffcapi.Tra
script, err = c.client.GetContractScript(ctx, tx.Destination)
if err != nil {
log.L(ctx).Error("error getting contract script: ", err)
return nil, "", err
}
}
if len(tx.Result().Errors) > 0 {
errorMessage := ""
var errs error
for _, err := range tx.Result().Errors {
errorMessage += err.Error()
errs = errors.Join(errs, err)
}
extraInfo.ErrorMessage = &errorMessage
return nil, "", err
}
if prim := tx.Metadata.Result.Storage; prim != nil {
val := micheline.NewValue(script.StorageType(), *prim)
m, err := val.Map()
if err != nil {
log.L(ctx).Error("error parsing contract storage: ", err)
return nil, "", err
}
storageBytes, _ := json.Marshal(m)
extraInfo.Storage = fftypes.JSONAnyPtrBytes(storageBytes)
Expand Down

0 comments on commit 5a8195a

Please sign in to comment.