github.com/algorand/go-algorand-sdk@v1.24.0/client/v2/indexer/lookupAssetTransactions.go (about) 1 package indexer 2 3 import ( 4 "context" 5 "encoding/base64" 6 "fmt" 7 "time" 8 9 "github.com/algorand/go-algorand-sdk/client/v2/common" 10 "github.com/algorand/go-algorand-sdk/client/v2/common/models" 11 ) 12 13 // LookupAssetTransactionsParams contains all of the query parameters for url serialization. 14 type LookupAssetTransactionsParams struct { 15 16 // AddressString only include transactions with this address in one of the 17 // transaction fields. 18 AddressString string `url:"address,omitempty"` 19 20 // AddressRole combine with the address parameter to define what type of address to 21 // search for. 22 AddressRole string `url:"address-role,omitempty"` 23 24 // AfterTime include results after the given time. Must be an RFC 3339 formatted 25 // string. 26 AfterTime string `url:"after-time,omitempty"` 27 28 // BeforeTime include results before the given time. Must be an RFC 3339 formatted 29 // string. 30 BeforeTime string `url:"before-time,omitempty"` 31 32 // CurrencyGreaterThan results should have an amount greater than this value. 33 // MicroAlgos are the default currency unless an asset-id is provided, in which 34 // case the asset will be used. 35 CurrencyGreaterThan uint64 `url:"currency-greater-than,omitempty"` 36 37 // CurrencyLessThan results should have an amount less than this value. MicroAlgos 38 // are the default currency unless an asset-id is provided, in which case the asset 39 // will be used. 40 CurrencyLessThan uint64 `url:"currency-less-than,omitempty"` 41 42 // ExcludeCloseTo combine with address and address-role parameters to define what 43 // type of address to search for. The close to fields are normally treated as a 44 // receiver, if you would like to exclude them set this parameter to true. 45 ExcludeCloseTo bool `url:"exclude-close-to,omitempty"` 46 47 // Limit maximum number of results to return. There could be additional pages even 48 // if the limit is not reached. 49 Limit uint64 `url:"limit,omitempty"` 50 51 // MaxRound include results at or before the specified max-round. 52 MaxRound uint64 `url:"max-round,omitempty"` 53 54 // MinRound include results at or after the specified min-round. 55 MinRound uint64 `url:"min-round,omitempty"` 56 57 // NextToken the next page of results. Use the next token provided by the previous 58 // results. 59 NextToken string `url:"next,omitempty"` 60 61 // NotePrefix specifies a prefix which must be contained in the note field. 62 NotePrefix string `url:"note-prefix,omitempty"` 63 64 // RekeyTo include results which include the rekey-to field. 65 RekeyTo bool `url:"rekey-to,omitempty"` 66 67 // Round include results for the specified round. 68 Round uint64 `url:"round,omitempty"` 69 70 // SigType sigType filters just results using the specified type of signature: 71 // * sig - Standard 72 // * msig - MultiSig 73 // * lsig - LogicSig 74 SigType string `url:"sig-type,omitempty"` 75 76 // TxType 77 TxType string `url:"tx-type,omitempty"` 78 79 // TXID lookup the specific transaction by ID. 80 TXID string `url:"txid,omitempty"` 81 } 82 83 // LookupAssetTransactions lookup transactions for an asset. Transactions are 84 // returned oldest to newest. 85 type LookupAssetTransactions struct { 86 c *Client 87 88 assetId uint64 89 90 p LookupAssetTransactionsParams 91 } 92 93 // AddressString only include transactions with this address in one of the 94 // transaction fields. 95 func (s *LookupAssetTransactions) AddressString(AddressString string) *LookupAssetTransactions { 96 s.p.AddressString = AddressString 97 98 return s 99 } 100 101 // AddressRole combine with the address parameter to define what type of address to 102 // search for. 103 func (s *LookupAssetTransactions) AddressRole(AddressRole string) *LookupAssetTransactions { 104 s.p.AddressRole = AddressRole 105 106 return s 107 } 108 109 // AfterTimeString include results after the given time. Must be an RFC 3339 110 // formatted string. 111 func (s *LookupAssetTransactions) AfterTimeString(AfterTime string) *LookupAssetTransactions { 112 s.p.AfterTime = AfterTime 113 114 return s 115 } 116 117 // AfterTime include results after the given time. Must be an RFC 3339 formatted 118 // string. 119 func (s *LookupAssetTransactions) AfterTime(AfterTime time.Time) *LookupAssetTransactions { 120 AfterTimeStr := AfterTime.Format(time.RFC3339) 121 122 return s.AfterTimeString(AfterTimeStr) 123 } 124 125 // BeforeTimeString include results before the given time. Must be an RFC 3339 126 // formatted string. 127 func (s *LookupAssetTransactions) BeforeTimeString(BeforeTime string) *LookupAssetTransactions { 128 s.p.BeforeTime = BeforeTime 129 130 return s 131 } 132 133 // BeforeTime include results before the given time. Must be an RFC 3339 formatted 134 // string. 135 func (s *LookupAssetTransactions) BeforeTime(BeforeTime time.Time) *LookupAssetTransactions { 136 BeforeTimeStr := BeforeTime.Format(time.RFC3339) 137 138 return s.BeforeTimeString(BeforeTimeStr) 139 } 140 141 // CurrencyGreaterThan results should have an amount greater than this value. 142 // MicroAlgos are the default currency unless an asset-id is provided, in which 143 // case the asset will be used. 144 func (s *LookupAssetTransactions) CurrencyGreaterThan(CurrencyGreaterThan uint64) *LookupAssetTransactions { 145 s.p.CurrencyGreaterThan = CurrencyGreaterThan 146 147 return s 148 } 149 150 // CurrencyLessThan results should have an amount less than this value. MicroAlgos 151 // are the default currency unless an asset-id is provided, in which case the asset 152 // will be used. 153 func (s *LookupAssetTransactions) CurrencyLessThan(CurrencyLessThan uint64) *LookupAssetTransactions { 154 s.p.CurrencyLessThan = CurrencyLessThan 155 156 return s 157 } 158 159 // ExcludeCloseTo combine with address and address-role parameters to define what 160 // type of address to search for. The close to fields are normally treated as a 161 // receiver, if you would like to exclude them set this parameter to true. 162 func (s *LookupAssetTransactions) ExcludeCloseTo(ExcludeCloseTo bool) *LookupAssetTransactions { 163 s.p.ExcludeCloseTo = ExcludeCloseTo 164 165 return s 166 } 167 168 // Limit maximum number of results to return. There could be additional pages even 169 // if the limit is not reached. 170 func (s *LookupAssetTransactions) Limit(Limit uint64) *LookupAssetTransactions { 171 s.p.Limit = Limit 172 173 return s 174 } 175 176 // MaxRound include results at or before the specified max-round. 177 func (s *LookupAssetTransactions) MaxRound(MaxRound uint64) *LookupAssetTransactions { 178 s.p.MaxRound = MaxRound 179 180 return s 181 } 182 183 // MinRound include results at or after the specified min-round. 184 func (s *LookupAssetTransactions) MinRound(MinRound uint64) *LookupAssetTransactions { 185 s.p.MinRound = MinRound 186 187 return s 188 } 189 190 // NextToken the next page of results. Use the next token provided by the previous 191 // results. 192 func (s *LookupAssetTransactions) NextToken(NextToken string) *LookupAssetTransactions { 193 s.p.NextToken = NextToken 194 195 return s 196 } 197 198 // NotePrefix specifies a prefix which must be contained in the note field. 199 func (s *LookupAssetTransactions) NotePrefix(NotePrefix []byte) *LookupAssetTransactions { 200 s.p.NotePrefix = base64.StdEncoding.EncodeToString(NotePrefix) 201 202 return s 203 } 204 205 // RekeyTo include results which include the rekey-to field. 206 func (s *LookupAssetTransactions) RekeyTo(RekeyTo bool) *LookupAssetTransactions { 207 s.p.RekeyTo = RekeyTo 208 209 return s 210 } 211 212 // Round include results for the specified round. 213 func (s *LookupAssetTransactions) Round(Round uint64) *LookupAssetTransactions { 214 s.p.Round = Round 215 216 return s 217 } 218 219 // SigType sigType filters just results using the specified type of signature: 220 // * sig - Standard 221 // * msig - MultiSig 222 // * lsig - LogicSig 223 func (s *LookupAssetTransactions) SigType(SigType string) *LookupAssetTransactions { 224 s.p.SigType = SigType 225 226 return s 227 } 228 229 // TxType 230 func (s *LookupAssetTransactions) TxType(TxType string) *LookupAssetTransactions { 231 s.p.TxType = TxType 232 233 return s 234 } 235 236 // TXID lookup the specific transaction by ID. 237 func (s *LookupAssetTransactions) TXID(TXID string) *LookupAssetTransactions { 238 s.p.TXID = TXID 239 240 return s 241 } 242 243 // Do performs the HTTP request 244 func (s *LookupAssetTransactions) Do(ctx context.Context, headers ...*common.Header) (response models.TransactionsResponse, err error) { 245 err = s.c.get(ctx, &response, fmt.Sprintf("/v2/assets/%s/transactions", common.EscapeParams(s.assetId)...), s.p, headers) 246 return 247 }