@algorandfoundation/algokit-utils 10.0.0-alpha.31 → 10.0.0-alpha.32

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.
Files changed (318) hide show
  1. package/account-manager.d.ts +448 -0
  2. package/account-manager.js +623 -0
  3. package/account-manager.js.map +1 -0
  4. package/account-manager.mjs +620 -0
  5. package/account-manager.mjs.map +1 -0
  6. package/account.d.ts +156 -0
  7. package/account.js +10 -0
  8. package/account.js.map +1 -0
  9. package/account.mjs +9 -0
  10. package/account.mjs.map +1 -0
  11. package/algorand-client-transaction-creator.d.ts +1103 -0
  12. package/algorand-client-transaction-creator.js +735 -0
  13. package/algorand-client-transaction-creator.js.map +1 -0
  14. package/algorand-client-transaction-creator.mjs +734 -0
  15. package/algorand-client-transaction-creator.mjs.map +1 -0
  16. package/algorand-client-transaction-sender.d.ts +1317 -0
  17. package/algorand-client-transaction-sender.js +933 -0
  18. package/algorand-client-transaction-sender.js.map +1 -0
  19. package/algorand-client-transaction-sender.mjs +932 -0
  20. package/algorand-client-transaction-sender.mjs.map +1 -0
  21. package/algorand-client.d.ts +246 -0
  22. package/algorand-client.js +325 -0
  23. package/algorand-client.js.map +1 -0
  24. package/algorand-client.mjs +325 -0
  25. package/algorand-client.mjs.map +1 -0
  26. package/amount.d.ts +46 -3
  27. package/amount.js +92 -13
  28. package/amount.js.map +1 -1
  29. package/amount.mjs +80 -3
  30. package/amount.mjs.map +1 -1
  31. package/app-client.d.ts +2130 -0
  32. package/app-client.js +909 -0
  33. package/app-client.js.map +1 -0
  34. package/app-client.mjs +908 -0
  35. package/app-client.mjs.map +1 -0
  36. package/app-deployer.d.ts +166 -0
  37. package/app-deployer.js +353 -0
  38. package/app-deployer.js.map +1 -0
  39. package/app-deployer.mjs +353 -0
  40. package/app-deployer.mjs.map +1 -0
  41. package/app-factory.d.ts +965 -0
  42. package/app-factory.js +448 -0
  43. package/app-factory.js.map +1 -0
  44. package/app-factory.mjs +448 -0
  45. package/app-factory.mjs.map +1 -0
  46. package/app-manager.d.ts +323 -0
  47. package/app-manager.js +468 -0
  48. package/app-manager.js.map +1 -0
  49. package/app-manager.mjs +468 -0
  50. package/app-manager.mjs.map +1 -0
  51. package/app-spec.d.ts +203 -0
  52. package/app-spec.js +137 -0
  53. package/app-spec.js.map +1 -0
  54. package/app-spec.mjs +137 -0
  55. package/app-spec.mjs.map +1 -0
  56. package/app.d.ts +257 -0
  57. package/app.js +49 -0
  58. package/app.js.map +1 -0
  59. package/app.mjs +42 -0
  60. package/app.mjs.map +1 -0
  61. package/asset-manager.d.ts +212 -0
  62. package/asset-manager.js +166 -0
  63. package/asset-manager.js.map +1 -0
  64. package/asset-manager.mjs +166 -0
  65. package/asset-manager.mjs.map +1 -0
  66. package/async-event-emitter.d.ts +16 -0
  67. package/async-event-emitter.js +38 -0
  68. package/async-event-emitter.js.map +1 -0
  69. package/async-event-emitter.mjs +37 -0
  70. package/async-event-emitter.mjs.map +1 -0
  71. package/client-manager.d.ts +475 -0
  72. package/client-manager.js +616 -0
  73. package/client-manager.js.map +1 -0
  74. package/client-manager.mjs +616 -0
  75. package/client-manager.mjs.map +1 -0
  76. package/composer.d.ts +947 -0
  77. package/composer.js +1584 -0
  78. package/composer.js.map +1 -0
  79. package/composer.mjs +1583 -0
  80. package/composer.mjs.map +1 -0
  81. package/config.d.ts +1 -1
  82. package/config.js +2 -2
  83. package/config.js.map +1 -1
  84. package/config.mjs +1 -1
  85. package/config.mjs.map +1 -1
  86. package/debugging.d.ts +47 -0
  87. package/debugging.js +20 -0
  88. package/debugging.js.map +1 -0
  89. package/debugging.mjs +15 -0
  90. package/debugging.mjs.map +1 -0
  91. package/dispenser-client.d.ts +90 -0
  92. package/dispenser-client.js +127 -0
  93. package/dispenser-client.js.map +1 -0
  94. package/dispenser-client.mjs +127 -0
  95. package/dispenser-client.mjs.map +1 -0
  96. package/expand.d.ts +2 -0
  97. package/expand.js +0 -0
  98. package/expand.mjs +0 -0
  99. package/index.d.ts +6 -5
  100. package/index.js +4 -3
  101. package/index.mjs +5 -5
  102. package/indexer-client/indexer-lookup.d.ts +1 -1
  103. package/indexer-client/indexer-lookup.js.map +1 -1
  104. package/indexer-client/indexer-lookup.mjs.map +1 -1
  105. package/indexer.d.ts +40 -0
  106. package/indexer.js +38 -0
  107. package/indexer.js.map +1 -0
  108. package/indexer.mjs +35 -0
  109. package/indexer.mjs.map +1 -0
  110. package/instance-of.d.ts +8 -0
  111. package/kmd-account-manager.d.ts +74 -0
  112. package/kmd-account-manager.js +167 -0
  113. package/kmd-account-manager.js.map +1 -0
  114. package/kmd-account-manager.mjs +165 -0
  115. package/kmd-account-manager.mjs.map +1 -0
  116. package/lifecycle-events.d.ts +14 -0
  117. package/lifecycle-events.js +11 -0
  118. package/lifecycle-events.js.map +1 -0
  119. package/lifecycle-events.mjs +10 -0
  120. package/lifecycle-events.mjs.map +1 -0
  121. package/logging.d.ts +13 -0
  122. package/logging.js +47 -0
  123. package/logging.js.map +1 -0
  124. package/logging.mjs +42 -0
  125. package/logging.mjs.map +1 -0
  126. package/logic-error.d.ts +39 -0
  127. package/logic-error.js +54 -0
  128. package/logic-error.js.map +1 -0
  129. package/logic-error.mjs +53 -0
  130. package/logic-error.mjs.map +1 -0
  131. package/network-client.d.ts +43 -0
  132. package/network-client.js +14 -0
  133. package/network-client.js.map +1 -0
  134. package/network-client.mjs +13 -0
  135. package/network-client.mjs.map +1 -0
  136. package/package.json +11 -1
  137. package/testing/account.d.ts +2 -2
  138. package/testing/account.js +1 -1
  139. package/testing/account.js.map +1 -1
  140. package/testing/account.mjs +1 -1
  141. package/testing/account.mjs.map +1 -1
  142. package/testing/fixtures/algokit-log-capture-fixture.d.ts +1 -1
  143. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  144. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  145. package/testing/fixtures/algorand-fixture.d.ts +2 -2
  146. package/testing/fixtures/algorand-fixture.js +2 -2
  147. package/testing/fixtures/algorand-fixture.js.map +1 -1
  148. package/testing/fixtures/algorand-fixture.mjs +2 -2
  149. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  150. package/testing/index.d.ts +2 -1
  151. package/testing/test-logger.d.ts +1 -1
  152. package/testing/test-logger.js.map +1 -1
  153. package/testing/test-logger.mjs.map +1 -1
  154. package/testing/types.d.ts +156 -0
  155. package/transaction/index.d.ts +4 -0
  156. package/transaction/index.js +9 -0
  157. package/transaction/index.mjs +4 -0
  158. package/transaction/perform-transaction-composer-simulate.d.ts +1 -1
  159. package/transaction/perform-transaction-composer-simulate.js.map +1 -1
  160. package/transaction/perform-transaction-composer-simulate.mjs.map +1 -1
  161. package/transaction/transaction.d.ts +2 -2
  162. package/transaction/transaction.js.map +1 -1
  163. package/transaction/transaction.mjs.map +1 -1
  164. package/transaction/types.d.ts +133 -0
  165. package/transactions/app-call.d.ts +1 -1
  166. package/transactions/app-call.js +1 -1
  167. package/transactions/app-call.js.map +1 -1
  168. package/transactions/app-call.mjs +1 -1
  169. package/transactions/app-call.mjs.map +1 -1
  170. package/transactions/common.d.ts +1 -1
  171. package/transactions/common.js.map +1 -1
  172. package/transactions/common.mjs.map +1 -1
  173. package/transactions/method-call.d.ts +1 -1
  174. package/transactions/method-call.js +1 -1
  175. package/transactions/method-call.js.map +1 -1
  176. package/transactions/method-call.mjs +1 -1
  177. package/transactions/method-call.mjs.map +1 -1
  178. package/transactions/payment.d.ts +1 -1
  179. package/transactions/payment.js.map +1 -1
  180. package/transactions/payment.mjs.map +1 -1
  181. package/types/account-manager.d.ts +11 -442
  182. package/types/account-manager.js +5 -616
  183. package/types/account-manager.js.map +1 -1
  184. package/types/account-manager.mjs +5 -614
  185. package/types/account-manager.mjs.map +1 -1
  186. package/types/account.d.ts +8 -150
  187. package/types/account.js +3 -4
  188. package/types/account.js.map +1 -1
  189. package/types/account.mjs +4 -4
  190. package/types/account.mjs.map +1 -1
  191. package/types/algorand-client-transaction-creator.d.ts +5 -1098
  192. package/types/algorand-client-transaction-creator.js +3 -729
  193. package/types/algorand-client-transaction-creator.js.map +1 -1
  194. package/types/algorand-client-transaction-creator.mjs +4 -729
  195. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  196. package/types/algorand-client-transaction-sender.d.ts +5 -1312
  197. package/types/algorand-client-transaction-sender.js +3 -927
  198. package/types/algorand-client-transaction-sender.js.map +1 -1
  199. package/types/algorand-client-transaction-sender.mjs +3 -926
  200. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  201. package/types/algorand-client.d.ts +5 -241
  202. package/types/algorand-client.js +3 -319
  203. package/types/algorand-client.js.map +1 -1
  204. package/types/algorand-client.mjs +3 -319
  205. package/types/algorand-client.mjs.map +1 -1
  206. package/types/amount.d.ts +6 -45
  207. package/types/amount.js +3 -79
  208. package/types/amount.js.map +1 -1
  209. package/types/amount.mjs +4 -79
  210. package/types/amount.mjs.map +1 -1
  211. package/types/app-client.d.ts +75 -2125
  212. package/types/app-client.js +3 -903
  213. package/types/app-client.js.map +1 -1
  214. package/types/app-client.mjs +3 -902
  215. package/types/app-client.mjs.map +1 -1
  216. package/types/app-deployer.d.ts +21 -161
  217. package/types/app-deployer.js +3 -347
  218. package/types/app-deployer.js.map +1 -1
  219. package/types/app-deployer.mjs +3 -347
  220. package/types/app-deployer.mjs.map +1 -1
  221. package/types/app-factory.d.ts +21 -960
  222. package/types/app-factory.js +3 -442
  223. package/types/app-factory.js.map +1 -1
  224. package/types/app-factory.mjs +3 -442
  225. package/types/app-factory.mjs.map +1 -1
  226. package/types/app-manager.d.ts +15 -318
  227. package/types/app-manager.js +3 -462
  228. package/types/app-manager.js.map +1 -1
  229. package/types/app-manager.mjs +3 -462
  230. package/types/app-manager.mjs.map +1 -1
  231. package/types/app-spec.d.ts +39 -198
  232. package/types/app-spec.js +3 -131
  233. package/types/app-spec.js.map +1 -1
  234. package/types/app-spec.mjs +3 -131
  235. package/types/app-spec.mjs.map +1 -1
  236. package/types/app.d.ts +62 -247
  237. package/types/app.js +15 -37
  238. package/types/app.js.map +1 -1
  239. package/types/app.mjs +16 -37
  240. package/types/app.mjs.map +1 -1
  241. package/types/asset-manager.d.ts +9 -207
  242. package/types/asset-manager.js +3 -160
  243. package/types/asset-manager.js.map +1 -1
  244. package/types/asset-manager.mjs +3 -160
  245. package/types/asset-manager.mjs.map +1 -1
  246. package/types/async-event-emitter.d.ts +7 -11
  247. package/types/async-event-emitter.js +3 -32
  248. package/types/async-event-emitter.js.map +1 -1
  249. package/types/async-event-emitter.mjs +4 -32
  250. package/types/async-event-emitter.mjs.map +1 -1
  251. package/types/client-manager.d.ts +27 -470
  252. package/types/client-manager.js +3 -610
  253. package/types/client-manager.js.map +1 -1
  254. package/types/client-manager.mjs +3 -610
  255. package/types/client-manager.mjs.map +1 -1
  256. package/types/composer.d.ts +79 -943
  257. package/types/composer.js +3 -1578
  258. package/types/composer.js.map +1 -1
  259. package/types/composer.mjs +3 -1577
  260. package/types/composer.mjs.map +1 -1
  261. package/types/config.d.ts +7 -52
  262. package/types/config.js +3 -74
  263. package/types/config.js.map +1 -1
  264. package/types/config.mjs +3 -74
  265. package/types/config.mjs.map +1 -1
  266. package/types/debugging.d.ts +12 -37
  267. package/types/debugging.js +11 -10
  268. package/types/debugging.js.map +1 -1
  269. package/types/debugging.mjs +12 -10
  270. package/types/debugging.mjs.map +1 -1
  271. package/types/dispenser-client.d.ts +11 -85
  272. package/types/dispenser-client.js +3 -121
  273. package/types/dispenser-client.js.map +1 -1
  274. package/types/dispenser-client.mjs +3 -121
  275. package/types/dispenser-client.mjs.map +1 -1
  276. package/types/expand.d.ts +8 -2
  277. package/types/indexer.d.ts +16 -36
  278. package/types/indexer.js +7 -30
  279. package/types/indexer.js.map +1 -1
  280. package/types/indexer.mjs +8 -30
  281. package/types/indexer.mjs.map +1 -1
  282. package/types/instance-of.d.ts +4 -4
  283. package/types/kmd-account-manager.d.ts +5 -69
  284. package/types/kmd-account-manager.js +3 -161
  285. package/types/kmd-account-manager.js.map +1 -1
  286. package/types/kmd-account-manager.mjs +3 -159
  287. package/types/kmd-account-manager.mjs.map +1 -1
  288. package/types/lifecycle-events.d.ts +7 -9
  289. package/types/lifecycle-events.js +3 -5
  290. package/types/lifecycle-events.js.map +1 -1
  291. package/types/lifecycle-events.mjs +4 -5
  292. package/types/lifecycle-events.mjs.map +1 -1
  293. package/types/logging.d.ts +14 -9
  294. package/types/logging.js +11 -37
  295. package/types/logging.js.map +1 -1
  296. package/types/logging.mjs +12 -37
  297. package/types/logging.mjs.map +1 -1
  298. package/types/logic-error.d.ts +8 -35
  299. package/types/logic-error.js +3 -48
  300. package/types/logic-error.js.map +1 -1
  301. package/types/logic-error.mjs +4 -48
  302. package/types/logic-error.mjs.map +1 -1
  303. package/types/network-client.d.ts +10 -39
  304. package/types/network-client.js +3 -8
  305. package/types/network-client.js.map +1 -1
  306. package/types/network-client.mjs +4 -8
  307. package/types/network-client.mjs.map +1 -1
  308. package/types/testing.d.ts +13 -151
  309. package/types/transaction.d.ts +33 -128
  310. package/updatable-config.d.ts +57 -0
  311. package/updatable-config.js +80 -0
  312. package/updatable-config.js.map +1 -0
  313. package/updatable-config.mjs +80 -0
  314. package/updatable-config.mjs.map +1 -0
  315. package/util.js +1 -1
  316. package/util.js.map +1 -1
  317. package/util.mjs +1 -1
  318. package/util.mjs.map +1 -1
