@algorandfoundation/algokit-utils 9.2.0 → 9.2.1-beta.1

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 (340) hide show
  1. package/_virtual/_rolldown/runtime.js +33 -0
  2. package/_virtual/_rolldown/runtime.mjs +13 -0
  3. package/account/account.d.ts +25 -30
  4. package/account/account.js +151 -146
  5. package/account/account.js.map +1 -1
  6. package/account/account.mjs +149 -144
  7. package/account/account.mjs.map +1 -1
  8. package/account/get-account-config-from-environment.d.ts +7 -2
  9. package/account/get-account-config-from-environment.js +19 -21
  10. package/account/get-account-config-from-environment.js.map +1 -1
  11. package/account/get-account-config-from-environment.mjs +19 -19
  12. package/account/get-account-config-from-environment.mjs.map +1 -1
  13. package/account/get-account.d.ts +14 -12
  14. package/account/get-account.js +56 -59
  15. package/account/get-account.js.map +1 -1
  16. package/account/get-account.mjs +56 -57
  17. package/account/get-account.mjs.map +1 -1
  18. package/account/get-dispenser-account.d.ts +9 -5
  19. package/account/get-dispenser-account.js +20 -18
  20. package/account/get-dispenser-account.js.map +1 -1
  21. package/account/get-dispenser-account.mjs +20 -16
  22. package/account/get-dispenser-account.mjs.map +1 -1
  23. package/account/mnemonic-account.d.ts +7 -3
  24. package/account/mnemonic-account.js +17 -17
  25. package/account/mnemonic-account.js.map +1 -1
  26. package/account/mnemonic-account.mjs +15 -15
  27. package/account/mnemonic-account.mjs.map +1 -1
  28. package/amount.d.ts +40 -35
  29. package/amount.js +33 -34
  30. package/amount.js.map +1 -1
  31. package/amount.mjs +33 -32
  32. package/amount.mjs.map +1 -1
  33. package/app-client.d.ts +10 -6
  34. package/app-client.js +91 -86
  35. package/app-client.js.map +1 -1
  36. package/app-client.mjs +91 -84
  37. package/app-client.mjs.map +1 -1
  38. package/app-deploy.d.ts +26 -24
  39. package/app-deploy.js +235 -253
  40. package/app-deploy.js.map +1 -1
  41. package/app-deploy.mjs +233 -251
  42. package/app-deploy.mjs.map +1 -1
  43. package/app.d.ts +45 -46
  44. package/app.js +253 -271
  45. package/app.js.map +1 -1
  46. package/app.mjs +249 -267
  47. package/app.mjs.map +1 -1
  48. package/asset.d.ts +16 -12
  49. package/asset.js +116 -122
  50. package/asset.js.map +1 -1
  51. package/asset.mjs +116 -120
  52. package/asset.mjs.map +1 -1
  53. package/config.d.ts +7 -2
  54. package/config.js +5 -7
  55. package/config.js.map +1 -1
  56. package/config.mjs +5 -4
  57. package/config.mjs.map +1 -1
  58. package/debugging/debugging.d.ts +5 -1
  59. package/debugging/debugging.js +11 -11
  60. package/debugging/debugging.js.map +1 -1
  61. package/debugging/debugging.mjs +11 -9
  62. package/debugging/debugging.mjs.map +1 -1
  63. package/dispenser-client.d.ts +7 -2
  64. package/dispenser-client.js +23 -24
  65. package/dispenser-client.js.map +1 -1
  66. package/dispenser-client.mjs +23 -22
  67. package/dispenser-client.mjs.map +1 -1
  68. package/index.d.ts +27 -18
  69. package/index.js +140 -143
  70. package/index.mjs +27 -29
  71. package/indexer-lookup.d.ts +18 -11
  72. package/indexer-lookup.js +112 -120
  73. package/indexer-lookup.js.map +1 -1
  74. package/indexer-lookup.mjs +105 -118
  75. package/indexer-lookup.mjs.map +1 -1
  76. package/localnet/get-kmd-wallet-account.d.ts +9 -7
  77. package/localnet/get-kmd-wallet-account.js +28 -26
  78. package/localnet/get-kmd-wallet-account.js.map +1 -1
  79. package/localnet/get-kmd-wallet-account.mjs +28 -24
  80. package/localnet/get-kmd-wallet-account.mjs.map +1 -1
  81. package/localnet/get-localnet-dispenser-account.d.ts +7 -5
  82. package/localnet/get-localnet-dispenser-account.js +17 -15
  83. package/localnet/get-localnet-dispenser-account.js.map +1 -1
  84. package/localnet/get-localnet-dispenser-account.mjs +17 -13
  85. package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
  86. package/localnet/get-or-create-kmd-wallet-account.d.ts +10 -8
  87. package/localnet/get-or-create-kmd-wallet-account.js +28 -26
  88. package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
  89. package/localnet/get-or-create-kmd-wallet-account.mjs +28 -24
  90. package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
  91. package/localnet/is-localnet.d.ts +7 -3
  92. package/localnet/is-localnet.js +9 -10
  93. package/localnet/is-localnet.js.map +1 -1
  94. package/localnet/is-localnet.mjs +9 -8
  95. package/localnet/is-localnet.mjs.map +1 -1
  96. package/network-client.d.ts +17 -15
  97. package/network-client.js +115 -116
  98. package/network-client.js.map +1 -1
  99. package/network-client.mjs +115 -114
  100. package/network-client.mjs.map +1 -1
  101. package/package.json +12 -3
  102. package/testing/account.d.ts +11 -9
  103. package/testing/account.js +31 -33
  104. package/testing/account.js.map +1 -1
  105. package/testing/account.mjs +29 -31
  106. package/testing/account.mjs.map +1 -1
  107. package/testing/fixtures/algokit-log-capture-fixture.d.ts +7 -2
  108. package/testing/fixtures/algokit-log-capture-fixture.js +36 -41
  109. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  110. package/testing/fixtures/algokit-log-capture-fixture.mjs +36 -39
  111. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  112. package/testing/fixtures/algorand-fixture.d.ts +9 -4
  113. package/testing/fixtures/algorand-fixture.js +67 -62
  114. package/testing/fixtures/algorand-fixture.js.map +1 -1
  115. package/testing/fixtures/algorand-fixture.mjs +66 -59
  116. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  117. package/testing/index.d.ts +7 -5
  118. package/testing/index.js +13 -18
  119. package/testing/index.mjs +7 -7
  120. package/testing/indexer.d.ts +5 -1
  121. package/testing/indexer.js +28 -37
  122. package/testing/indexer.js.map +1 -1
  123. package/testing/indexer.mjs +28 -35
  124. package/testing/indexer.mjs.map +1 -1
  125. package/testing/test-logger.d.ts +41 -36
  126. package/testing/test-logger.js +71 -76
  127. package/testing/test-logger.js.map +1 -1
  128. package/testing/test-logger.mjs +71 -74
  129. package/testing/test-logger.mjs.map +1 -1
  130. package/testing/transaction-logger.d.ts +30 -27
  131. package/testing/transaction-logger.js +77 -93
  132. package/testing/transaction-logger.js.map +1 -1
  133. package/testing/transaction-logger.mjs +74 -90
  134. package/testing/transaction-logger.mjs.map +1 -1
  135. package/transaction/legacy-bridge.js +100 -111
  136. package/transaction/legacy-bridge.js.map +1 -1
  137. package/transaction/legacy-bridge.mjs +97 -108
  138. package/transaction/legacy-bridge.mjs.map +1 -1
  139. package/transaction/perform-atomic-transaction-composer-simulate.d.ts +7 -5
  140. package/transaction/perform-atomic-transaction-composer-simulate.js +31 -36
  141. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  142. package/transaction/perform-atomic-transaction-composer-simulate.mjs +28 -33
  143. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  144. package/transaction/transaction.d.ts +34 -35
  145. package/transaction/transaction.js +716 -914
  146. package/transaction/transaction.js.map +1 -1
  147. package/transaction/transaction.mjs +713 -911
  148. package/transaction/transaction.mjs.map +1 -1
  149. package/transfer/transfer-algos.d.ts +9 -5
  150. package/transfer/transfer-algos.js +26 -27
  151. package/transfer/transfer-algos.js.map +1 -1
  152. package/transfer/transfer-algos.mjs +26 -25
  153. package/transfer/transfer-algos.mjs.map +1 -1
  154. package/transfer/transfer.d.ts +11 -8
  155. package/transfer/transfer.js +94 -100
  156. package/transfer/transfer.js.map +1 -1
  157. package/transfer/transfer.mjs +94 -98
  158. package/transfer/transfer.mjs.map +1 -1
  159. package/types/account-manager.d.ts +432 -429
  160. package/types/account-manager.js +591 -602
  161. package/types/account-manager.js.map +1 -1
  162. package/types/account-manager.mjs +587 -599
  163. package/types/account-manager.mjs.map +1 -1
  164. package/types/account.d.ts +192 -202
  165. package/types/account.js +91 -88
  166. package/types/account.js.map +1 -1
  167. package/types/account.mjs +88 -86
  168. package/types/account.mjs.map +1 -1
  169. package/types/algo-http-client-with-retry.d.ts +15 -10
  170. package/types/algo-http-client-with-retry.js +70 -92
  171. package/types/algo-http-client-with-retry.js.map +1 -1
  172. package/types/algo-http-client-with-retry.mjs +69 -90
  173. package/types/algo-http-client-with-retry.mjs.map +1 -1
  174. package/types/algorand-client-transaction-creator.d.ts +778 -771
  175. package/types/algorand-client-transaction-creator.js +733 -732
  176. package/types/algorand-client-transaction-creator.js.map +1 -1
  177. package/types/algorand-client-transaction-creator.mjs +732 -730
  178. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  179. package/types/algorand-client-transaction-sender.d.ts +1090 -1360
  180. package/types/algorand-client-transaction-sender.js +930 -961
  181. package/types/algorand-client-transaction-sender.js.map +1 -1
  182. package/types/algorand-client-transaction-sender.mjs +927 -959
  183. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  184. package/types/algorand-client.d.ts +239 -236
  185. package/types/algorand-client.js +322 -320
  186. package/types/algorand-client.js.map +1 -1
  187. package/types/algorand-client.mjs +321 -318
  188. package/types/algorand-client.mjs.map +1 -1
  189. package/types/amount.d.ts +47 -43
  190. package/types/amount.js +66 -70
  191. package/types/amount.js.map +1 -1
  192. package/types/amount.mjs +63 -68
  193. package/types/amount.mjs.map +1 -1
  194. package/types/app-arc56.d.ts +235 -272
  195. package/types/app-arc56.js +124 -170
  196. package/types/app-arc56.js.map +1 -1
  197. package/types/app-arc56.mjs +121 -168
  198. package/types/app-arc56.mjs.map +1 -1
  199. package/types/app-client.d.ts +1128 -2009
  200. package/types/app-client.js +1633 -1791
  201. package/types/app-client.js.map +1 -1
  202. package/types/app-client.mjs +1624 -1783
  203. package/types/app-client.mjs.map +1 -1
  204. package/types/app-deployer.d.ts +139 -141
  205. package/types/app-deployer.js +344 -384
  206. package/types/app-deployer.js.map +1 -1
  207. package/types/app-deployer.mjs +341 -382
  208. package/types/app-deployer.mjs.map +1 -1
  209. package/types/app-factory.d.ts +762 -932
  210. package/types/app-factory.js +496 -488
  211. package/types/app-factory.js.map +1 -1
  212. package/types/app-factory.mjs +491 -484
  213. package/types/app-factory.mjs.map +1 -1
  214. package/types/app-manager.d.ts +304 -310
  215. package/types/app-manager.js +422 -475
  216. package/types/app-manager.js.map +1 -1
  217. package/types/app-manager.mjs +419 -473
  218. package/types/app-manager.mjs.map +1 -1
  219. package/types/app-spec.d.ts +118 -117
  220. package/types/app-spec.js +125 -135
  221. package/types/app-spec.js.map +1 -1
  222. package/types/app-spec.mjs +121 -132
  223. package/types/app-spec.mjs.map +1 -1
  224. package/types/app.d.ts +229 -241
  225. package/types/app.js +36 -28
  226. package/types/app.js.map +1 -1
  227. package/types/app.mjs +33 -26
  228. package/types/app.mjs.map +1 -1
  229. package/types/asset-manager.d.ts +204 -199
  230. package/types/asset-manager.js +165 -174
  231. package/types/asset-manager.js.map +1 -1
  232. package/types/asset-manager.mjs +164 -172
  233. package/types/asset-manager.mjs.map +1 -1
  234. package/types/asset.d.ts +95 -91
  235. package/types/asset.js +0 -3
  236. package/types/asset.mjs +0 -2
  237. package/types/async-event-emitter.d.ts +18 -13
  238. package/types/async-event-emitter.js +37 -49
  239. package/types/async-event-emitter.js.map +1 -1
  240. package/types/async-event-emitter.mjs +36 -47
  241. package/types/async-event-emitter.mjs.map +1 -1
  242. package/types/client-manager.d.ts +453 -451
  243. package/types/client-manager.js +602 -598
  244. package/types/client-manager.js.map +1 -1
  245. package/types/client-manager.mjs +597 -594
  246. package/types/client-manager.mjs.map +1 -1
  247. package/types/composer.d.ts +1211 -1258
  248. package/types/composer.js +1436 -1498
  249. package/types/composer.js.map +1 -1
  250. package/types/composer.mjs +1430 -1493
  251. package/types/composer.mjs.map +1 -1
  252. package/types/config.d.ts +53 -48
  253. package/types/config.js +78 -77
  254. package/types/config.js.map +1 -1
  255. package/types/config.mjs +77 -75
  256. package/types/config.mjs.map +1 -1
  257. package/types/debugging.d.ts +25 -23
  258. package/types/debugging.js +9 -11
  259. package/types/debugging.js.map +1 -1
  260. package/types/debugging.mjs +8 -9
  261. package/types/debugging.mjs.map +1 -1
  262. package/types/dispenser-client.d.ts +57 -52
  263. package/types/dispenser-client.js +120 -141
  264. package/types/dispenser-client.js.map +1 -1
  265. package/types/dispenser-client.mjs +119 -139
  266. package/types/dispenser-client.mjs.map +1 -1
  267. package/types/expand.d.ts +5 -3
  268. package/types/expand.js +0 -3
  269. package/types/expand.mjs +0 -2
  270. package/types/indexer.d.ts +104 -100
  271. package/types/indexer.js +36 -31
  272. package/types/indexer.js.map +1 -1
  273. package/types/indexer.mjs +32 -30
  274. package/types/indexer.mjs.map +1 -1
  275. package/types/instance-of.d.ts +5 -3
  276. package/types/instance-of.js +0 -3
  277. package/types/instance-of.mjs +0 -2
  278. package/types/kmd-account-manager.d.ts +75 -70
  279. package/types/kmd-account-manager.js +150 -184
  280. package/types/kmd-account-manager.js.map +1 -1
  281. package/types/kmd-account-manager.mjs +147 -182
  282. package/types/kmd-account-manager.mjs.map +1 -1
  283. package/types/lifecycle-events.d.ts +13 -8
  284. package/types/lifecycle-events.js +10 -7
  285. package/types/lifecycle-events.js.map +1 -1
  286. package/types/lifecycle-events.mjs +9 -7
  287. package/types/lifecycle-events.mjs.map +1 -1
  288. package/types/logging.d.ts +15 -11
  289. package/types/logging.js +30 -31
  290. package/types/logging.js.map +1 -1
  291. package/types/logging.mjs +29 -29
  292. package/types/logging.mjs.map +1 -1
  293. package/types/logic-error.d.ts +33 -29
  294. package/types/logic-error.js +50 -49
  295. package/types/logic-error.js.map +1 -1
  296. package/types/logic-error.mjs +49 -47
  297. package/types/logic-error.mjs.map +1 -1
  298. package/types/network-client.d.ts +32 -27
  299. package/types/network-client.js +10 -9
  300. package/types/network-client.js.map +1 -1
  301. package/types/network-client.mjs +9 -7
  302. package/types/network-client.mjs.map +1 -1
  303. package/types/testing.d.ts +131 -132
  304. package/types/testing.js +0 -3
  305. package/types/testing.mjs +0 -2
  306. package/types/transaction.d.ts +110 -110
  307. package/types/transaction.js +0 -3
  308. package/types/transaction.mjs +0 -2
  309. package/types/transfer.d.ts +70 -66
  310. package/types/transfer.js +0 -3
  311. package/types/transfer.mjs +0 -2
  312. package/util.js +73 -118
  313. package/util.js.map +1 -1
  314. package/util.mjs +73 -116
  315. package/util.mjs.map +1 -1
  316. package/account/index.d.ts +0 -5
  317. package/debugging/index.d.ts +0 -1
  318. package/index.js.map +0 -1
  319. package/index.mjs.map +0 -1
  320. package/localnet/index.d.ts +0 -4
  321. package/testing/_asset.d.ts +0 -3
  322. package/testing/fixtures/index.d.ts +0 -2
  323. package/testing/index.js.map +0 -1
  324. package/testing/index.mjs.map +0 -1
  325. package/transaction/index.d.ts +0 -2
  326. package/transaction/legacy-bridge.d.ts +0 -35
  327. package/transfer/index.d.ts +0 -2
  328. package/types/asset.js.map +0 -1
  329. package/types/asset.mjs.map +0 -1
  330. package/types/expand.js.map +0 -1
  331. package/types/expand.mjs.map +0 -1
  332. package/types/instance-of.js.map +0 -1
  333. package/types/instance-of.mjs.map +0 -1
  334. package/types/testing.js.map +0 -1
  335. package/types/testing.mjs.map +0 -1
  336. package/types/transaction.js.map +0 -1
  337. package/types/transaction.mjs.map +0 -1
  338. package/types/transfer.js.map +0 -1
  339. package/types/transfer.mjs.map +0 -1
  340. package/util.d.ts +0 -48
