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