-
Notifications
You must be signed in to change notification settings - Fork 17
/
result.go
65 lines (56 loc) · 1.76 KB
/
result.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package operations
import (
"github.com/baking-bad/bcdhub/internal/bcd/consts"
"github.com/baking-bad/bcdhub/internal/bcd/tezerrors"
"github.com/baking-bad/bcdhub/internal/models/account"
"github.com/baking-bad/bcdhub/internal/models/operation"
"github.com/baking-bad/bcdhub/internal/models/types"
"github.com/baking-bad/bcdhub/internal/noderpc"
"github.com/baking-bad/bcdhub/internal/parsers"
)
func parseOperationResult(data noderpc.Operation, tx *operation.Operation, store parsers.Store) {
result := data.GetResult()
if result == nil {
return
}
tx.Status = types.NewOperationStatus(result.Status)
if result.ConsumedMilligas != nil {
tx.ConsumedGas = *result.ConsumedMilligas
} else {
tx.ConsumedGas = result.ConsumedGas * 100
}
if result.StorageSize != nil {
tx.StorageSize = *result.StorageSize
}
if result.PaidStorageSizeDiff != nil {
tx.PaidStorageSizeDiff = *result.PaidStorageSizeDiff
}
if len(result.Originated) > 0 {
tx.Destination = account.Account{
Address: result.Originated[0],
Type: types.AccountTypeContract,
Level: tx.Level,
OperationsCount: 1,
LastAction: tx.Timestamp,
}
}
if len(result.OriginatedRollup) > 0 {
tx.Destination = account.Account{
Address: result.OriginatedRollup,
Type: types.AccountTypeRollup,
Level: tx.Level,
OperationsCount: 1,
LastAction: tx.Timestamp,
}
}
tx.AllocatedDestinationContract = data.Kind == consts.Origination
if result.AllocatedDestinationContract != nil {
tx.AllocatedDestinationContract = *result.AllocatedDestinationContract
}
if errs, err := tezerrors.ParseArray(result.Errors); err == nil {
tx.Errors = errs
}
if tx.IsApplied() {
new(TicketUpdateParser).Parse(result, tx, store)
}
}