@@ -1,64 +1,69 @@
1
- 'use strict';
2
-
3
- var types_algorandClient = require('../../types/algorand-client.js');
4
- var types_clientManager = require('../../types/client-manager.js');
5
- var account = require('../account.js');
6
- var indexer = require('../indexer.js');
7
- var transactionLogger = require('../transaction-logger.js');
8
- var amount = require('../../amount.js');
9
- var config = require('../../config.js');
10
-
11
- function algorandFixture(fixtureConfig, config$1) {
12
- fixtureConfig = { ...fixtureConfig, ...config$1 };
13
- if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {
14
- fixtureConfig = { ...types_clientManager.ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig };
15
- }
16
- const algod = fixtureConfig.algod ?? types_clientManager.ClientManager.getAlgodClient(fixtureConfig.algodConfig);
17
- const indexer$1 = fixtureConfig.indexer ?? types_clientManager.ClientManager.getIndexerClient(fixtureConfig.indexerConfig);
18
- const kmd = fixtureConfig.kmd ?? types_clientManager.ClientManager.getKmdClient(fixtureConfig.kmdConfig);
19
- let context;
20
- let algorand;
21
- const newScope = async () => {
22
- config.Config.configure({ debug: true });
23
- const transactionLogger$1 = new transactionLogger.TransactionLogger();
24
- const transactionLoggerAlgod = transactionLogger$1.capture(algod);
25
- algorand = types_algorandClient.AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer: indexer$1, kmd }).setSuggestedParamsCacheTimeout(0);
26
- const testAccount = await account.getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? amount.algos(10), suppressLog: true }, algorand);
27
- algorand.setSignerFromAccount(testAccount);
28
- // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window
29
- // otherwise we are more likely to get invalid transactions.
30
- if (await algorand.client.isLocalNet()) {
31
- algorand.setDefaultValidityWindow(1000);
32
- }
33
- context = {
34
- algorand,
35
- algod: transactionLoggerAlgod,
36
- indexer: indexer$1,
37
- kmd: kmd,
38
- testAccount,
39
- generateAccount: async (params) => {
40
- const account$1 = await account.getTestAccount(params, algorand);
41
- algorand.setSignerFromAccount(account$1);
42
- return account$1;
43
- },
44
- transactionLogger: transactionLogger$1,
45
- waitForIndexer: () => transactionLogger$1.waitForIndexer(indexer$1),
46
- waitForIndexerTransaction: (transactionId) => indexer.runWhenIndexerCaughtUp(() => indexer$1.lookupTransactionByID(transactionId).do()),
47
- };
48
- };
49
- return {
50
- get context() {
51
- if (!context)
52
- throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.');
53
- return context;
54
- },
55
- get algorand() {
56
- return algorand;
57
- },
58
- beforeEach: newScope,
59
- newScope,
60
- };
1
+ const require_config = require("../../config.js");
2
+ const require_client_manager = require("../../types/client-manager.js");
3
+ const require_algorand_client = require("../../types/algorand-client.js");
4
+ const require_amount = require("../../amount.js");
5
+ const require_account = require("../account.js");
6
+ const require_indexer = require("../indexer.js");
7
+ const require_transaction_logger = require("../transaction-logger.js");
8
+ //#region src/testing/fixtures/algorand-fixture.ts
9
+ function algorandFixture(fixtureConfig, config) {
10
+ fixtureConfig = {
11
+ ...fixtureConfig,
12
+ ...config
13
+ };
14
+ if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) fixtureConfig = {
15
+ ...require_client_manager.ClientManager.getConfigFromEnvironmentOrLocalNet(),
16
+ ...fixtureConfig
17
+ };
18
+ const algod = fixtureConfig.algod ?? require_client_manager.ClientManager.getAlgodClient(fixtureConfig.algodConfig);
19
+ const indexer = fixtureConfig.indexer ?? require_client_manager.ClientManager.getIndexerClient(fixtureConfig.indexerConfig);
20
+ const kmd = fixtureConfig.kmd ?? require_client_manager.ClientManager.getKmdClient(fixtureConfig.kmdConfig);
21
+ let context;
22
+ let algorand;
23
+ const newScope = async () => {
24
+ require_config.Config.configure({ debug: true });
25
+ const transactionLogger = new require_transaction_logger.TransactionLogger();
26
+ const transactionLoggerAlgod = transactionLogger.capture(algod);
27
+ algorand = require_algorand_client.AlgorandClient.fromClients({
28
+ algod: transactionLoggerAlgod,
29
+ indexer,
30
+ kmd
31
+ }).setSuggestedParamsCacheTimeout(0);
32
+ const testAccount = await require_account.getTestAccount({
33
+ initialFunds: fixtureConfig?.testAccountFunding ?? require_amount.algos(10),
34
+ suppressLog: true
35
+ }, algorand);
36
+ algorand.setSignerFromAccount(testAccount);
37
+ if (await algorand.client.isLocalNet()) algorand.setDefaultValidityWindow(1e3);
38
+ context = {
39
+ algorand,
40
+ algod: transactionLoggerAlgod,
41
+ indexer,
42
+ kmd,
43
+ testAccount,
44
+ generateAccount: async (params) => {
45
+ const account = await require_account.getTestAccount(params, algorand);
46
+ algorand.setSignerFromAccount(account);
47
+ return account;
48
+ },
49
+ transactionLogger,
50
+ waitForIndexer: () => transactionLogger.waitForIndexer(indexer),
51
+ waitForIndexerTransaction: (transactionId) => require_indexer.runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do())
52
+ };
53
+ };
54
+ return {
55
+ get context() {
56
+ if (!context) throw new Error("Context not initialised; make sure to call fixture.newScope() before accessing context.");
57
+ return context;
58
+ },
59
+ get algorand() {
60
+ return algorand;
61
+ },
62
+ beforeEach: newScope,
63
+ newScope
64
+ };
61
65
  }
