Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Run make fmt.
  • Loading branch information
tolikzinovyev committed Nov 8, 2021
commit 5406b6c256c8825e000b36c33efe1cde696cbd63
46 changes: 23 additions & 23 deletions api/error_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ import (
)

const (
errInvalidRoundAndMinMax = "cannot specify round and min-round/max-round"
errInvalidRoundMinMax = "min-round must be less than max-round"
errUnableToParseAddress = "unable to parse address"
errInvalidCreatorAddress = "found an invalid creator address"
errUnableToParseBase64 = "unable to parse base64 data"
errUnableToParseDigest = "unable to parse base32 digest data"
errUnableToParseNext = "unable to parse next token"
errUnableToDecodeTransaction = "unable to decode transaction bytes"
errFailedSearchingAccount = "failed while searching for account"
errNoAccountsFound = "no accounts found for address"
errNoAssetsFound = "no assets found for asset-id"
errNoTransactionFound = "no transaction found for transaction id"
errMultipleTransactions = "multiple transactions found for this txid, please contact us this shouldn't happen"
errMultipleAccounts = "multiple accounts found for this address, please contact us this shouldn't happen"
errMultipleAssets = "multiple assets found for this id, please contact us this shouldn't happen"
errMultiAcctRewind = "multiple accounts rewind is not supported by this server"
errRewindingAccount = "error while rewinding account"
errLookingUpBlock = "error while looking up block for round"
errTransactionSearch = "error while searching for transaction"
errSpecialAccounts = "indexer doesn't support fee sink and rewards pool accounts, please refer to algod for relevant information"
errFailedLoadSpecialAccounts = "failed to retrieve special accounts"
errInvalidRoundAndMinMax = "cannot specify round and min-round/max-round"
errInvalidRoundMinMax = "min-round must be less than max-round"
errUnableToParseAddress = "unable to parse address"
errInvalidCreatorAddress = "found an invalid creator address"
errUnableToParseBase64 = "unable to parse base64 data"
errUnableToParseDigest = "unable to parse base32 digest data"
errUnableToParseNext = "unable to parse next token"
errUnableToDecodeTransaction = "unable to decode transaction bytes"
errFailedSearchingAccount = "failed while searching for account"
errNoAccountsFound = "no accounts found for address"
errNoAssetsFound = "no assets found for asset-id"
errNoTransactionFound = "no transaction found for transaction id"
errMultipleTransactions = "multiple transactions found for this txid, please contact us this shouldn't happen"
errMultipleAccounts = "multiple accounts found for this address, please contact us this shouldn't happen"
errMultipleAssets = "multiple assets found for this id, please contact us this shouldn't happen"
errMultiAcctRewind = "multiple accounts rewind is not supported by this server"
errRewindingAccount = "error while rewinding account"
errLookingUpBlock = "error while looking up block for round"
errTransactionSearch = "error while searching for transaction"
errSpecialAccounts = "indexer doesn't support fee sink and rewards pool accounts, please refer to algod for relevant information"
errFailedLoadSpecialAccounts = "failed to retrieve special accounts"
errZeroAddressCloseRemainderToRole = "searching transactions by zero address with close address role is not supported"
errZeroAddressAssetSenderRole = "searching transactions by zero address with asset sender role is not supported"
errZeroAddressAssetCloseToRole = "searching transactions by zero address with asset close address role is not supported"
errZeroAddressAssetSenderRole = "searching transactions by zero address with asset sender role is not supported"
errZeroAddressAssetCloseToRole = "searching transactions by zero address with asset close address role is not supported"
)

var errUnknownAddressRole string
Expand Down
6 changes: 3 additions & 3 deletions api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func validateTransactionFilter(filter *idb.TransactionFilter) error {
var address basics.Address
copy(address[:], filter.Address)
if address.IsZero() {
if filter.AddressRole & idb.AddressRoleCloseRemainderTo != 0 {
if filter.AddressRole&idb.AddressRoleCloseRemainderTo != 0 {
errorArr = append(errorArr, errZeroAddressCloseRemainderToRole)
}
if filter.AddressRole & idb.AddressRoleAssetSender != 0 {
if filter.AddressRole&idb.AddressRoleAssetSender != 0 {
errorArr = append(errorArr, errZeroAddressAssetSenderRole)
}
if filter.AddressRole & idb.AddressRoleAssetCloseTo != 0 {
if filter.AddressRole&idb.AddressRoleAssetCloseTo != 0 {
errorArr = append(errorArr, errZeroAddressAssetCloseToRole)
}
}
Expand Down
16 changes: 8 additions & 8 deletions api/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,23 +228,23 @@ func TestValidateTransactionFilter(t *testing.T) {
},
{
name: "Round + MinRound Error",
filter: idb.TransactionFilter{
Round: uint64Ptr(10),
filter: idb.TransactionFilter{
Round: uint64Ptr(10),
MaxRound: 15,
},
errorContains: []string{errInvalidRoundAndMinMax},
},
{
name: "Round + MinRound Error",
filter: idb.TransactionFilter{
Round: uint64Ptr(10),
filter: idb.TransactionFilter{
Round: uint64Ptr(10),
MinRound: 5,
},
errorContains: []string{errInvalidRoundAndMinMax},
},
{
name: "Swapped Min/Max Round",
filter: idb.TransactionFilter{
name: "Swapped Min/Max Round",
filter: idb.TransactionFilter{
MinRound: 15,
MaxRound: 5,
},
Expand All @@ -253,15 +253,15 @@ func TestValidateTransactionFilter(t *testing.T) {
{
name: "Zero address close address role",
filter: idb.TransactionFilter{
Address: addrSlice(basics.Address{}),
Address: addrSlice(basics.Address{}),
AddressRole: idb.AddressRoleSender | idb.AddressRoleCloseRemainderTo,
},
errorContains: []string{errZeroAddressCloseRemainderToRole},
},
{
name: "Zero address asset sender and asset close address role",
filter: idb.TransactionFilter{
Address: addrSlice(basics.Address{}),
Address: addrSlice(basics.Address{}),
AddressRole: idb.AddressRoleAssetSender | idb.AddressRoleAssetCloseTo,
},
errorContains: []string{
Expand Down
2 changes: 1 addition & 1 deletion api/pointer_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ func strArrayPtr(x []string) *[]string {

func addrSlice(x basics.Address) []byte {
xx := new(basics.Address)
*xx = x;
*xx = x
return xx[:]
}