@algorandfoundation/algokit-utils 1.0.0-beta.4 → 1.0.0-beta.40

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 (188) hide show
  1. package/README.md +9 -2
  2. package/{dist/account.d.ts → account.d.ts} +41 -36
  3. package/account.d.ts.map +1 -0
  4. package/{dist/account.js → account.js} +59 -44
  5. package/account.js.map +1 -0
  6. package/amount.d.ts +20 -0
  7. package/amount.d.ts.map +1 -0
  8. package/amount.js +36 -0
  9. package/amount.js.map +1 -0
  10. package/app-client.d.ts +14 -0
  11. package/app-client.d.ts.map +1 -0
  12. package/app-client.js +19 -0
  13. package/app-client.js.map +1 -0
  14. package/app-deploy.d.ts +95 -0
  15. package/app-deploy.d.ts.map +1 -0
  16. package/{dist/deploy-app.js → app-deploy.js} +158 -121
  17. package/app-deploy.js.map +1 -0
  18. package/app.d.ts +153 -0
  19. package/app.d.ts.map +1 -0
  20. package/app.js +582 -0
  21. package/app.js.map +1 -0
  22. package/index.d.ts +14 -0
  23. package/index.d.ts.map +1 -0
  24. package/{dist/index.js → index.js} +7 -3
  25. package/index.js.map +1 -0
  26. package/{dist/indexer-lookup.d.ts → indexer-lookup.d.ts} +11 -4
  27. package/indexer-lookup.d.ts.map +1 -0
  28. package/{dist/indexer-lookup.js → indexer-lookup.js} +19 -9
  29. package/indexer-lookup.js.map +1 -0
  30. package/{dist/localnet.d.ts → localnet.d.ts} +10 -10
  31. package/localnet.d.ts.map +1 -0
  32. package/{dist/localnet.js → localnet.js} +16 -16
  33. package/localnet.js.map +1 -0
  34. package/{dist/network-client.d.ts → network-client.d.ts} +15 -24
  35. package/network-client.d.ts.map +1 -0
  36. package/{dist/network-client.js → network-client.js} +16 -16
  37. package/{dist/network-client.js.map → network-client.js.map} +1 -1
  38. package/package.json +5 -93
  39. package/testing/account.d.ts +14 -0
  40. package/testing/account.d.ts.map +1 -0
  41. package/testing/account.js +31 -0
  42. package/testing/account.js.map +1 -0
  43. package/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
  44. package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
  45. package/testing/fixtures/algokit-log-capture-fixture.js +43 -0
  46. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
  47. package/testing/fixtures/algorand-fixture.d.ts +24 -0
  48. package/testing/fixtures/algorand-fixture.d.ts.map +1 -0
  49. package/testing/fixtures/algorand-fixture.js +60 -0
  50. package/testing/fixtures/algorand-fixture.js.map +1 -0
  51. package/testing/fixtures/index.d.ts +3 -0
  52. package/testing/fixtures/index.d.ts.map +1 -0
  53. package/testing/fixtures/index.js +19 -0
  54. package/testing/fixtures/index.js.map +1 -0
  55. package/testing/index.d.ts +6 -0
  56. package/testing/index.d.ts.map +1 -0
  57. package/testing/index.js +22 -0
  58. package/testing/index.js.map +1 -0
  59. package/testing/indexer.d.ts +12 -0
  60. package/testing/indexer.d.ts.map +1 -0
  61. package/testing/indexer.js +40 -0
  62. package/testing/indexer.js.map +1 -0
  63. package/testing/test-logger.d.ts +41 -0
  64. package/testing/test-logger.d.ts.map +1 -0
  65. package/testing/test-logger.js +71 -0
  66. package/testing/test-logger.js.map +1 -0
  67. package/testing/transaction-logger.d.ts +29 -0
  68. package/testing/transaction-logger.d.ts.map +1 -0
  69. package/testing/transaction-logger.js +71 -0
  70. package/testing/transaction-logger.js.map +1 -0
  71. package/transaction.d.ts +121 -0
  72. package/transaction.d.ts.map +1 -0
  73. package/transaction.js +364 -0
  74. package/transaction.js.map +1 -0
  75. package/transfer.d.ts +22 -0
  76. package/transfer.d.ts.map +1 -0
  77. package/transfer.js +67 -0
  78. package/transfer.js.map +1 -0
  79. package/types/account.d.ts +55 -0
  80. package/types/account.d.ts.map +1 -0
  81. package/types/account.js +91 -0
  82. package/types/account.js.map +1 -0
  83. package/types/algo-http-client-with-retry.d.ts.map +1 -0
  84. package/{dist → types}/algo-http-client-with-retry.js +2 -2
  85. package/types/algo-http-client-with-retry.js.map +1 -0
  86. package/{dist/types → types}/algod.d.ts +28 -15
  87. package/types/algod.d.ts.map +1 -0
  88. package/{dist/algo-amount.d.ts → types/amount.d.ts} +9 -3
  89. package/types/amount.d.ts.map +1 -0
  90. package/{dist/algo-amount.js → types/amount.js} +13 -3
  91. package/types/amount.js.map +1 -0
  92. package/types/app-client.d.ts +282 -0
  93. package/types/app-client.d.ts.map +1 -0
  94. package/types/app-client.js +529 -0
  95. package/types/app-client.js.map +1 -0
  96. package/types/app-spec.d.ts +141 -0
  97. package/types/app-spec.d.ts.map +1 -0
  98. package/{dist/types/appspec.js → types/app-spec.js} +5 -7
  99. package/types/app-spec.js.map +1 -0
  100. package/types/app.d.ts +285 -0
  101. package/types/app.d.ts.map +1 -0
  102. package/types/app.js +32 -0
  103. package/types/app.js.map +1 -0
  104. package/types/config.d.ts +32 -0
  105. package/types/config.d.ts.map +1 -0
  106. package/types/config.js +53 -0
  107. package/types/config.js.map +1 -0
  108. package/types/indexer.d.ts +624 -0
  109. package/types/indexer.d.ts.map +1 -0
  110. package/{dist/types → types}/indexer.js +9 -0
  111. package/types/indexer.js.map +1 -0
  112. package/{dist/config.d.ts → types/logging.d.ts} +2 -16
  113. package/types/logging.d.ts.map +1 -0
  114. package/{dist/config.js → types/logging.js} +5 -24
  115. package/types/logging.js.map +1 -0
  116. package/types/logic-error.d.ts +37 -0
  117. package/types/logic-error.d.ts.map +1 -0
  118. package/types/logic-error.js +50 -0
  119. package/types/logic-error.js.map +1 -0
  120. package/types/network-client.d.ts +11 -0
  121. package/types/network-client.d.ts.map +1 -0
  122. package/types/network-client.js +3 -0
  123. package/types/network-client.js.map +1 -0
  124. package/types/testing.d.ts +89 -0
  125. package/types/testing.d.ts.map +1 -0
  126. package/types/testing.js +3 -0
  127. package/types/testing.js.map +1 -0
  128. package/types/transaction.d.ts +112 -0
  129. package/types/transaction.d.ts.map +1 -0
  130. package/types/transaction.js +3 -0
  131. package/types/transaction.js.map +1 -0
  132. package/types/transfer.d.ts +32 -0
  133. package/types/transfer.d.ts.map +1 -0
  134. package/types/transfer.js +3 -0
  135. package/types/transfer.js.map +1 -0
  136. package/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
  137. package/types/urlTokenBaseHTTPClient.js.map +1 -0
  138. package/LICENSE +0 -21
  139. package/dist/account.d.ts.map +0 -1
  140. package/dist/account.js.map +0 -1
  141. package/dist/algo-amount.d.ts.map +0 -1
  142. package/dist/algo-amount.js.map +0 -1
  143. package/dist/algo-http-client-with-retry.d.ts.map +0 -1
  144. package/dist/algo-http-client-with-retry.js.map +0 -1
  145. package/dist/app.d.ts +0 -150
  146. package/dist/app.d.ts.map +0 -1
  147. package/dist/app.js +0 -156
  148. package/dist/app.js.map +0 -1
  149. package/dist/application-client.d.ts +0 -71
  150. package/dist/application-client.d.ts.map +0 -1
  151. package/dist/application-client.js +0 -145
  152. package/dist/application-client.js.map +0 -1
  153. package/dist/config.d.ts.map +0 -1
  154. package/dist/config.js.map +0 -1
  155. package/dist/deploy-app.d.ts +0 -149
  156. package/dist/deploy-app.d.ts.map +0 -1
  157. package/dist/deploy-app.js.map +0 -1
  158. package/dist/index.d.ts +0 -11
  159. package/dist/index.d.ts.map +0 -1
  160. package/dist/index.js.map +0 -1
  161. package/dist/indexer-lookup.d.ts.map +0 -1
  162. package/dist/indexer-lookup.js.map +0 -1
  163. package/dist/localnet.d.ts.map +0 -1
  164. package/dist/localnet.js.map +0 -1
  165. package/dist/network-client.d.ts.map +0 -1
  166. package/dist/package.json +0 -20
  167. package/dist/transaction.d.ts +0 -152
  168. package/dist/transaction.d.ts.map +0 -1
  169. package/dist/transaction.js +0 -268
  170. package/dist/transaction.js.map +0 -1
  171. package/dist/transfer.d.ts +0 -24
  172. package/dist/transfer.d.ts.map +0 -1
  173. package/dist/transfer.js +0 -33
  174. package/dist/transfer.js.map +0 -1
  175. package/dist/types/algod.d.ts.map +0 -1
  176. package/dist/types/appspec.d.ts +0 -79
  177. package/dist/types/appspec.d.ts.map +0 -1
  178. package/dist/types/appspec.js.map +0 -1
  179. package/dist/types/indexer.d.ts +0 -314
  180. package/dist/types/indexer.d.ts.map +0 -1
  181. package/dist/types/indexer.js.map +0 -1
  182. package/dist/urlTokenBaseHTTPClient.d.ts.map +0 -1
  183. package/dist/urlTokenBaseHTTPClient.js.map +0 -1
  184. /package/{dist → types}/algo-http-client-with-retry.d.ts +0 -0
  185. /package/{dist/types → types}/algod.js +0 -0
  186. /package/{dist/types → types}/algod.js.map +0 -0
  187. /package/{dist → types}/urlTokenBaseHTTPClient.d.ts +0 -0
  188. /package/{dist → types}/urlTokenBaseHTTPClient.js +0 -0
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getTestAccount = void 0;
7
+ const algosdk_1 = __importDefault(require("algosdk"));
8
+ const __1 = require("../");
9
+ const account_1 = require("../account");
10
+ const transfer_1 = require("../transfer");
11
+ /**
12
+ * Creates an ephemeral Algorand account for the purposes of testing.
13
+ * Returns a newly created random test account that is funded from the dispenser
14
+ * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
15
+ * Note: By default this will log the mnemonic of the account.
16
+ * @param param0 The config for the test account to generate
17
+ * @param algod An algod client
18
+ * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables
19
+ * @returns The account, with private key loaded
20
+ */
21
+ async function getTestAccount({ suppressLog, initialFunds }, algod, kmd) {
22
+ const account = algosdk_1.default.generateAccount();
23
+ __1.Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}' and mnemonic '${algosdk_1.default.secretKeyToMnemonic(account.sk)}'.`);
24
+ const dispenser = await (0, account_1.getDispenserAccount)(algod, kmd);
25
+ await (0, transfer_1.transferAlgos)({ from: dispenser, to: account.addr, amount: initialFunds, note: 'Funding test account', suppressLog }, algod);
26
+ const accountInfo = await algod.accountInformation(account.addr).do();
27
+ __1.Config.getLogger(suppressLog).info('Test account funded; account balance: %d µAlgos', accountInfo.amount);
28
+ return account;
29
+ }
30
+ exports.getTestAccount = getTestAccount;
31
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/testing/account.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwD;AACxD,2BAA4B;AAC5B,wCAAgD;AAChD,0CAA2C;AAG3C;;;;;;;;;GASG;AACI,KAAK,UAAU,cAAc,CAAC,EAAE,WAAW,EAAE,YAAY,EAAwB,EAAE,KAAc,EAAE,GAAS;IACjH,MAAM,OAAO,GAAG,iBAAO,CAAC,eAAe,EAAE,CAAA;IAEzC,UAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAChC,0CAA0C,OAAO,CAAC,IAAI,mBAAmB,iBAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CACrH,CAAA;IAED,MAAM,SAAS,GAAG,MAAM,IAAA,6BAAmB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAEvD,MAAM,IAAA,wBAAa,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,sBAAsB,EAAE,WAAW,EAAE,EAAE,KAAK,CAAC,CAAA;IAElI,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAA;IAErE,UAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,iDAAiD,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAEzG,OAAO,OAAO,CAAA;AAChB,CAAC;AAhBD,wCAgBC"}
@@ -0,0 +1,19 @@
1
+ import { AlgoKitLogCaptureFixture } from '../../types/testing';
2
+ /**
3
+ * Creates a test fixture for capturing AlgoKit logs.
4
+ *
5
+ * @example ```typescript
6
+ * const logs = algoKitLogCaptureFixture()
7
+ *
8
+ * beforeEach(logs.beforeEach)
9
+ * afterEach(logs.afterEach)
10
+ *
11
+ * test('My test', () => {
12
+ * const capturedLogs = logs.testLogger.capturedLogs
13
+ * })
14
+ * ```
15
+ *
16
+ * @returns The fixture
17
+ */
18
+ export declare const algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture;
19
+ //# sourceMappingURL=algokit-log-capture-fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algokit-log-capture-fixture.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAG9D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,wBAqB5C,CAAA"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.algoKitLogCaptureFixture = void 0;
4
+ const __1 = require("../../");
5
+ const test_logger_1 = require("../test-logger");
6
+ /**
7
+ * Creates a test fixture for capturing AlgoKit logs.
8
+ *
9
+ * @example ```typescript
10
+ * const logs = algoKitLogCaptureFixture()
11
+ *
12
+ * beforeEach(logs.beforeEach)
13
+ * afterEach(logs.afterEach)
14
+ *
15
+ * test('My test', () => {
16
+ * const capturedLogs = logs.testLogger.capturedLogs
17
+ * })
18
+ * ```
19
+ *
20
+ * @returns The fixture
21
+ */
22
+ const algoKitLogCaptureFixture = () => {
23
+ const originalLogger = __1.Config.logger;
24
+ let hybridLogger;
25
+ return {
26
+ get testLogger() {
27
+ return hybridLogger;
28
+ },
29
+ beforeEach: () => {
30
+ hybridLogger = new test_logger_1.TestLogger(originalLogger);
31
+ __1.Config.configure({
32
+ logger: hybridLogger,
33
+ });
34
+ },
35
+ afterEach: () => {
36
+ __1.Config.configure({
37
+ logger: originalLogger,
38
+ });
39
+ },
40
+ };
41
+ };
42
+ exports.algoKitLogCaptureFixture = algoKitLogCaptureFixture;
43
+ //# sourceMappingURL=algokit-log-capture-fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algokit-log-capture-fixture.js","sourceRoot":"","sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"names":[],"mappings":";;;AAAA,8BAA+B;AAE/B,gDAA2C;AAE3C;;;;;;;;;;;;;;;GAeG;AACI,MAAM,wBAAwB,GAAmC,GAAG,EAAE;IAC3E,MAAM,cAAc,GAAG,UAAM,CAAC,MAAM,CAAA;IAEpC,IAAI,YAAwB,CAAA;IAE5B,OAAO;QACL,IAAI,UAAU;YACZ,OAAO,YAAY,CAAA;QACrB,CAAC;QACD,UAAU,EAAE,GAAG,EAAE;YACf,YAAY,GAAG,IAAI,wBAAU,CAAC,cAAc,CAAC,CAAA;YAC7C,UAAM,CAAC,SAAS,CAAC;gBACf,MAAM,EAAE,YAAY;aACrB,CAAC,CAAA;QACJ,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,UAAM,CAAC,SAAS,CAAC;gBACf,MAAM,EAAE,cAAc;aACvB,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AArBY,QAAA,wBAAwB,4BAqBpC"}
@@ -0,0 +1,24 @@
1
+ import { AlgorandFixture, AlgorandFixtureConfig } from '../../types/testing';
2
+ /**
3
+ * Creates a test fixture for automated testing against Algorand.
4
+ * By default it tests against an environment variable specified client
5
+ * if the standard environment variables are specified, otherwise against
6
+ * a default LocalNet instance, but you can pass in an algod, indexer
7
+ * and/or kmd if you want to test against an explicitly defined network.
8
+ *
9
+ * @example ```typescript
10
+ * const algorand = algorandFixture()
11
+ *
12
+ * beforeEach(algorand.beforeEach, 10_000)
13
+ *
14
+ * test('My test', async () => {
15
+ * const {algod, indexer, testAccount, ...} = algorand.context
16
+ * // test things...
17
+ * })
18
+ * ```
19
+ *
20
+ * @param fixtureConfig The fixture configuration
21
+ * @returns The fixture
22
+ */
23
+ export declare const algorandFixture: (fixtureConfig?: AlgorandFixtureConfig) => AlgorandFixture;
24
+ //# sourceMappingURL=algorand-fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algorand-fixture.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAuD,MAAM,qBAAqB,CAAA;AAEjI;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,mBAAoB,qBAAqB,KAAG,eAyCvE,CAAA"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.algorandFixture = void 0;
4
+ const __1 = require("../");
5
+ const __2 = require("../../");
6
+ /**
7
+ * Creates a test fixture for automated testing against Algorand.
8
+ * By default it tests against an environment variable specified client
9
+ * if the standard environment variables are specified, otherwise against
10
+ * a default LocalNet instance, but you can pass in an algod, indexer
11
+ * and/or kmd if you want to test against an explicitly defined network.
12
+ *
13
+ * @example ```typescript
14
+ * const algorand = algorandFixture()
15
+ *
16
+ * beforeEach(algorand.beforeEach, 10_000)
17
+ *
18
+ * test('My test', async () => {
19
+ * const {algod, indexer, testAccount, ...} = algorand.context
20
+ * // test things...
21
+ * })
22
+ * ```
23
+ *
24
+ * @param fixtureConfig The fixture configuration
25
+ * @returns The fixture
26
+ */
27
+ const algorandFixture = (fixtureConfig) => {
28
+ const algodConfig = process && process.env && process.env.ALGOD_SERVER ? (0, __2.getAlgodConfigFromEnvironment)() : (0, __2.getDefaultLocalNetConfig)('algod');
29
+ const indexerConfig = process && process.env && process.env.INDEXER_SERVER ? (0, __2.getIndexerConfigFromEnvironment)() : (0, __2.getDefaultLocalNetConfig)('indexer');
30
+ const kmdConfig = process && process.env && process.env.ALGOD_SERVER
31
+ ? { ...algodConfig, port: process?.env?.KMD_PORT ?? '4002' }
32
+ : (0, __2.getDefaultLocalNetConfig)('kmd');
33
+ const algod = fixtureConfig?.algod ?? (0, __2.getAlgoClient)(algodConfig);
34
+ const indexer = fixtureConfig?.indexer ?? (0, __2.getAlgoIndexerClient)(indexerConfig);
35
+ const kmd = fixtureConfig?.kmd ?? (0, __2.getAlgoKmdClient)(kmdConfig);
36
+ let context;
37
+ const beforeEach = async () => {
38
+ __2.Config.configure({ debug: true });
39
+ const transactionLogger = new __1.TransactionLogger();
40
+ const transactionLoggerAlgod = transactionLogger.capture(algod);
41
+ context = {
42
+ algod: transactionLoggerAlgod,
43
+ indexer: indexer,
44
+ kmd: kmd,
45
+ testAccount: await (0, __1.getTestAccount)({ initialFunds: fixtureConfig?.testAccountFunding ?? (0, __2.algos)(10), suppressLog: true }, transactionLoggerAlgod, kmd),
46
+ generateAccount: (params) => (0, __1.getTestAccount)(params, transactionLoggerAlgod, kmd),
47
+ transactionLogger: transactionLogger,
48
+ waitForIndexer: () => transactionLogger.waitForIndexer(indexer),
49
+ waitForIndexerTransaction: (transactionId) => (0, __1.runWhenIndexerCaughtUp)(() => (0, __2.lookupTransactionById)(transactionId, indexer)),
50
+ };
51
+ };
52
+ return {
53
+ get context() {
54
+ return context;
55
+ },
56
+ beforeEach,
57
+ };
58
+ };
59
+ exports.algorandFixture = algorandFixture;
60
+ //# sourceMappingURL=algorand-fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algorand-fixture.js","sourceRoot":"","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"names":[],"mappings":";;;AAAA,2BAA+E;AAC/E,8BAUe;AAIf;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,eAAe,GAAG,CAAC,aAAqC,EAAmB,EAAE;IACxF,MAAM,WAAW,GACf,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAA,iCAA6B,GAAE,CAAC,CAAC,CAAC,IAAA,4BAAwB,EAAC,OAAO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,EACtB,GAAG,CACJ;YACD,eAAe,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,IAAA,kBAAc,EAAC,MAAM,EAAE,sBAAsB,EAAE,GAAG,CAAC;YACtG,iBAAiB,EAAE,iBAAiB;YACpC,cAAc,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,OAAO,CAAC;YAC/D,yBAAyB,EAAE,CAAC,aAAqB,EAAE,EAAE,CAAC,IAAA,0BAAsB,EAAC,GAAG,EAAE,CAAC,IAAA,yBAAqB,EAAC,aAAa,EAAE,OAAO,CAAC,CAAC;SAClI,CAAA;IACH,CAAC,CAAA;IAED,OAAO;QACL,IAAI,OAAO;YACT,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,UAAU;KACX,CAAA;AACH,CAAC,CAAA;AAzCY,QAAA,eAAe,mBAyC3B"}
@@ -0,0 +1,3 @@
1
+ export * from './algokit-log-capture-fixture';
2
+ export * from './algorand-fixture';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,oBAAoB,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./algokit-log-capture-fixture"), exports);
18
+ __exportStar(require("./algorand-fixture"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/fixtures/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA6C;AAC7C,qDAAkC"}
@@ -0,0 +1,6 @@
1
+ export * from './account';
2
+ export * from './fixtures';
3
+ export * from './indexer';
4
+ export * from './test-logger';
5
+ export * from './transaction-logger';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./account"), exports);
18
+ __exportStar(require("./fixtures"), exports);
19
+ __exportStar(require("./indexer"), exports);
20
+ __exportStar(require("./test-logger"), exports);
21
+ __exportStar(require("./transaction-logger"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,6CAA0B;AAC1B,4CAAyB;AACzB,gDAA6B;AAC7B,uDAAoC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Runs the given indexer call until a 404 error is no longer returned.
3
+ * Tried every 200ms up to 20 times.
4
+ * Very rudimentary implementation designed for automated testing.
5
+ * @example ```typescript
6
+ * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())
7
+ * ```
8
+ * @param run The code to run
9
+ * @returns The result (as a promise), or throws if the indexer didn't catch up in time
10
+ */
11
+ export declare function runWhenIndexerCaughtUp<T>(run: () => Promise<T>): Promise<T>;
12
+ //# sourceMappingURL=indexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../src/testing/indexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAuBjF"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runWhenIndexerCaughtUp = void 0;
4
+ /**
5
+ * Runs the given indexer call until a 404 error is no longer returned.
6
+ * Tried every 200ms up to 20 times.
7
+ * Very rudimentary implementation designed for automated testing.
8
+ * @example ```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
+ */
14
+ 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 > 20) {
28
+ throw e;
29
+ }
30
+ await new Promise((resolve) => setTimeout(resolve, 200));
31
+ }
32
+ else {
33
+ throw e;
34
+ }
35
+ }
36
+ }
37
+ return result;
38
+ }
39
+ exports.runWhenIndexerCaughtUp = runWhenIndexerCaughtUp;
40
+ //# sourceMappingURL=indexer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../src/testing/indexer.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACI,KAAK,UAAU,sBAAsB,CAAI,GAAqB;IACnE,IAAI,MAAM,GAAa,IAAI,CAAA;IAC3B,IAAI,EAAE,GAAG,KAAK,CAAA;IACd,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,EAAE;QACV,IAAI;YACF,MAAM,GAAG,MAAM,GAAG,EAAE,CAAA;YACpB,EAAE,GAAG,IAAI,CAAA;YACT,8DAA8D;SAC/D;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,EAAE;gBACrB,KAAK,EAAE,CAAA;gBACP,IAAI,KAAK,GAAG,EAAE,EAAE;oBACd,MAAM,CAAC,CAAA;iBACR;gBACD,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;aAC/D;iBAAM;gBACL,MAAM,CAAC,CAAA;aACR;SACF;KACF;IAED,OAAO,MAAW,CAAA;AACpB,CAAC;AAvBD,wDAuBC"}
@@ -0,0 +1,41 @@
1
+ import { Logger } from '../types/logging';
2
+ import { LogSnapshotConfig } from '../types/testing';
3
+ /** Exposes an AlgoKit logger which captures log messages, while wrapping an original logger.
4
+ * This is useful for automated testing.
5
+ */
6
+ export declare class TestLogger implements Logger {
7
+ private originalLogger;
8
+ private logs;
9
+ /**
10
+ * Create a new test logger that wraps the given logger if provided.
11
+ * @param originalLogger The optional original logger to wrap.
12
+ */
13
+ constructor(originalLogger?: Logger);
14
+ /** Returns all logs captured thus far. */
15
+ get capturedLogs(): string[];
16
+ /** Clears all logs captured so far. */
17
+ clear(): void;
18
+ /**
19
+ * Returns a captured log snapshot.
20
+ * This helps ensure that the provided configuration items won't appear
21
+ * with random values in the log snapshot, but rather will get substituted with predictable ids.
22
+ *
23
+ * https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic
24
+ *
25
+ * @example Jest Example
26
+ * ```typescript
27
+ * const logger = new TestLogger()
28
+ * ...
29
+ * expect(logger.getLogSnapshot()).toMatchSnapshot()
30
+ * ```
31
+ * @param config The snapshot configuration
32
+ * @returns The snapshotted logs.
33
+ */
34
+ getLogSnapshot(config?: LogSnapshotConfig): string;
35
+ error(message: string, ...optionalParams: unknown[]): void;
36
+ warn(message: string, ...optionalParams: unknown[]): void;
37
+ info(message: string, ...optionalParams: unknown[]): void;
38
+ verbose(message: string, ...optionalParams: unknown[]): void;
39
+ debug(message: string, ...optionalParams: unknown[]): void;
40
+ }
41
+ //# sourceMappingURL=test-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-logger.d.ts","sourceRoot":"","sources":["../../src/testing/test-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;GAEG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,OAAO,CAAC,cAAc,CAAoB;IAC1C,OAAO,CAAC,IAAI,CAAU;IAEtB;;;OAGG;gBACS,cAAc,CAAC,EAAE,MAAM;IAKnC,0CAA0C;IAC1C,IAAI,YAAY,IAAI,MAAM,EAAE,CAE3B;IAED,uCAAuC;IACvC,KAAK;IAIL;;;;;;;;;;;;;;;OAeG;IACH,cAAc,CAAC,MAAM,CAAC,EAAE,iBAAiB;IAczC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAI1D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAIzD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAIzD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAI5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;CAI3D"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TestLogger = void 0;
4
+ const __1 = require("../");
5
+ /** Exposes an AlgoKit logger which captures log messages, while wrapping an original logger.
6
+ * This is useful for automated testing.
7
+ */
8
+ class TestLogger {
9
+ /**
10
+ * Create a new test logger that wraps the given logger if provided.
11
+ * @param originalLogger The optional original logger to wrap.
12
+ */
13
+ constructor(originalLogger) {
14
+ this.originalLogger = originalLogger;
15
+ this.logs = [];
16
+ }
17
+ /** Returns all logs captured thus far. */
18
+ get capturedLogs() {
19
+ return this.logs;
20
+ }
21
+ /** Clears all logs captured so far. */
22
+ clear() {
23
+ this.logs = [];
24
+ }
25
+ /**
26
+ * Returns a captured log snapshot.
27
+ * This helps ensure that the provided configuration items won't appear
28
+ * with random values in the log snapshot, but rather will get substituted with predictable ids.
29
+ *
30
+ * https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic
31
+ *
32
+ * @example Jest Example
33
+ * ```typescript
34
+ * const logger = new TestLogger()
35
+ * ...
36
+ * expect(logger.getLogSnapshot()).toMatchSnapshot()
37
+ * ```
38
+ * @param config The snapshot configuration
39
+ * @returns The snapshotted logs.
40
+ */
41
+ getLogSnapshot(config) {
42
+ const { transactions: transactionIds, accounts, apps } = config ?? {};
43
+ let snapshot = this.capturedLogs.join('\n');
44
+ transactionIds?.forEach((txn, id) => (snapshot = snapshot.replace(new RegExp(typeof txn === 'string' ? txn : txn.txID(), 'g'), `TXID_${id + 1}`)));
45
+ accounts?.forEach((sender, id) => (snapshot = snapshot.replace(new RegExp(typeof sender === 'string' ? sender : (0, __1.getSenderAddress)(sender), 'g'), `ACCOUNT_${id + 1}`)));
46
+ apps?.forEach((app, id) => (snapshot = snapshot.replace(new RegExp(`\\b${app.toString()}\\b(?! bytes)`, 'g'), `APP_${id + 1}`)));
47
+ return snapshot;
48
+ }
49
+ error(message, ...optionalParams) {
50
+ this.originalLogger?.error(message, ...optionalParams);
51
+ this.logs.push(`ERROR: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
52
+ }
53
+ warn(message, ...optionalParams) {
54
+ this.originalLogger?.warn(message, ...optionalParams);
55
+ this.logs.push(`WARN: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
56
+ }
57
+ info(message, ...optionalParams) {
58
+ this.originalLogger?.info(message, ...optionalParams);
59
+ this.logs.push(`INFO: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
60
+ }
61
+ verbose(message, ...optionalParams) {
62
+ this.originalLogger?.verbose(message, ...optionalParams);
63
+ this.logs.push(`VERBOSE: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
64
+ }
65
+ debug(message, ...optionalParams) {
66
+ this.originalLogger?.debug(message, ...optionalParams);
67
+ this.logs.push(`DEBUG: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
68
+ }
69
+ }
70
+ exports.TestLogger = TestLogger;
71
+ //# sourceMappingURL=test-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-logger.js","sourceRoot":"","sources":["../../src/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O,CAAC,OAAe,EAAE,GAAG,cAAyB;QACnD,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;QACxD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC7G,CAAC;IACD,KAAK,CAAC,OAAe,EAAE,GAAG,cAAyB;QACjD,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;QACtD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC3G,CAAC;CACF;AAzED,gCAyEC"}
@@ -0,0 +1,29 @@
1
+ import { Algodv2, Indexer } from 'algosdk';
2
+ /**
3
+ * Allows you to keep track of Algorand transaction IDs by wrapping an `Algodv2` in a proxy.
4
+ * Useful for automated tests.
5
+ */
6
+ export declare class TransactionLogger {
7
+ private _sentTransactionIds;
8
+ /**
9
+ * The list of transaction IDs that has been logged thus far.
10
+ */
11
+ get sentTransactionIds(): Readonly<string[]>;
12
+ /**
13
+ * Clear all logged IDs.
14
+ */
15
+ clear(): void;
16
+ /**
17
+ * The method that captures raw transactions and stores the transaction IDs.
18
+ */
19
+ logRawTransaction(signedTransactions: Uint8Array | Uint8Array[]): void;
20
+ /** Return a proxy that wraps the given Algodv2 with this transaction logger.
21
+ *
22
+ * @param algod The `Algodv2` to wrap
23
+ * @returns The wrapped `Algodv2`, any transactions sent using this algod instance will be logged by this transaction logger
24
+ */
25
+ capture(algod: Algodv2): Algodv2;
26
+ /** Wait until all logged transactions IDs appear in the given `Indexer`. */
27
+ waitForIndexer(indexer: Indexer): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=transaction-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-logger.d.ts","sourceRoot":"","sources":["../../src/testing/transaction-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,OAAO,EAAE,MAAM,SAAS,CAAA;AAGnE;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,mBAAmB,CAAe;IAE1C;;OAEG;IACH,IAAI,kBAAkB,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC,CAE3C;IAED;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,iBAAiB,CAAC,kBAAkB,EAAE,UAAU,GAAG,UAAU,EAAE;IAY/D;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAIhC,4EAA4E;IACtE,cAAc,CAAC,OAAO,EAAE,OAAO;CAGtC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionLogger = void 0;
4
+ const algosdk_1 = require("algosdk");
5
+ const _1 = require("./");
6
+ /**
7
+ * Allows you to keep track of Algorand transaction IDs by wrapping an `Algodv2` in a proxy.
8
+ * Useful for automated tests.
9
+ */
10
+ class TransactionLogger {
11
+ constructor() {
12
+ this._sentTransactionIds = [];
13
+ }
14
+ /**
15
+ * The list of transaction IDs that has been logged thus far.
16
+ */
17
+ get sentTransactionIds() {
18
+ return this._sentTransactionIds;
19
+ }
20
+ /**
21
+ * Clear all logged IDs.
22
+ */
23
+ clear() {
24
+ this._sentTransactionIds = [];
25
+ }
26
+ /**
27
+ * The method that captures raw transactions and stores the transaction IDs.
28
+ */
29
+ logRawTransaction(signedTransactions) {
30
+ if (Array.isArray(signedTransactions)) {
31
+ for (const stxn of signedTransactions) {
32
+ const decoded = (0, algosdk_1.decodeSignedTransaction)(stxn);
33
+ this._sentTransactionIds.push(decoded.txn.txID());
34
+ }
35
+ }
36
+ else {
37
+ const decoded = (0, algosdk_1.decodeSignedTransaction)(signedTransactions);
38
+ this._sentTransactionIds.push(decoded.txn.txID());
39
+ }
40
+ }
41
+ /** Return a proxy that wraps the given Algodv2 with this transaction logger.
42
+ *
43
+ * @param algod The `Algodv2` to wrap
44
+ * @returns The wrapped `Algodv2`, any transactions sent using this algod instance will be logged by this transaction logger
45
+ */
46
+ capture(algod) {
47
+ return new Proxy(algod, new TransactionLoggingAlgodv2ProxyHandler(this));
48
+ }
49
+ /** Wait until all logged transactions IDs appear in the given `Indexer`. */
50
+ async waitForIndexer(indexer) {
51
+ await Promise.all(this._sentTransactionIds.map((txnId) => (0, _1.runWhenIndexerCaughtUp)(() => indexer.lookupTransactionByID(txnId).do())));
52
+ }
53
+ }
54
+ exports.TransactionLogger = TransactionLogger;
55
+ class TransactionLoggingAlgodv2ProxyHandler {
56
+ constructor(transactionLogger) {
57
+ this.transactionLogger = transactionLogger;
58
+ }
59
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
+ get(target, property, receiver) {
61
+ if (property === 'sendRawTransaction') {
62
+ return (stxOrStxs) => {
63
+ this.transactionLogger.logRawTransaction(stxOrStxs);
64
+ return target[property].call(receiver, stxOrStxs);
65
+ };
66
+ }
67
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
+ return target[property];
69
+ }
70
+ }
71
+ //# sourceMappingURL=transaction-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-logger.js","sourceRoot":"","sources":["../../src/testing/transaction-logger.ts"],"names":[],"mappings":";;;AAAA,qCAAmE;AACnE,yBAA2C;AAE3C;;;GAGG;AACH,MAAa,iBAAiB;IAA9B;QACU,wBAAmB,GAAa,EAAE,CAAA;IA4C5C,CAAC;IA1CC;;OAEG;IACH,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,mBAAmB,CAAA;IACjC,CAAC;IAED;;OAEG;IACH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