-
Notifications
You must be signed in to change notification settings - Fork 1
/
operation_result.go
85 lines (64 loc) · 2.33 KB
/
operation_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package core
import (
"math/big"
tz "github.com/ecadlabs/gotez/v2"
)
type InternalOperationResult interface {
OperationContents
OperationWithResult
}
type ManagerOperationResult interface {
Status() string
IsApplied() bool
}
type ManagerOperationResultAppliedOrBacktracked interface {
ManagerOperationResult
GetResultContents() any
}
// SuccessfulManagerOperationResult is used to represent implicit operations results
type SuccessfulManagerOperationResult interface {
OperationContents
ManagerOperationResultAppliedOrBacktracked
}
//json:status=Status()
type OperationResultApplied[T any] struct {
Contents T `json:"contents"`
}
func (*OperationResultApplied[T]) Status() string { return "applied" }
func (*OperationResultApplied[T]) IsApplied() bool { return true }
func (r *OperationResultApplied[T]) GetResultContents() any { return r.Contents }
var _ ManagerOperationResultAppliedOrBacktracked = (*OperationResultApplied[struct{}])(nil)
//json:status=Status()
type OperationResultBacktracked[T any] struct {
Errors tz.Option[OperationResultErrors] `json:"errors"`
Contents T `json:"contents"`
}
func (*OperationResultBacktracked[T]) Status() string { return "backtracked" }
func (*OperationResultBacktracked[T]) IsApplied() bool { return false }
func (r *OperationResultBacktracked[T]) GetResultContents() any { return r.Contents }
var _ ManagerOperationResultAppliedOrBacktracked = (*OperationResultBacktracked[struct{}])(nil)
type OperationResultErrors struct {
Errors []Bytes `tz:"dyn" json:"errors"`
}
//json:status=Status()
type OperationResultFailed OperationResultErrors
func (*OperationResultFailed) Status() string { return "failed" }
func (*OperationResultFailed) IsApplied() bool { return false }
//json:status=Status()
type OperationResultSkipped struct{}
func (*OperationResultSkipped) Status() string { return "skipped" }
func (*OperationResultSkipped) IsApplied() bool { return false }
type ResultWithConsumedMilligas interface {
GetConsumedMilligas() tz.BigUint
}
type ResultWithStorageSize interface {
StorageSizeEstimator
GetStorageSize() tz.BigInt
}
type ResultWithPaidStorageSizeDiff interface {
StorageSizeEstimator
GetPaidStorageSizeDiff() tz.BigInt
}
type StorageSizeEstimator interface {
EstimateStorageSize(constants Constants) *big.Int
}