@@ -1,615 +1,8 @@
1
- import { Config } from "../config.mjs";
2
- import { genesisIdIsLocalNet } from "./network-client.mjs";
3
- import { AlgodClient } from "../packages/algod_client/src/client.mjs";
4
- import { IndexerClient } from "../packages/indexer_client/src/client.mjs";
5
- import { KmdClient } from "../packages/kmd_client/src/client.mjs";
6
- import { AppClient } from "./app-client.mjs";
7
- import { AppFactory } from "./app-factory.mjs";
8
- import { TestNetDispenserApiClient } from "./dispenser-client.mjs";
1
+ import { ClientManager as ClientManager$1 } from "../client-manager.mjs";
9
2
 
10
3
  //#region src/types/client-manager.ts
11
- /** Exposes access to various API clients. */
12
- var ClientManager = class ClientManager {
13
- _algod;
14
- _indexer;
15
- _kmd;
16
- _algorand;
17
- /**
18
- * algosdk clients or config for interacting with the official Algorand APIs.
19
- * @param clientsOrConfig The clients or config to use
20
- * @example Algod client only
21
- * ```typescript
22
- * const clientManager = new ClientManager({ algod: algodClient })
23
- * ```
24
- * @example All clients
25
- * ```typescript
26
- * const clientManager = new ClientManager({ algod: algodClient, indexer: indexerClient, kmd: kmdClient })
27
- * ```
28
- * @example Algod config only
29
- * ```typescript
30
- * const clientManager = new ClientManager({ algodConfig })
31
- * ```
32
- * @example All client configs
33
- * ```typescript
34
- * const clientManager = new ClientManager({ algodConfig, indexerConfig, kmdConfig })
35
- * ```
36
- */
37
- constructor(clientsOrConfig, algorandClient) {
38
- const _clients = "algod" in clientsOrConfig ? clientsOrConfig : {
39
- algod: ClientManager.getAlgodClient(clientsOrConfig.algodConfig),
40
- indexer: clientsOrConfig.indexerConfig ? ClientManager.getIndexerClient(clientsOrConfig.indexerConfig) : void 0,
41
- kmd: clientsOrConfig.kmdConfig ? ClientManager.getKmdClient(clientsOrConfig.kmdConfig) : void 0
42
- };
43
- this._algod = _clients.algod;
44
- this._indexer = _clients.indexer;
45
- this._kmd = _clients.kmd;
46
- this._algorand = algorandClient;
47
- }
48
- /**
49
- * Returns an Algod API client.
50
- * @returns The Algod client
51
- */
52
- get algod() {
53
- return this._algod;
54
- }
55
- /**
56
- * Returns an Indexer API client or throws an error if it's not been provided.
57
- * @returns The Indexer client
58
- * @throws Error if no Indexer client is configured
59
- */
60
- get indexer() {
61
- if (!this._indexer) throw new Error("Attempt to use Indexer client in AlgoKit instance with no Indexer configured");
62
- return this._indexer;
63
- }
64
- /**
65
- * Returns an Indexer API client or `undefined` if it's not been provided.
66
- * @returns The Indexer client or `undefined`
67
- */
68
- get indexerIfPresent() {
69
- return this._indexer;
70
- }
71
- /**
72
- * Returns a KMD API client or throws an error if it's not been provided.
73
- * @returns The KMD client
74
- * @throws Error if no KMD client is configured
75
- */
76
- get kmd() {
77
- if (!this._kmd) throw new Error("Attempt to use Kmd client in AlgoKit instance with no Kmd configured");
78
- return this._kmd;
79
- }
80
- _getNetworkPromise;
81
- /**
82
- * Get details about the current network.
83
- * @example Getting genesis ID
84
- * ```typescript
85
- * const network = await networkClient.network()
86
- * const genesisId = network.genesisId
87
- * ```
88
- * @returns The current network details
89
- */
90
- async network() {
91
- if (!this._getNetworkPromise) this._getNetworkPromise = this._algod.suggestedParams();
92
- const params = await this._getNetworkPromise;
93
- return {
94
- isTestNet: [
95
- "testnet-v1.0",
96
- "testnet-v1",
97
- "testnet"
98
- ].includes(params.genesisId ?? "unknown"),
99
- isMainNet: [
100
- "mainnet-v1.0",
101
- "mainnet-v1",
102
- "mainnet"
103
- ].includes(params.genesisId ?? "unknown"),
104
- isLocalNet: ClientManager.genesisIdIsLocalNet(params.genesisId ?? "unknown"),
105
- genesisId: params.genesisId ?? "unknown",
106
- genesisHash: params.genesisHash ? Buffer.from(params.genesisHash).toString("base64") : "unknown"
107
- };
108
- }
109
- /**
110
- * Returns true if the given network genesisId is associated with a LocalNet network.
111
- * @param genesisId The network genesis ID
112
- * @returns Whether the given genesis ID is associated with a LocalNet network
113
- * @example
114
- * ```typescript
115
- * const isLocalNet = ClientManager.genesisIdIsLocalNet('testnet-v1.0')
116
- * ```
117
- */
118
- static genesisIdIsLocalNet(genesisId) {
119
- return genesisIdIsLocalNet(genesisId);
120
- }
121
- /**
122
- * Returns true if the current network is LocalNet.
123
- * @returns True if the current network is LocalNet.
124
- * @example
125
- * ```typescript
126
- * const isLocalNet = await clientManager.isLocalNet()
127
- * ```
128
- */
129
- async isLocalNet() {
130
- return (await this.network()).isLocalNet;
131
- }
132
- /**
133
- * Returns true if the current network is TestNet.
134
- * @returns True if the current network is TestNet.
135
- * @example
136
- * ```typescript
137
- * const isTestNet = await clientManager.isTestNet()
138
- * ```
139
- */
140
- async isTestNet() {
141
- return (await this.network()).isTestNet;
142
- }
143
- /**
144
- * Returns true if the current network is MainNet.
145
- * @returns True if the current network is MainNet.
146
- * @example
147
- * ```typescript
148
- * const isMainNet = await clientManager.isMainNet()
149
- * ```
150
- */
151
- async isMainNet() {
152
- return (await this.network()).isMainNet;
153
- }
154
- /**
155
- * Returns a TestNet Dispenser API client.
156
- *
157
- * Refer to [docs](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md) on guidance to obtain an access token.
158
- *
159
- * @param params An object containing parameters for the TestNetDispenserApiClient class.
160
- * @example
161
- * const client = clientManager.getTestNetDispenser(
162
- * {
163
- * authToken: 'your_auth_token',
164
- * requestTimeout: 15,
165
- * }
166
- * )
167
- *
168
- * @returns An instance of the TestNetDispenserApiClient class.
169
- */
170
- getTestNetDispenser(params) {
171
- return new TestNetDispenserApiClient(params);
172
- }
173
- /**
174
- * Returns a TestNet Dispenser API client, loading the auth token from `process.env.ALGOKIT_DISPENSER_ACCESS_TOKEN`.
175
- *
176
- * Refer to [docs](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md) on guidance to obtain an access token.
177
- *
178
- * @param params An object containing parameters for the TestNetDispenserApiClient class.
179
- * @example
180
- * const client = clientManager.getTestNetDispenserFromEnvironment(
181
- * {
182
- * requestTimeout: 15,
183
- * }
184
- * )
185
- *
186
- * @returns An instance of the TestNetDispenserApiClient class.
187
- */
188
- getTestNetDispenserFromEnvironment(params) {
189
- return new TestNetDispenserApiClient(params ? {
190
- ...params,
191
- authToken: ""
192
- } : void 0);
193
- }
194
- /**
195
- * Returns a new `AppFactory` client
196
- * @param params The parameters to create the app factory
197
- * @example Basic example
198
- * ```typescript
199
- * const factory = clientManager.getAppFactory({
200
- * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\/}',
201
- * })
202
- * ```
203
- * @example Advanced example
204
- * ```typescript
205
- * const factory = clientManager.getAppFactory({
206
- * appSpec: parsedAppSpec_AppSpec_or_Arc56Contract,
207
- * defaultSender: "SENDERADDRESS",
208
- * appName: "OverriddenAppName",
209
- * version: "2.0.0",
210
- * updatable: true,
211
- * deletable: false,
212
- * deployTimeParams: { ONE: 1, TWO: 'value' }
213
- * })
214
- * ```
215
- * @returns The `AppFactory` instance
216
- */
217
- getAppFactory(params) {
218
- if (!this._algorand) throw new Error("Attempt to get app factory from a ClientManager without an Algorand client");
219
- return new AppFactory({
220
- ...params,
221
- algorand: this._algorand
222
- });
223
- }
224
- /**
225
- * Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
226
- * This method resolves the app ID by looking up the creator address and name
227
- * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
228
- * @param params The parameters to create the app client
229
- * @example Basic
230
- * ```typescript
231
- * const appClient = clientManager.getAppClientByCreatorAndName({
232
- * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
233
- * // appId resolved by looking for app ID of named app by this creator
234
- * creatorAddress: 'CREATORADDRESS',
235
- * })
236
- * ```
237
- * @returns The `AppClient` instance
238
- */
239
- getAppClientByCreatorAndName(params) {
240
- if (!this._algorand) throw new Error("Attempt to get app client from a ClientManager without an Algorand client");
241
- return AppClient.fromCreatorAndName({
242
- ...params,
243
- algorand: this._algorand
244
- });
245
- }
246
- /**
247
- * Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
248
- * @param params The parameters to create the app client
249
- * @example Basic
250
- * ```typescript
251
- * const appClient = clientManager.getAppClientById({
252
- * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
253
- * appId: 12345n,
254
- * })
255
- * ```
256
- * @returns The `AppClient` instance
257
- */
258
- getAppClientById(params) {
259
- if (!this._algorand) throw new Error("Attempt to get app client from a ClientManager without an Algorand client");
260
- return new AppClient({
261
- ...params,
262
- algorand: this._algorand
263
- });
264
- }
265
- /**
266
- * Returns a new `AppClient` client for managing calls and state for an ARC-56 app.
267
- * This method resolves the app ID for the current network based on
268
- * pre-determined network-specific app IDs specified in the ARC-56 app spec.
269
- *
270
- * If no IDs are in the app spec or the network isn't recognised, an error is thrown.
271
- * @param params The parameters to create the app client
272
- * @example Basic
273
- * ```typescript
274
- * const appClient = clientManager.getAppClientByNetwork({
275
- * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
276
- * // appId resolved by using ARC-56 spec to find app ID for current network
277
- * })
278
- * ```
279
- * @returns The `AppClient` instance
280
- */
281
- async getAppClientByNetwork(params) {
282
- if (!this._algorand) throw new Error("Attempt to get app client from a ClientManager without an Algorand client");
283
- return AppClient.fromNetwork({
284
- ...params,
285
- algorand: this._algorand
286
- });
287
- }
288
- /**
289
- * Returns a new typed client, resolving the app by creator address and name.
290
- * @param typedClient The typed client type to use
291
- * @param params The params to resolve the app by creator address and name
292
- * @example Use name in ARC-32 / ARC-56 app spec
293
- * ```typescript
294
- * const appClient = clientManager.getTypedAppClientByCreatorAndName(MyContractClient, {
295
- * creatorAddress: "CREATORADDRESS",
296
- * defaultSender: alice,
297
- * })
298
- * ```
299
- * @example Specify name
300
- * ```typescript
301
- * const appClient = clientManager.getTypedAppClientByCreatorAndName(MyContractClient, {
302
- * creatorAddress: "CREATORADDRESS",
303
- * name: "contract-name",
304
- * defaultSender: alice,
305
- * })
306
- * ```
307
- * @returns The typed client instance
308
- */
309
- async getTypedAppClientByCreatorAndName(typedClient, params) {
310
- if (!this._algorand) throw new Error("Attempt to get app client from a ClientManager without an Algorand client");
311
- return typedClient.fromCreatorAndName({
312
- ...params,
313
- algorand: this._algorand
314
- });
315
- }
316
- /**
317
- * Returns a new typed client, resolving the app by app ID.
318
- * @param typedClient The typed client type to use
319
- * @param params The params to resolve the app by ID
320
- * @example
321
- * ```typescript
322
- * const appClient = clientManager.getTypedAppClientById(MyContractClient, {
323
- * appId: 12345n,
324
- * defaultSender: alice,
325
- * })
326
- * ```
327
- * @returns The typed client instance
328
- */
329
- getTypedAppClientById(typedClient, params) {
330
- if (!this._algorand) throw new Error("Attempt to get app client from a ClientManager without an Algorand client");
331
- return new typedClient({
332
- ...params,
333
- algorand: this._algorand
334
- });
335
- }
336
- /**
337
- * Returns a new typed client, resolves the app ID for the current network based on
338
- * pre-determined network-specific app IDs specified in the ARC-56 app spec.
339
- *
340
- * If no IDs are in the app spec or the network isn't recognised, an error is thrown.
341
- * @param typedClient The typed client type to use
342
- * @param params The params to resolve the app by network
343
- * @example
344
- * ```typescript
345
- * const appClient = clientManager.getTypedAppClientByNetwork(MyContractClient, {
346
- * defaultSender: alice,
347
- * })
348
- * ```
349
- * @returns The typed client instance
350
- */
351
- getTypedAppClientByNetwork(typedClient, params) {
352
- if (!this._algorand) throw new Error("Attempt to get app client from a ClientManager without an Algorand client");
353
- return typedClient.fromNetwork({
354
- ...params,
355
- algorand: this._algorand
356
- });
357
- }
358
- /**
359
- * Returns a new typed app factory.
360
- * @param typedFactory The typed factory type to use
361
- * @param params The params to resolve the factory by
362
- * @example
363
- * ```typescript
364
- * const appFactory = clientManager.getTypedAppFactory(MyContractClient, {
365
- * sender: alice,
366
- * })
367
- * ```
368
- * @returns The typed client instance
369
- */
370
- getTypedAppFactory(typedFactory, params) {
371
- if (!this._algorand) throw new Error("Attempt to get app factory from a ClientManager without an Algorand client");
372
- return new typedFactory({
373
- ...params,
374
- algorand: this._algorand
375
- });
376
- }
377
- /**
378
- * Retrieve client configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment)
379
- *
380
- * If both `process.env.INDEXER_SERVER` and `process.env.ALGOD_SERVER` is defined it will use both along with optional `process.env.ALGOD_PORT`, `process.env.ALGOD_TOKEN`, `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.
381
- *
382
- * If only `process.env.ALGOD_SERVER` is defined it will use this along with optional `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN` and leave indexer as `undefined`.
383
- *
384
- * If only `process.env.INDEXER_SERVER` is defined it will use the default (LocalNet) configuration for both algod and indexer.
385
- *
386
- * It will return a KMD configuration that uses `process.env.KMD_PORT` (or port 4002) if `process.env.ALGOD_SERVER` is defined,
387
- * otherwise it will use the default LocalNet config unless it detects testnet or mainnet.
388
- * @example
389
- * ```typescript
390
- * const config = ClientManager.getConfigFromEnvironmentOrLocalNet()
391
- * ```
392
- * @returns The config for algod, indexer and kmd
393
- */
394
- static getConfigFromEnvironmentOrLocalNet() {
395
- if (!process || !process.env) throw new Error("Attempt to get default client configuration from a non Node.js context; supply the config instead");
396
- const [algodConfig, indexerConfig, kmdConfig] = process.env.ALGOD_SERVER ? [
397
- ClientManager.getAlgodConfigFromEnvironment(),
398
- process.env.INDEXER_SERVER ? ClientManager.getIndexerConfigFromEnvironment() : void 0,
399
- !process.env.ALGOD_SERVER.includes("mainnet") && !process.env.ALGOD_SERVER.includes("testnet") ? {
400
- ...ClientManager.getAlgodConfigFromEnvironment(),
401
- port: process?.env?.KMD_PORT ?? "4002"
402
- } : void 0
403
- ] : [
404
- ClientManager.getDefaultLocalNetConfig("algod"),
405
- ClientManager.getDefaultLocalNetConfig("indexer"),
406
- ClientManager.getDefaultLocalNetConfig("kmd")
407
- ];
408
- return {
409
- algodConfig,
410
- indexerConfig,
411
- kmdConfig
412
- };
413
- }
414
- /**
415
- * Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment)
416
- *
417
- * Expects `process.env.ALGOD_SERVER` to be defined, and you can also specify `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN`.
418
- * @returns The Algod client configuration
419
- * @throws Error if `process.env.ALGOD_SERVER` is not defined
420
- * @example
421
- * ```typescript
422
- * const config = ClientManager.getAlgodConfigFromEnvironment()
423
- * ```
424
- */
425
- static getAlgodConfigFromEnvironment() {
426
- if (!process || !process.env) throw new Error("Attempt to get default algod configuration from a non Node.js context; supply the config instead");
427
- if (!process.env.ALGOD_SERVER) throw new Error("Attempt to get default algod configuration without specifying ALGOD_SERVER in the environment variables");
428
- return {
429
- server: process.env.ALGOD_SERVER,
430
- port: process.env.ALGOD_PORT,
431
- token: process.env.ALGOD_TOKEN
432
- };
433
- }
434
- /**
435
- * Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment).
436
- *
437
- * Expects `process.env.INDEXER_SERVER` to be defined, and you can also specify `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.
438
- * @returns The Indexer client configuration
439
- * @throws Error if `process.env.INDEXER_SERVER` is not defined
440
- * @example
441
- * ```typescript
442
- * const config = ClientManager.getIndexerConfigFromEnvironment()
443
- * ```
444
- */
445
- static getIndexerConfigFromEnvironment() {
446
- if (!process || !process.env) throw new Error("Attempt to get default indexer configuration from a non Node.js context; supply the config instead");
447
- if (!process.env.INDEXER_SERVER) throw new Error("Attempt to get default indexer configuration without specifying INDEXER_SERVER in the environment variables");
448
- return {
449
- server: process.env.INDEXER_SERVER,
450
- port: process.env.INDEXER_PORT,
451
- token: process.env.INDEXER_TOKEN
452
- };
453
- }
454
- /** Returns the Algorand configuration to point to the free tier of the AlgoNode service.
455
- *
456
- * @param network Which network to connect to - TestNet or MainNet
457
- * @param config Which algod config to return - Algod or Indexer
458
- * @returns The AlgoNode client configuration
459
- * @example
460
- * ```typescript
461
- * const config = ClientManager.getAlgoNodeConfig('testnet', 'algod')
462
- * ```
463
- */
464
- static getAlgoNodeConfig(network, config) {
465
- return {
466
- server: `https://${network}-${config === "algod" ? "api" : "idx"}.algonode.cloud/`,
467
- port: 443
468
- };
469
- }
470
- /** Returns the Algorand configuration to point to the default LocalNet.
471
- *
472
- * @param configOrPort Which algod config to return - algod, kmd, or indexer OR a port number
473
- * @returns The LocalNet client configuration
474
- * @example
475
- * ```typescript
476
- * const config = ClientManager.getDefaultLocalNetConfig('algod')
477
- * ```
478
- */
479
- static getDefaultLocalNetConfig(configOrPort) {
480
- return {
481
- server: `http://localhost`,
482
- port: configOrPort === "algod" ? 4001 : configOrPort === "indexer" ? 8980 : configOrPort === "kmd" ? 4002 : configOrPort,
483
- token: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
484
- };
485
- }
486
- /**
487
- * Returns an algod SDK client that automatically retries on idempotent calls.
488
- *
489
- * @param config The config of the client
490
- * @returns The Algod client
491
- * @example AlgoNode (testnet)
492
- * ```typescript
493
- * const algod = ClientManager.getAlgodClient(ClientManager.getAlgoNodeConfig('testnet', 'algod'))
494
- * await algod.healthCheck().do()
495
- * ```
496
- * @example AlgoNode (mainnet)
497
- * ```typescript
498
- * const algod = ClientManager.getAlgodClient(ClientManager.getAlgoNodeConfig('mainnet', 'algod'))
499
- * await algod.healthCheck().do()
500
- * ```
501
- * @example Custom (e.g. default LocalNet)
502
- * ```typescript
503
- * const algod = ClientManager.getAlgodClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
504
- * await algod.healthCheck().do()
505
- * ```
506
- */
507
- static getAlgodClient(config) {
508
- const { token, server, port } = config;
509
- return new AlgodClient({
510
- baseUrl: server,
511
- port,
512
- token,
513
- logger: Config.logger
514
- });
515
- }
516
- /**
517
- * Returns an algod SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).
518
- *
519
- * @returns The Algod client
520
- * @example
521
- * ```typescript
522
- * // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN
523
- * const algod = ClientManager.getAlgodClientFromEnvironment()
524
- * await algod.healthCheck().do()
525
- * ```
526
- */
527
- static getAlgodClientFromEnvironment() {
528
- return ClientManager.getAlgodClient(ClientManager.getAlgodConfigFromEnvironment());
529
- }
530
- /**
531
- * Returns an indexer SDK client that automatically retries on idempotent calls
532
- *
533
- * @param config The config of the client
534
- * @returns The Indexer client
535
- * @example AlgoNode (testnet)
536
- * ```typescript
537
- * const indexer = ClientManager.getIndexerClient(ClientManager.getAlgoNodeConfig('testnet', 'indexer'))
538
- * await indexer.makeHealthCheck().do()
539
- * ```
540
- * @example AlgoNode (mainnet)
541
- * ```typescript
542
- * const indexer = ClientManager.getIndexerClient(ClientManager.getAlgoNodeConfig('mainnet', 'indexer'))
543
- * await indexer.makeHealthCheck().do()
544
- * ```
545
- * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
546
- * ```typescript
547
- * const indexer = ClientManager.getIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
548
- * await indexer.makeHealthCheck().do()
549
- * ```
550
- */
551
- static getIndexerClient(config) {
552
- const { token, server, port } = config;
553
- return new IndexerClient({
554
- baseUrl: server,
555
- port,
556
- token,
557
- logger: Config.logger
558
- });
559
- }
560
- /**
561
- * Returns an indexer SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).
562
- *
563
- * @returns The Indexer client
564
- * @example
565
- *
566
- * ```typescript
567
- * // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN
568
- * const indexer = ClientManager.getIndexerClientFromEnvironment()
569
- * await indexer.makeHealthCheck().do()
570
- * ```
571
- */
572
- static getIndexerClientFromEnvironment() {
573
- return ClientManager.getIndexerClient(ClientManager.getIndexerConfigFromEnvironment());
574
- }
575
- /**
576
- * Returns a KMD SDK client.
577
- *
578
- * KMD client allows you to export private keys, which is useful to (for instance) get the default account in a LocalNet network.
579
- *
580
- * @param config The config for the client
581
- * @returns The KMD client
582
- * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
583
- * ```typescript
584
- * const kmd = ClientManager.getKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
585
- * ```
586
- */
587
- static getKmdClient(config) {
588
- const { token, server, port } = config;
589
- return new KmdClient({
590
- baseUrl: server,
591
- port,
592
- token,
593
- logger: Config.logger
594
- });
595
- }
596
- /**
597
- * Returns a KMD SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).
598
- *
599
- * @returns The KMD client
600
- * @example
601
- * ```typescript
602
- * // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN
603
- * const kmd = ClientManager.getKmdClientFromEnvironment()
604
- * ```
605
- */
606
- static getKmdClientFromEnvironment() {
607
- return ClientManager.getKmdClient({
608
- ...ClientManager.getAlgodConfigFromEnvironment(),
609
- port: process?.env?.KMD_PORT ?? "4002"
610
- });
611
- }
612
- };
4
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/client-manager` instead */
5
+ const ClientManager = ClientManager$1;
613
6
 
614
7
  //#endregion
615
8
  export { ClientManager };