@algorandfoundation/algokit-utils 6.3.0-beta.1 → 7.0.0-alpha.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/LICENSE +21 -0
- package/README.md +22 -26
- package/account/account.d.ts +12 -10
- package/account/account.js +17 -14
- package/account/account.js.map +1 -1
- package/account/account.mjs +18 -15
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.d.ts +0 -1
- package/account/get-account-config-from-environment.js.map +1 -1
- package/account/get-account-config-from-environment.mjs.map +1 -1
- package/account/get-account.d.ts +2 -3
- package/account/get-account.js +1 -1
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs +1 -1
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +2 -3
- package/account/get-dispenser-account.js +1 -1
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs +1 -1
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/index.d.ts +0 -1
- package/account/mnemonic-account.d.ts +1 -2
- package/account/mnemonic-account.js +1 -1
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs +1 -1
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.d.ts +15 -5
- package/amount.js +9 -2
- package/amount.js.map +1 -1
- package/amount.mjs +9 -3
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +19 -5
- package/app-client.js +19 -4
- package/app-client.js.map +1 -1
- package/app-client.mjs +19 -4
- package/app-client.mjs.map +1 -1
- package/app-deploy.d.ts +18 -2
- package/app-deploy.js +159 -342
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +163 -346
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +39 -3
- package/app.js +121 -371
- package/app.js.map +1 -1
- package/app.mjs +122 -372
- package/app.mjs.map +1 -1
- package/asset.d.ts +5 -6
- package/asset.js +5 -8
- package/asset.js.map +1 -1
- package/asset.mjs +5 -8
- package/asset.mjs.map +1 -1
- package/config.d.ts +0 -1
- package/config.js.map +1 -1
- package/config.mjs.map +1 -1
- package/debugging/debugging.d.ts +3 -5
- package/debugging/debugging.js +4 -128
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs +4 -109
- package/debugging/debugging.mjs.map +1 -1
- package/debugging/index.d.ts +0 -2
- package/dispenser-client.d.ts +0 -1
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +5 -4
- package/index.js +36 -26
- package/index.js.map +1 -1
- package/index.mjs +6 -5
- package/index.mjs.map +1 -1
- package/indexer-lookup.d.ts +10 -9
- package/indexer-lookup.js +14 -10
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs +14 -10
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.d.ts +1 -2
- package/localnet/get-kmd-wallet-account.js +1 -1
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs +1 -1
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +1 -2
- package/localnet/get-localnet-dispenser-account.js +1 -1
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs +1 -1
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +1 -2
- package/localnet/get-or-create-kmd-wallet-account.js +1 -1
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/index.d.ts +0 -1
- package/localnet/is-localnet.d.ts +1 -2
- package/localnet/is-localnet.js +1 -1
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs +1 -1
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +3 -10
- package/network-client.js +4 -11
- package/network-client.js.map +1 -1
- package/network-client.mjs +4 -11
- package/network-client.mjs.map +1 -1
- package/package.json +3 -4
- package/testing/_asset.d.ts +2 -2
- package/testing/account.d.ts +4 -4
- package/testing/account.js +8 -2
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +9 -3
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +0 -1
- package/testing/fixtures/algorand-fixture.js +13 -14
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +13 -14
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/fixtures/index.d.ts +0 -1
- package/testing/index.d.ts +0 -1
- package/testing/indexer.d.ts +0 -1
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.d.ts +0 -1
- package/testing/test-logger.js +7 -3
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs +7 -3
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.d.ts +0 -1
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/index.d.ts +0 -1
- package/transaction/legacy-bridge.d.ts +31 -6
- package/transaction/legacy-bridge.js +101 -7
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +101 -10
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +4 -2
- package/transaction/perform-atomic-transaction-composer-simulate.js +14 -9
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +15 -10
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +38 -19
- package/transaction/transaction.js +217 -137
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +218 -138
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/index.d.ts +0 -1
- package/transfer/transfer-algos.d.ts +1 -2
- package/transfer/transfer-algos.js +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +1 -2
- package/transfer/transfer.js +6 -4
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +6 -4
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +33 -25
- package/types/account-manager.js +54 -31
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +56 -33
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +17 -9
- package/types/account.js +2 -2
- package/types/account.js.map +1 -1
- package/types/account.mjs +3 -3
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +1 -3
- package/types/algo-http-client-with-retry.js +33 -3
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs +32 -2
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +28 -0
- package/types/algorand-client-interface.js +3 -0
- package/types/algorand-client-interface.js.map +1 -0
- package/types/algorand-client-interface.mjs +2 -0
- package/types/algorand-client-interface.mjs.map +1 -0
- package/types/algorand-client-transaction-creator.d.ts +452 -23
- package/types/algorand-client-transaction-creator.js +407 -23
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +407 -23
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +772 -47
- package/types/algorand-client-transaction-sender.js +445 -15
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +445 -15
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +24 -17
- package/types/algorand-client.js +26 -16
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +28 -15
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +10 -11
- package/types/amount.js +7 -7
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +7 -7
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +359 -0
- package/types/app-arc56.js +184 -0
- package/types/app-arc56.js.map +1 -0
- package/types/app-arc56.mjs +175 -0
- package/types/app-arc56.mjs.map +1 -0
- package/types/app-client.d.ts +1508 -12
- package/types/app-client.js +1018 -29
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +1020 -32
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +126 -0
- package/types/app-deployer.js +353 -0
- package/types/app-deployer.js.map +1 -0
- package/types/app-deployer.mjs +351 -0
- package/types/app-deployer.mjs.map +1 -0
- package/types/app-factory.d.ts +846 -0
- package/types/app-factory.js +410 -0
- package/types/app-factory.js.map +1 -0
- package/types/app-factory.mjs +408 -0
- package/types/app-factory.mjs.map +1 -0
- package/types/app-manager.d.ts +244 -0
- package/types/app-manager.js +423 -0
- package/types/app-manager.js.map +1 -0
- package/types/app-manager.mjs +421 -0
- package/types/app-manager.mjs.map +1 -0
- package/types/app-spec.d.ts +2 -1
- package/types/app-spec.js +127 -0
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +126 -0
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +57 -18
- package/types/app.js +1 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +10 -10
- package/types/asset-manager.js +13 -17
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +13 -17
- package/types/asset-manager.mjs.map +1 -1
- package/types/asset.d.ts +0 -1
- package/types/async-event-emitter.d.ts +14 -0
- package/types/async-event-emitter.js +50 -0
- package/types/async-event-emitter.js.map +1 -0
- package/types/async-event-emitter.mjs +48 -0
- package/types/async-event-emitter.mjs.map +1 -0
- package/types/client-manager.d.ts +135 -60
- package/types/client-manager.js +158 -44
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +159 -45
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +271 -87
- package/types/composer.js +405 -125
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +407 -125
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +3 -6
- package/types/config.js +5 -44
- package/types/config.js.map +1 -1
- package/types/config.mjs +5 -27
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +29 -101
- package/types/debugging.js +16 -109
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -107
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +2 -2
- package/types/dispenser-client.js +10 -5
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +10 -5
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +7 -0
- package/types/expand.js +3 -0
- package/types/expand.js.map +1 -0
- package/types/expand.mjs +2 -0
- package/types/expand.mjs.map +1 -0
- package/types/indexer.d.ts +74 -756
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +2 -3
- package/types/kmd-account-manager.js +3 -3
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +4 -4
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +10 -0
- package/types/lifecycle-events.js +8 -0
- package/types/lifecycle-events.js.map +1 -0
- package/types/lifecycle-events.mjs +8 -0
- package/types/lifecycle-events.mjs.map +1 -0
- package/types/logging.d.ts +0 -1
- package/types/logging.js.map +1 -1
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +2 -4
- package/types/logic-error.js +3 -3
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +3 -3
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +14 -2
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +8 -10
- package/types/transaction.d.ts +17 -4
- package/types/transfer.d.ts +0 -1
- package/util.d.ts +2 -2
- package/util.js +11 -10
- package/util.js.map +1 -1
- package/util.mjs +11 -10
- package/util.mjs.map +1 -1
- package/account/account.d.ts.map +0 -1
- package/account/get-account-config-from-environment.d.ts.map +0 -1
- package/account/get-account.d.ts.map +0 -1
- package/account/get-dispenser-account.d.ts.map +0 -1
- package/account/index.d.ts.map +0 -1
- package/account/mnemonic-account.d.ts.map +0 -1
- package/amount.d.ts.map +0 -1
- package/app-client.d.ts.map +0 -1
- package/app-deploy.d.ts.map +0 -1
- package/app.d.ts.map +0 -1
- package/asset.d.ts.map +0 -1
- package/config.d.ts.map +0 -1
- package/debugging/debugging.d.ts.map +0 -1
- package/debugging/index.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.d.ts +0 -20
- package/debugging/simulate-and-persist-response.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.js +0 -108
- package/debugging/simulate-and-persist-response.js.map +0 -1
- package/debugging/simulate-and-persist-response.mjs +0 -89
- package/debugging/simulate-and-persist-response.mjs.map +0 -1
- package/dispenser-client.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
- package/indexer-lookup.d.ts.map +0 -1
- package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/index.d.ts.map +0 -1
- package/localnet/is-localnet.d.ts.map +0 -1
- package/network-client.d.ts.map +0 -1
- package/testing/_asset.d.ts.map +0 -1
- package/testing/account.d.ts.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/testing/fixtures/index.d.ts.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/indexer.d.ts.map +0 -1
- package/testing/test-logger.d.ts.map +0 -1
- package/testing/transaction-logger.d.ts.map +0 -1
- package/transaction/index.d.ts.map +0 -1
- package/transaction/legacy-bridge.d.ts.map +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
- package/transaction/transaction.d.ts.map +0 -1
- package/transfer/index.d.ts.map +0 -1
- package/transfer/transfer-algos.d.ts.map +0 -1
- package/transfer/transfer.d.ts.map +0 -1
- package/types/account-manager.d.ts.map +0 -1
- package/types/account.d.ts.map +0 -1
- package/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/types/algorand-client-transaction-creator.d.ts.map +0 -1
- package/types/algorand-client-transaction-sender.d.ts.map +0 -1
- package/types/algorand-client.d.ts.map +0 -1
- package/types/amount.d.ts.map +0 -1
- package/types/app-client.d.ts.map +0 -1
- package/types/app-spec.d.ts.map +0 -1
- package/types/app.d.ts.map +0 -1
- package/types/asset-manager.d.ts.map +0 -1
- package/types/asset.d.ts.map +0 -1
- package/types/client-manager.d.ts.map +0 -1
- package/types/composer.d.ts.map +0 -1
- package/types/config.d.ts.map +0 -1
- package/types/debugging.d.ts.map +0 -1
- package/types/dispenser-client.d.ts.map +0 -1
- package/types/indexer.d.ts.map +0 -1
- package/types/kmd-account-manager.d.ts.map +0 -1
- package/types/logging.d.ts.map +0 -1
- package/types/logic-error.d.ts.map +0 -1
- package/types/network-client.d.ts.map +0 -1
- package/types/testing.d.ts.map +0 -1
- package/types/transaction.d.ts.map +0 -1
- package/types/transfer.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts +0 -41
- package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.js +0 -153
- package/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/types/urlTokenBaseHTTPClient.mjs +0 -151
- package/types/urlTokenBaseHTTPClient.mjs.map +0 -1
- package/util.d.ts.map +0 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import algosdk from 'algosdk';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AlgorandClientInterface } from './algorand-client-interface';
|
|
3
|
+
import { AppClient, AppClientParams, ResolveAppClientByCreatorAndName } from './app-client';
|
|
4
|
+
import { AppFactory, AppFactoryParams } from './app-factory';
|
|
4
5
|
import { TestNetDispenserApiClient, TestNetDispenserApiClientParams } from './dispenser-client';
|
|
5
|
-
import {
|
|
6
|
+
import { Expand } from './expand';
|
|
7
|
+
import { AlgoClientConfig, AlgoConfig, NetworkDetails } from './network-client';
|
|
6
8
|
import Kmd = algosdk.Kmd;
|
|
7
9
|
import Indexer = algosdk.Indexer;
|
|
8
10
|
import Algodv2 = algosdk.Algodv2;
|
|
9
|
-
import IntDecoding = algosdk.IntDecoding;
|
|
10
11
|
/** Clients from algosdk that interact with the official Algorand APIs */
|
|
11
12
|
export interface AlgoSdkClients {
|
|
12
13
|
/** Algod client, see https://developer.algorand.org/docs/rest-apis/algod/ */
|
|
@@ -16,24 +17,28 @@ export interface AlgoSdkClients {
|
|
|
16
17
|
/** Optional KMD client, see https://developer.algorand.org/docs/rest-apis/kmd/ */
|
|
17
18
|
kmd?: algosdk.Kmd;
|
|
18
19
|
}
|
|
19
|
-
/**
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
/** Params to get an app factory from `ClientManager`. */
|
|
21
|
+
export type ClientAppFactoryParams = Expand<Omit<AppFactoryParams, 'algorand'>>;
|
|
22
|
+
/** Params to get an app client by creator address and name from `ClientManager`. */
|
|
23
|
+
export type ClientResolveAppClientByCreatorAndNameParams = Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand'>>;
|
|
24
|
+
/** Params to get an app client by ID from `ClientManager`. */
|
|
25
|
+
export type ClientAppClientParams = Expand<Omit<AppClientParams, 'algorand'>>;
|
|
26
|
+
/** Params to get an app client by network from `ClientManager`. */
|
|
27
|
+
export type ClientAppClientByNetworkParams = Expand<Omit<AppClientParams, 'algorand' | 'appId'>>;
|
|
28
|
+
/** Params to get a typed app client by creator address and name from `ClientManager`. */
|
|
29
|
+
export type ClientTypedAppClientByCreatorAndNameParams = Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand' | 'appSpec'>>;
|
|
30
|
+
/** Params to get a typed app client by ID from `ClientManager`. */
|
|
31
|
+
export type ClientTypedAppClientParams = Expand<Omit<AppClientParams, 'algorand' | 'appSpec'>>;
|
|
32
|
+
/** Params to get a typed app client by network from `ClientManager`. */
|
|
33
|
+
export type ClientTypedAppClientByNetworkParams = Expand<Omit<AppClientParams, 'algorand' | 'appSpec' | 'appId'>>;
|
|
34
|
+
/** Params to get a typed app factory from `ClientManager`. */
|
|
35
|
+
export type ClientTypedAppFactoryParams = Expand<Omit<AppFactoryParams, 'algorand' | 'appSpec'>>;
|
|
32
36
|
/** Exposes access to various API clients. */
|
|
33
37
|
export declare class ClientManager {
|
|
34
38
|
private _algod;
|
|
35
39
|
private _indexer?;
|
|
36
40
|
private _kmd?;
|
|
41
|
+
private _algorand?;
|
|
37
42
|
/**
|
|
38
43
|
* algosdk clients or config for interacting with the official Algorand APIs.
|
|
39
44
|
* @param clientsOrConfig The clients or config to use
|
|
@@ -54,11 +59,13 @@ export declare class ClientManager {
|
|
|
54
59
|
* const clientManager = new ClientManager({ algodConfig, indexerConfig, kmdConfig })
|
|
55
60
|
* ```
|
|
56
61
|
*/
|
|
57
|
-
constructor(clientsOrConfig: AlgoConfig | AlgoSdkClients);
|
|
62
|
+
constructor(clientsOrConfig: AlgoConfig | AlgoSdkClients, algorandClient?: AlgorandClientInterface);
|
|
58
63
|
/** Returns an algosdk Algod API client. */
|
|
59
64
|
get algod(): algosdk.Algodv2;
|
|
60
65
|
/** Returns an algosdk Indexer API client or throws an error if it's not been provided. */
|
|
61
66
|
get indexer(): algosdk.Indexer;
|
|
67
|
+
/** Returns an algosdk Indexer API client or `undefined` if it's not been provided. */
|
|
68
|
+
get indexerIfPresent(): algosdk.Indexer | undefined;
|
|
62
69
|
/** Returns an algosdk KMD API client or throws an error if it's not been provided. */
|
|
63
70
|
get kmd(): algosdk.Kmd;
|
|
64
71
|
private _getNetworkPromise;
|
|
@@ -127,28 +134,82 @@ export declare class ClientManager {
|
|
|
127
134
|
*/
|
|
128
135
|
getTestNetDispenserFromEnvironment(params?: Omit<TestNetDispenserApiClientParams, 'authToken'>): TestNetDispenserApiClient;
|
|
129
136
|
/**
|
|
130
|
-
* Returns a new `
|
|
131
|
-
* @
|
|
132
|
-
*
|
|
133
|
-
*
|
|
137
|
+
* Returns a new `AppFactory` client
|
|
138
|
+
* @example Basic example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const factory = algorand.client.getAppFactory({
|
|
141
|
+
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\/}',
|
|
142
|
+
* })
|
|
143
|
+
* ```
|
|
144
|
+
* @example Advanced example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const factory = algorand.client.getAppFactory({
|
|
147
|
+
* appSpec: parsedAppSpec_AppSpec_or_Arc56Contract,
|
|
148
|
+
* defaultSender: "SENDERADDRESS",
|
|
149
|
+
* appName: "OverriddenAppName",
|
|
150
|
+
* version: "2.0.0",
|
|
151
|
+
* updatable: true,
|
|
152
|
+
* deletable: false,
|
|
153
|
+
* deployTimeParams: { ONE: 1, TWO: 'value' }
|
|
154
|
+
* })
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
getAppFactory(params: ClientAppFactoryParams): AppFactory;
|
|
158
|
+
/**
|
|
159
|
+
* Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
|
|
160
|
+
* This method resolves the app ID by looking up the creator address and name
|
|
161
|
+
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
|
|
162
|
+
* @param params The parameters to create the app client
|
|
163
|
+
* @example Basic
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const appClient = algorand.client.getAppClientByCreatorAndName({
|
|
166
|
+
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
167
|
+
* // appId resolved by looking for app ID of named app by this creator
|
|
168
|
+
* creatorAddress: 'CREATORADDRESS',
|
|
169
|
+
* })
|
|
170
|
+
* ```
|
|
171
|
+
* @returns The `AppClient`
|
|
172
|
+
*/
|
|
173
|
+
getAppClientByCreatorAndName(params: ClientResolveAppClientByCreatorAndNameParams): Promise<AppClient>;
|
|
174
|
+
/**
|
|
175
|
+
* Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
|
|
176
|
+
* @param params The parameters to create the app client
|
|
177
|
+
* @example Basic
|
|
178
|
+
* ```typescript
|
|
179
|
+
* const appClient = algorand.client.getAppClientById({
|
|
180
|
+
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
181
|
+
* appId: 12345n,
|
|
182
|
+
* })
|
|
183
|
+
* ```
|
|
184
|
+
* @returns The `AppClient`
|
|
134
185
|
*/
|
|
135
|
-
|
|
186
|
+
getAppClientById(params: ClientAppClientParams): AppClient;
|
|
136
187
|
/**
|
|
137
|
-
* Returns a new `
|
|
138
|
-
*
|
|
139
|
-
*
|
|
188
|
+
* Returns a new `AppClient` client for managing calls and state for an ARC-56 app.
|
|
189
|
+
* This method resolves the app ID for the current network based on
|
|
190
|
+
* pre-determined network-specific app IDs specified in the ARC-56 app spec.
|
|
191
|
+
*
|
|
192
|
+
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
|
|
193
|
+
* @param params The parameters to create the app client
|
|
194
|
+
* @example Basic
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const appClient = algorand.client.getAppClientByNetwork({
|
|
197
|
+
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
198
|
+
* // appId resolved by using ARC-56 spec to find app ID for current network
|
|
199
|
+
* })
|
|
200
|
+
* ```
|
|
201
|
+
* @returns The `AppClient`
|
|
140
202
|
*/
|
|
141
|
-
|
|
203
|
+
getAppClientByNetwork(params: ClientAppClientByNetworkParams): Promise<AppClient>;
|
|
142
204
|
/**
|
|
143
205
|
* Returns a new typed client, resolving the app by creator address and name.
|
|
144
206
|
* @param typedClient The typed client type to use
|
|
145
|
-
* @param
|
|
146
|
-
* @
|
|
147
|
-
* @example Use name in ARC-32 app spec
|
|
207
|
+
* @param params The params to resolve the app by creator address and name
|
|
208
|
+
* @example Use name in ARC-32 / ARC-56 app spec
|
|
148
209
|
* ```typescript
|
|
149
210
|
* const appClient = algorand.client.getTypedAppClientByCreatorAndName(MyContractClient, {
|
|
150
211
|
* creatorAddress: "CREATORADDRESS",
|
|
151
|
-
*
|
|
212
|
+
* defaultSender: alice,
|
|
152
213
|
* })
|
|
153
214
|
* ```
|
|
154
215
|
* @example Specify name
|
|
@@ -156,26 +217,55 @@ export declare class ClientManager {
|
|
|
156
217
|
* const appClient = algorand.client.getTypedAppClientByCreatorAndName(MyContractClient, {
|
|
157
218
|
* creatorAddress: "CREATORADDRESS",
|
|
158
219
|
* name: "contract-name",
|
|
159
|
-
*
|
|
220
|
+
* defaultSender: alice,
|
|
160
221
|
* })
|
|
161
222
|
* ```
|
|
162
223
|
* @returns The typed client instance
|
|
163
224
|
*/
|
|
164
|
-
getTypedAppClientByCreatorAndName<TClient
|
|
225
|
+
getTypedAppClientByCreatorAndName<TClient extends TypedAppClient<InstanceType<TClient>>>(typedClient: TClient, params: ClientTypedAppClientByCreatorAndNameParams): Promise<InstanceType<TClient>>;
|
|
165
226
|
/**
|
|
166
227
|
* Returns a new typed client, resolving the app by app ID.
|
|
167
228
|
* @param typedClient The typed client type to use
|
|
168
|
-
* @param
|
|
229
|
+
* @param params The params to resolve the app by ID
|
|
169
230
|
* @example
|
|
170
231
|
* ```typescript
|
|
171
232
|
* const appClient = algorand.client.getTypedAppClientById(MyContractClient, {
|
|
172
|
-
*
|
|
233
|
+
* appId: 12345n,
|
|
234
|
+
* defaultSender: alice,
|
|
235
|
+
* })
|
|
236
|
+
* ```
|
|
237
|
+
* @returns The typed client instance
|
|
238
|
+
*/
|
|
239
|
+
getTypedAppClientById<TClient extends TypedAppClient<InstanceType<TClient>>>(typedClient: TClient, params: ClientTypedAppClientParams): InstanceType<TClient>;
|
|
240
|
+
/**
|
|
241
|
+
* Returns a new typed client, resolves the app ID for the current network based on
|
|
242
|
+
* pre-determined network-specific app IDs specified in the ARC-56 app spec.
|
|
243
|
+
*
|
|
244
|
+
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
|
|
245
|
+
* @param typedClient The typed client type to use
|
|
246
|
+
* @param params The params to resolve the app by network
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* const appClient = algorand.client.getTypedAppClientByNetwork(MyContractClient, {
|
|
250
|
+
* defaultSender: alice,
|
|
251
|
+
* })
|
|
252
|
+
* ```
|
|
253
|
+
* @returns The typed client instance
|
|
254
|
+
*/
|
|
255
|
+
getTypedAppClientByNetwork<TClient extends TypedAppClient<InstanceType<TClient>>>(typedClient: TClient, params?: ClientTypedAppClientByNetworkParams): Promise<InstanceType<TClient>>;
|
|
256
|
+
/**
|
|
257
|
+
* Returns a new typed app factory.
|
|
258
|
+
* @param typedFactory The typed factory type to use
|
|
259
|
+
* @param params The params to resolve the factory by
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* const appFactory = algorand.client.getTypedAppFactory(MyContractClient, {
|
|
173
263
|
* sender: alice,
|
|
174
264
|
* })
|
|
175
265
|
* ```
|
|
176
266
|
* @returns The typed client instance
|
|
177
267
|
*/
|
|
178
|
-
|
|
268
|
+
getTypedAppFactory<TClient>(typedFactory: TypedAppFactory<TClient>, params?: ClientTypedAppFactoryParams): TClient;
|
|
179
269
|
/**
|
|
180
270
|
* Retrieve client configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment)
|
|
181
271
|
*
|
|
@@ -252,7 +342,6 @@ export declare class ClientManager {
|
|
|
252
342
|
* Returns an indexer SDK client that automatically retries on idempotent calls
|
|
253
343
|
*
|
|
254
344
|
* @param config The config of the client
|
|
255
|
-
* @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers
|
|
256
345
|
* @example AlgoNode (testnet)
|
|
257
346
|
* ```typescript
|
|
258
347
|
* const indexer = ClientManager.getIndexerClient(ClientManager.getAlgoNodeConfig('testnet', 'indexer'))
|
|
@@ -268,16 +357,11 @@ export declare class ClientManager {
|
|
|
268
357
|
* const indexer = ClientManager.getIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
269
358
|
* await indexer.makeHealthCheck().do()
|
|
270
359
|
* ```
|
|
271
|
-
* @example Override int decoding for responses
|
|
272
|
-
* ```typescript
|
|
273
|
-
* const indexer = ClientManager.getIndexerClient(config, IntDecoding.BIGINT)
|
|
274
|
-
* ```
|
|
275
360
|
*/
|
|
276
|
-
static getIndexerClient(config: AlgoClientConfig
|
|
361
|
+
static getIndexerClient(config: AlgoClientConfig): Indexer;
|
|
277
362
|
/**
|
|
278
363
|
* Returns an indexer SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).
|
|
279
364
|
*
|
|
280
|
-
* @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers
|
|
281
365
|
* @example
|
|
282
366
|
*
|
|
283
367
|
* ```typescript
|
|
@@ -286,7 +370,7 @@ export declare class ClientManager {
|
|
|
286
370
|
* await indexer.makeHealthCheck().do()
|
|
287
371
|
* ```
|
|
288
372
|
*/
|
|
289
|
-
static getIndexerClientFromEnvironment(
|
|
373
|
+
static getIndexerClientFromEnvironment(): Indexer;
|
|
290
374
|
/**
|
|
291
375
|
* Returns a KMD SDK client.
|
|
292
376
|
*
|
|
@@ -314,22 +398,13 @@ export declare class ClientManager {
|
|
|
314
398
|
* Interface to identify a typed client that can be used to interact with an application.
|
|
315
399
|
*/
|
|
316
400
|
export interface TypedAppClient<TClient> {
|
|
317
|
-
new (
|
|
401
|
+
new (params: Omit<AppClientParams, 'appSpec'>): TClient;
|
|
402
|
+
fromNetwork(params: Omit<AppClientParams, 'appId' | 'appSpec'>): Promise<TClient>;
|
|
403
|
+
fromCreatorAndName(params: Omit<ResolveAppClientByCreatorAndName, 'appSpec'>): Promise<TClient>;
|
|
318
404
|
}
|
|
319
405
|
/**
|
|
320
|
-
*
|
|
321
|
-
*/
|
|
322
|
-
export type AppClientByCreatorAndNameDetails = AppSpecAppDetailsBase & AppDetailsBase & Omit<ResolveAppByCreatorAndNameBase, 'findExistingUsing'>;
|
|
323
|
-
/**
|
|
324
|
-
* Details to resolve a typed app creator address and name.
|
|
325
|
-
*/
|
|
326
|
-
export type TypedAppClientByCreatorAndNameDetails = AppDetailsBase & Omit<ResolveAppByCreatorAndNameBase, 'findExistingUsing'>;
|
|
327
|
-
/**
|
|
328
|
-
* Details to resolve an app client by app ID.
|
|
406
|
+
* Interface to identify a typed factory that can be used to create and deploy an application.
|
|
329
407
|
*/
|
|
330
|
-
export
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
*/
|
|
334
|
-
export type TypedAppClientByIdDetails = AppDetailsBase & ResolveAppByIdBase;
|
|
335
|
-
//# sourceMappingURL=client-manager.d.ts.map
|
|
408
|
+
export interface TypedAppFactory<TClient> {
|
|
409
|
+
new (params: Omit<AppFactoryParams, 'appSpec'>): TClient;
|
|
410
|
+
}
|
package/types/client-manager.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
var algosdk = require('algosdk');
|
|
4
4
|
var types_algoHttpClientWithRetry = require('./algo-http-client-with-retry.js');
|
|
5
5
|
var types_appClient = require('./app-client.js');
|
|
6
|
+
var types_appFactory = require('./app-factory.js');
|
|
6
7
|
var types_dispenserClient = require('./dispenser-client.js');
|
|
7
8
|
var types_networkClient = require('./network-client.js');
|
|
8
9
|
|
|
9
10
|
var Kmd = algosdk.Kmd;
|
|
10
11
|
var Indexer = algosdk.Indexer;
|
|
11
|
-
var IntDecoding = algosdk.IntDecoding;
|
|
12
12
|
/** Exposes access to various API clients. */
|
|
13
13
|
class ClientManager {
|
|
14
14
|
/**
|
|
@@ -31,7 +31,7 @@ class ClientManager {
|
|
|
31
31
|
* const clientManager = new ClientManager({ algodConfig, indexerConfig, kmdConfig })
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
constructor(clientsOrConfig) {
|
|
34
|
+
constructor(clientsOrConfig, algorandClient) {
|
|
35
35
|
const _clients = 'algod' in clientsOrConfig
|
|
36
36
|
? clientsOrConfig
|
|
37
37
|
: {
|
|
@@ -42,6 +42,7 @@ class ClientManager {
|
|
|
42
42
|
this._algod = _clients.algod;
|
|
43
43
|
this._indexer = _clients.indexer;
|
|
44
44
|
this._kmd = _clients.kmd;
|
|
45
|
+
this._algorand = algorandClient;
|
|
45
46
|
}
|
|
46
47
|
/** Returns an algosdk Algod API client. */
|
|
47
48
|
get algod() {
|
|
@@ -53,6 +54,10 @@ class ClientManager {
|
|
|
53
54
|
throw new Error('Attempt to use Indexer client in AlgoKit instance with no Indexer configured');
|
|
54
55
|
return this._indexer;
|
|
55
56
|
}
|
|
57
|
+
/** Returns an algosdk Indexer API client or `undefined` if it's not been provided. */
|
|
58
|
+
get indexerIfPresent() {
|
|
59
|
+
return this._indexer;
|
|
60
|
+
}
|
|
56
61
|
/** Returns an algosdk KMD API client or throws an error if it's not been provided. */
|
|
57
62
|
get kmd() {
|
|
58
63
|
if (!this._kmd)
|
|
@@ -74,11 +79,11 @@ class ClientManager {
|
|
|
74
79
|
}
|
|
75
80
|
const params = await this._getNetworkPromise;
|
|
76
81
|
return {
|
|
77
|
-
isTestNet: ['testnet-v1.0', 'testnet-v1', 'testnet'].includes(params.genesisID),
|
|
78
|
-
isMainNet: ['mainnet-v1.0', 'mainnet-v1', 'mainnet'].includes(params.genesisID),
|
|
79
|
-
isLocalNet: ClientManager.genesisIdIsLocalNet(params.genesisID),
|
|
80
|
-
genesisId: params.genesisID,
|
|
81
|
-
genesisHash: params.genesisHash,
|
|
82
|
+
isTestNet: ['testnet-v1.0', 'testnet-v1', 'testnet'].includes(params.genesisID ?? 'unknown'),
|
|
83
|
+
isMainNet: ['mainnet-v1.0', 'mainnet-v1', 'mainnet'].includes(params.genesisID ?? 'unknown'),
|
|
84
|
+
isLocalNet: ClientManager.genesisIdIsLocalNet(params.genesisID ?? 'unknown'),
|
|
85
|
+
genesisId: params.genesisID ?? 'unknown',
|
|
86
|
+
genesisHash: params.genesisHash ? Buffer.from(params.genesisHash).toString('base64') : 'unknown',
|
|
82
87
|
};
|
|
83
88
|
}
|
|
84
89
|
/**
|
|
@@ -148,32 +153,105 @@ class ClientManager {
|
|
|
148
153
|
return new types_dispenserClient.TestNetDispenserApiClient(params ? { ...params, authToken: '' } : undefined);
|
|
149
154
|
}
|
|
150
155
|
/**
|
|
151
|
-
* Returns a new `
|
|
152
|
-
* @
|
|
153
|
-
*
|
|
154
|
-
*
|
|
156
|
+
* Returns a new `AppFactory` client
|
|
157
|
+
* @example Basic example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const factory = algorand.client.getAppFactory({
|
|
160
|
+
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\/}',
|
|
161
|
+
* })
|
|
162
|
+
* ```
|
|
163
|
+
* @example Advanced example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const factory = algorand.client.getAppFactory({
|
|
166
|
+
* appSpec: parsedAppSpec_AppSpec_or_Arc56Contract,
|
|
167
|
+
* defaultSender: "SENDERADDRESS",
|
|
168
|
+
* appName: "OverriddenAppName",
|
|
169
|
+
* version: "2.0.0",
|
|
170
|
+
* updatable: true,
|
|
171
|
+
* deletable: false,
|
|
172
|
+
* deployTimeParams: { ONE: 1, TWO: 'value' }
|
|
173
|
+
* })
|
|
174
|
+
* ```
|
|
155
175
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
176
|
+
getAppFactory(params) {
|
|
177
|
+
if (!this._algorand) {
|
|
178
|
+
throw new Error('Attempt to get app factory from a ClientManager without an Algorand client');
|
|
179
|
+
}
|
|
180
|
+
return new types_appFactory.AppFactory({ ...params, algorand: this._algorand });
|
|
158
181
|
}
|
|
159
182
|
/**
|
|
160
|
-
* Returns a new `
|
|
161
|
-
*
|
|
162
|
-
*
|
|
183
|
+
* Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
|
|
184
|
+
* This method resolves the app ID by looking up the creator address and name
|
|
185
|
+
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
|
|
186
|
+
* @param params The parameters to create the app client
|
|
187
|
+
* @example Basic
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const appClient = algorand.client.getAppClientByCreatorAndName({
|
|
190
|
+
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
191
|
+
* // appId resolved by looking for app ID of named app by this creator
|
|
192
|
+
* creatorAddress: 'CREATORADDRESS',
|
|
193
|
+
* })
|
|
194
|
+
* ```
|
|
195
|
+
* @returns The `AppClient`
|
|
196
|
+
*/
|
|
197
|
+
getAppClientByCreatorAndName(params) {
|
|
198
|
+
if (!this._algorand) {
|
|
199
|
+
throw new Error('Attempt to get app client from a ClientManager without an Algorand client');
|
|
200
|
+
}
|
|
201
|
+
return types_appClient.AppClient.fromCreatorAndName({
|
|
202
|
+
...params,
|
|
203
|
+
algorand: this._algorand,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
|
|
208
|
+
* @param params The parameters to create the app client
|
|
209
|
+
* @example Basic
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const appClient = algorand.client.getAppClientById({
|
|
212
|
+
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
213
|
+
* appId: 12345n,
|
|
214
|
+
* })
|
|
215
|
+
* ```
|
|
216
|
+
* @returns The `AppClient`
|
|
217
|
+
*/
|
|
218
|
+
getAppClientById(params) {
|
|
219
|
+
if (!this._algorand) {
|
|
220
|
+
throw new Error('Attempt to get app client from a ClientManager without an Algorand client');
|
|
221
|
+
}
|
|
222
|
+
return new types_appClient.AppClient({ ...params, algorand: this._algorand });
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Returns a new `AppClient` client for managing calls and state for an ARC-56 app.
|
|
226
|
+
* This method resolves the app ID for the current network based on
|
|
227
|
+
* pre-determined network-specific app IDs specified in the ARC-56 app spec.
|
|
228
|
+
*
|
|
229
|
+
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
|
|
230
|
+
* @param params The parameters to create the app client
|
|
231
|
+
* @example Basic
|
|
232
|
+
* ```typescript
|
|
233
|
+
* const appClient = algorand.client.getAppClientByNetwork({
|
|
234
|
+
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
235
|
+
* // appId resolved by using ARC-56 spec to find app ID for current network
|
|
236
|
+
* })
|
|
237
|
+
* ```
|
|
238
|
+
* @returns The `AppClient`
|
|
163
239
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
240
|
+
async getAppClientByNetwork(params) {
|
|
241
|
+
if (!this._algorand) {
|
|
242
|
+
throw new Error('Attempt to get app client from a ClientManager without an Algorand client');
|
|
243
|
+
}
|
|
244
|
+
return types_appClient.AppClient.fromNetwork({ ...params, algorand: this._algorand });
|
|
166
245
|
}
|
|
167
246
|
/**
|
|
168
247
|
* Returns a new typed client, resolving the app by creator address and name.
|
|
169
248
|
* @param typedClient The typed client type to use
|
|
170
|
-
* @param
|
|
171
|
-
* @
|
|
172
|
-
* @example Use name in ARC-32 app spec
|
|
249
|
+
* @param params The params to resolve the app by creator address and name
|
|
250
|
+
* @example Use name in ARC-32 / ARC-56 app spec
|
|
173
251
|
* ```typescript
|
|
174
252
|
* const appClient = algorand.client.getTypedAppClientByCreatorAndName(MyContractClient, {
|
|
175
253
|
* creatorAddress: "CREATORADDRESS",
|
|
176
|
-
*
|
|
254
|
+
* defaultSender: alice,
|
|
177
255
|
* })
|
|
178
256
|
* ```
|
|
179
257
|
* @example Specify name
|
|
@@ -181,29 +259,74 @@ class ClientManager {
|
|
|
181
259
|
* const appClient = algorand.client.getTypedAppClientByCreatorAndName(MyContractClient, {
|
|
182
260
|
* creatorAddress: "CREATORADDRESS",
|
|
183
261
|
* name: "contract-name",
|
|
184
|
-
*
|
|
262
|
+
* defaultSender: alice,
|
|
185
263
|
* })
|
|
186
264
|
* ```
|
|
187
265
|
* @returns The typed client instance
|
|
188
266
|
*/
|
|
189
|
-
getTypedAppClientByCreatorAndName(typedClient,
|
|
190
|
-
|
|
267
|
+
async getTypedAppClientByCreatorAndName(typedClient, params) {
|
|
268
|
+
if (!this._algorand) {
|
|
269
|
+
throw new Error('Attempt to get app client from a ClientManager without an Algorand client');
|
|
270
|
+
}
|
|
271
|
+
return typedClient.fromCreatorAndName({ ...params, algorand: this._algorand });
|
|
191
272
|
}
|
|
192
273
|
/**
|
|
193
274
|
* Returns a new typed client, resolving the app by app ID.
|
|
194
275
|
* @param typedClient The typed client type to use
|
|
195
|
-
* @param
|
|
276
|
+
* @param params The params to resolve the app by ID
|
|
196
277
|
* @example
|
|
197
278
|
* ```typescript
|
|
198
279
|
* const appClient = algorand.client.getTypedAppClientById(MyContractClient, {
|
|
199
|
-
*
|
|
280
|
+
* appId: 12345n,
|
|
281
|
+
* defaultSender: alice,
|
|
282
|
+
* })
|
|
283
|
+
* ```
|
|
284
|
+
* @returns The typed client instance
|
|
285
|
+
*/
|
|
286
|
+
getTypedAppClientById(typedClient, params) {
|
|
287
|
+
if (!this._algorand) {
|
|
288
|
+
throw new Error('Attempt to get app client from a ClientManager without an Algorand client');
|
|
289
|
+
}
|
|
290
|
+
return new typedClient({ ...params, algorand: this._algorand });
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Returns a new typed client, resolves the app ID for the current network based on
|
|
294
|
+
* pre-determined network-specific app IDs specified in the ARC-56 app spec.
|
|
295
|
+
*
|
|
296
|
+
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
|
|
297
|
+
* @param typedClient The typed client type to use
|
|
298
|
+
* @param params The params to resolve the app by network
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* const appClient = algorand.client.getTypedAppClientByNetwork(MyContractClient, {
|
|
302
|
+
* defaultSender: alice,
|
|
303
|
+
* })
|
|
304
|
+
* ```
|
|
305
|
+
* @returns The typed client instance
|
|
306
|
+
*/
|
|
307
|
+
getTypedAppClientByNetwork(typedClient, params) {
|
|
308
|
+
if (!this._algorand) {
|
|
309
|
+
throw new Error('Attempt to get app client from a ClientManager without an Algorand client');
|
|
310
|
+
}
|
|
311
|
+
return typedClient.fromNetwork({ ...params, algorand: this._algorand });
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Returns a new typed app factory.
|
|
315
|
+
* @param typedFactory The typed factory type to use
|
|
316
|
+
* @param params The params to resolve the factory by
|
|
317
|
+
* @example
|
|
318
|
+
* ```typescript
|
|
319
|
+
* const appFactory = algorand.client.getTypedAppFactory(MyContractClient, {
|
|
200
320
|
* sender: alice,
|
|
201
321
|
* })
|
|
202
322
|
* ```
|
|
203
323
|
* @returns The typed client instance
|
|
204
324
|
*/
|
|
205
|
-
|
|
206
|
-
|
|
325
|
+
getTypedAppFactory(typedFactory, params) {
|
|
326
|
+
if (!this._algorand) {
|
|
327
|
+
throw new Error('Attempt to get app factory from a ClientManager without an Algorand client');
|
|
328
|
+
}
|
|
329
|
+
return new typedFactory({ ...params, algorand: this._algorand });
|
|
207
330
|
}
|
|
208
331
|
/**
|
|
209
332
|
* Retrieve client configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment)
|
|
@@ -324,7 +447,7 @@ class ClientManager {
|
|
|
324
447
|
*/
|
|
325
448
|
static getAlgodClient(config) {
|
|
326
449
|
const { token, server, port } = config;
|
|
327
|
-
const tokenHeader = typeof token === 'string' ? { 'X-Algo-API-Token': token } : token ?? {};
|
|
450
|
+
const tokenHeader = typeof token === 'string' ? { 'X-Algo-API-Token': token } : (token ?? {});
|
|
328
451
|
const httpClientWithRetry = new types_algoHttpClientWithRetry.AlgoHttpClientWithRetry(tokenHeader, server, port);
|
|
329
452
|
return new algosdk.Algodv2(httpClientWithRetry, server);
|
|
330
453
|
}
|
|
@@ -345,7 +468,6 @@ class ClientManager {
|
|
|
345
468
|
* Returns an indexer SDK client that automatically retries on idempotent calls
|
|
346
469
|
*
|
|
347
470
|
* @param config The config of the client
|
|
348
|
-
* @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers
|
|
349
471
|
* @example AlgoNode (testnet)
|
|
350
472
|
* ```typescript
|
|
351
473
|
* const indexer = ClientManager.getIndexerClient(ClientManager.getAlgoNodeConfig('testnet', 'indexer'))
|
|
@@ -361,24 +483,16 @@ class ClientManager {
|
|
|
361
483
|
* const indexer = ClientManager.getIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
362
484
|
* await indexer.makeHealthCheck().do()
|
|
363
485
|
* ```
|
|
364
|
-
* @example Override int decoding for responses
|
|
365
|
-
* ```typescript
|
|
366
|
-
* const indexer = ClientManager.getIndexerClient(config, IntDecoding.BIGINT)
|
|
367
|
-
* ```
|
|
368
486
|
*/
|
|
369
|
-
static getIndexerClient(config
|
|
487
|
+
static getIndexerClient(config) {
|
|
370
488
|
const { token, server, port } = config;
|
|
371
|
-
const tokenHeader = typeof token === 'string' ? { 'X-Indexer-API-Token': token } : token ?? {};
|
|
489
|
+
const tokenHeader = typeof token === 'string' ? { 'X-Indexer-API-Token': token } : (token ?? {});
|
|
372
490
|
const httpClientWithRetry = new types_algoHttpClientWithRetry.AlgoHttpClientWithRetry(tokenHeader, server, port);
|
|
373
|
-
|
|
374
|
-
// Use mixed int decoding by default so bigints don't have lost precision
|
|
375
|
-
indexer.setIntEncoding(overrideIntDecoding ?? IntDecoding.MIXED);
|
|
376
|
-
return indexer;
|
|
491
|
+
return new Indexer(httpClientWithRetry);
|
|
377
492
|
}
|
|
378
493
|
/**
|
|
379
494
|
* Returns an indexer SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).
|
|
380
495
|
*
|
|
381
|
-
* @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers
|
|
382
496
|
* @example
|
|
383
497
|
*
|
|
384
498
|
* ```typescript
|
|
@@ -387,8 +501,8 @@ class ClientManager {
|
|
|
387
501
|
* await indexer.makeHealthCheck().do()
|
|
388
502
|
* ```
|
|
389
503
|
*/
|
|
390
|
-
static getIndexerClientFromEnvironment(
|
|
391
|
-
return ClientManager.getIndexerClient(ClientManager.getIndexerConfigFromEnvironment()
|
|
504
|
+
static getIndexerClientFromEnvironment() {
|
|
505
|
+
return ClientManager.getIndexerClient(ClientManager.getIndexerConfigFromEnvironment());
|
|
392
506
|
}
|
|
393
507
|
/**
|
|
394
508
|
* Returns a KMD SDK client.
|