-
Notifications
You must be signed in to change notification settings - Fork 1
/
flow.go
132 lines (114 loc) · 3.02 KB
/
flow.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package types
import (
"reflect"
"github.com/onflow/cadence"
"github.com/onflow/flow-go-sdk"
)
// Tx represents an already existing blockchain transaction
type Txs []Tx
type Tx struct {
Height uint64
TransactionID string
//Transaction Details
Script []byte
Arguments [][]byte
ReferenceBlockID string
GasLimit uint64
ProposalKey string
Payer string
Authorizers []string
PayloadSignatures []byte
EnvelopeSignatures []byte
}
func NewTx(height uint64, transactionID string,
script []byte, arguments [][]byte, referenceBlockID string,
gasLimit uint64, proposalKey string, payer string, authorizers []string, payloadSignatures []byte,
envelopeSignatures []byte) Tx {
return Tx{
Height: height,
TransactionID: transactionID,
//Transaction Details
Script: script,
Arguments: arguments,
ReferenceBlockID: referenceBlockID,
GasLimit: gasLimit,
ProposalKey: proposalKey,
Payer: payer,
Authorizers: authorizers,
PayloadSignatures: payloadSignatures,
EnvelopeSignatures: envelopeSignatures,
}
}
type Event struct {
//Transaction Result Event
Height int
Type string
TransactionID string
TransactionIndex int
EventIndex int
Value cadence.Event
}
func NewEvent(height int, t string, transactionID string, transactionIndex int, eventIndex int,
value cadence.Event) Event {
return Event{
//Transaction Result Event
Height: height,
Type: t,
TransactionID: transactionID,
TransactionIndex: transactionIndex,
EventIndex: eventIndex,
Value: value,
}
}
// Successful tells whether this tx is successful or not
func (tx Tx) Successful() bool {
return true
}
type Collection struct {
Height uint64
Id string
Processed bool
TransactionIds []flow.Identifier
}
// Equal tells whether v and w represent the same rows
func (v Collection) Equal(w Collection) bool {
return v.Height == w.Height &&
v.Id == w.Id &&
v.Processed == w.Processed &&
reflect.DeepEqual(v.TransactionIds, w.TransactionIds)
}
// Collection allows to build a new Collection
func NewCollection(
height uint64,
id string,
processed bool,
transactionIds []flow.Identifier) Collection {
return Collection{
Height: height,
Id: id,
Processed: processed,
TransactionIds: transactionIds,
}
}
type TransactionResult struct {
TransactionId string
Status string
Error string
}
// Equal tells whether v and w represent the same rows
func (v TransactionResult) Equal(w TransactionResult) bool {
return v.TransactionId == w.TransactionId &&
v.Status == w.Status &&
v.Error == w.Error
}
// TransactionResult allows to build a new TransactionResult
func NewTransactionResult(
transactionId string,
status string,
error string) TransactionResult {
return TransactionResult{
TransactionId: transactionId,
Status: status,
Error: error,
}
}