@algorandfoundation/algokit-utils 9.2.0 → 9.2.1-beta.2
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/_virtual/_rolldown/runtime.js +33 -0
- package/_virtual/_rolldown/runtime.mjs +13 -0
- package/account/account.d.ts +25 -30
- package/account/account.js +151 -146
- package/account/account.js.map +1 -1
- package/account/account.mjs +149 -144
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.d.ts +7 -2
- package/account/get-account-config-from-environment.js +19 -21
- package/account/get-account-config-from-environment.js.map +1 -1
- package/account/get-account-config-from-environment.mjs +19 -19
- package/account/get-account-config-from-environment.mjs.map +1 -1
- package/account/get-account.d.ts +14 -12
- package/account/get-account.js +56 -59
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs +56 -57
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +9 -5
- package/account/get-dispenser-account.js +20 -18
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs +20 -16
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/mnemonic-account.d.ts +7 -3
- package/account/mnemonic-account.js +17 -17
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs +15 -15
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.d.ts +40 -35
- package/amount.js +33 -34
- package/amount.js.map +1 -1
- package/amount.mjs +33 -32
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +10 -6
- package/app-client.js +91 -86
- package/app-client.js.map +1 -1
- package/app-client.mjs +91 -84
- package/app-client.mjs.map +1 -1
- package/app-deploy.d.ts +26 -24
- package/app-deploy.js +235 -253
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +233 -251
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +45 -46
- package/app.js +253 -271
- package/app.js.map +1 -1
- package/app.mjs +249 -267
- package/app.mjs.map +1 -1
- package/asset.d.ts +16 -12
- package/asset.js +116 -122
- package/asset.js.map +1 -1
- package/asset.mjs +116 -120
- package/asset.mjs.map +1 -1
- package/config.d.ts +7 -2
- package/config.js +5 -7
- package/config.js.map +1 -1
- package/config.mjs +5 -4
- package/config.mjs.map +1 -1
- package/debugging/debugging.d.ts +5 -1
- package/debugging/debugging.js +11 -11
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs +11 -9
- package/debugging/debugging.mjs.map +1 -1
- package/dispenser-client.d.ts +7 -2
- package/dispenser-client.js +23 -24
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs +23 -22
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +27 -18
- package/index.js +140 -143
- package/index.mjs +27 -29
- package/indexer-lookup.d.ts +18 -11
- package/indexer-lookup.js +112 -120
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs +105 -118
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.d.ts +9 -7
- package/localnet/get-kmd-wallet-account.js +28 -26
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs +28 -24
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +7 -5
- package/localnet/get-localnet-dispenser-account.js +17 -15
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs +17 -13
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +10 -8
- package/localnet/get-or-create-kmd-wallet-account.js +28 -26
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs +28 -24
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/is-localnet.d.ts +7 -3
- package/localnet/is-localnet.js +9 -10
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs +9 -8
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +17 -15
- package/network-client.js +115 -116
- package/network-client.js.map +1 -1
- package/network-client.mjs +115 -114
- package/network-client.mjs.map +1 -1
- package/package.json +12 -3
- package/testing/account.d.ts +11 -9
- package/testing/account.js +31 -33
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +29 -31
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +7 -2
- package/testing/fixtures/algokit-log-capture-fixture.js +36 -41
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs +36 -39
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +9 -4
- package/testing/fixtures/algorand-fixture.js +67 -62
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +66 -59
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/index.d.ts +7 -5
- package/testing/index.js +13 -18
- package/testing/index.mjs +7 -7
- package/testing/indexer.d.ts +5 -1
- package/testing/indexer.js +28 -37
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs +28 -35
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.d.ts +41 -36
- package/testing/test-logger.js +71 -76
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs +71 -74
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.d.ts +30 -27
- package/testing/transaction-logger.js +77 -93
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs +74 -90
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/legacy-bridge.js +100 -111
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +97 -108
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +7 -5
- package/transaction/perform-atomic-transaction-composer-simulate.js +31 -36
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +28 -33
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +34 -35
- package/transaction/transaction.js +716 -914
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +713 -911
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer-algos.d.ts +9 -5
- package/transfer/transfer-algos.js +26 -27
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +26 -25
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +11 -8
- package/transfer/transfer.js +94 -100
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +94 -98
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +432 -429
- package/types/account-manager.js +591 -602
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +587 -599
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +192 -202
- package/types/account.js +91 -88
- package/types/account.js.map +1 -1
- package/types/account.mjs +88 -86
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +15 -10
- package/types/algo-http-client-with-retry.js +70 -92
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs +69 -90
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +778 -771
- package/types/algorand-client-transaction-creator.js +733 -732
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +732 -730
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +1090 -1360
- package/types/algorand-client-transaction-sender.js +930 -961
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +927 -959
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +239 -236
- package/types/algorand-client.js +322 -320
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +321 -318
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +47 -43
- package/types/amount.js +66 -70
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +63 -68
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +235 -272
- package/types/app-arc56.js +124 -170
- package/types/app-arc56.js.map +1 -1
- package/types/app-arc56.mjs +121 -168
- package/types/app-arc56.mjs.map +1 -1
- package/types/app-client.d.ts +1128 -2009
- package/types/app-client.js +1633 -1791
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +1624 -1783
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +139 -141
- package/types/app-deployer.js +344 -384
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +341 -382
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +762 -932
- package/types/app-factory.js +496 -488
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +491 -484
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +304 -310
- package/types/app-manager.js +422 -475
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +419 -473
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.d.ts +118 -117
- package/types/app-spec.js +125 -135
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +121 -132
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +229 -241
- package/types/app.js +36 -28
- package/types/app.js.map +1 -1
- package/types/app.mjs +33 -26
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +204 -199
- package/types/asset-manager.js +165 -174
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +164 -172
- package/types/asset-manager.mjs.map +1 -1
- package/types/asset.d.ts +95 -91
- package/types/asset.js +0 -3
- package/types/asset.mjs +0 -2
- package/types/async-event-emitter.d.ts +18 -13
- package/types/async-event-emitter.js +37 -49
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +36 -47
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +453 -451
- package/types/client-manager.js +602 -598
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +597 -594
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +1211 -1258
- package/types/composer.js +1436 -1498
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +1430 -1493
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +53 -48
- package/types/config.js +78 -77
- package/types/config.js.map +1 -1
- package/types/config.mjs +77 -75
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +25 -23
- package/types/debugging.js +9 -11
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +8 -9
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +57 -52
- package/types/dispenser-client.js +120 -141
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +119 -139
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +5 -3
- package/types/expand.js +0 -3
- package/types/expand.mjs +0 -2
- package/types/indexer.d.ts +104 -100
- package/types/indexer.js +36 -31
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs +32 -30
- package/types/indexer.mjs.map +1 -1
- package/types/instance-of.d.ts +5 -3
- package/types/instance-of.js +0 -3
- package/types/instance-of.mjs +0 -2
- package/types/kmd-account-manager.d.ts +75 -70
- package/types/kmd-account-manager.js +150 -184
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +147 -182
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +13 -8
- package/types/lifecycle-events.js +10 -7
- package/types/lifecycle-events.js.map +1 -1
- package/types/lifecycle-events.mjs +9 -7
- package/types/lifecycle-events.mjs.map +1 -1
- package/types/logging.d.ts +15 -11
- package/types/logging.js +30 -31
- package/types/logging.js.map +1 -1
- package/types/logging.mjs +29 -29
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +33 -29
- package/types/logic-error.js +50 -49
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +49 -47
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +32 -27
- package/types/network-client.js +10 -9
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs +9 -7
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +131 -132
- package/types/testing.js +0 -3
- package/types/testing.mjs +0 -2
- package/types/transaction.d.ts +110 -110
- package/types/transaction.js +0 -3
- package/types/transaction.mjs +0 -2
- package/types/transfer.d.ts +70 -66
- package/types/transfer.js +0 -3
- package/types/transfer.mjs +0 -2
- package/util.js +73 -118
- package/util.js.map +1 -1
- package/util.mjs +73 -116
- package/util.mjs.map +1 -1
- package/account/index.d.ts +0 -5
- package/debugging/index.d.ts +0 -1
- package/index.js.map +0 -1
- package/index.mjs.map +0 -1
- package/localnet/index.d.ts +0 -4
- package/testing/_asset.d.ts +0 -3
- package/testing/fixtures/index.d.ts +0 -2
- package/testing/index.js.map +0 -1
- package/testing/index.mjs.map +0 -1
- package/transaction/index.d.ts +0 -2
- package/transaction/legacy-bridge.d.ts +0 -35
- package/transfer/index.d.ts +0 -2
- package/types/asset.js.map +0 -1
- package/types/asset.mjs.map +0 -1
- package/types/expand.js.map +0 -1
- package/types/expand.mjs.map +0 -1
- package/types/instance-of.js.map +0 -1
- package/types/instance-of.mjs.map +0 -1
- package/types/testing.js.map +0 -1
- package/types/testing.mjs.map +0 -1
- package/types/transaction.js.map +0 -1
- package/types/transaction.mjs.map +0 -1
- package/types/transfer.js.map +0 -1
- package/types/transfer.mjs.map +0 -1
- package/util.d.ts +0 -48
package/indexer-lookup.js
CHANGED
|
@@ -1,141 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let algosdk = require("algosdk");
|
|
3
|
+
algosdk = require_runtime.__toESM(algosdk);
|
|
4
|
+
//#region src/indexer-lookup.ts
|
|
5
|
+
var indexer_lookup_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
6
|
+
executePaginatedRequest: () => executePaginatedRequest,
|
|
7
|
+
lookupAccountByAddress: () => lookupAccountByAddress,
|
|
8
|
+
lookupAccountCreatedApplicationByAddress: () => lookupAccountCreatedApplicationByAddress,
|
|
9
|
+
lookupAssetHoldings: () => lookupAssetHoldings,
|
|
10
|
+
lookupTransactionById: () => lookupTransactionById,
|
|
11
|
+
searchTransactions: () => searchTransactions
|
|
12
|
+
});
|
|
13
|
+
const DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT = 1e3;
|
|
6
14
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
* @deprecated Use `indexer.lookupTransactionByID(transactionId).do()`.
|
|
16
|
+
* Looks up a transaction by ID using Indexer.
|
|
17
|
+
* @param transactionId The ID of the transaction to look up
|
|
18
|
+
* @param indexer An indexer client
|
|
19
|
+
* @returns The result of the look-up
|
|
20
|
+
*/
|
|
13
21
|
async function lookupTransactionById(transactionId, indexer) {
|
|
14
|
-
|
|
22
|
+
return await indexer.lookupTransactionByID(transactionId).do();
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
* @deprecated Use `indexer.lookupAccountByID(accountAddress).do()`.
|
|
26
|
+
* Looks up an account by address using Indexer.
|
|
27
|
+
* @param accountAddress The address of the account to look up
|
|
28
|
+
* @param indexer An indexer client
|
|
29
|
+
* @returns The result of the look-up
|
|
30
|
+
*/
|
|
23
31
|
async function lookupAccountByAddress(accountAddress, indexer) {
|
|
24
|
-
|
|
32
|
+
return await indexer.lookupAccountByID(accountAddress).do();
|
|
25
33
|
}
|
|
26
34
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
async function lookupAccountCreatedApplicationByAddress(indexer, address, getAll =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
s = s.nextToken(nextToken);
|
|
47
|
-
}
|
|
48
|
-
return s;
|
|
49
|
-
});
|
|
35
|
+
* Looks up applications that were created by the given address; will automatically paginate through all data.
|
|
36
|
+
* @param indexer An indexer instance
|
|
37
|
+
* @param address The address of the creator to look up
|
|
38
|
+
* @param getAll Whether or not to include deleted applications
|
|
39
|
+
* @param paginationLimit The number of records to return per paginated request, default 1000
|
|
40
|
+
* @returns The list of application results
|
|
41
|
+
*/
|
|
42
|
+
async function lookupAccountCreatedApplicationByAddress(indexer, address, getAll = void 0, paginationLimit) {
|
|
43
|
+
return await executePaginatedRequest((response) => {
|
|
44
|
+
if ("message" in response) throw {
|
|
45
|
+
status: 404,
|
|
46
|
+
...response
|
|
47
|
+
};
|
|
48
|
+
return response.applications;
|
|
49
|
+
}, (nextToken) => {
|
|
50
|
+
let s = indexer.lookupAccountCreatedApplications(address).includeAll(getAll).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT);
|
|
51
|
+
if (nextToken) s = s.nextToken(nextToken);
|
|
52
|
+
return s;
|
|
53
|
+
});
|
|
50
54
|
}
|
|
51
55
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
* Looks up asset holdings for the given asset; will automatically paginate through all data.
|
|
57
|
+
* @param indexer An indexer instance
|
|
58
|
+
* @param assetId The ID of the asset to look up holdings for
|
|
59
|
+
* @param options Optional options to control the lookup
|
|
60
|
+
* @param paginationLimit The number of records to return per paginated request, default 1000
|
|
61
|
+
* @returns The list of application results
|
|
62
|
+
*/
|
|
59
63
|
async function lookupAssetHoldings(indexer, assetId, options, paginationLimit) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
s = s.includeAll(options.includeAll);
|
|
75
|
-
}
|
|
76
|
-
if (nextToken) {
|
|
77
|
-
s = s.nextToken(nextToken);
|
|
78
|
-
}
|
|
79
|
-
return s;
|
|
80
|
-
});
|
|
64
|
+
return await executePaginatedRequest((response) => {
|
|
65
|
+
if ("message" in response) throw {
|
|
66
|
+
status: 404,
|
|
67
|
+
...response
|
|
68
|
+
};
|
|
69
|
+
return response.balances;
|
|
70
|
+
}, (nextToken) => {
|
|
71
|
+
let s = indexer.lookupAssetBalances(Number(assetId)).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT);
|
|
72
|
+
if (options?.currencyGreaterThan !== void 0) s = s.currencyGreaterThan(options.currencyGreaterThan);
|
|
73
|
+
if (options?.currencyLessThan !== void 0) s = s.currencyLessThan(options.currencyLessThan);
|
|
74
|
+
if (options?.includeAll !== void 0) s = s.includeAll(options.includeAll);
|
|
75
|
+
if (nextToken) s = s.nextToken(nextToken);
|
|
76
|
+
return s;
|
|
77
|
+
});
|
|
81
78
|
}
|
|
82
79
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
* Allows transactions to be searched for the given criteria.
|
|
81
|
+
* @param indexer An indexer client
|
|
82
|
+
* @param searchCriteria The criteria to search for
|
|
83
|
+
* @param paginationLimit The number of records to return per paginated request, default 1000
|
|
84
|
+
* @returns The search results
|
|
85
|
+
*/
|
|
89
86
|
async function searchTransactions(indexer, searchCriteria, paginationLimit) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
nextToken: undefined,
|
|
109
|
-
transactions: transactions,
|
|
110
|
-
});
|
|
87
|
+
let currentRound = 0n;
|
|
88
|
+
const transactions = await executePaginatedRequest((response) => {
|
|
89
|
+
if ("message" in response) throw {
|
|
90
|
+
status: 404,
|
|
91
|
+
...response
|
|
92
|
+
};
|
|
93
|
+
if (response.currentRound > currentRound) currentRound = response.currentRound;
|
|
94
|
+
return response.transactions;
|
|
95
|
+
}, (nextToken) => {
|
|
96
|
+
let s = searchCriteria(indexer.searchForTransactions()).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT);
|
|
97
|
+
if (nextToken) s = s.nextToken(nextToken);
|
|
98
|
+
return s;
|
|
99
|
+
});
|
|
100
|
+
return new algosdk.default.indexerModels.TransactionsResponse({
|
|
101
|
+
currentRound,
|
|
102
|
+
nextToken: void 0,
|
|
103
|
+
transactions
|
|
104
|
+
});
|
|
111
105
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
results.push(...items);
|
|
127
|
-
nextToken = response['nextToken'];
|
|
128
|
-
if (!nextToken) {
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return results;
|
|
106
|
+
async function executePaginatedRequest(extractItems, buildRequest) {
|
|
107
|
+
const results = [];
|
|
108
|
+
let nextToken = void 0;
|
|
109
|
+
while (true) {
|
|
110
|
+
const response = await buildRequest(nextToken).do();
|
|
111
|
+
const items = extractItems(response);
|
|
112
|
+
if (items == null || items.length === 0) break;
|
|
113
|
+
results.push(...items);
|
|
114
|
+
nextToken = response["nextToken"];
|
|
115
|
+
if (!nextToken) break;
|
|
116
|
+
}
|
|
117
|
+
return results;
|
|
133
118
|
}
|
|
134
|
-
|
|
119
|
+
//#endregion
|
|
135
120
|
exports.executePaginatedRequest = executePaginatedRequest;
|
|
121
|
+
Object.defineProperty(exports, "indexer_lookup_exports", {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function() {
|
|
124
|
+
return indexer_lookup_exports;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
136
127
|
exports.lookupAccountByAddress = lookupAccountByAddress;
|
|
137
128
|
exports.lookupAccountCreatedApplicationByAddress = lookupAccountCreatedApplicationByAddress;
|
|
138
129
|
exports.lookupAssetHoldings = lookupAssetHoldings;
|
|
139
130
|
exports.lookupTransactionById = lookupTransactionById;
|
|
140
131
|
exports.searchTransactions = searchTransactions;
|
|
141
|
-
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=indexer-lookup.js.map
|
package/indexer-lookup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexer-lookup.js","sources":["../src/indexer-lookup.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { LookupAssetHoldingsOptions } from './types/indexer'\nimport Indexer = algosdk.Indexer\nexport type SearchForTransactions = ReturnType<Indexer['searchForTransactions']>\n\nconst DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT = 1000 //MaxAPIResourcesPerAccount: This is the default maximum, though may be provider specific\n\n/**\n * @deprecated Use `indexer.lookupTransactionByID(transactionId).do()`.\n * Looks up a transaction by ID using Indexer.\n * @param transactionId The ID of the transaction to look up\n * @param indexer An indexer client\n * @returns The result of the look-up\n */\nexport async function lookupTransactionById(transactionId: string, indexer: Indexer) {\n return await indexer.lookupTransactionByID(transactionId).do()\n}\n\n/**\n * @deprecated Use `indexer.lookupAccountByID(accountAddress).do()`.\n * Looks up an account by address using Indexer.\n * @param accountAddress The address of the account to look up\n * @param indexer An indexer client\n * @returns The result of the look-up\n */\nexport async function lookupAccountByAddress(accountAddress: string | Address, indexer: Indexer) {\n return await indexer.lookupAccountByID(accountAddress).do()\n}\n\n/**\n * Looks up applications that were created by the given address; will automatically paginate through all data.\n * @param indexer An indexer instance\n * @param address The address of the creator to look up\n * @param getAll Whether or not to include deleted applications\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The list of application results\n */\nexport async function lookupAccountCreatedApplicationByAddress(\n indexer: Indexer,\n address: string | Address,\n getAll: boolean | undefined = undefined,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.Application[]> {\n return await executePaginatedRequest(\n (response: algosdk.indexerModels.ApplicationsResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n return response.applications\n },\n (nextToken) => {\n let s = indexer\n .lookupAccountCreatedApplications(address)\n .includeAll(getAll)\n .limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n}\n\n/**\n * Looks up asset holdings for the given asset; will automatically paginate through all data.\n * @param indexer An indexer instance\n * @param assetId The ID of the asset to look up holdings for\n * @param options Optional options to control the lookup\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The list of application results\n */\nexport async function lookupAssetHoldings(\n indexer: Indexer,\n assetId: number | bigint,\n options?: LookupAssetHoldingsOptions,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.MiniAssetHolding[]> {\n return await executePaginatedRequest(\n (response: algosdk.indexerModels.AssetBalancesResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n return response.balances\n },\n (nextToken) => {\n let s = indexer.lookupAssetBalances(Number(assetId)).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (options?.currencyGreaterThan !== undefined) {\n s = s.currencyGreaterThan(options.currencyGreaterThan)\n }\n if (options?.currencyLessThan !== undefined) {\n s = s.currencyLessThan(options.currencyLessThan)\n }\n if (options?.includeAll !== undefined) {\n s = s.includeAll(options.includeAll)\n }\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n}\n\n/**\n * Allows transactions to be searched for the given criteria.\n * @param indexer An indexer client\n * @param searchCriteria The criteria to search for\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The search results\n */\nexport async function searchTransactions(\n indexer: Indexer,\n searchCriteria: (s: SearchForTransactions) => SearchForTransactions,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.TransactionsResponse> {\n let currentRound = 0n\n const transactions = await executePaginatedRequest(\n (response: algosdk.indexerModels.TransactionsResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n if (response.currentRound > currentRound) {\n currentRound = response.currentRound\n }\n return response.transactions\n },\n (nextToken) => {\n let s = searchCriteria(indexer.searchForTransactions()).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n\n return new algosdk.indexerModels.TransactionsResponse({\n currentRound,\n nextToken: undefined,\n transactions: transactions,\n })\n}\n\n// https://dev.algorand.co/reference/rest-
|
|
1
|
+
{"version":3,"file":"indexer-lookup.js","names":[],"sources":["../src/indexer-lookup.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { LookupAssetHoldingsOptions } from './types/indexer'\nimport Indexer = algosdk.Indexer\nexport type SearchForTransactions = ReturnType<Indexer['searchForTransactions']>\n\nconst DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT = 1000 //MaxAPIResourcesPerAccount: This is the default maximum, though may be provider specific\n\n/**\n * @deprecated Use `indexer.lookupTransactionByID(transactionId).do()`.\n * Looks up a transaction by ID using Indexer.\n * @param transactionId The ID of the transaction to look up\n * @param indexer An indexer client\n * @returns The result of the look-up\n */\nexport async function lookupTransactionById(transactionId: string, indexer: Indexer) {\n return await indexer.lookupTransactionByID(transactionId).do()\n}\n\n/**\n * @deprecated Use `indexer.lookupAccountByID(accountAddress).do()`.\n * Looks up an account by address using Indexer.\n * @param accountAddress The address of the account to look up\n * @param indexer An indexer client\n * @returns The result of the look-up\n */\nexport async function lookupAccountByAddress(accountAddress: string | Address, indexer: Indexer) {\n return await indexer.lookupAccountByID(accountAddress).do()\n}\n\n/**\n * Looks up applications that were created by the given address; will automatically paginate through all data.\n * @param indexer An indexer instance\n * @param address The address of the creator to look up\n * @param getAll Whether or not to include deleted applications\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The list of application results\n */\nexport async function lookupAccountCreatedApplicationByAddress(\n indexer: Indexer,\n address: string | Address,\n getAll: boolean | undefined = undefined,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.Application[]> {\n return await executePaginatedRequest(\n (response: algosdk.indexerModels.ApplicationsResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n return response.applications\n },\n (nextToken) => {\n let s = indexer\n .lookupAccountCreatedApplications(address)\n .includeAll(getAll)\n .limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n}\n\n/**\n * Looks up asset holdings for the given asset; will automatically paginate through all data.\n * @param indexer An indexer instance\n * @param assetId The ID of the asset to look up holdings for\n * @param options Optional options to control the lookup\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The list of application results\n */\nexport async function lookupAssetHoldings(\n indexer: Indexer,\n assetId: number | bigint,\n options?: LookupAssetHoldingsOptions,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.MiniAssetHolding[]> {\n return await executePaginatedRequest(\n (response: algosdk.indexerModels.AssetBalancesResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n return response.balances\n },\n (nextToken) => {\n let s = indexer.lookupAssetBalances(Number(assetId)).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (options?.currencyGreaterThan !== undefined) {\n s = s.currencyGreaterThan(options.currencyGreaterThan)\n }\n if (options?.currencyLessThan !== undefined) {\n s = s.currencyLessThan(options.currencyLessThan)\n }\n if (options?.includeAll !== undefined) {\n s = s.includeAll(options.includeAll)\n }\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n}\n\n/**\n * Allows transactions to be searched for the given criteria.\n * @param indexer An indexer client\n * @param searchCriteria The criteria to search for\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The search results\n */\nexport async function searchTransactions(\n indexer: Indexer,\n searchCriteria: (s: SearchForTransactions) => SearchForTransactions,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.TransactionsResponse> {\n let currentRound = 0n\n const transactions = await executePaginatedRequest(\n (response: algosdk.indexerModels.TransactionsResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n if (response.currentRound > currentRound) {\n currentRound = response.currentRound\n }\n return response.transactions\n },\n (nextToken) => {\n let s = searchCriteria(indexer.searchForTransactions()).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n\n return new algosdk.indexerModels.TransactionsResponse({\n currentRound,\n nextToken: undefined,\n transactions: transactions,\n })\n}\n\n// https://dev.algorand.co/reference/rest-api/indexer\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function executePaginatedRequest<TResult, TRequest extends { do: () => Promise<any> }>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n extractItems: (response: any) => TResult[],\n buildRequest: (nextToken?: string) => TRequest,\n): Promise<TResult[]> {\n const results = []\n\n let nextToken: string | undefined = undefined\n while (true) {\n const request = buildRequest(nextToken)\n const response = await request.do()\n const items = extractItems(response)\n if (items == null || items.length === 0) {\n break\n }\n results.push(...items)\n nextToken = response['nextToken']\n if (!nextToken) {\n break\n }\n }\n\n return results\n}\n"],"mappings":";;;;;;;;;;;;AAKA,MAAM,gDAAgD;;;;;;;;AAStD,eAAsB,sBAAsB,eAAuB,SAAkB;CACnF,OAAO,MAAM,QAAQ,sBAAsB,aAAa,CAAC,CAAC,GAAG;AAC/D;;;;;;;;AASA,eAAsB,uBAAuB,gBAAkC,SAAkB;CAC/F,OAAO,MAAM,QAAQ,kBAAkB,cAAc,CAAC,CAAC,GAAG;AAC5D;;;;;;;;;AAUA,eAAsB,yCACpB,SACA,SACA,SAA8B,KAAA,GAC9B,iBAC8C;CAC9C,OAAO,MAAM,yBACV,aAA+E;EAC9E,IAAI,aAAa,UACf,MAAM;GAAE,QAAQ;GAAK,GAAG;EAAS;EAEnC,OAAO,SAAS;CAClB,IACC,cAAc;EACb,IAAI,IAAI,QACL,iCAAiC,OAAO,CAAC,CACzC,WAAW,MAAM,CAAC,CAClB,MAAM,mBAAmB,6CAA6C;EACzE,IAAI,WACF,IAAI,EAAE,UAAU,SAAS;EAE3B,OAAO;CACT,CACF;AACF;;;;;;;;;AAUA,eAAsB,oBACpB,SACA,SACA,SACA,iBACmD;CACnD,OAAO,MAAM,yBACV,aAAgF;EAC/E,IAAI,aAAa,UACf,MAAM;GAAE,QAAQ;GAAK,GAAG;EAAS;EAEnC,OAAO,SAAS;CAClB,IACC,cAAc;EACb,IAAI,IAAI,QAAQ,oBAAoB,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,mBAAmB,6CAA6C;EAC3H,IAAI,SAAS,wBAAwB,KAAA,GACnC,IAAI,EAAE,oBAAoB,QAAQ,mBAAmB;EAEvD,IAAI,SAAS,qBAAqB,KAAA,GAChC,IAAI,EAAE,iBAAiB,QAAQ,gBAAgB;EAEjD,IAAI,SAAS,eAAe,KAAA,GAC1B,IAAI,EAAE,WAAW,QAAQ,UAAU;EAErC,IAAI,WACF,IAAI,EAAE,UAAU,SAAS;EAE3B,OAAO;CACT,CACF;AACF;;;;;;;;AASA,eAAsB,mBACpB,SACA,gBACA,iBACqD;CACrD,IAAI,eAAe;CACnB,MAAM,eAAe,MAAM,yBACxB,aAA+E;EAC9E,IAAI,aAAa,UACf,MAAM;GAAE,QAAQ;GAAK,GAAG;EAAS;EAEnC,IAAI,SAAS,eAAe,cAC1B,eAAe,SAAS;EAE1B,OAAO,SAAS;CAClB,IACC,cAAc;EACb,IAAI,IAAI,eAAe,QAAQ,sBAAsB,CAAC,CAAC,CAAC,MAAM,mBAAmB,6CAA6C;EAC9H,IAAI,WACF,IAAI,EAAE,UAAU,SAAS;EAE3B,OAAO;CACT,CACF;CAEA,OAAO,IAAI,QAAA,QAAQ,cAAc,qBAAqB;EACpD;EACA,WAAW,KAAA;EACG;CAChB,CAAC;AACH;AAIA,eAAsB,wBAEpB,cACA,cACoB;CACpB,MAAM,UAAU,CAAC;CAEjB,IAAI,YAAgC,KAAA;CACpC,OAAO,MAAM;EAEX,MAAM,WAAW,MADD,aAAa,SACA,CAAC,CAAC,GAAG;EAClC,MAAM,QAAQ,aAAa,QAAQ;EACnC,IAAI,SAAS,QAAQ,MAAM,WAAW,GACpC;EAEF,QAAQ,KAAK,GAAG,KAAK;EACrB,YAAY,SAAS;EACrB,IAAI,CAAC,WACH;CAEJ;CAEA,OAAO;AACT"}
|
package/indexer-lookup.mjs
CHANGED
|
@@ -1,134 +1,121 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import algosdk from "algosdk";
|
|
3
|
+
//#region src/indexer-lookup.ts
|
|
4
|
+
var indexer_lookup_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
executePaginatedRequest: () => executePaginatedRequest,
|
|
6
|
+
lookupAccountByAddress: () => lookupAccountByAddress,
|
|
7
|
+
lookupAccountCreatedApplicationByAddress: () => lookupAccountCreatedApplicationByAddress,
|
|
8
|
+
lookupAssetHoldings: () => lookupAssetHoldings,
|
|
9
|
+
lookupTransactionById: () => lookupTransactionById,
|
|
10
|
+
searchTransactions: () => searchTransactions
|
|
11
|
+
});
|
|
12
|
+
const DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT = 1e3;
|
|
4
13
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
* @deprecated Use `indexer.lookupTransactionByID(transactionId).do()`.
|
|
15
|
+
* Looks up a transaction by ID using Indexer.
|
|
16
|
+
* @param transactionId The ID of the transaction to look up
|
|
17
|
+
* @param indexer An indexer client
|
|
18
|
+
* @returns The result of the look-up
|
|
19
|
+
*/
|
|
11
20
|
async function lookupTransactionById(transactionId, indexer) {
|
|
12
|
-
|
|
21
|
+
return await indexer.lookupTransactionByID(transactionId).do();
|
|
13
22
|
}
|
|
14
23
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
* @deprecated Use `indexer.lookupAccountByID(accountAddress).do()`.
|
|
25
|
+
* Looks up an account by address using Indexer.
|
|
26
|
+
* @param accountAddress The address of the account to look up
|
|
27
|
+
* @param indexer An indexer client
|
|
28
|
+
* @returns The result of the look-up
|
|
29
|
+
*/
|
|
21
30
|
async function lookupAccountByAddress(accountAddress, indexer) {
|
|
22
|
-
|
|
31
|
+
return await indexer.lookupAccountByID(accountAddress).do();
|
|
23
32
|
}
|
|
24
33
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
async function lookupAccountCreatedApplicationByAddress(indexer, address, getAll =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
s = s.nextToken(nextToken);
|
|
45
|
-
}
|
|
46
|
-
return s;
|
|
47
|
-
});
|
|
34
|
+
* Looks up applications that were created by the given address; will automatically paginate through all data.
|
|
35
|
+
* @param indexer An indexer instance
|
|
36
|
+
* @param address The address of the creator to look up
|
|
37
|
+
* @param getAll Whether or not to include deleted applications
|
|
38
|
+
* @param paginationLimit The number of records to return per paginated request, default 1000
|
|
39
|
+
* @returns The list of application results
|
|
40
|
+
*/
|
|
41
|
+
async function lookupAccountCreatedApplicationByAddress(indexer, address, getAll = void 0, paginationLimit) {
|
|
42
|
+
return await executePaginatedRequest((response) => {
|
|
43
|
+
if ("message" in response) throw {
|
|
44
|
+
status: 404,
|
|
45
|
+
...response
|
|
46
|
+
};
|
|
47
|
+
return response.applications;
|
|
48
|
+
}, (nextToken) => {
|
|
49
|
+
let s = indexer.lookupAccountCreatedApplications(address).includeAll(getAll).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT);
|
|
50
|
+
if (nextToken) s = s.nextToken(nextToken);
|
|
51
|
+
return s;
|
|
52
|
+
});
|
|
48
53
|
}
|
|
49
54
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
* Looks up asset holdings for the given asset; will automatically paginate through all data.
|
|
56
|
+
* @param indexer An indexer instance
|
|
57
|
+
* @param assetId The ID of the asset to look up holdings for
|
|
58
|
+
* @param options Optional options to control the lookup
|
|
59
|
+
* @param paginationLimit The number of records to return per paginated request, default 1000
|
|
60
|
+
* @returns The list of application results
|
|
61
|
+
*/
|
|
57
62
|
async function lookupAssetHoldings(indexer, assetId, options, paginationLimit) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
s = s.includeAll(options.includeAll);
|
|
73
|
-
}
|
|
74
|
-
if (nextToken) {
|
|
75
|
-
s = s.nextToken(nextToken);
|
|
76
|
-
}
|
|
77
|
-
return s;
|
|
78
|
-
});
|
|
63
|
+
return await executePaginatedRequest((response) => {
|
|
64
|
+
if ("message" in response) throw {
|
|
65
|
+
status: 404,
|
|
66
|
+
...response
|
|
67
|
+
};
|
|
68
|
+
return response.balances;
|
|
69
|
+
}, (nextToken) => {
|
|
70
|
+
let s = indexer.lookupAssetBalances(Number(assetId)).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT);
|
|
71
|
+
if (options?.currencyGreaterThan !== void 0) s = s.currencyGreaterThan(options.currencyGreaterThan);
|
|
72
|
+
if (options?.currencyLessThan !== void 0) s = s.currencyLessThan(options.currencyLessThan);
|
|
73
|
+
if (options?.includeAll !== void 0) s = s.includeAll(options.includeAll);
|
|
74
|
+
if (nextToken) s = s.nextToken(nextToken);
|
|
75
|
+
return s;
|
|
76
|
+
});
|
|
79
77
|
}
|
|
80
78
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
* Allows transactions to be searched for the given criteria.
|
|
80
|
+
* @param indexer An indexer client
|
|
81
|
+
* @param searchCriteria The criteria to search for
|
|
82
|
+
* @param paginationLimit The number of records to return per paginated request, default 1000
|
|
83
|
+
* @returns The search results
|
|
84
|
+
*/
|
|
87
85
|
async function searchTransactions(indexer, searchCriteria, paginationLimit) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
nextToken: undefined,
|
|
107
|
-
transactions: transactions,
|
|
108
|
-
});
|
|
86
|
+
let currentRound = 0n;
|
|
87
|
+
const transactions = await executePaginatedRequest((response) => {
|
|
88
|
+
if ("message" in response) throw {
|
|
89
|
+
status: 404,
|
|
90
|
+
...response
|
|
91
|
+
};
|
|
92
|
+
if (response.currentRound > currentRound) currentRound = response.currentRound;
|
|
93
|
+
return response.transactions;
|
|
94
|
+
}, (nextToken) => {
|
|
95
|
+
let s = searchCriteria(indexer.searchForTransactions()).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT);
|
|
96
|
+
if (nextToken) s = s.nextToken(nextToken);
|
|
97
|
+
return s;
|
|
98
|
+
});
|
|
99
|
+
return new algosdk.indexerModels.TransactionsResponse({
|
|
100
|
+
currentRound,
|
|
101
|
+
nextToken: void 0,
|
|
102
|
+
transactions
|
|
103
|
+
});
|
|
109
104
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
results.push(...items);
|
|
125
|
-
nextToken = response['nextToken'];
|
|
126
|
-
if (!nextToken) {
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return results;
|
|
105
|
+
async function executePaginatedRequest(extractItems, buildRequest) {
|
|
106
|
+
const results = [];
|
|
107
|
+
let nextToken = void 0;
|
|
108
|
+
while (true) {
|
|
109
|
+
const response = await buildRequest(nextToken).do();
|
|
110
|
+
const items = extractItems(response);
|
|
111
|
+
if (items == null || items.length === 0) break;
|
|
112
|
+
results.push(...items);
|
|
113
|
+
nextToken = response["nextToken"];
|
|
114
|
+
if (!nextToken) break;
|
|
115
|
+
}
|
|
116
|
+
return results;
|
|
131
117
|
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { executePaginatedRequest, indexer_lookup_exports, lookupAccountByAddress, lookupAccountCreatedApplicationByAddress, lookupAssetHoldings, lookupTransactionById, searchTransactions };
|
|
132
120
|
|
|
133
|
-
|
|
134
|
-
//# sourceMappingURL=indexer-lookup.mjs.map
|
|
121
|
+
//# sourceMappingURL=indexer-lookup.mjs.map
|
package/indexer-lookup.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexer-lookup.mjs","sources":["../src/indexer-lookup.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { LookupAssetHoldingsOptions } from './types/indexer'\nimport Indexer = algosdk.Indexer\nexport type SearchForTransactions = ReturnType<Indexer['searchForTransactions']>\n\nconst DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT = 1000 //MaxAPIResourcesPerAccount: This is the default maximum, though may be provider specific\n\n/**\n * @deprecated Use `indexer.lookupTransactionByID(transactionId).do()`.\n * Looks up a transaction by ID using Indexer.\n * @param transactionId The ID of the transaction to look up\n * @param indexer An indexer client\n * @returns The result of the look-up\n */\nexport async function lookupTransactionById(transactionId: string, indexer: Indexer) {\n return await indexer.lookupTransactionByID(transactionId).do()\n}\n\n/**\n * @deprecated Use `indexer.lookupAccountByID(accountAddress).do()`.\n * Looks up an account by address using Indexer.\n * @param accountAddress The address of the account to look up\n * @param indexer An indexer client\n * @returns The result of the look-up\n */\nexport async function lookupAccountByAddress(accountAddress: string | Address, indexer: Indexer) {\n return await indexer.lookupAccountByID(accountAddress).do()\n}\n\n/**\n * Looks up applications that were created by the given address; will automatically paginate through all data.\n * @param indexer An indexer instance\n * @param address The address of the creator to look up\n * @param getAll Whether or not to include deleted applications\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The list of application results\n */\nexport async function lookupAccountCreatedApplicationByAddress(\n indexer: Indexer,\n address: string | Address,\n getAll: boolean | undefined = undefined,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.Application[]> {\n return await executePaginatedRequest(\n (response: algosdk.indexerModels.ApplicationsResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n return response.applications\n },\n (nextToken) => {\n let s = indexer\n .lookupAccountCreatedApplications(address)\n .includeAll(getAll)\n .limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n}\n\n/**\n * Looks up asset holdings for the given asset; will automatically paginate through all data.\n * @param indexer An indexer instance\n * @param assetId The ID of the asset to look up holdings for\n * @param options Optional options to control the lookup\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The list of application results\n */\nexport async function lookupAssetHoldings(\n indexer: Indexer,\n assetId: number | bigint,\n options?: LookupAssetHoldingsOptions,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.MiniAssetHolding[]> {\n return await executePaginatedRequest(\n (response: algosdk.indexerModels.AssetBalancesResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n return response.balances\n },\n (nextToken) => {\n let s = indexer.lookupAssetBalances(Number(assetId)).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (options?.currencyGreaterThan !== undefined) {\n s = s.currencyGreaterThan(options.currencyGreaterThan)\n }\n if (options?.currencyLessThan !== undefined) {\n s = s.currencyLessThan(options.currencyLessThan)\n }\n if (options?.includeAll !== undefined) {\n s = s.includeAll(options.includeAll)\n }\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n}\n\n/**\n * Allows transactions to be searched for the given criteria.\n * @param indexer An indexer client\n * @param searchCriteria The criteria to search for\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The search results\n */\nexport async function searchTransactions(\n indexer: Indexer,\n searchCriteria: (s: SearchForTransactions) => SearchForTransactions,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.TransactionsResponse> {\n let currentRound = 0n\n const transactions = await executePaginatedRequest(\n (response: algosdk.indexerModels.TransactionsResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n if (response.currentRound > currentRound) {\n currentRound = response.currentRound\n }\n return response.transactions\n },\n (nextToken) => {\n let s = searchCriteria(indexer.searchForTransactions()).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n\n return new algosdk.indexerModels.TransactionsResponse({\n currentRound,\n nextToken: undefined,\n transactions: transactions,\n })\n}\n\n// https://dev.algorand.co/reference/rest-
|
|
1
|
+
{"version":3,"file":"indexer-lookup.mjs","names":[],"sources":["../src/indexer-lookup.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { LookupAssetHoldingsOptions } from './types/indexer'\nimport Indexer = algosdk.Indexer\nexport type SearchForTransactions = ReturnType<Indexer['searchForTransactions']>\n\nconst DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT = 1000 //MaxAPIResourcesPerAccount: This is the default maximum, though may be provider specific\n\n/**\n * @deprecated Use `indexer.lookupTransactionByID(transactionId).do()`.\n * Looks up a transaction by ID using Indexer.\n * @param transactionId The ID of the transaction to look up\n * @param indexer An indexer client\n * @returns The result of the look-up\n */\nexport async function lookupTransactionById(transactionId: string, indexer: Indexer) {\n return await indexer.lookupTransactionByID(transactionId).do()\n}\n\n/**\n * @deprecated Use `indexer.lookupAccountByID(accountAddress).do()`.\n * Looks up an account by address using Indexer.\n * @param accountAddress The address of the account to look up\n * @param indexer An indexer client\n * @returns The result of the look-up\n */\nexport async function lookupAccountByAddress(accountAddress: string | Address, indexer: Indexer) {\n return await indexer.lookupAccountByID(accountAddress).do()\n}\n\n/**\n * Looks up applications that were created by the given address; will automatically paginate through all data.\n * @param indexer An indexer instance\n * @param address The address of the creator to look up\n * @param getAll Whether or not to include deleted applications\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The list of application results\n */\nexport async function lookupAccountCreatedApplicationByAddress(\n indexer: Indexer,\n address: string | Address,\n getAll: boolean | undefined = undefined,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.Application[]> {\n return await executePaginatedRequest(\n (response: algosdk.indexerModels.ApplicationsResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n return response.applications\n },\n (nextToken) => {\n let s = indexer\n .lookupAccountCreatedApplications(address)\n .includeAll(getAll)\n .limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n}\n\n/**\n * Looks up asset holdings for the given asset; will automatically paginate through all data.\n * @param indexer An indexer instance\n * @param assetId The ID of the asset to look up holdings for\n * @param options Optional options to control the lookup\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The list of application results\n */\nexport async function lookupAssetHoldings(\n indexer: Indexer,\n assetId: number | bigint,\n options?: LookupAssetHoldingsOptions,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.MiniAssetHolding[]> {\n return await executePaginatedRequest(\n (response: algosdk.indexerModels.AssetBalancesResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n return response.balances\n },\n (nextToken) => {\n let s = indexer.lookupAssetBalances(Number(assetId)).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (options?.currencyGreaterThan !== undefined) {\n s = s.currencyGreaterThan(options.currencyGreaterThan)\n }\n if (options?.currencyLessThan !== undefined) {\n s = s.currencyLessThan(options.currencyLessThan)\n }\n if (options?.includeAll !== undefined) {\n s = s.includeAll(options.includeAll)\n }\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n}\n\n/**\n * Allows transactions to be searched for the given criteria.\n * @param indexer An indexer client\n * @param searchCriteria The criteria to search for\n * @param paginationLimit The number of records to return per paginated request, default 1000\n * @returns The search results\n */\nexport async function searchTransactions(\n indexer: Indexer,\n searchCriteria: (s: SearchForTransactions) => SearchForTransactions,\n paginationLimit?: number,\n): Promise<algosdk.indexerModels.TransactionsResponse> {\n let currentRound = 0n\n const transactions = await executePaginatedRequest(\n (response: algosdk.indexerModels.TransactionsResponse | { message: string }) => {\n if ('message' in response) {\n throw { status: 404, ...response }\n }\n if (response.currentRound > currentRound) {\n currentRound = response.currentRound\n }\n return response.transactions\n },\n (nextToken) => {\n let s = searchCriteria(indexer.searchForTransactions()).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT)\n if (nextToken) {\n s = s.nextToken(nextToken)\n }\n return s\n },\n )\n\n return new algosdk.indexerModels.TransactionsResponse({\n currentRound,\n nextToken: undefined,\n transactions: transactions,\n })\n}\n\n// https://dev.algorand.co/reference/rest-api/indexer\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function executePaginatedRequest<TResult, TRequest extends { do: () => Promise<any> }>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n extractItems: (response: any) => TResult[],\n buildRequest: (nextToken?: string) => TRequest,\n): Promise<TResult[]> {\n const results = []\n\n let nextToken: string | undefined = undefined\n while (true) {\n const request = buildRequest(nextToken)\n const response = await request.do()\n const items = extractItems(response)\n if (items == null || items.length === 0) {\n break\n }\n results.push(...items)\n nextToken = response['nextToken']\n if (!nextToken) {\n break\n }\n }\n\n return results\n}\n"],"mappings":";;;;;;;;;;;AAKA,MAAM,gDAAgD;;;;;;;;AAStD,eAAsB,sBAAsB,eAAuB,SAAkB;CACnF,OAAO,MAAM,QAAQ,sBAAsB,aAAa,CAAC,CAAC,GAAG;AAC/D;;;;;;;;AASA,eAAsB,uBAAuB,gBAAkC,SAAkB;CAC/F,OAAO,MAAM,QAAQ,kBAAkB,cAAc,CAAC,CAAC,GAAG;AAC5D;;;;;;;;;AAUA,eAAsB,yCACpB,SACA,SACA,SAA8B,KAAA,GAC9B,iBAC8C;CAC9C,OAAO,MAAM,yBACV,aAA+E;EAC9E,IAAI,aAAa,UACf,MAAM;GAAE,QAAQ;GAAK,GAAG;EAAS;EAEnC,OAAO,SAAS;CAClB,IACC,cAAc;EACb,IAAI,IAAI,QACL,iCAAiC,OAAO,CAAC,CACzC,WAAW,MAAM,CAAC,CAClB,MAAM,mBAAmB,6CAA6C;EACzE,IAAI,WACF,IAAI,EAAE,UAAU,SAAS;EAE3B,OAAO;CACT,CACF;AACF;;;;;;;;;AAUA,eAAsB,oBACpB,SACA,SACA,SACA,iBACmD;CACnD,OAAO,MAAM,yBACV,aAAgF;EAC/E,IAAI,aAAa,UACf,MAAM;GAAE,QAAQ;GAAK,GAAG;EAAS;EAEnC,OAAO,SAAS;CAClB,IACC,cAAc;EACb,IAAI,IAAI,QAAQ,oBAAoB,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,mBAAmB,6CAA6C;EAC3H,IAAI,SAAS,wBAAwB,KAAA,GACnC,IAAI,EAAE,oBAAoB,QAAQ,mBAAmB;EAEvD,IAAI,SAAS,qBAAqB,KAAA,GAChC,IAAI,EAAE,iBAAiB,QAAQ,gBAAgB;EAEjD,IAAI,SAAS,eAAe,KAAA,GAC1B,IAAI,EAAE,WAAW,QAAQ,UAAU;EAErC,IAAI,WACF,IAAI,EAAE,UAAU,SAAS;EAE3B,OAAO;CACT,CACF;AACF;;;;;;;;AASA,eAAsB,mBACpB,SACA,gBACA,iBACqD;CACrD,IAAI,eAAe;CACnB,MAAM,eAAe,MAAM,yBACxB,aAA+E;EAC9E,IAAI,aAAa,UACf,MAAM;GAAE,QAAQ;GAAK,GAAG;EAAS;EAEnC,IAAI,SAAS,eAAe,cAC1B,eAAe,SAAS;EAE1B,OAAO,SAAS;CAClB,IACC,cAAc;EACb,IAAI,IAAI,eAAe,QAAQ,sBAAsB,CAAC,CAAC,CAAC,MAAM,mBAAmB,6CAA6C;EAC9H,IAAI,WACF,IAAI,EAAE,UAAU,SAAS;EAE3B,OAAO;CACT,CACF;CAEA,OAAO,IAAI,QAAQ,cAAc,qBAAqB;EACpD;EACA,WAAW,KAAA;EACG;CAChB,CAAC;AACH;AAIA,eAAsB,wBAEpB,cACA,cACoB;CACpB,MAAM,UAAU,CAAC;CAEjB,IAAI,YAAgC,KAAA;CACpC,OAAO,MAAM;EAEX,MAAM,WAAW,MADD,aAAa,SACA,CAAC,CAAC,GAAG;EAClC,MAAM,QAAQ,aAAa,QAAQ;EACnC,IAAI,SAAS,QAAQ,MAAM,WAAW,GACpC;EAEF,QAAQ,KAAK,GAAG,KAAK;EACrB,YAAY,SAAS;EACrB,IAAI,CAAC,WACH;CAEJ;CAEA,OAAO;AACT"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import algosdk from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import Kmd = algosdk.Kmd;
|
|
1
|
+
import algosdk from "algosdk";
|
|
2
|
+
|
|
3
|
+
//#region src/localnet/get-kmd-wallet-account.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* @deprecated use `algorand.account.kmd.getWalletAccount(name, predicate)` or `new KMDAccountManager(clientManager).getWalletAccount(name, predicate)` instead.
|
|
7
6
|
*
|
|
@@ -21,7 +20,10 @@ import Kmd = algosdk.Kmd;
|
|
|
21
20
|
* )
|
|
22
21
|
* ```
|
|
23
22
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
declare function getKmdWalletAccount(walletAccount: {
|
|
24
|
+
name: string;
|
|
25
|
+
predicate?: (account: Record<string, any>) => boolean;
|
|
27
26
|
}, algod: Algodv2, kmdClient?: Kmd): Promise<Account | undefined>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { getKmdWalletAccount };
|
|
29
|
+
//# sourceMappingURL=get-kmd-wallet-account.d.ts.map
|