algosdk 3.5.1 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/browser/algosdk.min.js +1 -1
- package/dist/browser/algosdk.min.js.map +1 -1
- package/dist/cjs/appAccess.js +14 -6
- package/dist/cjs/appAccess.js.map +1 -1
- package/dist/cjs/client/v2/algod/accountApplicationsInformation.js +38 -0
- package/dist/cjs/client/v2/algod/accountApplicationsInformation.js.map +1 -0
- package/dist/cjs/client/v2/algod/accountAssetsInformation.js +31 -0
- package/dist/cjs/client/v2/algod/accountAssetsInformation.js.map +1 -0
- package/dist/cjs/client/v2/algod/algod.js +23 -1
- package/dist/cjs/client/v2/algod/algod.js.map +1 -1
- package/dist/cjs/client/v2/algod/getApplicationBoxes.js +116 -5
- package/dist/cjs/client/v2/algod/getApplicationBoxes.js.map +1 -1
- package/dist/cjs/client/v2/algod/models/types.js +243 -20
- package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
- package/dist/cjs/dryrun.js.map +1 -1
- package/dist/cjs/transaction.js +1 -0
- package/dist/cjs/transaction.js.map +1 -1
- package/dist/esm/appAccess.js +14 -6
- package/dist/esm/appAccess.js.map +1 -1
- package/dist/esm/client/v2/algod/accountApplicationsInformation.js +32 -0
- package/dist/esm/client/v2/algod/accountApplicationsInformation.js.map +1 -0
- package/dist/esm/client/v2/algod/accountAssetsInformation.js +25 -0
- package/dist/esm/client/v2/algod/accountAssetsInformation.js.map +1 -0
- package/dist/esm/client/v2/algod/algod.js +23 -1
- package/dist/esm/client/v2/algod/algod.js.map +1 -1
- package/dist/esm/client/v2/algod/getApplicationBoxes.js +116 -5
- package/dist/esm/client/v2/algod/getApplicationBoxes.js.map +1 -1
- package/dist/esm/client/v2/algod/models/types.js +239 -18
- package/dist/esm/client/v2/algod/models/types.js.map +1 -1
- package/dist/esm/dryrun.js.map +1 -1
- package/dist/esm/transaction.js +1 -0
- package/dist/esm/transaction.js.map +1 -1
- package/dist/types/client/v2/algod/accountApplicationsInformation.d.ts +16 -0
- package/dist/types/client/v2/algod/accountAssetsInformation.d.ts +12 -0
- package/dist/types/client/v2/algod/algod.d.ts +19 -1
- package/dist/types/client/v2/algod/getApplicationBoxes.d.ts +100 -5
- package/dist/types/client/v2/algod/models/types.d.ts +146 -15
- package/package.json +1 -1
- package/src/appAccess.ts +17 -6
- package/src/client/v2/algod/accountApplicationsInformation.ts +46 -0
- package/src/client/v2/algod/accountAssetsInformation.ts +33 -0
- package/src/client/v2/algod/algod.ts +25 -1
- package/src/client/v2/algod/getApplicationBoxes.ts +123 -5
- package/src/client/v2/algod/models/types.ts +409 -32
- package/src/dryrun.ts +2 -2
- package/src/transaction.ts +1 -0
|
@@ -238,6 +238,60 @@ export declare class Account implements Encodable {
|
|
|
238
238
|
toEncodingData(): Map<string, unknown>;
|
|
239
239
|
static fromEncodingData(data: unknown): Account;
|
|
240
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* AccountApplicationResource describes the account's application resource (local
|
|
243
|
+
* state and params if the account is the creator) for a specific application ID.
|
|
244
|
+
*/
|
|
245
|
+
export declare class AccountApplicationResource implements Encodable {
|
|
246
|
+
private static encodingSchemaValue;
|
|
247
|
+
static get encodingSchema(): Schema;
|
|
248
|
+
/**
|
|
249
|
+
* The application ID.
|
|
250
|
+
*/
|
|
251
|
+
id: number;
|
|
252
|
+
/**
|
|
253
|
+
* (appl) the application local data stored in this account.
|
|
254
|
+
* The raw account uses `AppLocalState` for this type.
|
|
255
|
+
*/
|
|
256
|
+
appLocalState?: ApplicationLocalState;
|
|
257
|
+
/**
|
|
258
|
+
* Round when the account opted into or created the application.
|
|
259
|
+
*/
|
|
260
|
+
createdAtRound?: number;
|
|
261
|
+
/**
|
|
262
|
+
* Whether the application has been deleted.
|
|
263
|
+
*/
|
|
264
|
+
deleted?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* (appp) parameters of the application created by this account including app
|
|
267
|
+
* global data.
|
|
268
|
+
* The raw account uses `AppParams` for this type.
|
|
269
|
+
* Only present if the account is the creator and `include=params` is specified.
|
|
270
|
+
*/
|
|
271
|
+
params?: ApplicationParams;
|
|
272
|
+
/**
|
|
273
|
+
* Creates a new `AccountApplicationResource` object.
|
|
274
|
+
* @param id - The application ID.
|
|
275
|
+
* @param appLocalState - (appl) the application local data stored in this account.
|
|
276
|
+
* The raw account uses `AppLocalState` for this type.
|
|
277
|
+
* @param createdAtRound - Round when the account opted into or created the application.
|
|
278
|
+
* @param deleted - Whether the application has been deleted.
|
|
279
|
+
* @param params - (appp) parameters of the application created by this account including app
|
|
280
|
+
* global data.
|
|
281
|
+
* The raw account uses `AppParams` for this type.
|
|
282
|
+
* Only present if the account is the creator and `include=params` is specified.
|
|
283
|
+
*/
|
|
284
|
+
constructor({ id, appLocalState, createdAtRound, deleted, params, }: {
|
|
285
|
+
id: number | bigint;
|
|
286
|
+
appLocalState?: ApplicationLocalState;
|
|
287
|
+
createdAtRound?: number | bigint;
|
|
288
|
+
deleted?: boolean;
|
|
289
|
+
params?: ApplicationParams;
|
|
290
|
+
});
|
|
291
|
+
getEncodingSchema(): Schema;
|
|
292
|
+
toEncodingData(): Map<string, unknown>;
|
|
293
|
+
static fromEncodingData(data: unknown): AccountApplicationResource;
|
|
294
|
+
}
|
|
241
295
|
/**
|
|
242
296
|
* AccountApplicationResponse describes the account's application local state and
|
|
243
297
|
* global state (AppLocalState and AppParams, if either exists) for a specific
|
|
@@ -280,6 +334,41 @@ export declare class AccountApplicationResponse implements Encodable {
|
|
|
280
334
|
toEncodingData(): Map<string, unknown>;
|
|
281
335
|
static fromEncodingData(data: unknown): AccountApplicationResponse;
|
|
282
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* AccountApplicationsInformationResponse contains a list of application resources
|
|
339
|
+
* for an account.
|
|
340
|
+
*/
|
|
341
|
+
export declare class AccountApplicationsInformationResponse implements Encodable {
|
|
342
|
+
private static encodingSchemaValue;
|
|
343
|
+
static get encodingSchema(): Schema;
|
|
344
|
+
/**
|
|
345
|
+
* The round for which this information is relevant.
|
|
346
|
+
*/
|
|
347
|
+
round: number;
|
|
348
|
+
applicationResources?: AccountApplicationResource[];
|
|
349
|
+
/**
|
|
350
|
+
* Used for pagination, when making another request provide this token with the
|
|
351
|
+
* next parameter. The next token is the next application ID to use as the
|
|
352
|
+
* pagination cursor.
|
|
353
|
+
*/
|
|
354
|
+
nextToken?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Creates a new `AccountApplicationsInformationResponse` object.
|
|
357
|
+
* @param round - The round for which this information is relevant.
|
|
358
|
+
* @param applicationResources -
|
|
359
|
+
* @param nextToken - Used for pagination, when making another request provide this token with the
|
|
360
|
+
* next parameter. The next token is the next application ID to use as the
|
|
361
|
+
* pagination cursor.
|
|
362
|
+
*/
|
|
363
|
+
constructor({ round, applicationResources, nextToken, }: {
|
|
364
|
+
round: number | bigint;
|
|
365
|
+
applicationResources?: AccountApplicationResource[];
|
|
366
|
+
nextToken?: string;
|
|
367
|
+
});
|
|
368
|
+
getEncodingSchema(): Schema;
|
|
369
|
+
toEncodingData(): Map<string, unknown>;
|
|
370
|
+
static fromEncodingData(data: unknown): AccountApplicationsInformationResponse;
|
|
371
|
+
}
|
|
283
372
|
/**
|
|
284
373
|
* AccountAssetHolding describes the account's asset holding and asset parameters
|
|
285
374
|
* (if either exist) for a specific asset ID.
|
|
@@ -508,7 +597,7 @@ export declare class Application implements Encodable {
|
|
|
508
597
|
/**
|
|
509
598
|
* (appparams) application parameters.
|
|
510
599
|
*/
|
|
511
|
-
params
|
|
600
|
+
params?: ApplicationParams;
|
|
512
601
|
/**
|
|
513
602
|
* Creates a new `Application` object.
|
|
514
603
|
* @param id - (appidx) application index.
|
|
@@ -516,7 +605,7 @@ export declare class Application implements Encodable {
|
|
|
516
605
|
*/
|
|
517
606
|
constructor({ id, params, }: {
|
|
518
607
|
id: number | bigint;
|
|
519
|
-
params
|
|
608
|
+
params?: ApplicationParams;
|
|
520
609
|
});
|
|
521
610
|
getEncodingSchema(): Schema;
|
|
522
611
|
toEncodingData(): Map<string, unknown>;
|
|
@@ -684,6 +773,10 @@ export declare class ApplicationParams implements Encodable {
|
|
|
684
773
|
* (lsch) local schema
|
|
685
774
|
*/
|
|
686
775
|
localStateSchema?: ApplicationStateSchema;
|
|
776
|
+
/**
|
|
777
|
+
* (ss) the account responsible for extra pages and global state MBR
|
|
778
|
+
*/
|
|
779
|
+
sizeSponsor?: Address;
|
|
687
780
|
/**
|
|
688
781
|
* (v) the number of updates to the application programs
|
|
689
782
|
*/
|
|
@@ -698,9 +791,10 @@ export declare class ApplicationParams implements Encodable {
|
|
|
698
791
|
* @param globalState - (gs) global state
|
|
699
792
|
* @param globalStateSchema - (gsch) global schema
|
|
700
793
|
* @param localStateSchema - (lsch) local schema
|
|
794
|
+
* @param sizeSponsor - (ss) the account responsible for extra pages and global state MBR
|
|
701
795
|
* @param version - (v) the number of updates to the application programs
|
|
702
796
|
*/
|
|
703
|
-
constructor({ approvalProgram, clearStateProgram, creator, extraProgramPages, globalState, globalStateSchema, localStateSchema, version, }: {
|
|
797
|
+
constructor({ approvalProgram, clearStateProgram, creator, extraProgramPages, globalState, globalStateSchema, localStateSchema, sizeSponsor, version, }: {
|
|
704
798
|
approvalProgram: string | Uint8Array;
|
|
705
799
|
clearStateProgram: string | Uint8Array;
|
|
706
800
|
creator: Address | string;
|
|
@@ -708,6 +802,7 @@ export declare class ApplicationParams implements Encodable {
|
|
|
708
802
|
globalState?: TealKeyValue[];
|
|
709
803
|
globalStateSchema?: ApplicationStateSchema;
|
|
710
804
|
localStateSchema?: ApplicationStateSchema;
|
|
805
|
+
sizeSponsor?: Address | string;
|
|
711
806
|
version?: number | bigint;
|
|
712
807
|
});
|
|
713
808
|
getEncodingSchema(): Schema;
|
|
@@ -806,7 +901,7 @@ export declare class Asset implements Encodable {
|
|
|
806
901
|
* Definition:
|
|
807
902
|
* data/transactions/asset.go : AssetParams
|
|
808
903
|
*/
|
|
809
|
-
params
|
|
904
|
+
params?: AssetParams;
|
|
810
905
|
/**
|
|
811
906
|
* Creates a new `Asset` object.
|
|
812
907
|
* @param index - unique asset identifier
|
|
@@ -817,7 +912,7 @@ export declare class Asset implements Encodable {
|
|
|
817
912
|
*/
|
|
818
913
|
constructor({ index, params, }: {
|
|
819
914
|
index: number | bigint;
|
|
820
|
-
params
|
|
915
|
+
params?: AssetParams;
|
|
821
916
|
});
|
|
822
917
|
getEncodingSchema(): Schema;
|
|
823
918
|
toEncodingData(): Map<string, unknown>;
|
|
@@ -1210,12 +1305,20 @@ export declare class BoxDescriptor implements Encodable {
|
|
|
1210
1305
|
* Base64 encoded box name
|
|
1211
1306
|
*/
|
|
1212
1307
|
name: Uint8Array;
|
|
1308
|
+
/**
|
|
1309
|
+
* Base64 encoded box value. Present only when the `values` query parameter is set
|
|
1310
|
+
* to true.
|
|
1311
|
+
*/
|
|
1312
|
+
value?: Uint8Array;
|
|
1213
1313
|
/**
|
|
1214
1314
|
* Creates a new `BoxDescriptor` object.
|
|
1215
1315
|
* @param name - Base64 encoded box name
|
|
1316
|
+
* @param value - Base64 encoded box value. Present only when the `values` query parameter is set
|
|
1317
|
+
* to true.
|
|
1216
1318
|
*/
|
|
1217
|
-
constructor({ name }: {
|
|
1319
|
+
constructor({ name, value, }: {
|
|
1218
1320
|
name: string | Uint8Array;
|
|
1321
|
+
value?: string | Uint8Array;
|
|
1219
1322
|
});
|
|
1220
1323
|
getEncodingSchema(): Schema;
|
|
1221
1324
|
toEncodingData(): Map<string, unknown>;
|
|
@@ -1249,18 +1352,34 @@ export declare class BoxReference implements Encodable {
|
|
|
1249
1352
|
static fromEncodingData(data: unknown): BoxReference;
|
|
1250
1353
|
}
|
|
1251
1354
|
/**
|
|
1252
|
-
*
|
|
1355
|
+
* Boxes of an application
|
|
1253
1356
|
*/
|
|
1254
1357
|
export declare class BoxesResponse implements Encodable {
|
|
1255
1358
|
private static encodingSchemaValue;
|
|
1256
1359
|
static get encodingSchema(): Schema;
|
|
1257
1360
|
boxes: BoxDescriptor[];
|
|
1361
|
+
/**
|
|
1362
|
+
* Used for pagination, when making another request provide this token with the
|
|
1363
|
+
* next parameter. The next token is the box name to use as the pagination cursor,
|
|
1364
|
+
* encoded in the goal app call arg form.
|
|
1365
|
+
*/
|
|
1366
|
+
nextToken?: string;
|
|
1367
|
+
/**
|
|
1368
|
+
* The round for which this information is relevant.
|
|
1369
|
+
*/
|
|
1370
|
+
round?: number;
|
|
1258
1371
|
/**
|
|
1259
1372
|
* Creates a new `BoxesResponse` object.
|
|
1260
1373
|
* @param boxes -
|
|
1374
|
+
* @param nextToken - Used for pagination, when making another request provide this token with the
|
|
1375
|
+
* next parameter. The next token is the box name to use as the pagination cursor,
|
|
1376
|
+
* encoded in the goal app call arg form.
|
|
1377
|
+
* @param round - The round for which this information is relevant.
|
|
1261
1378
|
*/
|
|
1262
|
-
constructor({ boxes }: {
|
|
1379
|
+
constructor({ boxes, nextToken, round, }: {
|
|
1263
1380
|
boxes: BoxDescriptor[];
|
|
1381
|
+
nextToken?: string;
|
|
1382
|
+
round?: number | bigint;
|
|
1264
1383
|
});
|
|
1265
1384
|
getEncodingSchema(): Schema;
|
|
1266
1385
|
toEncodingData(): Map<string, unknown>;
|
|
@@ -2897,9 +3016,16 @@ export declare class SupplyResponse implements Encodable {
|
|
|
2897
3016
|
*/
|
|
2898
3017
|
currentRound: bigint;
|
|
2899
3018
|
/**
|
|
2900
|
-
*
|
|
3019
|
+
* Total stake held by accounts with status Online at current_round, including
|
|
3020
|
+
* those whose participation keys have expired but have not yet been marked
|
|
3021
|
+
* offline.
|
|
2901
3022
|
*/
|
|
2902
3023
|
onlineMoney: bigint;
|
|
3024
|
+
/**
|
|
3025
|
+
* Online stake used by agreement to vote for current_round, excluding accounts
|
|
3026
|
+
* whose participation keys have expired.
|
|
3027
|
+
*/
|
|
3028
|
+
onlineStake: bigint;
|
|
2903
3029
|
/**
|
|
2904
3030
|
* TotalMoney
|
|
2905
3031
|
*/
|
|
@@ -2907,12 +3033,17 @@ export declare class SupplyResponse implements Encodable {
|
|
|
2907
3033
|
/**
|
|
2908
3034
|
* Creates a new `SupplyResponse` object.
|
|
2909
3035
|
* @param currentRound - Round
|
|
2910
|
-
* @param onlineMoney -
|
|
3036
|
+
* @param onlineMoney - Total stake held by accounts with status Online at current_round, including
|
|
3037
|
+
* those whose participation keys have expired but have not yet been marked
|
|
3038
|
+
* offline.
|
|
3039
|
+
* @param onlineStake - Online stake used by agreement to vote for current_round, excluding accounts
|
|
3040
|
+
* whose participation keys have expired.
|
|
2911
3041
|
* @param totalMoney - TotalMoney
|
|
2912
3042
|
*/
|
|
2913
|
-
constructor({ currentRound, onlineMoney, totalMoney, }: {
|
|
3043
|
+
constructor({ currentRound, onlineMoney, onlineStake, totalMoney, }: {
|
|
2914
3044
|
currentRound: number | bigint;
|
|
2915
3045
|
onlineMoney: number | bigint;
|
|
3046
|
+
onlineStake: number | bigint;
|
|
2916
3047
|
totalMoney: number | bigint;
|
|
2917
3048
|
});
|
|
2918
3049
|
getEncodingSchema(): Schema;
|
|
@@ -3027,8 +3158,8 @@ export declare class TransactionParametersResponse implements Encodable {
|
|
|
3027
3158
|
*/
|
|
3028
3159
|
lastRound: bigint;
|
|
3029
3160
|
/**
|
|
3030
|
-
* The minimum transaction fee (not per byte) required for the
|
|
3031
|
-
*
|
|
3161
|
+
* The minimum transaction fee (not per byte) required for the txn to validate for
|
|
3162
|
+
* the current network protocol.
|
|
3032
3163
|
*/
|
|
3033
3164
|
minFee: bigint;
|
|
3034
3165
|
/**
|
|
@@ -3042,8 +3173,8 @@ export declare class TransactionParametersResponse implements Encodable {
|
|
|
3042
3173
|
* @param genesisHash - GenesisHash is the hash of the genesis block.
|
|
3043
3174
|
* @param genesisId - GenesisID is an ID listed in the genesis block.
|
|
3044
3175
|
* @param lastRound - LastRound indicates the last round seen
|
|
3045
|
-
* @param minFee - The minimum transaction fee (not per byte) required for the
|
|
3046
|
-
*
|
|
3176
|
+
* @param minFee - The minimum transaction fee (not per byte) required for the txn to validate for
|
|
3177
|
+
* the current network protocol.
|
|
3047
3178
|
*/
|
|
3048
3179
|
constructor({ consensusVersion, fee, genesisHash, genesisId, lastRound, minFee, }: {
|
|
3049
3180
|
consensusVersion: string;
|
package/package.json
CHANGED
package/src/appAccess.ts
CHANGED
|
@@ -20,8 +20,14 @@ export function resourceReferencesToEncodingData(
|
|
|
20
20
|
function ensure(target: ResourceReference): number {
|
|
21
21
|
for (let idx = 0; idx < accessList.length; idx++) {
|
|
22
22
|
const a = accessList[idx];
|
|
23
|
+
const aAddress = a.get('d') as Address | undefined;
|
|
24
|
+
const addressesEqual =
|
|
25
|
+
(!target.address && !aAddress) ||
|
|
26
|
+
(target.address &&
|
|
27
|
+
aAddress &&
|
|
28
|
+
(target.address as Address).equals(aAddress));
|
|
23
29
|
if (
|
|
24
|
-
|
|
30
|
+
addressesEqual &&
|
|
25
31
|
a.get('s') === target.assetIndex &&
|
|
26
32
|
a.get('p') === target.appIndex
|
|
27
33
|
) {
|
|
@@ -139,11 +145,12 @@ export function convertIndicesToResourceReferences(
|
|
|
139
145
|
if (!hAssetIndex) {
|
|
140
146
|
throw new Error(`Holding missing asset index: ${holding}`);
|
|
141
147
|
}
|
|
148
|
+
|
|
142
149
|
const hAddress =
|
|
143
150
|
hAddressIndex === 0
|
|
144
151
|
? Address.zeroAddress()
|
|
145
|
-
: (
|
|
146
|
-
const asset =
|
|
152
|
+
: (accessList[hAddressIndex - 1].get('d') as Address);
|
|
153
|
+
const asset = accessList[hAssetIndex - 1].get('s') as bigint;
|
|
147
154
|
references.push({ holding: { address: hAddress, assetIndex: asset } });
|
|
148
155
|
continue;
|
|
149
156
|
}
|
|
@@ -154,11 +161,11 @@ export function convertIndicesToResourceReferences(
|
|
|
154
161
|
const lAddress =
|
|
155
162
|
lAddressIndex === 0
|
|
156
163
|
? Address.zeroAddress()
|
|
157
|
-
: (
|
|
164
|
+
: (accessList[lAddressIndex - 1].get('d') as Address);
|
|
158
165
|
const app =
|
|
159
166
|
lAppIndex === 0
|
|
160
167
|
? BigInt(0)
|
|
161
|
-
: (
|
|
168
|
+
: (accessList[lAppIndex - 1].get('p') as bigint);
|
|
162
169
|
references.push({ locals: { address: lAddress, appIndex: app } });
|
|
163
170
|
continue;
|
|
164
171
|
}
|
|
@@ -172,9 +179,13 @@ export function convertIndicesToResourceReferences(
|
|
|
172
179
|
const app =
|
|
173
180
|
bAppIndex === 0
|
|
174
181
|
? BigInt(0)
|
|
175
|
-
: (
|
|
182
|
+
: (accessList[bAppIndex - 1].get('p') as number | bigint);
|
|
176
183
|
references.push({ box: { appIndex: app, name } });
|
|
184
|
+
continue;
|
|
177
185
|
}
|
|
186
|
+
|
|
187
|
+
// Empty resource reference - treat as an empty box reference
|
|
188
|
+
references.push({ box: { appIndex: BigInt(0), name: new Uint8Array(0) } });
|
|
178
189
|
}
|
|
179
190
|
return references;
|
|
180
191
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import JSONRequest from '../jsonrequest.js';
|
|
2
|
+
import { HTTPClient, HTTPClientResponse } from '../../client.js';
|
|
3
|
+
import { decodeJSON } from '../../../encoding/encoding.js';
|
|
4
|
+
import { AccountApplicationsInformationResponse } from './models/types.js';
|
|
5
|
+
import { Address } from '../../../encoding/address.js';
|
|
6
|
+
|
|
7
|
+
export default class AccountApplicationsInformation extends JSONRequest<AccountApplicationsInformationResponse> {
|
|
8
|
+
private account: string;
|
|
9
|
+
|
|
10
|
+
constructor(c: HTTPClient, account: string | Address) {
|
|
11
|
+
super(c);
|
|
12
|
+
this.account = account.toString();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
path() {
|
|
16
|
+
return `/v2/accounts/${this.account}/applications`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param include - use `params` to include full application parameters.
|
|
21
|
+
*/
|
|
22
|
+
include(include: string[]) {
|
|
23
|
+
this.query.include = include.join(',');
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
limit(limit: number) {
|
|
28
|
+
this.query.limit = limit;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
next(next: string) {
|
|
33
|
+
this.query.next = next;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line class-methods-use-this
|
|
38
|
+
prepare(
|
|
39
|
+
response: HTTPClientResponse
|
|
40
|
+
): AccountApplicationsInformationResponse {
|
|
41
|
+
return decodeJSON(
|
|
42
|
+
response.getJSONText(),
|
|
43
|
+
AccountApplicationsInformationResponse
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import JSONRequest from '../jsonrequest.js';
|
|
2
|
+
import { HTTPClient, HTTPClientResponse } from '../../client.js';
|
|
3
|
+
import { decodeJSON } from '../../../encoding/encoding.js';
|
|
4
|
+
import { AccountAssetsInformationResponse } from './models/types.js';
|
|
5
|
+
import { Address } from '../../../encoding/address.js';
|
|
6
|
+
|
|
7
|
+
export default class AccountAssetsInformation extends JSONRequest<AccountAssetsInformationResponse> {
|
|
8
|
+
private account: string;
|
|
9
|
+
|
|
10
|
+
constructor(c: HTTPClient, account: string | Address) {
|
|
11
|
+
super(c);
|
|
12
|
+
this.account = account.toString();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
path() {
|
|
16
|
+
return `/v2/accounts/${this.account}/assets`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
limit(limit: number) {
|
|
20
|
+
this.query.limit = limit;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
next(next: string) {
|
|
25
|
+
this.query.next = next;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line class-methods-use-this
|
|
30
|
+
prepare(response: HTTPClientResponse): AccountAssetsInformationResponse {
|
|
31
|
+
return decodeJSON(response.getJSONText(), AccountAssetsInformationResponse);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -2,6 +2,8 @@ import ServiceClient from '../serviceClient.js';
|
|
|
2
2
|
import * as modelsv2 from './models/types.js';
|
|
3
3
|
import AccountInformation from './accountInformation.js';
|
|
4
4
|
import AccountAssetInformation from './accountAssetInformation.js';
|
|
5
|
+
import AccountAssetsInformation from './accountAssetsInformation.js';
|
|
6
|
+
import AccountApplicationsInformation from './accountApplicationsInformation.js';
|
|
5
7
|
import AccountApplicationInformation from './accountApplicationInformation.js';
|
|
6
8
|
import Block from './block.js';
|
|
7
9
|
import Compile from './compile.js';
|
|
@@ -177,6 +179,26 @@ export class AlgodClient extends ServiceClient {
|
|
|
177
179
|
return new AccountAssetInformation(this.c, account, index);
|
|
178
180
|
}
|
|
179
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Returns the given account's asset holdings, paginated.
|
|
184
|
+
*
|
|
185
|
+
* @param account - The address of the account to look up.
|
|
186
|
+
* @category GET
|
|
187
|
+
*/
|
|
188
|
+
accountAssetsInformation(account: string | Address) {
|
|
189
|
+
return new AccountAssetsInformation(this.c, account);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Returns the given account's application holdings, paginated.
|
|
194
|
+
*
|
|
195
|
+
* @param account - The address of the account to look up.
|
|
196
|
+
* @category GET
|
|
197
|
+
*/
|
|
198
|
+
accountApplicationsInformation(account: string | Address) {
|
|
199
|
+
return new AccountApplicationsInformation(this.c, account);
|
|
200
|
+
}
|
|
201
|
+
|
|
180
202
|
/**
|
|
181
203
|
* Returns the given account's application information for a specific application.
|
|
182
204
|
*
|
|
@@ -512,7 +534,7 @@ export class AlgodClient extends ServiceClient {
|
|
|
512
534
|
}
|
|
513
535
|
|
|
514
536
|
/**
|
|
515
|
-
* Given an application ID, return all the
|
|
537
|
+
* Given an application ID, return all the boxes associated with the app.
|
|
516
538
|
*
|
|
517
539
|
* #### Example
|
|
518
540
|
* ```typescript
|
|
@@ -520,6 +542,8 @@ export class AlgodClient extends ServiceClient {
|
|
|
520
542
|
* const boxesResponse = await algodClient.getApplicationBoxes(index).max(3).do();
|
|
521
543
|
* const boxNames = boxesResponse.boxes.map(box => box.name);
|
|
522
544
|
* ```
|
|
545
|
+
* With the `.include("values")` parameter, returns values in addition to names. Pagination is supported with `limit`. If using pagination,
|
|
546
|
+
* it is recommended to use the `.round()` parameter to ensure each page is for the same round.
|
|
523
547
|
*
|
|
524
548
|
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idboxes)
|
|
525
549
|
* @param index - The application ID to look up.
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import JSONRequest from '../jsonrequest.js';
|
|
2
2
|
import { HTTPClient, HTTPClientResponse } from '../../client.js';
|
|
3
3
|
import { decodeJSON } from '../../../encoding/encoding.js';
|
|
4
|
+
import { bytesToBase64 } from '../../../encoding/binarydata.js';
|
|
5
|
+
import { ensureSafeInteger } from '../../../utils/utils.js';
|
|
4
6
|
import { BoxesResponse } from './models/types.js';
|
|
5
7
|
|
|
8
|
+
export type BoxInclude = 'values';
|
|
9
|
+
|
|
6
10
|
/**
|
|
7
|
-
* Given an application ID, return all the
|
|
11
|
+
* Given an application ID, return all the boxes associated with the app.
|
|
8
12
|
*
|
|
9
13
|
* #### Example
|
|
10
14
|
* ```typescript
|
|
@@ -13,6 +17,9 @@ import { BoxesResponse } from './models/types.js';
|
|
|
13
17
|
* const boxNames = boxesResponse.boxes.map(box => box.name);
|
|
14
18
|
* ```
|
|
15
19
|
*
|
|
20
|
+
* With the `.include("values")` parameter, returns values in addition to names. Pagination is supported with `limit`. If using pagination,
|
|
21
|
+
* it is recommended to use the `.round()` parameter to ensure each page is for the same round.
|
|
22
|
+
*
|
|
16
23
|
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idboxes)
|
|
17
24
|
* @param index - The application ID to look up.
|
|
18
25
|
* @category GET
|
|
@@ -34,18 +41,20 @@ export default class GetApplicationBoxes extends JSONRequest<BoxesResponse> {
|
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
/**
|
|
37
|
-
*
|
|
44
|
+
* @deprecated - Use `limit` instead for proper pagination with a limit.
|
|
45
|
+
*
|
|
46
|
+
* Set the max amount of boxes to return. Returns HTTP 400 if max is exceeded.
|
|
38
47
|
*
|
|
39
48
|
* #### Example
|
|
40
49
|
* ```typescript
|
|
41
50
|
* const maxResults = 20;
|
|
42
51
|
* const boxesResult = await algodClient
|
|
43
|
-
* .
|
|
44
|
-
* .
|
|
52
|
+
* .getApplicationBoxes(1234)
|
|
53
|
+
* .max(maxResults)
|
|
45
54
|
* .do();
|
|
46
55
|
* ```
|
|
47
56
|
*
|
|
48
|
-
* @param
|
|
57
|
+
* @param max - maximum number of results to return.
|
|
49
58
|
* @category query
|
|
50
59
|
*/
|
|
51
60
|
max(max: number) {
|
|
@@ -53,6 +62,115 @@ export default class GetApplicationBoxes extends JSONRequest<BoxesResponse> {
|
|
|
53
62
|
return this;
|
|
54
63
|
}
|
|
55
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Pagination token returned by the previous call.
|
|
67
|
+
*
|
|
68
|
+
* This is the value returned by a previous call to this endpoint in the
|
|
69
|
+
* `next-token` response field. Provide this token to get the next page of
|
|
70
|
+
* results. The token is the box name to use as the pagination cursor,
|
|
71
|
+
* encoded in the goal app call arg form.
|
|
72
|
+
*
|
|
73
|
+
* #### Example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const boxesResponse = await algodClient
|
|
76
|
+
* .getApplicationBoxes(1234)
|
|
77
|
+
* .limit(20)
|
|
78
|
+
* .next("b64:AAECAw==")
|
|
79
|
+
* .do();
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @param nextToken - The next token to use for pagination.
|
|
83
|
+
* @category query
|
|
84
|
+
*/
|
|
85
|
+
next(nextToken: string | undefined) {
|
|
86
|
+
this.query.next = nextToken;
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Filter box names by a prefix.
|
|
92
|
+
*
|
|
93
|
+
* #### Example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const boxesResponse = await algodClient
|
|
96
|
+
* .getApplicationBoxes(1234)
|
|
97
|
+
* .prefix(myAddr.publicKey)
|
|
98
|
+
* .do();
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @param prefix - The prefix to filter box names by
|
|
102
|
+
* @category query
|
|
103
|
+
*/
|
|
104
|
+
prefix(prefix: Uint8Array) {
|
|
105
|
+
this.query.prefix = `b64:${bytesToBase64(prefix)}`;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Include additional items in the response.
|
|
111
|
+
*
|
|
112
|
+
* Use `values` to include box values.
|
|
113
|
+
*
|
|
114
|
+
* #### Example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const boxesResponse = await algodClient
|
|
117
|
+
* .getApplicationBoxes(1234)
|
|
118
|
+
* .prefix(myAddr.publicKey)
|
|
119
|
+
* .include("values")
|
|
120
|
+
* .do();
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @param include - The additional items to include in the response.
|
|
124
|
+
* @category query
|
|
125
|
+
*/
|
|
126
|
+
include(...include: BoxInclude[]) {
|
|
127
|
+
this.query.include = include.join(',');
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Limits results per page when using pagination.
|
|
133
|
+
*
|
|
134
|
+
* #### Example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const maxResults = 20;
|
|
137
|
+
* const boxesResult = await algodClient
|
|
138
|
+
* .getApplicationBoxes(1234)
|
|
139
|
+
* .limit(maxResults)
|
|
140
|
+
* .do();
|
|
141
|
+
* const { nextToken } = boxesResult
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @param limit - maximum number of results to return per page.
|
|
145
|
+
* @category query
|
|
146
|
+
*/
|
|
147
|
+
limit(limit: number) {
|
|
148
|
+
this.query.limit = limit;
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Return results for the specified round.
|
|
154
|
+
*
|
|
155
|
+
* If not provided, results will be from the latest round. This parameter
|
|
156
|
+
* can be used to pin all pages of a paginated query to a consistent round.
|
|
157
|
+
*
|
|
158
|
+
* #### Example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const boxesResponse = await algodClient
|
|
161
|
+
* .getApplicationBoxes(1234)
|
|
162
|
+
* .round(12345678)
|
|
163
|
+
* .do();
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @param roundNumber - The round to query.
|
|
167
|
+
* @category query
|
|
168
|
+
*/
|
|
169
|
+
round(roundNumber: number | bigint) {
|
|
170
|
+
this.query.round = ensureSafeInteger(roundNumber);
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
|
|
56
174
|
// eslint-disable-next-line class-methods-use-this
|
|
57
175
|
prepare(response: HTTPClientResponse): BoxesResponse {
|
|
58
176
|
return decodeJSON(response.getJSONText(), BoxesResponse);
|