-
Notifications
You must be signed in to change notification settings - Fork 147
/
receipt.go
40 lines (35 loc) · 1.35 KB
/
receipt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package isc
import (
"encoding/hex"
"fmt"
"github.com/iotaledger/wasp/packages/vm/gas"
)
// Receipt represents a blocklog.RequestReceipt with a resolved error string
type Receipt struct {
Request []byte `json:"request"`
Error *UnresolvedVMError `json:"error"`
GasBudget uint64 `json:"gasBudget"`
GasBurned uint64 `json:"gasBurned"`
GasFeeCharged uint64 `json:"gasFeeCharged"`
SDCharged uint64 `json:"storageDepositCharged"`
BlockIndex uint32 `json:"blockIndex"`
RequestIndex uint16 `json:"requestIndex"`
ResolvedError string `json:"resolvedError"`
GasBurnLog *gas.BurnLog `json:"-"`
}
func (r Receipt) DeserializedRequest() Request {
req, err := RequestFromBytes(r.Request)
if err != nil {
panic(err)
}
return req
}
func (r Receipt) String() string {
ret := fmt.Sprintf("ID: %s\n", r.DeserializedRequest().ID().String())
ret += fmt.Sprintf("Err: %v\n", r.ResolvedError)
ret += fmt.Sprintf("Block/Request index: %d / %d\n", r.BlockIndex, r.RequestIndex)
ret += fmt.Sprintf("Gas budget / burned / fee charged: %d / %d /%d\n", r.GasBudget, r.GasBurned, r.GasFeeCharged)
ret += fmt.Sprintf("Storage deposit charged: %d\n", r.SDCharged)
ret += fmt.Sprintf("Call data: %s\n", hex.EncodeToString(r.Request))
return ret
}