Skip to content

Commit 8c60436

Browse files
authored
Revert Box Application Pagination support. (#983)
1 parent e5f7232 commit 8c60436

File tree

3 files changed

+70
-177
lines changed

3 files changed

+70
-177
lines changed

src/client/v2/algod/getApplicationBoxes.ts

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { BoxesResponse } from './models/types.js';
99
* #### Example
1010
* ```typescript
1111
* const index = 60553466;
12-
* const boxesResponse = await algodClient.getApplicationBoxes(index).prefix('int:1234').next('b64:A==').values(true).do();
12+
* const boxesResponse = await algodClient.getApplicationBoxes(index).max(3).do();
1313
* const boxNames = boxesResponse.boxes.map(box => box.name);
1414
* ```
1515
*
@@ -53,66 +53,6 @@ export default class GetApplicationBoxes extends JSONRequest<BoxesResponse> {
5353
return this;
5454
}
5555

56-
/**
57-
* A box name prefix, in the goal app call arg form 'encoding:value'. For ints, use the form 'int:1234'. For raw bytes, use the form 'b64:A=='. For printable strings, use the form 'str:hello'. For addresses, use the form 'addr:XYZ...'.
58-
*
59-
* #### Example
60-
* ```typescript
61-
* const prefix = 'int:1234';
62-
* const boxesResult = await algodClient
63-
* .GetApplicationBoxes(1234)
64-
* .prefix(prefix)
65-
* .do();
66-
* ```
67-
*
68-
* @param prefix - the box name prefix in the form 'encoding:value'
69-
* @category query
70-
*/
71-
prefix(prefix: string) {
72-
this.query.prefix = prefix;
73-
return this;
74-
}
75-
76-
/**
77-
* A box name, in the goal app call arg form 'encoding:value'. When provided, the returned boxes begin (lexographically) with the supplied name. Callers may implement pagination by reinvoking the endpoint with the token from a previous call's next-token.
78-
*
79-
* #### Example
80-
* ```typescript
81-
* const next = 'int:1234';
82-
* const boxesResult = await algodClient
83-
* .GetApplicationBoxes(1234)
84-
* .next(next)
85-
* .do();
86-
* ```
87-
*
88-
* @param next - the next box name for pagination, in the goal app call arg form 'encoding:value'
89-
* @category query
90-
*/
91-
next(next: string) {
92-
this.query.next = next;
93-
return this;
94-
}
95-
96-
/**
97-
* If true, box values will be returned.
98-
*
99-
* #### Example
100-
* ```typescript
101-
* const values = true;
102-
* const boxesResult = await algodClient
103-
* .GetApplicationBoxes(1234)
104-
* .values(values)
105-
* .do();
106-
* ```
107-
*
108-
* @param values - if true, box values will be returned
109-
* @category query
110-
*/
111-
values(values: boolean) {
112-
this.query.values = values;
113-
return this;
114-
}
115-
11656
// eslint-disable-next-line class-methods-use-this
11757
prepare(response: HTTPClientResponse): BoxesResponse {
11858
return decodeJSON(response.getJSONText(), BoxesResponse);

src/client/v2/algod/models/types.ts

Lines changed: 66 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/cucumber/steps/steps.js

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,17 +2157,9 @@ module.exports = function getSteps(options) {
21572157
);
21582158

21592159
When(
2160-
'we make a GetApplicationBoxes call for applicationID {int} with max {int} prefix {string} next {string} values {string}',
2161-
async function (index, limit, prefix, next, valuesAsString) {
2162-
const values = valuesAsString === 'true';
2163-
2164-
await this.v2Client
2165-
.getApplicationBoxes(index)
2166-
.max(limit)
2167-
.prefix(prefix)
2168-
.next(next)
2169-
.values(values)
2170-
.doRaw();
2160+
'we make a GetApplicationBoxes call for applicationID {int} with max {int}',
2161+
async function (index, limit) {
2162+
await this.v2Client.getApplicationBoxes(index).max(limit).doRaw();
21712163
}
21722164
);
21732165

@@ -5147,58 +5139,13 @@ module.exports = function getSteps(options) {
51475139
}
51485140
);
51495141

5150-
async function advanceChainWaitForBox(
5151-
algodClient,
5152-
account,
5153-
appIndex,
5154-
boxLength
5155-
) {
5156-
// balancesFlushInterval in algod is 5 seconds, so we need at least that amount of time to pass to trigger the flush we need
5157-
// eslint-disable-next-line no-promise-executor-return
5158-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
5159-
/* eslint-disable no-await-in-loop */
5160-
for (let i = 0; i < 50; i++) {
5161-
const sp = await algodClient.getTransactionParams().do();
5162-
const algoTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
5163-
sender: account.addr,
5164-
receiver: account.addr,
5165-
amount: 0,
5166-
suggestedParams: sp,
5167-
});
5168-
5169-
const algoStxn = algoTxn.signTxn(account.sk);
5170-
await algodClient.sendRawTransaction(algoStxn).do();
5171-
5172-
// MaxAccountLookback is 4, we start checking for our boxes after the 5th round from create transaction
5173-
if (i > 5) {
5174-
const resp = await algodClient.getApplicationBoxes(appIndex).do();
5175-
5176-
// If the boxes have shown up, break out of loop
5177-
if (resp.boxes.length === boxLength) {
5178-
break;
5179-
} else {
5180-
await sleep(1000); // Sleep then continue
5181-
}
5182-
}
5183-
}
5184-
/* eslint-enable no-await-in-loop */
5185-
}
5186-
51875142
Then(
51885143
'according to {string}, the current application should have the following boxes {string}.',
51895144
async function (fromClient, boxNames) {
51905145
const boxes = splitBoxNames(boxNames);
51915146

51925147
let resp = null;
51935148
if (fromClient === 'algod') {
5194-
// We need to advance a few rounds so that app boxes endpoint returns expected boxes (
5195-
// it only pulls persisted data, so need to get past MaxAccountLookback and flush after)
5196-
await advanceChainWaitForBox(
5197-
this.v2Client,
5198-
this.transientAccount,
5199-
this.currentApplicationIndex,
5200-
boxes.length
5201-
);
52025149
resp = await this.v2Client
52035150
.getApplicationBoxes(this.currentApplicationIndex)
52045151
.do();

0 commit comments

Comments
 (0)