@algorandfoundation/algokit-utils 1.0.0-beta.3 → 1.0.0-beta.31

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 (180) hide show
  1. package/README.md +1 -1
  2. package/{dist/account.d.ts → account.d.ts} +36 -32
  3. package/account.d.ts.map +1 -0
  4. package/{dist/account.js → account.js} +55 -41
  5. package/account.js.map +1 -0
  6. package/amount.d.ts +8 -0
  7. package/amount.d.ts.map +1 -0
  8. package/amount.js +24 -0
  9. package/amount.js.map +1 -0
  10. package/app.d.ts +118 -0
  11. package/app.d.ts.map +1 -0
  12. package/app.js +541 -0
  13. package/app.js.map +1 -0
  14. package/application-client.d.ts +10 -0
  15. package/application-client.d.ts.map +1 -0
  16. package/application-client.js +15 -0
  17. package/application-client.js.map +1 -0
  18. package/deploy-app.d.ts +96 -0
  19. package/deploy-app.d.ts.map +1 -0
  20. package/{dist/deploy-app.js → deploy-app.js} +139 -114
  21. package/deploy-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} +6 -2
  25. package/index.js.map +1 -0
  26. package/{dist/localnet.d.ts → localnet.d.ts} +6 -6
  27. package/localnet.d.ts.map +1 -0
  28. package/{dist/localnet.js → localnet.js} +12 -12
  29. package/localnet.js.map +1 -0
  30. package/{dist/network-client.d.ts → network-client.d.ts} +15 -24
  31. package/network-client.d.ts.map +1 -0
  32. package/{dist/network-client.js → network-client.js} +16 -16
  33. package/{dist/network-client.js.map → network-client.js.map} +1 -1
  34. package/package.json +5 -93
  35. package/testing/account.d.ts +14 -0
  36. package/testing/account.d.ts.map +1 -0
  37. package/testing/account.js +31 -0
  38. package/testing/account.js.map +1 -0
  39. package/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
  40. package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
  41. package/testing/fixtures/algokit-log-capture-fixture.js +43 -0
  42. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
  43. package/testing/fixtures/algorand-fixture.d.ts +20 -0
  44. package/testing/fixtures/algorand-fixture.d.ts.map +1 -0
  45. package/testing/fixtures/algorand-fixture.js +49 -0
  46. package/testing/fixtures/algorand-fixture.js.map +1 -0
  47. package/testing/fixtures/index.d.ts +3 -0
  48. package/testing/fixtures/index.d.ts.map +1 -0
  49. package/testing/fixtures/index.js +19 -0
  50. package/testing/fixtures/index.js.map +1 -0
  51. package/testing/index.d.ts +6 -0
  52. package/testing/index.d.ts.map +1 -0
  53. package/testing/index.js +22 -0
  54. package/testing/index.js.map +1 -0
  55. package/testing/indexer.d.ts +12 -0
  56. package/testing/indexer.d.ts.map +1 -0
  57. package/testing/indexer.js +39 -0
  58. package/testing/indexer.js.map +1 -0
  59. package/testing/test-logger.d.ts +39 -0
  60. package/testing/test-logger.d.ts.map +1 -0
  61. package/testing/test-logger.js +69 -0
  62. package/testing/test-logger.js.map +1 -0
  63. package/testing/transaction-logger.d.ts +29 -0
  64. package/testing/transaction-logger.d.ts.map +1 -0
  65. package/testing/transaction-logger.js +71 -0
  66. package/testing/transaction-logger.js.map +1 -0
  67. package/transaction.d.ts +120 -0
  68. package/transaction.d.ts.map +1 -0
  69. package/transaction.js +316 -0
  70. package/transaction.js.map +1 -0
  71. package/transfer.d.ts +21 -0
  72. package/transfer.d.ts.map +1 -0
  73. package/transfer.js +65 -0
  74. package/transfer.js.map +1 -0
  75. package/types/account.d.ts +55 -0
  76. package/types/account.d.ts.map +1 -0
  77. package/types/account.js +91 -0
  78. package/types/account.js.map +1 -0
  79. package/types/algo-http-client-with-retry.d.ts.map +1 -0
  80. package/{dist → types}/algo-http-client-with-retry.js +2 -2
  81. package/types/algo-http-client-with-retry.js.map +1 -0
  82. package/{dist/types → types}/algod.d.ts +22 -9
  83. package/types/algod.d.ts.map +1 -0
  84. package/{dist/algo-amount.d.ts → types/amount.d.ts} +3 -1
  85. package/types/amount.d.ts.map +1 -0
  86. package/{dist/algo-amount.js → types/amount.js} +7 -1
  87. package/types/amount.js.map +1 -0
  88. package/types/app.d.ts +286 -0
  89. package/types/app.d.ts.map +1 -0
  90. package/types/app.js +32 -0
  91. package/types/app.js.map +1 -0
  92. package/types/application-client.d.ts +232 -0
  93. package/types/application-client.d.ts.map +1 -0
  94. package/types/application-client.js +470 -0
  95. package/types/application-client.js.map +1 -0
  96. package/types/appspec.d.ts +77 -0
  97. package/types/appspec.d.ts.map +1 -0
  98. package/types/appspec.js +15 -0
  99. package/types/appspec.js.map +1 -0
  100. package/types/config.d.ts +15 -0
  101. package/types/config.d.ts.map +1 -0
  102. package/types/config.js +27 -0
  103. package/types/config.js.map +1 -0
  104. package/{dist/types → types}/indexer.d.ts +8 -9
  105. package/{dist/types → types}/indexer.d.ts.map +1 -1
  106. package/{dist/config.d.ts → types/logging.d.ts} +2 -16
  107. package/types/logging.d.ts.map +1 -0
  108. package/{dist/config.js → types/logging.js} +5 -24
  109. package/types/logging.js.map +1 -0
  110. package/types/logic-error.d.ts +33 -0
  111. package/types/logic-error.d.ts.map +1 -0
  112. package/types/logic-error.js +46 -0
  113. package/types/logic-error.js.map +1 -0
  114. package/types/network-client.d.ts +11 -0
  115. package/types/network-client.d.ts.map +1 -0
  116. package/types/network-client.js +3 -0
  117. package/types/network-client.js.map +1 -0
  118. package/types/testing.d.ts +89 -0
  119. package/types/testing.d.ts.map +1 -0
  120. package/types/testing.js +3 -0
  121. package/types/testing.js.map +1 -0
  122. package/types/transaction.d.ts +85 -0
  123. package/types/transaction.d.ts.map +1 -0
  124. package/types/transaction.js +3 -0
  125. package/types/transaction.js.map +1 -0
  126. package/types/transfer.d.ts +32 -0
  127. package/types/transfer.d.ts.map +1 -0
  128. package/types/transfer.js +3 -0
  129. package/types/transfer.js.map +1 -0
  130. package/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
  131. package/types/urlTokenBaseHTTPClient.js.map +1 -0
  132. package/LICENSE +0 -21
  133. package/dist/account.d.ts.map +0 -1
  134. package/dist/account.js.map +0 -1
  135. package/dist/algo-amount.d.ts.map +0 -1
  136. package/dist/algo-amount.js.map +0 -1
  137. package/dist/algo-http-client-with-retry.d.ts.map +0 -1
  138. package/dist/algo-http-client-with-retry.js.map +0 -1
  139. package/dist/app.d.ts +0 -150
  140. package/dist/app.d.ts.map +0 -1
  141. package/dist/app.js +0 -156
  142. package/dist/app.js.map +0 -1
  143. package/dist/application-client.d.ts +0 -1
  144. package/dist/application-client.d.ts.map +0 -1
  145. package/dist/application-client.js +0 -69
  146. package/dist/application-client.js.map +0 -1
  147. package/dist/config.d.ts.map +0 -1
  148. package/dist/config.js.map +0 -1
  149. package/dist/deploy-app.d.ts +0 -149
  150. package/dist/deploy-app.d.ts.map +0 -1
  151. package/dist/deploy-app.js.map +0 -1
  152. package/dist/index.d.ts +0 -11
  153. package/dist/index.d.ts.map +0 -1
  154. package/dist/index.js.map +0 -1
  155. package/dist/localnet.d.ts.map +0 -1
  156. package/dist/localnet.js.map +0 -1
  157. package/dist/network-client.d.ts.map +0 -1
  158. package/dist/package.json +0 -20
  159. package/dist/transaction.d.ts +0 -152
  160. package/dist/transaction.d.ts.map +0 -1
  161. package/dist/transaction.js +0 -268
  162. package/dist/transaction.js.map +0 -1
  163. package/dist/transfer.d.ts +0 -24
  164. package/dist/transfer.d.ts.map +0 -1
  165. package/dist/transfer.js +0 -33
  166. package/dist/transfer.js.map +0 -1
  167. package/dist/types/algod.d.ts.map +0 -1
  168. package/dist/urlTokenBaseHTTPClient.d.ts.map +0 -1
  169. package/dist/urlTokenBaseHTTPClient.js.map +0 -1
  170. /package/{dist/indexer-lookup.d.ts → indexer-lookup.d.ts} +0 -0
  171. /package/{dist/indexer-lookup.d.ts.map → indexer-lookup.d.ts.map} +0 -0
  172. /package/{dist/indexer-lookup.js → indexer-lookup.js} +0 -0
  173. /package/{dist/indexer-lookup.js.map → indexer-lookup.js.map} +0 -0
  174. /package/{dist → types}/algo-http-client-with-retry.d.ts +0 -0
  175. /package/{dist/types → types}/algod.js +0 -0
  176. /package/{dist/types → types}/algod.js.map +0 -0
  177. /package/{dist/types → types}/indexer.js +0 -0
  178. /package/{dist/types → types}/indexer.js.map +0 -0
  179. /package/{dist → types}/urlTokenBaseHTTPClient.d.ts +0 -0
  180. /package/{dist → types}/urlTokenBaseHTTPClient.js +0 -0
