@algorandfoundation/algokit-utils 1.0.0-beta.9 → 1.1.0

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 (158) hide show
  1. package/README.md +38 -0
  2. package/account.d.ts +41 -36
  3. package/account.d.ts.map +1 -1
  4. package/account.js +59 -44
  5. package/account.js.map +1 -1
  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/{deploy-app.js → app-deploy.js} +129 -119
  17. package/app-deploy.js.map +1 -0
  18. package/app.d.ts +112 -148
  19. package/app.d.ts.map +1 -1
  20. package/app.js +460 -143
  21. package/app.js.map +1 -1
  22. package/index.d.ts +6 -4
  23. package/index.d.ts.map +1 -1
  24. package/index.js +7 -4
  25. package/index.js.map +1 -1
  26. package/indexer-lookup.d.ts +11 -4
  27. package/indexer-lookup.d.ts.map +1 -1
  28. package/indexer-lookup.js +19 -9
  29. package/indexer-lookup.js.map +1 -1
  30. package/localnet.d.ts +10 -10
  31. package/localnet.d.ts.map +1 -1
  32. package/localnet.js +16 -16
  33. package/localnet.js.map +1 -1
  34. package/network-client.d.ts +15 -24
  35. package/network-client.d.ts.map +1 -1
  36. package/network-client.js +16 -16
  37. package/network-client.js.map +1 -1
  38. package/package.json +2 -2
  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 +55 -91
  72. package/transaction.d.ts.map +1 -1
  73. package/transaction.js +213 -155
  74. package/transaction.js.map +1 -1
  75. package/transfer.d.ts +14 -16
  76. package/transfer.d.ts.map +1 -1
  77. package/transfer.js +38 -4
  78. package/transfer.js.map +1 -1
  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/{algo-http-client-with-retry.js → types/algo-http-client-with-retry.js} +3 -3
  85. package/types/algo-http-client-with-retry.js.map +1 -0
  86. package/types/algod.d.ts +28 -15
  87. package/types/algod.d.ts.map +1 -1
  88. package/{algo-amount.d.ts → types/amount.d.ts} +9 -3
  89. package/types/amount.d.ts.map +1 -0
  90. package/{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/types/{appspec.js → 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 +368 -58
  109. package/types/indexer.d.ts.map +1 -1
  110. package/types/indexer.js +9 -0
  111. package/types/indexer.js.map +1 -1
  112. package/{config.d.ts → types/logging.d.ts} +2 -16
  113. package/types/logging.d.ts.map +1 -0
  114. package/{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/algo-amount.d.ts.map +0 -1
  139. package/algo-amount.js.map +0 -1
  140. package/algo-http-client-with-retry.d.ts.map +0 -1
  141. package/algo-http-client-with-retry.js.map +0 -1
  142. package/application-client.d.ts +0 -113
  143. package/application-client.d.ts.map +0 -1
  144. package/application-client.js +0 -258
  145. package/application-client.js.map +0 -1
  146. package/config.d.ts.map +0 -1
  147. package/config.js.map +0 -1
  148. package/deploy-app.d.ts +0 -164
  149. package/deploy-app.d.ts.map +0 -1
  150. package/deploy-app.js.map +0 -1
  151. package/types/appspec.d.ts +0 -78
  152. package/types/appspec.d.ts.map +0 -1
  153. package/types/appspec.js.map +0 -1
  154. package/urlTokenBaseHTTPClient.d.ts.map +0 -1
  155. package/urlTokenBaseHTTPClient.js.map +0 -1
  156. /package/{algo-http-client-with-retry.d.ts → types/algo-http-client-with-retry.d.ts} +0 -0
  157. /package/{urlTokenBaseHTTPClient.d.ts → types/urlTokenBaseHTTPClient.d.ts} +0 -0
  158. /package/{urlTokenBaseHTTPClient.js → types/urlTokenBaseHTTPClient.js} +0 -0
package/network-client.js CHANGED
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.isLocalNet = exports.getAlgoKmdClient = exports.getAlgoIndexerClient = exports.getAlgoClient = exports.getDefaultLocalNetConfig = exports.getAlgoNodeConfig = exports.getIndexerConfigFromEnvironment = exports.getAlgodConfigFromEnvironment = void 0;
27
27
  const algosdk_1 = __importStar(require("algosdk"));
28
- const algo_http_client_with_retry_1 = require("./algo-http-client-with-retry");
28
+ const algo_http_client_with_retry_1 = require("./types/algo-http-client-with-retry");
29
29
  /** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
30
30
  function getAlgodConfigFromEnvironment() {
31
31
  if (!process || !process.env) {
@@ -92,24 +92,24 @@ function getAlgoTokenHeader(server, token, defaultHeader) {
92
92
  * @param config The config if you want to override the default (getting config from process.env)
93
93
  * @example Default (load from environment variables)
94
94
  *
95
- * ```
95
+ * ```typescript
96
96
  * // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN
97
97
  * // Automatically detects if you are using PureStake to switch in the right header name for ALGOD_TOKEN
98
98
  * const algod = getAlgoClient()
99
99
  * await algod.healthCheck().do()
100
100
  * ```
101
101
  * @example AlgoNode (testnet)
102
- * ```
102
+ * ```typescript
103
103
  * const algod = getAlgoClient(getAlgoNodeConfig('testnet', 'algod'))
104
104
  * await algod.healthCheck().do()
105
105
  * ```
106
106
  * @example AlgoNode (mainnet)
107
- * ```
107
+ * ```typescript
108
108
  * const algod = getAlgoClient(getAlgoNodeConfig('mainnet', 'algod'))
109
109
  * await algod.healthCheck().do()
110
110
  * ```
111
- * @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
112
- * ```
111
+ * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
112
+ * ```typescript
113
113
  * const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
114
114
  * await algod.healthCheck().do()
115
115
  * ```
@@ -125,24 +125,24 @@ exports.getAlgoClient = getAlgoClient;
125
125
  * @param config The config if you want to override the default (getting config from process.env)
126
126
  * @example Default (load from environment variables)
127
127
  *
128
- * ```
128
+ * ```typescript
129
129
  * // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN
130
130
  * // Automatically detects if you are using PureStake to switch in the right header name for INDEXER_TOKEN
131
131
  * const indexer = getAlgoIndexerClient()
132
132
  * await indexer.makeHealthCheck().do()
133
133
  * ```
134
134
  * @example AlgoNode (testnet)
135
- * ```
135
+ * ```typescript
136
136
  * const indexer = getAlgoIndexerClient(getAlgoNodeConfig('testnet', 'indexer'))
137
137
  * await indexer.makeHealthCheck().do()
138
138
  * ```
139
139
  * @example AlgoNode (mainnet)
140
- * ```
140
+ * ```typescript
141
141
  * const indexer = getAlgoIndexerClient(getAlgoNodeConfig('mainnet', 'indexer'))
142
142
  * await indexer.makeHealthCheck().do()
143
143
  * ```
144
- * @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
145
- * ```
144
+ * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
145
+ * ```typescript
146
146
  * const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
147
147
  * await indexer.makeHealthCheck().do()
148
148
  * ```
@@ -156,23 +156,23 @@ exports.getAlgoIndexerClient = getAlgoIndexerClient;
156
156
  /**
157
157
  * Returns a KMD SDK client that automatically retries on idempotent calls
158
158
  *
159
- * KMD client allows you to export private keys, which is useful to get the default account in a sandbox network.
159
+ * KMD client allows you to export private keys, which is useful to get the default account in a LocalNet network.
160
160
  *
161
161
  * @param config The config if you want to override the default (getting config from process.env)
162
162
  * @example Default (load from environment variables)
163
163
  *
164
- * ```
164
+ * ```typescript
165
165
  * // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN
166
166
  * const kmd = getAlgoKmdClient()
167
167
  * ```
168
- * @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
169
- * ```
168
+ * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
169
+ * ```typescript
170
170
  * const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
171
171
  * ```
172
172
  */
173
173
  function getAlgoKmdClient(config) {
174
174
  const { token, server } = config ?? getAlgodConfigFromEnvironment();
175
- // We can only use Kmd on the Sandbox otherwise it's not exposed so this makes some assumptions
175
+ // We can only use Kmd on the LocalNet otherwise it's not exposed so this makes some assumptions
176
176
  // (e.g. same token and server as algod and port 4002 by default)
177
177
  return new algosdk_1.Kmd(token, server, process?.env?.KMD_PORT ?? '4002');
178
178
  }
@@ -1 +1 @@
1
- {"version":3,"file":"network-client.js","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwD;AAExD,+EAAuE;AAYvE,mIAAmI;AACnI,SAAgB,6BAA6B;IAC3C,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,kGAAkG,CAAC,CAAA;KACpH;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,yGAAyG,CAAC,CAAA;KAC3H;IAED,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;QAChC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;QAC5B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;KAC/B,CAAA;AACH,CAAC;AAdD,sEAcC;AAED,qIAAqI;AACrI,SAAgB,+BAA+B;IAC7C,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,oGAAoG,CAAC,CAAA;KACtH;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,6GAA6G,CAAC,CAAA;KAC/H;IAED,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;QAClC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;QAC9B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;KACjC,CAAA;AACH,CAAC;AAdD,0EAcC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,OAA8B,EAAE,MAA2B;IAC3F,OA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,EAAE,GAAG,MAAM,IAAI,6BAA6B,EAAE,CAAA;IACnE,gGAAgG;IAChG,iEAAiE;IACjE,OAAO,IAAI,aAAG,CAAC,KAAe,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,IAAI,MAAM,CAAC,CAAA;AAC3E,CAAC;AALD,4CAKC;AAED,uCAAuC;AAA9B,sGAAA,UAAU,OAAA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "main": "index.js",
3
3
  "types": "index.d.ts",
4
4
  "name": "@algorandfoundation/algokit-utils",
5
- "version": "1.0.0-beta.9",
5
+ "version": "1.1.0",
6
6
  "private": false,
7
7
  "description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
8
8
  "author": "Algorand Foundation",
@@ -14,7 +14,7 @@
14
14
  "**/*"
15
15
  ],
16
16
  "dependencies": {
17
- "algosdk": "^2.1.0",
17
+ "algosdk": "^2.2.0",
18
18
  "buffer": "^6.0.3"
19
19
  }
20
20
  }
@@ -0,0 +1,14 @@
1
+ import { Account, Algodv2, Kmd } from 'algosdk';
2
+ import { GetTestAccountParams } from '../types/testing';
3
+ /**
4
+ * Creates an ephemeral Algorand account for the purposes of testing.
5
+ * Returns a newly created random test account that is funded from the dispenser
6
+ * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
7
+ * Note: By default this will log the mnemonic of the account.
8
+ * @param param0 The config for the test account to generate
9
+ * @param algod An algod client
10
+ * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables
11
+ * @returns The account, with private key loaded
12
+ */
13
+ export declare function getTestAccount({ suppressLog, initialFunds }: GetTestAccountParams, algod: Algodv2, kmd?: Kmd): Promise<Account>;
14
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/testing/account.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAIxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBrI"}
@@ -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,CAAC,CAAA;IAC1H,MAAM,aAAa,GACjB,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,IAAA,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G,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/testing/test-logger.ts"],"names":[],"mappings":";;;AAAA,2BAAsC;AAItC;;GAEG;AACH,MAAa,UAAU;IAIrB;;;OAGG;IACH,YAAY,cAAuB;QACjC,IAAI,CAAC,cA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