62
-
66
+ //#endregion
63
67
  exports.algorandFixture = algorandFixture;
64
- //# sourceMappingURL=algorand-fixture.js.map
68
+
69
+ //# sourceMappingURL=algorand-fixture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"algorand-fixture.js","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new Algodv2('localhost', 12345, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"names":["config","ClientManager","indexer","Config","transactionLogger","TransactionLogger","AlgorandClient","getTestAccount","algos","account","runWhenIndexerCaughtUp"],"mappings":";;;;;;;;;;AA4EgB,SAAA,eAAe,CAAC,aAAqC,EAAEA,QAAmB,EAAA;IACxF,aAAa,GAAG,EAAE,GAAG,aAAa,EAAE,GAAGA,QAAM,EAAE;AAC/C,IAAA,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;QACxE,aAAa,GAAG,EAAE,GAAGC,iCAAa,CAAC,kCAAkC,EAAE,EAAE,GAAG,aAAa,EAAE;;AAG7F,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,IAAIA,iCAAa,CAAC,cAAc,CAAC,aAAa,CAAC,WAAY,CAAC;AAC7F,IAAA,MAAMC,SAAO,GAAG,aAAa,CAAC,OAAO,IAAID,iCAAa,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAc,CAAC;AACrG,IAAA,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAIA,iCAAa,CAAC,YAAY,CAAC,aAAa,CAAC,SAAU,CAAC;AACrF,IAAA,IAAI,OAAsC;AAC1C,IAAA,IAAI,QAAwB;AAE5B,IAAA,MAAM,QAAQ,GAAG,YAAW;QAC1BE,aAAM,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACjC,QAAA,MAAMC,mBAAiB,GAAG,IAAIC,mCAAiB,EAAE;QACjD,MAAM,sBAAsB,GAAGD,mBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC;QAE/D,QAAQ,GAAGE,mCAAc,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,sBAAsB,WAAEJ,SAAO,EAAE,GAAG,EAAE,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAExH,MAAM,WAAW,GAAG,MAAMK,sBAAc,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,kBAAkB,IAAIC,YAAK,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC;AACvI,QAAA,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC;;;QAI1C,IAAI,MAAM,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE;AACtC,YAAA,QAAQ,CAAC,wBAAwB,CAAC,IAAI,CAAC;;AAEzC,QAAA,OAAO,GAAG;YACR,QAAQ;AACR,YAAA,KAAK,EAAE,sBAAsB;AAC7B,YAAA,OAAO,EAAEN,SAAO;AAChB,YAAA,GAAG,EAAE,GAAG;YACR,WAAW;AACX,YAAA,eAAe,EAAE,OAAO,MAA4B,KAAI;gBACtD,MAAMO,SAAO,GAAG,MAAMF,sBAAc,CAAC,MAAM,EAAE,QAAQ,CAAC;AACtD,gBAAA,QAAQ,CAAC,oBAAoB,CAACE,SAAO,CAAC;AACtC,gBAAA,OAAOA,SAAO;aACf;AACD,YAAA,iBAAiB,EAAEL,mBAAiB;YACpC,cAAc,EAAE,MAAMA,mBAAiB,CAAC,cAAc,CAACF,SAAO,CAAC;YAC/D,yBAAyB,EAAE,CAAC,aAAqB,KAAKQ,8BAAsB,CAAC,MAAMR,SAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,EAAE,EAAE,CAAC;SACtI;AACH,KAAC;IAED,OAAO;AACL,QAAA,IAAI,OAAO,GAAA;AACT,YAAA,IAAI,CAAC,OAAO;AAAE,gBAAA,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC;AACxH,YAAA,OAAO,OAAO;SACf;AACD,QAAA,IAAI,QAAQ,GAAA;AACV,YAAA,OAAO,QAAQ;SAChB;AACD,QAAA,UAAU,EAAE,QAAQ;QACpB,QAAQ;KACT;AACH;;;;"}
1
+ {"version":3,"file":"algorand-fixture.js","names":["ClientManager","TransactionLogger","AlgorandClient","getTestAccount","algos","runWhenIndexerCaughtUp"],"sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new Algodv2('localhost', 12345, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"mappings":";;;;;;;;AA4EA,SAAgB,gBAAgB,eAAuC,QAAsC;CAC3G,gBAAgB;EAAE,GAAG;EAAe,GAAG;CAAO;CAC9C,IAAI,CAAC,cAAc,SAAS,CAAC,cAAc,WAAW,CAAC,cAAc,KACnE,gBAAgB;EAAE,GAAGA,uBAAAA,cAAc,mCAAmC;EAAG,GAAG;CAAc;CAG5F,MAAM,QAAQ,cAAc,SAASA,uBAAAA,cAAc,eAAe,cAAc,WAAY;CAC5F,MAAM,UAAU,cAAc,WAAWA,uBAAAA,cAAc,iBAAiB,cAAc,aAAc;CACpG,MAAM,MAAM,cAAc,OAAOA,uBAAAA,cAAc,aAAa,cAAc,SAAU;CACpF,IAAI;CACJ,IAAI;CAEJ,MAAM,WAAW,YAAY;EAC3B,eAAA,OAAO,UAAU,EAAE,OAAO,KAAK,CAAC;EAChC,MAAM,oBAAoB,IAAIC,2BAAAA,kBAAkB;EAChD,MAAM,yBAAyB,kBAAkB,QAAQ,KAAK;EAE9D,WAAWC,wBAAAA,eAAe,YAAY;GAAE,OAAO;GAAwB;GAAS;EAAI,CAAC,CAAC,CAAC,+BAA+B,CAAC;EAEvH,MAAM,cAAc,MAAMC,gBAAAA,eAAe;GAAE,cAAc,eAAe,sBAAsBC,eAAAA,MAAM,EAAE;GAAG,aAAa;EAAK,GAAG,QAAQ;EACtI,SAAS,qBAAqB,WAAW;EAIzC,IAAI,MAAM,SAAS,OAAO,WAAW,GACnC,SAAS,yBAAyB,GAAI;EAExC,UAAU;GACR;GACA,OAAO;GACE;GACJ;GACL;GACA,iBAAiB,OAAO,WAAiC;IACvD,MAAM,UAAU,MAAMD,gBAAAA,eAAe,QAAQ,QAAQ;IACrD,SAAS,qBAAqB,OAAO;IACrC,OAAO;GACT;GACmB;GACnB,sBAAsB,kBAAkB,eAAe,OAAO;GAC9D,4BAA4B,kBAA0BE,gBAAAA,6BAA6B,QAAQ,sBAAsB,aAAa,CAAC,CAAC,GAAG,CAAC;EACtI;CACF;CAEA,OAAO;EACL,IAAI,UAAU;GACZ,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,yFAAyF;GACvH,OAAO;EACT;EACA,IAAI,WAAW;GACb,OAAO;EACT;EACA,YAAY;EACZ;CACF;AACF"}
@@ -1,62 +1,69 @@
1
- import { AlgorandClient } from '../../types/algorand-client.mjs';
2
- import { ClientManager } from '../../types/client-manager.mjs';
3
- import { getTestAccount } from '../account.mjs';
4
- import { runWhenIndexerCaughtUp } from '../indexer.mjs';
5
- import { TransactionLogger } from '../transaction-logger.mjs';
6
- import { algos } from '../../amount.mjs';
7
- import { Config } from '../../config.mjs';
8
-
1
+ import { Config } from "../../config.mjs";
2
+ import { ClientManager } from "../../types/client-manager.mjs";
3
+ import { AlgorandClient } from "../../types/algorand-client.mjs";
4
+ import { algos } from "../../amount.mjs";
5
+ import { getTestAccount } from "../account.mjs";
6
+ import { runWhenIndexerCaughtUp } from "../indexer.mjs";
7
+ import { TransactionLogger } from "../transaction-logger.mjs";
8
+ //#region src/testing/fixtures/algorand-fixture.ts
9
9
  function algorandFixture(fixtureConfig, config) {
10
- fixtureConfig = { ...fixtureConfig, ...config };
11
- if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {
12
- fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig };
13
- }
14
- const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig);
15
- const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig);
16
- const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig);
17
- let context;
18
- let algorand;
19
- const newScope = async () => {
20
- Config.configure({ debug: true });
21
- const transactionLogger = new TransactionLogger();
22
- const transactionLoggerAlgod = transactionLogger.capture(algod);
23
- algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0);
24
- const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand);
25
- algorand.setSignerFromAccount(testAccount);
26
- // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window
27
- // otherwise we are more likely to get invalid transactions.
28
- if (await algorand.client.isLocalNet()) {
29
- algorand.setDefaultValidityWindow(1000);
30
- }
31
- context = {
32
- algorand,
33
- algod: transactionLoggerAlgod,
34
- indexer: indexer,
35
- kmd: kmd,
36
- testAccount,
37
- generateAccount: async (params) => {
38
- const account = await getTestAccount(params, algorand);
39
- algorand.setSignerFromAccount(account);
40
- return account;
41
- },
42
- transactionLogger: transactionLogger,
43
- waitForIndexer: () => transactionLogger.waitForIndexer(indexer),
44
- waitForIndexerTransaction: (transactionId) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()),
45
- };
46
- };
47
- return {
48
- get context() {
49
- if (!context)
50
- throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.');
51
- return context;
52
- },
53
- get algorand() {
54
- return algorand;
55
- },
56
- beforeEach: newScope,
57
- newScope,
58
- };
10
+ fixtureConfig = {
11
+ ...fixtureConfig,
12
+ ...config
13
+ };
14
+ if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) fixtureConfig = {
15
+ ...ClientManager.getConfigFromEnvironmentOrLocalNet(),
16
+ ...fixtureConfig
17
+ };
18
+ const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig);
19
+ const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig);
20
+ const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig);
21
+ let context;
22
+ let algorand;
23
+ const newScope = async () => {
24
+ Config.configure({ debug: true });
25
+ const transactionLogger = new TransactionLogger();
26
+ const transactionLoggerAlgod = transactionLogger.capture(algod);
27
+ algorand = AlgorandClient.fromClients({
28
+ algod: transactionLoggerAlgod,
29
+ indexer,
30
+ kmd
31
+ }).setSuggestedParamsCacheTimeout(0);
32
+ const testAccount = await getTestAccount({
33
+ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10),
34
+ suppressLog: true
35
+ }, algorand);
36
+ algorand.setSignerFromAccount(testAccount);
37
+ if (await algorand.client.isLocalNet()) algorand.setDefaultValidityWindow(1e3);
38
+ context = {
39
+ algorand,
40
+ algod: transactionLoggerAlgod,
41
+ indexer,
42
+ kmd,
43
+ testAccount,
44
+ generateAccount: async (params) => {
45
+ const account = await getTestAccount(params, algorand);
46
+ algorand.setSignerFromAccount(account);
47
+ return account;
48
+ },
49
+ transactionLogger,
50
+ waitForIndexer: () => transactionLogger.waitForIndexer(indexer),
51
+ waitForIndexerTransaction: (transactionId) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do())
52
+ };
53
+ };
54
+ return {
55
+ get context() {
56
+ if (!context) throw new Error("Context not initialised; make sure to call fixture.newScope() before accessing context.");
57
+ return context;
58
+ },
59
+ get algorand() {
60
+ return algorand;
61
+ },
62
+ beforeEach: newScope,
63
+ newScope
64
+ };
59
65
  }
