summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHang Su <hang.su@algorand.com>2022-07-15 14:56:30 -0400
committerHang Su <hang.su@algorand.com>2022-07-15 15:58:39 -0400
commitc1d3115b7b304d2c709553512204a741ada68ad7 (patch)
tree766a075b0deaad514793f64986202b1a9ea3a970
parentc67a28e8c6b5d553c1882b023ce8aa5660262ba1 (diff)
allow algod client to pass in max box number to returnboxes-client-param
-rw-r--r--daemon/algod/api/client/restClient.go14
-rw-r--r--libgoal/libgoal.go4
-rw-r--r--test/e2e-go/restAPI/restClient_test.go5
3 files changed, 19 insertions, 4 deletions
diff --git a/daemon/algod/api/client/restClient.go b/daemon/algod/api/client/restClient.go
index 19d142967..df6b45318 100644
--- a/daemon/algod/api/client/restClient.go
+++ b/daemon/algod/api/client/restClient.go
@@ -422,9 +422,19 @@ func (client RestClient) AccountInformation(address string) (response v1.Account
return
}
+type applicationBoxesParams struct {
+ Max *uint64 `url:"max,omitempty"`
+}
+
// ApplicationBoxes gets the BoxesResponse associated with the passed application ID
-func (client RestClient) ApplicationBoxes(appID uint64) (response generatedV2.BoxesResponse, err error) {
- err = client.get(&response, fmt.Sprintf("/v2/applications/%d/boxes", appID), nil)
+func (client RestClient) ApplicationBoxes(appID uint64, optionalMaxBoxNum ...uint64) (response generatedV2.BoxesResponse, err error) {
+ if len(optionalMaxBoxNum) == 0 {
+ err = client.get(&response, fmt.Sprintf("/v2/applications/%d/boxes", appID), nil)
+ } else if len(optionalMaxBoxNum) == 1 {
+ err = client.get(&response, fmt.Sprintf("/v2/applications/%d/boxes", appID), applicationBoxesParams{&optionalMaxBoxNum[0]})
+ } else {
+ err = fmt.Errorf("unexpected argument numbers %d, only allowing at most 1 uint64 args for boxesLimit", len(optionalMaxBoxNum))
+ }
return
}
diff --git a/libgoal/libgoal.go b/libgoal/libgoal.go
index 798d93bf7..525c16623 100644
--- a/libgoal/libgoal.go
+++ b/libgoal/libgoal.go
@@ -777,10 +777,10 @@ func (c *Client) ApplicationInformation(index uint64) (resp generatedV2.Applicat
}
// ApplicationBoxes takes an app's index and returns the names of boxes under it
-func (c *Client) ApplicationBoxes(index uint64) (resp generatedV2.BoxesResponse, err error) {
+func (c *Client) ApplicationBoxes(appID uint64, optionalMaxBoxNum ...uint64) (resp generatedV2.BoxesResponse, err error) {
algod, err := c.ensureAlgodClient()
if err == nil {
- resp, err = algod.ApplicationBoxes(index)
+ resp, err = algod.ApplicationBoxes(appID, optionalMaxBoxNum...)
}
return
}
diff --git a/test/e2e-go/restAPI/restClient_test.go b/test/e2e-go/restAPI/restClient_test.go
index c84e53439..2a5f9e90b 100644
--- a/test/e2e-go/restAPI/restClient_test.go
+++ b/test/e2e-go/restAPI/restClient_test.go
@@ -1476,6 +1476,11 @@ end:
operateAndMatchRes("create", strSliceTest)
}
+ maxBoxNumToGet := uint64(10)
+ resp, err = testClient.ApplicationBoxes(uint64(createdAppID), maxBoxNumToGet)
+ a.NoError(err)
+ a.Len(resp.Boxes, int(maxBoxNumToGet))
+
for i := 0; i < len(testingBoxNames); i += 16 {
var strSliceTest []string
// grouping box names to operate, and delete such boxes