-
Notifications
You must be signed in to change notification settings - Fork 113
/
receipt.go
38 lines (34 loc) · 917 Bytes
/
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
package itest
import (
"github.com/iost-official/go-iost/common"
"github.com/iost-official/go-iost/core/tx"
"github.com/iost-official/go-iost/rpc/pb"
)
// Receipt is the transaction receipt object
type Receipt struct {
*tx.TxReceipt
}
// Success will return whether the receipt is successful
func (r *Receipt) Success() bool {
return r.Status.Code == tx.Success
}
// NewReceiptFromPb returns a new Receipt instance from protobuffer struct.
func NewReceiptFromPb(tr *rpcpb.TxReceipt) *Receipt {
ret := &tx.TxReceipt{
TxHash: common.Base58Decode(tr.TxHash),
GasUsage: int64(tr.GasUsage * 100),
RAMUsage: tr.RamUsage,
Status: &tx.Status{
Message: tr.Message,
Code: tx.StatusCode(tr.StatusCode),
},
Returns: tr.Returns,
}
for _, r := range tr.Receipts {
ret.Receipts = append(ret.Receipts, &tx.Receipt{
FuncName: r.FuncName,
Content: r.Content,
})
}
return &Receipt{ret}
}