-
Notifications
You must be signed in to change notification settings - Fork 90
/
lookupAssetTransactions.go
228 lines (182 loc) · 7.58 KB
/
lookupAssetTransactions.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package indexer
import (
"context"
"encoding/base64"
"fmt"
"time"
"github.com/algorand/go-algorand-sdk/client/v2/common"
"github.com/algorand/go-algorand-sdk/client/v2/common/models"
)
// LookupAssetTransactionsParams contains all of the query parameters for url serialization.
type LookupAssetTransactionsParams struct {
// AddressString only include transactions with this address in one of the
// transaction fields.
AddressString string `url:"address,omitempty"`
// AddressRole combine with the address parameter to define what type of address to
// search for.
AddressRole string `url:"address-role,omitempty"`
// AfterTime include results after the given time. Must be an RFC 3339 formatted
// string.
AfterTime string `url:"after-time,omitempty"`
// BeforeTime include results before the given time. Must be an RFC 3339 formatted
// string.
BeforeTime string `url:"before-time,omitempty"`
// CurrencyGreaterThan results should have an amount greater than this value.
// MicroAlgos are the default currency unless an asset-id is provided, in which
// case the asset will be used.
CurrencyGreaterThan uint64 `url:"currency-greater-than,omitempty"`
// CurrencyLessThan results should have an amount less than this value. MicroAlgos
// are the default currency unless an asset-id is provided, in which case the asset
// will be used.
CurrencyLessThan uint64 `url:"currency-less-than,omitempty"`
// ExcludeCloseTo combine with address and address-role parameters to define what
// type of address to search for. The close to fields are normally treated as a
// receiver, if you would like to exclude them set this parameter to true.
ExcludeCloseTo bool `url:"exclude-close-to,omitempty"`
// Limit maximum number of results to return.
Limit uint64 `url:"limit,omitempty"`
// MaxRound include results at or before the specified max-round.
MaxRound uint64 `url:"max-round,omitempty"`
// MinRound include results at or after the specified min-round.
MinRound uint64 `url:"min-round,omitempty"`
// NextToken the next page of results. Use the next token provided by the previous
// results.
NextToken string `url:"next,omitempty"`
// NotePrefix specifies a prefix which must be contained in the note field.
NotePrefix string `url:"note-prefix,omitempty"`
// RekeyTo include results which include the rekey-to field.
RekeyTo bool `url:"rekey-to,omitempty"`
// Round include results for the specified round.
Round uint64 `url:"round,omitempty"`
// SigType sigType filters just results using the specified type of signature:
// * sig - Standard
// * msig - MultiSig
// * lsig - LogicSig
SigType string `url:"sig-type,omitempty"`
// TxType
TxType string `url:"tx-type,omitempty"`
// TXID lookup the specific transaction by ID.
TXID string `url:"txid,omitempty"`
}
// LookupAssetTransactions lookup transactions for an asset.
type LookupAssetTransactions struct {
c *Client
assetId uint64
p LookupAssetTransactionsParams
}
// AddressString only include transactions with this address in one of the
// transaction fields.
func (s *LookupAssetTransactions) AddressString(AddressString string) *LookupAssetTransactions {
s.p.AddressString = AddressString
return s
}
// AddressRole combine with the address parameter to define what type of address to
// search for.
func (s *LookupAssetTransactions) AddressRole(AddressRole string) *LookupAssetTransactions {
s.p.AddressRole = AddressRole
return s
}
// AfterTimeString include results after the given time. Must be an RFC 3339
// formatted string.
func (s *LookupAssetTransactions) AfterTimeString(AfterTime string) *LookupAssetTransactions {
s.p.AfterTime = AfterTime
return s
}
// AfterTime include results after the given time. Must be an RFC 3339 formatted
// string.
func (s *LookupAssetTransactions) AfterTime(AfterTime time.Time) *LookupAssetTransactions {
AfterTimeStr := AfterTime.Format(time.RFC3339)
return s.AfterTimeString(AfterTimeStr)
}
// BeforeTimeString include results before the given time. Must be an RFC 3339
// formatted string.
func (s *LookupAssetTransactions) BeforeTimeString(BeforeTime string) *LookupAssetTransactions {
s.p.BeforeTime = BeforeTime
return s
}
// BeforeTime include results before the given time. Must be an RFC 3339 formatted
// string.
func (s *LookupAssetTransactions) BeforeTime(BeforeTime time.Time) *LookupAssetTransactions {
BeforeTimeStr := BeforeTime.Format(time.RFC3339)
return s.BeforeTimeString(BeforeTimeStr)
}
// CurrencyGreaterThan results should have an amount greater than this value.
// MicroAlgos are the default currency unless an asset-id is provided, in which
// case the asset will be used.
func (s *LookupAssetTransactions) CurrencyGreaterThan(CurrencyGreaterThan uint64) *LookupAssetTransactions {
s.p.CurrencyGreaterThan = CurrencyGreaterThan
return s
}
// CurrencyLessThan results should have an amount less than this value. MicroAlgos
// are the default currency unless an asset-id is provided, in which case the asset
// will be used.
func (s *LookupAssetTransactions) CurrencyLessThan(CurrencyLessThan uint64) *LookupAssetTransactions {
s.p.CurrencyLessThan = CurrencyLessThan
return s
}
// ExcludeCloseTo combine with address and address-role parameters to define what
// type of address to search for. The close to fields are normally treated as a
// receiver, if you would like to exclude them set this parameter to true.
func (s *LookupAssetTransactions) ExcludeCloseTo(ExcludeCloseTo bool) *LookupAssetTransactions {
s.p.ExcludeCloseTo = ExcludeCloseTo
return s
}
// Limit maximum number of results to return.
func (s *LookupAssetTransactions) Limit(Limit uint64) *LookupAssetTransactions {
s.p.Limit = Limit
return s
}
// MaxRound include results at or before the specified max-round.
func (s *LookupAssetTransactions) MaxRound(MaxRound uint64) *LookupAssetTransactions {
s.p.MaxRound = MaxRound
return s
}
// MinRound include results at or after the specified min-round.
func (s *LookupAssetTransactions) MinRound(MinRound uint64) *LookupAssetTransactions {
s.p.MinRound = MinRound
return s
}
// NextToken the next page of results. Use the next token provided by the previous
// results.
func (s *LookupAssetTransactions) NextToken(NextToken string) *LookupAssetTransactions {
s.p.NextToken = NextToken
return s
}
// NotePrefix specifies a prefix which must be contained in the note field.
func (s *LookupAssetTransactions) NotePrefix(NotePrefix []byte) *LookupAssetTransactions {
s.p.NotePrefix = base64.StdEncoding.EncodeToString(NotePrefix)
return s
}
// RekeyTo include results which include the rekey-to field.
func (s *LookupAssetTransactions) RekeyTo(RekeyTo bool) *LookupAssetTransactions {
s.p.RekeyTo = RekeyTo
return s
}
// Round include results for the specified round.
func (s *LookupAssetTransactions) Round(Round uint64) *LookupAssetTransactions {
s.p.Round = Round
return s
}
// SigType sigType filters just results using the specified type of signature:
// * sig - Standard
// * msig - MultiSig
// * lsig - LogicSig
func (s *LookupAssetTransactions) SigType(SigType string) *LookupAssetTransactions {
s.p.SigType = SigType
return s
}
// TxType
func (s *LookupAssetTransactions) TxType(TxType string) *LookupAssetTransactions {
s.p.TxType = TxType
return s
}
// TXID lookup the specific transaction by ID.
func (s *LookupAssetTransactions) TXID(TXID string) *LookupAssetTransactions {
s.p.TXID = TXID
return s
}
// Do performs the HTTP request
func (s *LookupAssetTransactions) Do(ctx context.Context, headers ...*common.Header) (response models.TransactionsResponse, err error) {
err = s.c.get(ctx, &response, fmt.Sprintf("/v2/assets/%v/transactions", s.assetId), s.p, headers)
return
}