Skip to content

Commit 8a3bafb

Browse files
committed
Algorand 4.1.x API updates support, includes enhanced Application Box search.
1 parent 941d425 commit 8a3bafb

File tree

5 files changed

+71
-8
lines changed

5 files changed

+71
-8
lines changed

algosdk/v2client/algod.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,41 @@ def application_box_by_name(
194194
return self.algod_request("GET", req, params=params, **kwargs)
195195

196196
def application_boxes(
197-
self, application_id: int, limit: int = 0, **kwargs: Any
197+
self,
198+
application_id: int,
199+
limit: int = 0,
200+
prefix: Optional[str] = None,
201+
next: Optional[str] = None,
202+
values: Optional[bool] = False,
203+
**kwargs: Any,
198204
) -> AlgodResponseType:
199205
"""
200-
Given an application ID, return all Box names. No particular ordering is guaranteed. Request fails when client or server-side configured limits prevent returning all Box names.
201-
206+
Given an application ID, return boxes in lexographical order by name. If the results must be truncated, a next-token is supplied to continue the request.
202207
NOTE: box names are returned as base64-encoded strings.
203208
204209
Args:
205210
application_id (int): The ID of the application to look up.
206211
limit (int, optional): Max number of box names to return.
207212
If max is not set, or max == 0, returns all box-names up to the maximum configured by the algod server being queried.
213+
prefix (str, optional): A box name prefix, in the goal app
214+
call arg form 'encoding:value'. For ints, use the form 'int:1234'. For raw bytes, use the form 'b64:A=='.
215+
For printable strings, use the form 'str:hello'. For addresses, use the form 'addr:XYZ...'.
216+
next (str, optional): A box name, in the goal app call arg
217+
form 'encoding:value'. When provided, the returned boxes begin (lexographically) with the supplied name. Callers may
218+
implement pagination by reinvoking the endpoint with the token from a previous call's next-token.
219+
values (bool, optional): If true, box values will be returned.
208220
"""
221+
query = {}
222+
if limit:
223+
query["max"] = limit
224+
if prefix:
225+
query["prefix"] = prefix
226+
if next:
227+
query["next"] = next
228+
if values:
229+
query["values"] = "true"
209230
req = "/applications/" + str(application_id) + "/boxes"
210-
params = {"max": limit} if limit else {}
211-
return self.algod_request("GET", req, params=params, **kwargs)
231+
return self.algod_request("GET", req, params=query, **kwargs)
212232

213233
def account_asset_info(
214234
self, address: str, asset_id: int, **kwargs: Any

algosdk/v2client/indexer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def accounts(
106106
round_num=None,
107107
include_all=False,
108108
exclude=None,
109+
online_only=False,
109110
**kwargs
110111
):
111112
"""
@@ -144,6 +145,8 @@ def accounts(
144145
application local data stored for this account,
145146
asset parameters created by this account,
146147
and application parameters created by this account.
148+
online_only (bool, optional): return only accounts whose participation
149+
status is currently online. Defaults to false.
147150
"""
148151
req = "/accounts"
149152
query = dict()
@@ -166,6 +169,8 @@ def accounts(
166169
query["include-all"] = include_all
167170
if exclude:
168171
query["exclude"] = exclude
172+
if online_only:
173+
query["online-only"] = "true"
169174
return self.indexer_request("GET", req, query, **kwargs)
170175

171176
def asset_balances(

algosdk/v2client/models/application_params.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class ApplicationParams(object):
2020
"local_state_schema": "ApplicationStateSchema",
2121
"global_state_schema": "ApplicationStateSchema",
2222
"global_state": "list[TealKeyValue]",
23+
"version": "int",
2324
}
2425

2526
attribute_map = {
@@ -29,6 +30,7 @@ class ApplicationParams(object):
2930
"local_state_schema": "local-state-schema",
3031
"global_state_schema": "global-state-schema",
3132
"global_state": "global-state",
33+
"version": "version",
3234
}
3335

3436
def __init__(
@@ -39,6 +41,7 @@ def __init__(
3941
local_state_schema=None,
4042
global_state_schema=None,
4143
global_state=None,
44+
version=None,
4245
): # noqa: E501
4346
"""ApplicationParams - a model defined in OpenAPI""" # noqa: E501
4447

@@ -48,6 +51,7 @@ def __init__(
4851
self._local_state_schema = None
4952
self._global_state_schema = None
5053
self._global_state = None
54+
self._version = None
5155

5256
self.creator = creator
5357
self.approval_program = approval_program
@@ -58,6 +62,8 @@ def __init__(
5862
self.global_state_schema = global_state_schema
5963
if global_state is not None:
6064
self.global_state = global_state
65+
if version is not None:
66+
self.version = version
6167

6268
@property
6369
def creator(self):
@@ -193,6 +199,29 @@ def global_state(self, global_state):
193199

194200
self._global_state = global_state
195201

202+
@property
203+
def version(self):
204+
"""Gets the version of this Application programs. # noqa: E501
205+
206+
Represents the number of updates to the application programs. # noqa: E501
207+
208+
:return: The version of this Application programs. # noqa: E501
209+
:rtype: int
210+
"""
211+
return self._version
212+
213+
@version.setter
214+
def version(self, version):
215+
"""Sets the version of this Application programs.
216+
217+
Represents the number of updates to the application programs. # noqa: E501
218+
219+
:param version: The the version of this Application programs. # noqa: E501
220+
:type version: int
221+
"""
222+
223+
self._version = version
224+
196225
def dictify(self):
197226
"""Returns the model properties as a dict"""
198227
result = {}

tests/steps/account_v2_steps.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ def search_accounts(
177177
)
178178

179179

180+
@when(
181+
'we make a Search Accounts call with onlineOnly "{onlineOnly:MaybeBool}"'
182+
)
183+
def search_accounts_online_only(context, onlineOnly):
184+
context.response = context.icl.accounts(
185+
online_only=onlineOnly,
186+
)
187+
188+
180189
@when(
181190
'we make a Search Accounts call with assetID {index} limit {limit} currencyGreaterThan {currencyGreaterThan} currencyLessThan {currencyLessThan} round {block} and authenticating address "{authAddr:MaybeString}"'
182191
)

tests/steps/application_v2_steps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ def application_box_by_name(context, app_id, box_name):
181181

182182

183183
@when(
184-
"we make a GetApplicationBoxes call for applicationID {app_id} with max {max_results}"
184+
'we make a GetApplicationBoxes call for applicationID {app_id} with max {max_results} prefix "{prefix:MaybeString}" next "{next:MaybeString}" values "{values:MaybeBool}"'
185185
)
186-
def application_boxes(context, app_id, max_results):
186+
def application_boxes(context, app_id, max_results, prefix, next, values):
187187
context.response = context.acl.application_boxes(
188-
app_id, limit=int(max_results)
188+
app_id, limit=int(max_results), prefix=prefix, next=next, values=values
189189
)
190190

191191

0 commit comments

Comments
 (0)