60
-
66
+ //#endregion
61
67
  export { algorandFixture };
62
- //# sourceMappingURL=algorand-fixture.mjs.map
68
+
69
+ //# sourceMappingURL=algorand-fixture.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"algorand-fixture.mjs","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new Algodv2('localhost', 12345, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"names":[],"mappings":";;;;;;;;AA4EgB,SAAA,eAAe,CAAC,aAAqC,EAAE,MAAmB,EAAA;IACxF,aAAa,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,EAAE;AAC/C,IAAA,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;QACxE,aAAa,GAAG,EAAE,GAAG,aAAa,CAAC,kCAAkC,EAAE,EAAE,GAAG,aAAa,EAAE;;AAG7F,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,WAAY,CAAC;AAC7F,IAAA,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,aAAa,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAc,CAAC;AACrG,IAAA,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,aAAa,CAAC,SAAU,CAAC;AACrF,IAAA,IAAI,OAAsC;AAC1C,IAAA,IAAI,QAAwB;AAE5B,IAAA,MAAM,QAAQ,GAAG,YAAW;QAC1B,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACjC,QAAA,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE;QACjD,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC;QAE/D,QAAQ,GAAG,cAAc,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAExH,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,kBAAkB,IAAI,KAAK,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC;AACvI,QAAA,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC;;;QAI1C,IAAI,MAAM,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE;AACtC,YAAA,QAAQ,CAAC,wBAAwB,CAAC,IAAI,CAAC;;AAEzC,QAAA,OAAO,GAAG;YACR,QAAQ;AACR,YAAA,KAAK,EAAE,sBAAsB;AAC7B,YAAA,OAAO,EAAE,OAAO;AAChB,YAAA,GAAG,EAAE,GAAG;YACR,WAAW;AACX,YAAA,eAAe,EAAE,OAAO,MAA4B,KAAI;gBACtD,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC;AACtD,gBAAA,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAC;AACtC,gBAAA,OAAO,OAAO;aACf;AACD,YAAA,iBAAiB,EAAE,iBAAiB;YACpC,cAAc,EAAE,MAAM,iBAAiB,CAAC,cAAc,CAAC,OAAO,CAAC;YAC/D,yBAAyB,EAAE,CAAC,aAAqB,KAAK,sBAAsB,CAAC,MAAM,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,EAAE,EAAE,CAAC;SACtI;AACH,KAAC;IAED,OAAO;AACL,QAAA,IAAI,OAAO,GAAA;AACT,YAAA,IAAI,CAAC,OAAO;AAAE,gBAAA,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC;AACxH,YAAA,OAAO,OAAO;SACf;AACD,QAAA,IAAI,QAAQ,GAAA;AACV,YAAA,OAAO,QAAQ;SAChB;AACD,QAAA,UAAU,EAAE,QAAQ;QACpB,QAAQ;KACT;AACH;;;;"}
1
+ {"version":3,"file":"algorand-fixture.mjs","names":[],"sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new Algodv2('localhost', 12345, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"mappings":";;;;;;;;AA4EA,SAAgB,gBAAgB,eAAuC,QAAsC;CAC3G,gBAAgB;EAAE,GAAG;EAAe,GAAG;CAAO;CAC9C,IAAI,CAAC,cAAc,SAAS,CAAC,cAAc,WAAW,CAAC,cAAc,KACnE,gBAAgB;EAAE,GAAG,cAAc,mCAAmC;EAAG,GAAG;CAAc;CAG5F,MAAM,QAAQ,cAAc,SAAS,cAAc,eAAe,cAAc,WAAY;CAC5F,MAAM,UAAU,cAAc,WAAW,cAAc,iBAAiB,cAAc,aAAc;CACpG,MAAM,MAAM,cAAc,OAAO,cAAc,aAAa,cAAc,SAAU;CACpF,IAAI;CACJ,IAAI;CAEJ,MAAM,WAAW,YAAY;EAC3B,OAAO,UAAU,EAAE,OAAO,KAAK,CAAC;EAChC,MAAM,oBAAoB,IAAI,kBAAkB;EAChD,MAAM,yBAAyB,kBAAkB,QAAQ,KAAK;EAE9D,WAAW,eAAe,YAAY;GAAE,OAAO;GAAwB;GAAS;EAAI,CAAC,CAAC,CAAC,+BAA+B,CAAC;EAEvH,MAAM,cAAc,MAAM,eAAe;GAAE,cAAc,eAAe,sBAAsB,MAAM,EAAE;GAAG,aAAa;EAAK,GAAG,QAAQ;EACtI,SAAS,qBAAqB,WAAW;EAIzC,IAAI,MAAM,SAAS,OAAO,WAAW,GACnC,SAAS,yBAAyB,GAAI;EAExC,UAAU;GACR;GACA,OAAO;GACE;GACJ;GACL;GACA,iBAAiB,OAAO,WAAiC;IACvD,MAAM,UAAU,MAAM,eAAe,QAAQ,QAAQ;IACrD,SAAS,qBAAqB,OAAO;IACrC,OAAO;GACT;GACmB;GACnB,sBAAsB,kBAAkB,eAAe,OAAO;GAC9D,4BAA4B,kBAA0B,6BAA6B,QAAQ,sBAAsB,aAAa,CAAC,CAAC,GAAG,CAAC;EACtI;CACF;CAEA,OAAO;EACL,IAAI,UAAU;GACZ,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,yFAAyF;GACvH,OAAO;EACT;EACA,IAAI,WAAW;GACb,OAAO;EACT;EACA,YAAY;EACZ;CACF;AACF"}
@@ -1,5 +1,7 @@
1
- export * from './account';
2
- export * from './fixtures';
3
- export * from './indexer';
4
- export * from './test-logger';
5
- export * from './transaction-logger';
1
+ import { TestLogger } from "./test-logger.js";
2
+ import { getTestAccount } from "./account.js";
3
+ import { algoKitLogCaptureFixture } from "./fixtures/algokit-log-capture-fixture.js";
4
+ import { algorandFixture } from "./fixtures/algorand-fixture.js";
5
+ import { runWhenIndexerCaughtUp } from "./indexer.js";
6
+ import { TransactionLogger } from "./transaction-logger.js";
7
+ export { TestLogger, TransactionLogger, algoKitLogCaptureFixture, algorandFixture, getTestAccount, runWhenIndexerCaughtUp };
package/testing/index.js CHANGED
@@ -1,18 +1,13 @@
1
- 'use strict';
2
-
3
- var account = require('./account.js');
4
- var indexer = require('./indexer.js');
5
- var testLogger = require('./test-logger.js');
6
- var transactionLogger = require('./transaction-logger.js');
7
- var algokitLogCaptureFixture = require('./fixtures/algokit-log-capture-fixture.js');
8
- var algorandFixture = require('./fixtures/algorand-fixture.js');
9
-
10
-
11
-
12
- exports.getTestAccount = account.getTestAccount;
13
- exports.runWhenIndexerCaughtUp = indexer.runWhenIndexerCaughtUp;
14
- exports.TestLogger = testLogger.TestLogger;
15
- exports.TransactionLogger = transactionLogger.TransactionLogger;
16
- exports.algoKitLogCaptureFixture = algokitLogCaptureFixture.algoKitLogCaptureFixture;
17
- exports.algorandFixture = algorandFixture.algorandFixture;
18
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_account = require("./account.js");
3
+ const require_test_logger = require("./test-logger.js");
4
+ const require_algokit_log_capture_fixture = require("./fixtures/algokit-log-capture-fixture.js");
5
+ const require_indexer = require("./indexer.js");
6
+ const require_transaction_logger = require("./transaction-logger.js");
7
+ const require_algorand_fixture = require("./fixtures/algorand-fixture.js");
8
+ exports.TestLogger = require_test_logger.TestLogger;
9
+ exports.TransactionLogger = require_transaction_logger.TransactionLogger;
10
+ exports.algoKitLogCaptureFixture = require_algokit_log_capture_fixture.algoKitLogCaptureFixture;
11
+ exports.algorandFixture = require_algorand_fixture.algorandFixture;
12
+ exports.getTestAccount = require_account.getTestAccount;
13
+ exports.runWhenIndexerCaughtUp = require_indexer.runWhenIndexerCaughtUp;
package/testing/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- export { getTestAccount } from './account.mjs';
2
- export { runWhenIndexerCaughtUp } from './indexer.mjs';
3
- export { TestLogger } from './test-logger.mjs';
4
- export { TransactionLogger } from './transaction-logger.mjs';
5
- export { algoKitLogCaptureFixture } from './fixtures/algokit-log-capture-fixture.mjs';
6
- export { algorandFixture } from './fixtures/algorand-fixture.mjs';
7
- //# sourceMappingURL=index.mjs.map
1
+ import { getTestAccount } from "./account.mjs";
2
+ import { TestLogger } from "./test-logger.mjs";
3
+ import { algoKitLogCaptureFixture } from "./fixtures/algokit-log-capture-fixture.mjs";
4
+ import { runWhenIndexerCaughtUp } from "./indexer.mjs";
5
+ import { TransactionLogger } from "./transaction-logger.mjs";
6
+ import { algorandFixture } from "./fixtures/algorand-fixture.mjs";
7
+ export { TestLogger, TransactionLogger, algoKitLogCaptureFixture, algorandFixture, getTestAccount, runWhenIndexerCaughtUp };
@@ -1,3 +1,4 @@
1
+ //#region src/testing/indexer.d.ts
1
2
  /**
2
3
  * Runs the given indexer call until a 404 error is no longer returned.
3
4
  * Tried every 200ms up to 100 times.
@@ -9,4 +10,7 @@
9
10
  * @param run The code to run
10
11
  * @returns The result (as a promise), or throws if the indexer didn't catch up in time
11
12
  */
12
- export declare function runWhenIndexerCaughtUp<T>(run: () => Promise<T>): Promise<T>;
13
+ declare function runWhenIndexerCaughtUp<T>(run: () => Promise<T>): Promise<T>;
14
+ //#endregion
15
+ export { runWhenIndexerCaughtUp };
16
+ //# sourceMappingURL=indexer.d.ts.map
@@ -1,41 +1,32 @@
1
- 'use strict';
2
-
1
+ //#region src/testing/indexer.ts
3
2
  /**
4
- * Runs the given indexer call until a 404 error is no longer returned.
5
- * Tried every 200ms up to 100 times.
6
- * Very rudimentary implementation designed for automated testing.
7
- * @example
8
- * ```typescript
9
- * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())
10
- * ```
11
- * @param run The code to run
12
- * @returns The result (as a promise), or throws if the indexer didn't catch up in time
13
- */
3
+ * Runs the given indexer call until a 404 error is no longer returned.
4
+ * Tried every 200ms up to 100 times.
5
+ * Very rudimentary implementation designed for automated testing.
6
+ * @example
7
+ * ```typescript
8
+ * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())
9
+ * ```
10
+ * @param run The code to run
11
+ * @returns The result (as a promise), or throws if the indexer didn't catch up in time
12
+ */
14
13
  async function runWhenIndexerCaughtUp(run) {
15
- let result = null;
16
- let ok = false;
17
- let tries = 0;
18
- while (!ok) {
19
- try {
20
- result = await run();
21
- ok = true;
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- }
24
- catch (e) {
25
- if (e?.status === 404) {
26
- tries++;
27
- if (tries > 100) {
28
- throw e;
29
- }
30
- await new Promise((resolve) => setTimeout(resolve, 200));
31
- }
32
- else {
33
- throw e;
34
- }
35
- }
36
- }
37
- return result;
14
+ let result = null;
15
+ let ok = false;
16
+ let tries = 0;
17
+ while (!ok) try {
18
+ result = await run();
19
+ ok = true;
20
+ } catch (e) {
21
+ if (e?.status === 404) {
22
+ tries++;
23
+ if (tries > 100) throw e;
24
+ await new Promise((resolve) => setTimeout(resolve, 200));
25
+ } else throw e;
26
+ }
27
+ return result;
38
28
  }
39
-
29
+ //#endregion
40
30
  exports.runWhenIndexerCaughtUp = runWhenIndexerCaughtUp;
41
- //# sourceMappingURL=indexer.js.map
31
+
32
+ //# sourceMappingURL=indexer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"indexer.js","sources":["../../src/testing/indexer.ts"],"sourcesContent":["/**\n * Runs the given indexer call until a 404 error is no longer returned.\n * Tried every 200ms up to 100 times.\n * Very rudimentary implementation designed for automated testing.\n * @example\n * ```typescript\n * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())\n * ```\n * @param run The code to run\n * @returns The result (as a promise), or throws if the indexer didn't catch up in time\n */\nexport async function runWhenIndexerCaughtUp<T>(run: () => Promise<T>): Promise<T> {\n let result: T | null = null\n let ok = false\n let tries = 0\n while (!ok) {\n try {\n result = await run()\n ok = true\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (e?.status === 404) {\n tries++\n if (tries > 100) {\n throw e\n }\n await new Promise<void>((resolve) => setTimeout(resolve, 200))\n } else {\n throw e\n }\n }\n }\n\n return result as T\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;AAUG;AACI,eAAe,sBAAsB,CAAI,GAAqB,EAAA;IACnE,IAAI,MAAM,GAAa,IAAI;IAC3B,IAAI,EAAE,GAAG,KAAK;IACd,IAAI,KAAK,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,EAAE;AACV,QAAA,IAAI;AACF,YAAA,MAAM,GAAG,MAAM,GAAG,EAAE;YACpB,EAAE,GAAG,IAAI;;;QAET,OAAO,CAAM,EAAE;AACf,YAAA,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,EAAE;AACrB,gBAAA,KAAK,EAAE;AACP,gBAAA,IAAI,KAAK,GAAG,GAAG,EAAE;AACf,oBAAA,MAAM,CAAC;;AAET,gBAAA,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;;iBACzD;AACL,gBAAA,MAAM,CAAC;;;;AAKb,IAAA,OAAO,MAAW;AACpB;;;;"}
1
+ {"version":3,"file":"indexer.js","names":[],"sources":["../../src/testing/indexer.ts"],"sourcesContent":["/**\n * Runs the given indexer call until a 404 error is no longer returned.\n * Tried every 200ms up to 100 times.\n * Very rudimentary implementation designed for automated testing.\n * @example\n * ```typescript\n * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())\n * ```\n * @param run The code to run\n * @returns The result (as a promise), or throws if the indexer didn't catch up in time\n */\nexport async function runWhenIndexerCaughtUp<T>(run: () => Promise<T>): Promise<T> {\n let result: T | null = null\n let ok = false\n let tries = 0\n while (!ok) {\n try {\n result = await run()\n ok = true\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (e?.status === 404) {\n tries++\n if (tries > 100) {\n throw e\n }\n await new Promise<void>((resolve) => setTimeout(resolve, 200))\n } else {\n throw e\n }\n }\n }\n\n return result as T\n}\n"],"mappings":";;;;;;;;;;;;AAWA,eAAsB,uBAA0B,KAAmC;CACjF,IAAI,SAAmB;CACvB,IAAI,KAAK;CACT,IAAI,QAAQ;CACZ,OAAO,CAAC,IACN,IAAI;EACF,SAAS,MAAM,IAAI;EACnB,KAAK;CAEP,SAAS,GAAQ;EACf,IAAI,GAAG,WAAW,KAAK;GACrB;GACA,IAAI,QAAQ,KACV,MAAM;GAER,MAAM,IAAI,SAAe,YAAY,WAAW,SAAS,GAAG,CAAC;EAC/D,OACE,MAAM;CAEV;CAGF,OAAO;AACT"}
@@ -1,39 +1,32 @@
1
+ //#region src/testing/indexer.ts
1
2
  /**
2
- * Runs the given indexer call until a 404 error is no longer returned.
3
- * Tried every 200ms up to 100 times.
4
- * Very rudimentary implementation designed for automated testing.
5
- * @example
6
- * ```typescript
7
- * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())
8
- * ```
9
- * @param run The code to run
10
- * @returns The result (as a promise), or throws if the indexer didn't catch up in time
11
- */
3
+ * Runs the given indexer call until a 404 error is no longer returned.
4
+ * Tried every 200ms up to 100 times.
5
+ * Very rudimentary implementation designed for automated testing.
6
+ * @example
7
+ * ```typescript
8
+ * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())
9
+ * ```
10
+ * @param run The code to run
11
+ * @returns The result (as a promise), or throws if the indexer didn't catch up in time
12
+ */
12
13
  async function runWhenIndexerCaughtUp(run) {
13
- let result = null;
14
- let ok = false;
15
- let tries = 0;
16
- while (!ok) {
17
- try {
18
- result = await run();
19
- ok = true;
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- }
22
- catch (e) {
23
- if (e?.status === 404) {
24
- tries++;
25
- if (tries > 100) {
26
- throw e;
27
- }
28
- await new Promise((resolve) => setTimeout(resolve, 200));
29
- }
30
- else {
31
- throw e;
32
- }
33
- }
34
- }
35
- return result;
14
+ let result = null;
15
+ let ok = false;
16
+ let tries = 0;
17
+ while (!ok) try {
18
+ result = await run();
19
+ ok = true;
20
+ } catch (e) {
21
+ if (e?.status === 404) {
22
+ tries++;
23
+ if (tries > 100) throw e;
24
+ await new Promise((resolve) => setTimeout(resolve, 200));
25
+ } else throw e;
26
+ }
27
+ return result;
36
28
  }
37
-
29
+ //#endregion
38
30
  export { runWhenIndexerCaughtUp };
39
- //# sourceMappingURL=indexer.mjs.map
31
+
32
+ //# sourceMappingURL=indexer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"indexer.mjs","sources":["../../src/testing/indexer.ts"],"sourcesContent":["/**\n * Runs the given indexer call until a 404 error is no longer returned.\n * Tried every 200ms up to 100 times.\n * Very rudimentary implementation designed for automated testing.\n * @example\n * ```typescript\n * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())\n * ```\n * @param run The code to run\n * @returns The result (as a promise), or throws if the indexer didn't catch up in time\n */\nexport async function runWhenIndexerCaughtUp<T>(run: () => Promise<T>): Promise<T> {\n let result: T | null = null\n let ok = false\n let tries = 0\n while (!ok) {\n try {\n result = await run()\n ok = true\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (e?.status === 404) {\n tries++\n if (tries > 100) {\n throw e\n }\n await new Promise<void>((resolve) => setTimeout(resolve, 200))\n } else {\n throw e\n }\n }\n }\n\n return result as T\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AACI,eAAe,sBAAsB,CAAI,GAAqB,EAAA;IACnE,IAAI,MAAM,GAAa,IAAI;IAC3B,IAAI,EAAE,GAAG,KAAK;IACd,IAAI,KAAK,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,EAAE;AACV,QAAA,IAAI;AACF,YAAA,MAAM,GAAG,MAAM,GAAG,EAAE;YACpB,EAAE,GAAG,IAAI;;;QAET,OAAO,CAAM,EAAE;AACf,YAAA,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,EAAE;AACrB,gBAAA,KAAK,EAAE;AACP,gBAAA,IAAI,KAAK,GAAG,GAAG,EAAE;AACf,oBAAA,MAAM,CAAC;;AAET,gBAAA,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;;iBACzD;AACL,gBAAA,MAAM,CAAC;;;;AAKb,IAAA,OAAO,MAAW;AACpB;;;;"}
1
+ {"version":3,"file":"indexer.mjs","names":[],"sources":["../../src/testing/indexer.ts"],"sourcesContent":["/**\n * Runs the given indexer call until a 404 error is no longer returned.\n * Tried every 200ms up to 100 times.\n * Very rudimentary implementation designed for automated testing.\n * @example\n * ```typescript\n * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())\n * ```\n * @param run The code to run\n * @returns The result (as a promise), or throws if the indexer didn't catch up in time\n */\nexport async function runWhenIndexerCaughtUp<T>(run: () => Promise<T>): Promise<T> {\n let result: T | null = null\n let ok = false\n let tries = 0\n while (!ok) {\n try {\n result = await run()\n ok = true\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (e?.status === 404) {\n tries++\n if (tries > 100) {\n throw e\n }\n await new Promise<void>((resolve) => setTimeout(resolve, 200))\n } else {\n throw e\n }\n }\n }\n\n return result as T\n}\n"],"mappings":";;;;;;;;;;;;AAWA,eAAsB,uBAA0B,KAAmC;CACjF,IAAI,SAAmB;CACvB,IAAI,KAAK;CACT,IAAI,QAAQ;CACZ,OAAO,CAAC,IACN,IAAI;EACF,SAAS,MAAM,IAAI;EACnB,KAAK;CAEP,SAAS,GAAQ;EACf,IAAI,GAAG,WAAW,KAAK;GACrB;GACA,IAAI,QAAQ,KACV,MAAM;GAER,MAAM,IAAI,SAAe,YAAY,WAAW,SAAS,GAAG,CAAC;EAC/D,OACE,MAAM;CAEV;CAGF,OAAO;AACT"}