Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bd40522
Merge branch 'release/2.8.3'
onetechnical Feb 1, 2022
4997285
Merge branch 'release/2.8.4'
bricerisingalgorand Feb 7, 2022
ae96643
Ledger refactoring changes (#870)
tolikzinovyev Feb 22, 2022
76faddd
unlimited assets: backwards-compatible JSON encodings for account dat…
cce Feb 24, 2022
c941e78
REST API changes for unlimited assets (#872)
cce Feb 25, 2022
dadae50
Merge remote-tracking branch 'origin/develop' into feature/unlimited-…
cce Feb 25, 2022
8444586
REST API: count include-all results when checking max resources limit…
cce Feb 25, 2022
20c5ade
add "none" to exclude enum
cce Feb 25, 2022
ebc44d5
rename MaxAccountNestedObjects => MaxAPIResourcesPerAccount
cce Feb 25, 2022
b3ebf76
update docs for MaxAccountNestedObjects => MaxAPIResourcesPerAccount
cce Feb 25, 2022
0a20fa2
remove "creator" from required since it has been removed from response
cce Feb 25, 2022
12aaa71
achieve parity
cce Feb 25, 2022
6bc3394
Merge branch 'release/2.9.0'
algobarb Mar 2, 2022
6fdb088
Merge remote-tracking branch 'origin/master' into feature/unlimited-a…
cce Mar 3, 2022
ff54cba
Merge remote-tracking branch 'origin/develop' into feature/unlimited-…
cce Mar 8, 2022
333fedf
add DisabledMapConfig to handles_e2e_test defaultOpts
cce Mar 8, 2022
6402d35
Merge remote-tracking branch 'origin/develop' into feature/unlimited-…
cce Mar 9, 2022
482097a
REST API: use ErrorResponse instead of AccountsErrorResponse (#916)
cce Mar 10, 2022
2b82173
Merge branch 'develop' into feature/unlimited-assets
winder Mar 10, 2022
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
Next Next commit
REST API: use ErrorResponse instead of AccountsErrorResponse (#916)
* use ErrorResponse instead of AccountsErrorResponse

* update for ErrorResponse format in tests

* remove unnecessary pointers from preparing ErrorResponse
  • Loading branch information
cce authored Mar 10, 2022
commit 482097a83c5e0eef24272f3bcb5b8662acbcad0b
21 changes: 12 additions & 9 deletions api/converter_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,16 +635,19 @@ func (si *ServerImplementation) transactionParamsToTransactionFilter(params gene
return
}

func (si *ServerImplementation) maxAccountsErrorToAccountsErrorResponse(maxErr idb.MaxAPIResourcesPerAccountError) generated.AccountsErrorResponse {
func (si *ServerImplementation) maxAccountsErrorToAccountsErrorResponse(maxErr idb.MaxAPIResourcesPerAccountError) generated.ErrorResponse {
addr := maxErr.Address.String()
max := uint64(si.opts.MaxAPIResourcesPerAccount)
return generated.AccountsErrorResponse{
Message: "Result limit exceeded",
MaxResults: &max,
Address: &addr,
TotalAssetsOptedIn: &maxErr.TotalAssets,
TotalCreatedAssets: &maxErr.TotalAssetParams,
TotalAppsOptedIn: &maxErr.TotalAppLocalStates,
TotalCreatedApps: &maxErr.TotalAppParams,
extraData := map[string]interface{}{
"max-results": max,
"address": addr,
"total-assets-opted-in": maxErr.TotalAssets,
"total-created-assets": maxErr.TotalAssetParams,
"total-apps-opted-in": maxErr.TotalAppLocalStates,
"total-created-apps": maxErr.TotalAppParams,
}
return generated.ErrorResponse{
Message: "Result limit exceeded",
Data: &extraData,
}
}
305 changes: 152 additions & 153 deletions api/generated/common/routes.go

Large diffs are not rendered by default.

15 changes: 2 additions & 13 deletions api/generated/common/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

372 changes: 185 additions & 187 deletions api/generated/v2/routes.go

Large diffs are not rendered by default.

15 changes: 2 additions & 13 deletions api/generated/v2/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 29 additions & 16 deletions api/handlers_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,19 @@ func TestAccountExcludeParameters(t *testing.T) {

}

type accountsErrorResponse struct {
Data struct {
Address *string `json:"address,omitempty"`
MaxResults *uint64 `json:"max-results,omitempty"`
Message string `json:"message"`
TotalAppsOptedIn *uint64 `json:"total-apps-opted-in,omitempty"`
TotalAssetsOptedIn *uint64 `json:"total-assets-opted-in,omitempty"`
TotalCreatedApps *uint64 `json:"total-created-apps,omitempty"`
TotalCreatedAssets *uint64 `json:"total-created-assets,omitempty"`
} `json:"data,omitempty"`
Message string `json:"message"`
}

func TestAccountMaxResultsLimit(t *testing.T) {
db, shutdownFunc := setupIdb(t, test.MakeGenesis(), test.MakeGenesisBlock())
defer shutdownFunc()
Expand Down Expand Up @@ -529,19 +542,19 @@ func TestAccountMaxResultsLimit(t *testing.T) {
resp, data := makeReq(t, path, tc.exclude, tc.includeDeleted, nil, nil)
if tc.errStatus != 0 { // was a 400 error expected? check error response
require.Equal(t, tc.errStatus, resp.StatusCode)
var response generated.AccountsErrorResponse
var response accountsErrorResponse
err = json.Decode(data, &response)
require.NoError(t, err)
assert.Equal(t, tc.address.String(), *response.Address)
assert.Equal(t, uint64(maxResults), *response.MaxResults)
assert.Equal(t, tc.address.String(), *response.Data.Address)
assert.Equal(t, uint64(maxResults), *response.Data.MaxResults)
if tc.includeDeleted {
assert.Equal(t, uint64(10), *response.TotalCreatedApps)
assert.Equal(t, uint64(10), *response.TotalCreatedAssets)
assert.Equal(t, uint64(10), *response.Data.TotalCreatedApps)
assert.Equal(t, uint64(10), *response.Data.TotalCreatedAssets)
} else {
assert.Equal(t, uint64(5), *response.TotalAppsOptedIn)
assert.Equal(t, uint64(5), *response.TotalAssetsOptedIn)
assert.Equal(t, uint64(5), *response.TotalCreatedApps)
assert.Equal(t, uint64(5), *response.TotalCreatedAssets)
assert.Equal(t, uint64(5), *response.Data.TotalAppsOptedIn)
assert.Equal(t, uint64(5), *response.Data.TotalAssetsOptedIn)
assert.Equal(t, uint64(5), *response.Data.TotalCreatedApps)
assert.Equal(t, uint64(5), *response.Data.TotalCreatedAssets)
}
return
}
Expand Down Expand Up @@ -577,15 +590,15 @@ func TestAccountMaxResultsLimit(t *testing.T) {
resp, data := makeReq(t, "/v2/accounts", tc.exclude, false, nil, nil)
if tc.errStatus != 0 { // was a 400 error expected? check error response
require.Equal(t, tc.errStatus, resp.StatusCode)
var response generated.AccountsErrorResponse
var response accountsErrorResponse
err = json.Decode(data, &response)
require.NoError(t, err)
require.Equal(t, *response.Address, tc.errAddress.String())
require.Equal(t, *response.MaxResults, uint64(maxResults))
require.Equal(t, *response.TotalAppsOptedIn, uint64(5))
require.Equal(t, *response.TotalCreatedApps, uint64(5))
require.Equal(t, *response.TotalAssetsOptedIn, uint64(5))
require.Equal(t, *response.TotalCreatedAssets, uint64(5))
require.Equal(t, *response.Data.Address, tc.errAddress.String())
require.Equal(t, *response.Data.MaxResults, uint64(maxResults))
require.Equal(t, *response.Data.TotalAppsOptedIn, uint64(5))
require.Equal(t, *response.Data.TotalCreatedApps, uint64(5))
require.Equal(t, *response.Data.TotalAssetsOptedIn, uint64(5))
require.Equal(t, *response.Data.TotalCreatedAssets, uint64(5))
return
}
require.Equal(t, http.StatusOK, resp.StatusCode, fmt.Sprintf("unexpected return code, body: %s", string(data)))
Expand Down
37 changes: 2 additions & 35 deletions api/indexer.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"$ref": "#/responses/AccountsResponse"
},
"400": {
"$ref": "#/responses/AccountsErrorResponse"
"$ref": "#/responses/ErrorResponse"
},
"500": {
"$ref": "#/responses/ErrorResponse"
Expand Down Expand Up @@ -133,7 +133,7 @@
"$ref": "#/responses/AccountResponse"
},
"400": {
"$ref": "#/responses/AccountsErrorResponse"
"$ref": "#/responses/ErrorResponse"
},
"404": {
"$ref": "#/responses/ErrorResponse"
Expand Down Expand Up @@ -2647,39 +2647,6 @@
}
}
},
"AccountsErrorResponse": {
"description": "An error response for the /v2/accounts API endpoint, with optional information about limits that were exceeded.",
"type": "object",
"schema":{
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"type": "string"
},
"max-results": {
"type": "integer"
},
"address": {
"type": "string"
},
"total-apps-opted-in": {
"type": "integer"
},
"total-assets-opted-in": {
"type": "integer"
},
"total-created-apps": {
"type": "integer"
},
"total-created-assets": {
"type": "integer"
}
}
}
},
"AssetsResponse": {
"description": "(empty)",
"schema": {
Expand Down
84 changes: 10 additions & 74 deletions api/indexer.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,42 +272,6 @@
},
"description": "(empty)"
},
"AccountsErrorResponse": {
"content": {
"application/json": {
"schema": {
"properties": {
"address": {
"type": "string"
},
"max-results": {
"type": "integer"
},
"message": {
"type": "string"
},
"total-apps-opted-in": {
"type": "integer"
},
"total-assets-opted-in": {
"type": "integer"
},
"total-created-apps": {
"type": "integer"
},
"total-created-assets": {
"type": "integer"
}
},
"required": [
"message"
],
"type": "object"
}
}
},
"description": "An error response for the /v2/accounts API endpoint, with optional information about limits that were exceeded."
},
"AccountsResponse": {
"content": {
"application/json": {
Expand Down Expand Up @@ -766,11 +730,11 @@
"type": "string"
},
"total-apps-opted-in": {
"description": "The count of all application local data (AppLocalState objects) stored in this account.",
"description": "The count of all applications that have been opted in, equivalent to the count of application local data (AppLocalState objects) stored in this account.",
"type": "integer"
},
"total-assets-opted-in": {
"description": "The count of all assets (AssetHolding objects) held by this account.",
"description": "The count of all assets that have been opted in, equivalent to the count of AssetHolding objects held by this account.",
"type": "integer"
},
"total-created-apps": {
Expand Down Expand Up @@ -2147,26 +2111,12 @@
"application/json": {
"schema": {
"properties": {
"address": {
"type": "string"
},
"max-results": {
"type": "integer"
"data": {
"properties": {},
"type": "object"
},
"message": {
"type": "string"
},
"total-apps-opted-in": {
"type": "integer"
},
"total-assets-opted-in": {
"type": "integer"
},
"total-created-apps": {
"type": "integer"
},
"total-created-assets": {
"type": "integer"
}
},
"required": [
Expand All @@ -2176,7 +2126,7 @@
}
}
},
"description": "An error response for the /v2/accounts API endpoint, with optional information about limits that were exceeded."
"description": "Response for errors"
},
"500": {
"content": {
Expand Down Expand Up @@ -2287,26 +2237,12 @@
"application/json": {
"schema": {
"properties": {
"address": {
"type": "string"
},
"max-results": {
"type": "integer"
"data": {
"properties": {},
"type": "object"
},
"message": {
"type": "string"
},
"total-apps-opted-in": {
"type": "integer"
},
"total-assets-opted-in": {
"type": "integer"
},
"total-created-apps": {
"type": "integer"
},
"total-created-assets": {
"type": "integer"
}
},
"required": [
Expand All @@ -2316,7 +2252,7 @@
}
}
},
"description": "An error response for the /v2/accounts API endpoint, with optional information about limits that were exceeded."
"description": "Response for errors"
},
"404": {
"content": {
Expand Down