@@ -0,0 +1,49 @@
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 a default LocalNet instance, but you can pass in an algod and indexer if you want to test against, say, TestNet.
9
+ *
10
+ * @example ```typescript
11
+ * const algorand = algorandFixture()
12
+ *
13
+ * beforeEach(algorand.beforeEach, 10_000)
14
+ *
15
+ * test('My test', () => {
16
+ * const {algod, indexer, testAccount, ...} = algorand.context
17
+ * })
18
+ * ```
19
+ *
20
+ * @param fixtureConfig The fixture configuration
21
+ * @returns The fixture
22
+ */
23
+ const algorandFixture = (fixtureConfig) => {
24
+ const algod = fixtureConfig?.algod ?? (0, __2.getAlgoClient)((0, __2.getDefaultLocalNetConfig)('algod'));
25
+ const indexer = fixtureConfig?.indexer ?? (0, __2.getAlgoIndexerClient)((0, __2.getDefaultLocalNetConfig)('indexer'));
26
+ const kmd = fixtureConfig?.kmd ?? (0, __2.getAlgoKmdClient)((0, __2.getDefaultLocalNetConfig)('kmd'));
27
+ let context;
28
+ const beforeEach = async () => {
29
+ const transactionLogger = new __1.TransactionLogger();
30
+ context = {
31
+ algod: transactionLogger.capture(algod),
32
+ indexer: indexer,
33
+ kmd: kmd,
34
+ testAccount: await (0, __1.getTestAccount)({ initialFunds: fixtureConfig?.testAccountFunding ?? (0, __2.algos)(10), suppressLog: true }, algod, kmd),
35
+ generateAccount: (params) => (0, __1.getTestAccount)(params, algod, kmd),
36
+ transactionLogger: transactionLogger,
37
+ waitForIndexer: () => transactionLogger.waitForIndexer(indexer),
38
+ waitForIndexerTransaction: (transactionId) => (0, __1.runWhenIndexerCaughtUp)(() => (0, __2.lookupTransactionById)(transactionId, indexer)),
39
+ };
40
+ };
41
+ return {
42
+ get context() {
43
+ return context;
44
+ },
45
+ beforeEach,
46
+ };
47
+ };
48
+ exports.algorandFixture = algorandFixture;
49
+ //# 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,8BAAsI;AAGtI;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,eAAe,GAAG,CAAC,aAAqC,EAAmB,EAAE;IACxF,MAAM,KAAK,GAAG,aAAa,EAAE,KAAK,IAAI,IAAA,iBAAa,EAAC,IAAA,4BAAwB,EAAC,OAAO,CAAC,CAAC,CAAA;IACtF,MAAM,OAAO,GAAG,aAAa,EAAE,OAAO,IAAI,IAAA,wBAAoB,EAAC,IAAA,4BAAwB,EAAC,SAAS,CAAC,CAAC,CAAA;IACnG,MAAM,GAAG,GAAG,aAAa,EAAE,GAAG,IAAI,IAAA,oBAAgB,EAAC,IAAA,4BAAwB,EAAC,KAAK,CAAC,CAAC,CAAA;IACnF,IAAI,OAAsC,CAAA;IAE1C,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;QAC5B,MAAM,iBAAiB,GAAG,IAAI,qBAAiB,EAAE,CAAA;QACjD,OAAO,GAAG;YACR,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC;YACvC,OAAO,EAAE,OAAO;YAChB,GAAG,EAAE,GAAG;YACR,WAAW,EAAE,MAAM,IAAA,kBAAc,EAAC,EAAE,YAAY,EAAE,aAAa,EAAE,kBAAkB,IAAI,IAAA,SAAK,EAAC,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC;YAClI,eAAe,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,IAAA,kBAAc,EAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC;YACrF,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;AA1BY,QAAA,eAAe,mBA0B3B"}
@@ -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,CAsBjF"}
@@ -0,0 +1,39 @@
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
+ }
23
+ catch (e) {
24
+ if (e?.status === 404) {
25
+ tries++;
26
+ if (tries > 20) {
27
+ throw e;
28
+ }
29
+ await new Promise((resolve) => setTimeout(resolve, 200));
30
+ }
31
+ else {
32
+ throw e;
33
+ }
34
+ }
35
+ }
36
+ return result;
37
+ }
38
+ exports.runWhenIndexerCaughtUp = runWhenIndexerCaughtUp;
39
+ //# 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;SACV;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;AAtBD,wDAsBC"}
@@ -0,0 +1,39 @@
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
+ * @see https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic
23
+ * @example Jest Example
24
+ * ```typescript
25
+ * const logger = new TestLogger()
26
+ * ...
27
+ * expect(logger.getLogSnapshot()).toMatchSnapshot()
28
+ * ```
29
+ * @param config The snapshot configuration
30
+ * @returns The snapshotted logs.
31
+ */
32
+ getLogSnapshot(config?: LogSnapshotConfig): string;
33
+ error(message: string, ...optionalParams: unknown[]): void;
34
+ warn(message: string, ...optionalParams: unknown[]): void;
35
+ info(message: string, ...optionalParams: unknown[]): void;
36
+ verbose(message: string, ...optionalParams: unknown[]): void;
37
+ debug(message: string, ...optionalParams: unknown[]): void;
38
+ }
39
+ //# 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;;;;;;;;;;;;;OAaG;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,69 @@
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
+ * @see https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic
30
+ * @example Jest Example
31
+ * ```typescript
32
+ * const logger = new TestLogger()
33
+ * ...
34
+ * expect(logger.getLogSnapshot()).toMatchSnapshot()
35
+ * ```
36
+ * @param config The snapshot configuration
37
+ * @returns The snapshotted logs.
38
+ */
39
+ getLogSnapshot(config) {
40
+ const { transactions: transactionIds, accounts, apps } = config ?? {};
41
+ let snapshot = this.capturedLogs.join('\n');
42
+ transactionIds?.forEach((txn, id) => (snapshot = snapshot.replace(new RegExp(typeof txn === 'string' ? txn : txn.txID(), 'g'), `TXID_${id + 1}`)));
43
+ accounts?.forEach((sender, id) => (snapshot = snapshot.replace(new RegExp(typeof sender === 'string' ? sender : (0, __1.getSenderAddress)(sender), 'g'), `ACCOUNT_${id + 1}`)));
44
+ apps?.forEach((app, id) => (snapshot = snapshot.replace(new RegExp(`\\b${app.toString()}\\b`, 'g'), `APP_${id + 1}`)));
45
+ return snapshot;
46
+ }
47
+ error(message, ...optionalParams) {
48
+ this.originalLogger?.error(message, ...optionalParams);
49
+ this.logs.push(`ERROR: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
50
+ }
51
+ warn(message, ...optionalParams) {
52
+ this.originalLogger?.warn(message, ...optionalParams);
53
+ this.logs.push(`WARN: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
54
+ }
55
+ info(message, ...optionalParams) {
56
+ this.originalLogger?.info(message, ...optionalParams);
57
+ this.logs.push(`INFO: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
58
+ }
59
+ verbose(message, ...optionalParams) {
60
+ this.originalLogger?.verbose(message, ...optionalParams);
61
+ this.logs.push(`VERBOSE: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
62
+ }
63
+ debug(message, ...optionalParams) {
64
+ this.originalLogger?.debug(message, ...optionalParams);
65
+ this.logs.push(`DEBUG: ${message}${optionalParams.length ? ` | ${JSON.stringify(optionalParams)}` : ''}`);
66
+ }
67
+ }
68
+ exports.TestLogger = TestLogger;
69
+ //# sourceMappingURL=test-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-logger.js","sourceRoot":"","sources":["../../src/testing/test-logger.ts"],"names":[],"mappings":";;;AAAA,2BAAsC;AAItC;;GAEG;AACH,MAAa,UAAU;IAIrB;;;OAGG;IACH,YAAY,cAAuB;QACjC,IAAI,CAAC,cAAc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I,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;AAvED,gCAuEC"}
@@ -0,0 +1,29 @@
1
+ import { Algodv2, Indexer } from 'algosdk';
2
+ /**
3
+ * Allows you to keep track of Algorand transaction IDs by wrapping an @see 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 @see Algodv2 to wrap
23
+ * @returns The wrapped @see 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 @see 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,+EAA+E;IACzE,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 @see 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 @see Algodv2 to wrap
44
+ * @returns The wrapped @see 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 @see 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,KAAK;QACH,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAA;IAC/B,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,kBAA6C;QAC7D,IAAI,KAAK,CAAC,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,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;YACnD,CAAC,CAAA;SACF;QACD,8DAA8D;QAC9D,OAAQ,MAAc,CAAC,QAAQ,CAAC,CAAA;IAClC,CAAC;CACF"}
@@ -0,0 +1,120 @@
1
+ import algosdk, { Algodv2, AtomicTransactionComposer, SuggestedParams, Transaction } from 'algosdk';
2
+ import { PendingTransactionResponse } from './types/algod';
3
+ import { AlgoAmount } from './types/amount';
4
+ import { ABIReturn } from './types/app';
5
+ import { AtomicTransactionComposerToSend, SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionGroupToSend, TransactionNote } from './types/transaction';
6
+ /** Encodes a transaction note into a byte array ready to be included in an Algorand transaction.
7
+ *
8
+ * @param note The transaction note
9
+ * @returns the transaction note ready for inclusion in a transaction
10
+ *
11
+ * Case on the value of `data` this either either be:
12
+ * * `null` | `undefined`: `undefined`
13
+ * * `string`: The string value
14
+ * * Uint8Array: passthrough
15
+ * * Arc2TransactionNote object: ARC-0002 compatible transaction note
16
+ * * Else: The object/value converted into a JSON string representation
17
+ */
18
+ export declare function encodeTransactionNote(note?: TransactionNote): Uint8Array | undefined;
19
+ /**
20
+ * Returns the public address of the given transaction sender.
21
+ * @param sender A transaction sender
22
+ * @returns The public address
23
+ */
24
+ export declare const getSenderAddress: (sender: SendTransactionFrom) => string;
25
+ /**
26
+ * Returns a @see TransactionSigner for the given transaction sender.
27
+ * This function has memoization, so will return the same transaction signer for a given sender.
28
+ * @param sender A transaction sender
29
+ * @returns A transaction signer
30
+ */
31
+ export declare const getSenderTransactionSigner: (val: SendTransactionFrom) => algosdk.TransactionSigner;
32
+ /** Prepares a transaction for sending and then (if instructed) signs and sends the given transaction to the chain.
33
+ *
34
+ * @param send The details for the transaction to prepare/send, including:
35
+ * * `transaction`: The unsigned transaction
36
+ * * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account
37
+ * * `config`: The sending configuration for this transaction
38
+ * @param algod An algod client
39
+ *
40
+ * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or `undefined`) confirmation (`confirmation`)
41
+ */
42
+ export declare const sendTransaction: (send: {
43
+ transaction: Transaction;
44
+ from: SendTransactionFrom;
45
+ sendParams?: SendTransactionParams;
46
+ }, algod: Algodv2) => Promise<SendTransactionResult>;
47
+ /**
48
+ * Signs and sends transactions that have been collected by an @see AtomicTransactionComposer.
49
+ * @param atcSend The parameters controlling the send, including:
50
+ * * `atc` The @see AtomicTransactionComposer
51
+ * * `sendParams` The parameters to control the send behaviour
52
+ * @param algod An algod client
53
+ * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
54
+ */
55
+ export declare const sendAtomicTransactionComposer: (atcSend: AtomicTransactionComposerToSend, algod: Algodv2) => Promise<{
56
+ groupId: string | undefined;
57
+ confirmations: PendingTransactionResponse[] | undefined;
58
+ txIds: string[];
59
+ transactions: algosdk.Transaction[];
60
+ returns: ABIReturn[];
61
+ }>;
62
+ /**
63
+ * Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-details/atomic_transfers/#create-transactions) transactions to the chain
64
+ *
65
+ * @param groupSend The group details to send, with:
66
+ * * `transactions`: The array of transactions to send along with their signing account
67
+ * * `sendParams`: The parameters to dictate how the group is sent
68
+ * @param algod An algod client
69
+ * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
70
+ */
71
+ export declare const sendGroupOfTransactions: (groupSend: TransactionGroupToSend, algod: Algodv2) => Promise<{
72
+ groupId: string | undefined;
73
+ confirmations: PendingTransactionResponse[] | undefined;
74
+ txIds: string[];
75
+ transactions: algosdk.Transaction[];
76
+ returns: ABIReturn[];
77
+ }>;
78
+ /**
79
+ * Wait until the transaction is confirmed or rejected, or until `timeout`
80
+ * number of rounds have passed.
81
+ *
82
+ * @param algod An algod client
83
+ * @param transactionId The transaction ID to wait for
84
+ * @param maxRoundsToWait Maximum number of rounds to wait
85
+ *
86
+ * @return Pending transaction information
87
+ * @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds
88
+ */
89
+ export declare const waitForConfirmation: (transactionId: string, maxRoundsToWait: number, algod: Algodv2) => Promise<PendingTransactionResponse>;
90
+ /**
91
+ * Limit the acceptable fee to a defined amount of µALGOs.
92
+ * This also sets the transaction to be flatFee to ensure the transaction only succeeds at
93
+ * the estimated rate.
94
+ * @param transaction The transaction to cap or suggested params object about to be used to create a transaction
95
+ * @param maxAcceptableFee The maximum acceptable fee to pay
96
+ */
97
+ export declare function capTransactionFee(transaction: algosdk.Transaction | SuggestedParams, maxAcceptableFee: AlgoAmount): void;
98
+ /**
99
+ * Allows for control of fees on a @see Transaction or @see SuggestedParams object
100
+ * @param transaction The transaction or suggested params
101
+ * @param feeControl The fee control parameters
102
+ */
103
+ export declare function controlFees<T extends SuggestedParams | Transaction>(transaction: T, feeControl: {
104
+ fee?: AlgoAmount;
105
+ maxFee?: AlgoAmount;
106
+ }): T;
107
+ /**
108
+ * Returns suggested transaction parameters from algod unless some are already provided.
109
+ * @param params Optionally provide parameters to use
110
+ * @param algod Algod algod
111
+ * @returns The suggested transaction parameters
112
+ */
113
+ export declare function getTransactionParams(params: SuggestedParams | undefined, algod: Algodv2): Promise<algosdk.SuggestedParams>;
114
+ /**
115
+ * Returns the array of transactions currently present in the given @see AtomicTransactionComposer
116
+ * @param atc The atomic transaction composer
117
+ * @returns The array of transactions with signers
118
+ */
119
+ export declare function getAtomicTransactionComposerTransactions(atc: AtomicTransactionComposer): algosdk.TransactionWithSigner[];
120
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,WAAW,EAAqB,MAAM,SAAS,CAAA;AAG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