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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (318) hide show
  1. package/account-manager.d.ts +448 -0
  2. package/account-manager.js +623 -0
  3. package/account-manager.js.map +1 -0
  4. package/account-manager.mjs +620 -0
  5. package/account-manager.mjs.map +1 -0
  6. package/account.d.ts +156 -0
  7. package/account.js +10 -0
  8. package/account.js.map +1 -0
  9. package/account.mjs +9 -0
  10. package/account.mjs.map +1 -0
  11. package/algorand-client-transaction-creator.d.ts +1103 -0
  12. package/algorand-client-transaction-creator.js +735 -0
  13. package/algorand-client-transaction-creator.js.map +1 -0
  14. package/algorand-client-transaction-creator.mjs +734 -0
  15. package/algorand-client-transaction-creator.mjs.map +1 -0
  16. package/algorand-client-transaction-sender.d.ts +1317 -0
  17. package/algorand-client-transaction-sender.js +933 -0
  18. package/algorand-client-transaction-sender.js.map +1 -0
  19. package/algorand-client-transaction-sender.mjs +932 -0
  20. package/algorand-client-transaction-sender.mjs.map +1 -0
  21. package/algorand-client.d.ts +246 -0
  22. package/algorand-client.js +325 -0
  23. package/algorand-client.js.map +1 -0
  24. package/algorand-client.mjs +325 -0
  25. package/algorand-client.mjs.map +1 -0
  26. package/amount.d.ts +46 -3
  27. package/amount.js +92 -13
  28. package/amount.js.map +1 -1
  29. package/amount.mjs +80 -3
  30. package/amount.mjs.map +1 -1
  31. package/app-client.d.ts +2130 -0
  32. package/app-client.js +909 -0
  33. package/app-client.js.map +1 -0
  34. package/app-client.mjs +908 -0
  35. package/app-client.mjs.map +1 -0
  36. package/app-deployer.d.ts +166 -0
  37. package/app-deployer.js +353 -0
  38. package/app-deployer.js.map +1 -0
  39. package/app-deployer.mjs +353 -0
  40. package/app-deployer.mjs.map +1 -0
  41. package/app-factory.d.ts +965 -0
  42. package/app-factory.js +448 -0
  43. package/app-factory.js.map +1 -0
  44. package/app-factory.mjs +448 -0
  45. package/app-factory.mjs.map +1 -0
  46. package/app-manager.d.ts +323 -0
  47. package/app-manager.js +468 -0
  48. package/app-manager.js.map +1 -0
  49. package/app-manager.mjs +468 -0
  50. package/app-manager.mjs.map +1 -0
  51. package/app-spec.d.ts +203 -0
  52. package/app-spec.js +137 -0
  53. package/app-spec.js.map +1 -0
  54. package/app-spec.mjs +137 -0
  55. package/app-spec.mjs.map +1 -0
  56. package/app.d.ts +257 -0
  57. package/app.js +49 -0
  58. package/app.js.map +1 -0
  59. package/app.mjs +42 -0
  60. package/app.mjs.map +1 -0
  61. package/asset-manager.d.ts +212 -0
  62. package/asset-manager.js +166 -0
  63. package/asset-manager.js.map +1 -0
  64. package/asset-manager.mjs +166 -0
  65. package/asset-manager.mjs.map +1 -0
  66. package/async-event-emitter.d.ts +16 -0
  67. package/async-event-emitter.js +38 -0
  68. package/async-event-emitter.js.map +1 -0
  69. package/async-event-emitter.mjs +37 -0
  70. package/async-event-emitter.mjs.map +1 -0
  71. package/client-manager.d.ts +475 -0
  72. package/client-manager.js +616 -0
  73. package/client-manager.js.map +1 -0
  74. package/client-manager.mjs +616 -0
  75. package/client-manager.mjs.map +1 -0
  76. package/composer.d.ts +947 -0
  77. package/composer.js +1584 -0
  78. package/composer.js.map +1 -0
  79. package/composer.mjs +1583 -0
  80. package/composer.mjs.map +1 -0
  81. package/config.d.ts +1 -1
  82. package/config.js +2 -2
  83. package/config.js.map +1 -1
  84. package/config.mjs +1 -1
  85. package/config.mjs.map +1 -1
  86. package/debugging.d.ts +47 -0
  87. package/debugging.js +20 -0
  88. package/debugging.js.map +1 -0
  89. package/debugging.mjs +15 -0
  90. package/debugging.mjs.map +1 -0
  91. package/dispenser-client.d.ts +90 -0
  92. package/dispenser-client.js +127 -0
  93. package/dispenser-client.js.map +1 -0
  94. package/dispenser-client.mjs +127 -0
  95. package/dispenser-client.mjs.map +1 -0
  96. package/expand.d.ts +2 -0
  97. package/expand.js +0 -0
  98. package/expand.mjs +0 -0
  99. package/index.d.ts +6 -5
  100. package/index.js +4 -3
  101. package/index.mjs +5 -5
  102. package/indexer-client/indexer-lookup.d.ts +1 -1
  103. package/indexer-client/indexer-lookup.js.map +1 -1
  104. package/indexer-client/indexer-lookup.mjs.map +1 -1
  105. package/indexer.d.ts +40 -0
  106. package/indexer.js +38 -0
  107. package/indexer.js.map +1 -0
  108. package/indexer.mjs +35 -0
  109. package/indexer.mjs.map +1 -0
  110. package/instance-of.d.ts +8 -0
  111. package/kmd-account-manager.d.ts +74 -0
  112. package/kmd-account-manager.js +167 -0
  113. package/kmd-account-manager.js.map +1 -0
  114. package/kmd-account-manager.mjs +165 -0
  115. package/kmd-account-manager.mjs.map +1 -0
  116. package/lifecycle-events.d.ts +14 -0
  117. package/lifecycle-events.js +11 -0
  118. package/lifecycle-events.js.map +1 -0
  119. package/lifecycle-events.mjs +10 -0
  120. package/lifecycle-events.mjs.map +1 -0
  121. package/logging.d.ts +13 -0
  122. package/logging.js +47 -0
  123. package/logging.js.map +1 -0
  124. package/logging.mjs +42 -0
  125. package/logging.mjs.map +1 -0
  126. package/logic-error.d.ts +39 -0
  127. package/logic-error.js +54 -0
  128. package/logic-error.js.map +1 -0
  129. package/logic-error.mjs +53 -0
  130. package/logic-error.mjs.map +1 -0
  131. package/network-client.d.ts +43 -0
  132. package/network-client.js +14 -0
  133. package/network-client.js.map +1 -0
  134. package/network-client.mjs +13 -0
  135. package/network-client.mjs.map +1 -0
  136. package/package.json +11 -1
  137. package/testing/account.d.ts +2 -2
  138. package/testing/account.js +1 -1
  139. package/testing/account.js.map +1 -1
  140. package/testing/account.mjs +1 -1
  141. package/testing/account.mjs.map +1 -1
  142. package/testing/fixtures/algokit-log-capture-fixture.d.ts +1 -1
  143. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  144. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  145. package/testing/fixtures/algorand-fixture.d.ts +2 -2
  146. package/testing/fixtures/algorand-fixture.js +2 -2
  147. package/testing/fixtures/algorand-fixture.js.map +1 -1
  148. package/testing/fixtures/algorand-fixture.mjs +2 -2
  149. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  150. package/testing/index.d.ts +2 -1
  151. package/testing/test-logger.d.ts +1 -1
  152. package/testing/test-logger.js.map +1 -1
  153. package/testing/test-logger.mjs.map +1 -1
  154. package/testing/types.d.ts +156 -0
  155. package/transaction/index.d.ts +4 -0
  156. package/transaction/index.js +9 -0
  157. package/transaction/index.mjs +4 -0
  158. package/transaction/perform-transaction-composer-simulate.d.ts +1 -1
  159. package/transaction/perform-transaction-composer-simulate.js.map +1 -1
  160. package/transaction/perform-transaction-composer-simulate.mjs.map +1 -1
  161. package/transaction/transaction.d.ts +2 -2
  162. package/transaction/transaction.js.map +1 -1
  163. package/transaction/transaction.mjs.map +1 -1
  164. package/transaction/types.d.ts +133 -0
  165. package/transactions/app-call.d.ts +1 -1
  166. package/transactions/app-call.js +1 -1
  167. package/transactions/app-call.js.map +1 -1
  168. package/transactions/app-call.mjs +1 -1
  169. package/transactions/app-call.mjs.map +1 -1
  170. package/transactions/common.d.ts +1 -1
  171. package/transactions/common.js.map +1 -1
  172. package/transactions/common.mjs.map +1 -1
  173. package/transactions/method-call.d.ts +1 -1
  174. package/transactions/method-call.js +1 -1
  175. package/transactions/method-call.js.map +1 -1
  176. package/transactions/method-call.mjs +1 -1
  177. package/transactions/method-call.mjs.map +1 -1
  178. package/transactions/payment.d.ts +1 -1
  179. package/transactions/payment.js.map +1 -1
  180. package/transactions/payment.mjs.map +1 -1
  181. package/types/account-manager.d.ts +11 -442
  182. package/types/account-manager.js +5 -616
  183. package/types/account-manager.js.map +1 -1
  184. package/types/account-manager.mjs +5 -614
  185. package/types/account-manager.mjs.map +1 -1
  186. package/types/account.d.ts +8 -150
  187. package/types/account.js +3 -4
  188. package/types/account.js.map +1 -1
  189. package/types/account.mjs +4 -4
  190. package/types/account.mjs.map +1 -1
  191. package/types/algorand-client-transaction-creator.d.ts +5 -1098
  192. package/types/algorand-client-transaction-creator.js +3 -729
  193. package/types/algorand-client-transaction-creator.js.map +1 -1
  194. package/types/algorand-client-transaction-creator.mjs +4 -729
  195. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  196. package/types/algorand-client-transaction-sender.d.ts +5 -1312
  197. package/types/algorand-client-transaction-sender.js +3 -927
  198. package/types/algorand-client-transaction-sender.js.map +1 -1
  199. package/types/algorand-client-transaction-sender.mjs +3 -926
  200. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  201. package/types/algorand-client.d.ts +5 -241
  202. package/types/algorand-client.js +3 -319
  203. package/types/algorand-client.js.map +1 -1
  204. package/types/algorand-client.mjs +3 -319
  205. package/types/algorand-client.mjs.map +1 -1
  206. package/types/amount.d.ts +6 -45
  207. package/types/amount.js +3 -79
  208. package/types/amount.js.map +1 -1
  209. package/types/amount.mjs +4 -79
  210. package/types/amount.mjs.map +1 -1
  211. package/types/app-client.d.ts +75 -2125
  212. package/types/app-client.js +3 -903
  213. package/types/app-client.js.map +1 -1
  214. package/types/app-client.mjs +3 -902
  215. package/types/app-client.mjs.map +1 -1
  216. package/types/app-deployer.d.ts +21 -161
  217. package/types/app-deployer.js +3 -347
  218. package/types/app-deployer.js.map +1 -1
  219. package/types/app-deployer.mjs +3 -347
  220. package/types/app-deployer.mjs.map +1 -1
  221. package/types/app-factory.d.ts +21 -960
  222. package/types/app-factory.js +3 -442
  223. package/types/app-factory.js.map +1 -1
  224. package/types/app-factory.mjs +3 -442
  225. package/types/app-factory.mjs.map +1 -1
  226. package/types/app-manager.d.ts +15 -318
  227. package/types/app-manager.js +3 -462
  228. package/types/app-manager.js.map +1 -1
  229. package/types/app-manager.mjs +3 -462
  230. package/types/app-manager.mjs.map +1 -1
  231. package/types/app-spec.d.ts +39 -198
  232. package/types/app-spec.js +3 -131
  233. package/types/app-spec.js.map +1 -1
  234. package/types/app-spec.mjs +3 -131
  235. package/types/app-spec.mjs.map +1 -1
  236. package/types/app.d.ts +62 -247
  237. package/types/app.js +15 -37
  238. package/types/app.js.map +1 -1
  239. package/types/app.mjs +16 -37
  240. package/types/app.mjs.map +1 -1
  241. package/types/asset-manager.d.ts +9 -207
  242. package/types/asset-manager.js +3 -160
  243. package/types/asset-manager.js.map +1 -1
  244. package/types/asset-manager.mjs +3 -160
  245. package/types/asset-manager.mjs.map +1 -1
  246. package/types/async-event-emitter.d.ts +7 -11
  247. package/types/async-event-emitter.js +3 -32
  248. package/types/async-event-emitter.js.map +1 -1
  249. package/types/async-event-emitter.mjs +4 -32
  250. package/types/async-event-emitter.mjs.map +1 -1
  251. package/types/client-manager.d.ts +27 -470
  252. package/types/client-manager.js +3 -610
  253. package/types/client-manager.js.map +1 -1
  254. package/types/client-manager.mjs +3 -610
  255. package/types/client-manager.mjs.map +1 -1
  256. package/types/composer.d.ts +79 -943
  257. package/types/composer.js +3 -1578
  258. package/types/composer.js.map +1 -1
  259. package/types/composer.mjs +3 -1577
  260. package/types/composer.mjs.map +1 -1
  261. package/types/config.d.ts +7 -52
  262. package/types/config.js +3 -74
  263. package/types/config.js.map +1 -1
  264. package/types/config.mjs +3 -74
  265. package/types/config.mjs.map +1 -1
  266. package/types/debugging.d.ts +12 -37
  267. package/types/debugging.js +11 -10
  268. package/types/debugging.js.map +1 -1
  269. package/types/debugging.mjs +12 -10
  270. package/types/debugging.mjs.map +1 -1
  271. package/types/dispenser-client.d.ts +11 -85
  272. package/types/dispenser-client.js +3 -121
  273. package/types/dispenser-client.js.map +1 -1
  274. package/types/dispenser-client.mjs +3 -121
  275. package/types/dispenser-client.mjs.map +1 -1
  276. package/types/expand.d.ts +8 -2
  277. package/types/indexer.d.ts +16 -36
  278. package/types/indexer.js +7 -30
  279. package/types/indexer.js.map +1 -1
  280. package/types/indexer.mjs +8 -30
  281. package/types/indexer.mjs.map +1 -1
  282. package/types/instance-of.d.ts +4 -4
  283. package/types/kmd-account-manager.d.ts +5 -69
  284. package/types/kmd-account-manager.js +3 -161
  285. package/types/kmd-account-manager.js.map +1 -1
  286. package/types/kmd-account-manager.mjs +3 -159
  287. package/types/kmd-account-manager.mjs.map +1 -1
  288. package/types/lifecycle-events.d.ts +7 -9
  289. package/types/lifecycle-events.js +3 -5
  290. package/types/lifecycle-events.js.map +1 -1
  291. package/types/lifecycle-events.mjs +4 -5
  292. package/types/lifecycle-events.mjs.map +1 -1
  293. package/types/logging.d.ts +14 -9
  294. package/types/logging.js +11 -37
  295. package/types/logging.js.map +1 -1
  296. package/types/logging.mjs +12 -37
  297. package/types/logging.mjs.map +1 -1
  298. package/types/logic-error.d.ts +8 -35
  299. package/types/logic-error.js +3 -48
  300. package/types/logic-error.js.map +1 -1
  301. package/types/logic-error.mjs +4 -48
  302. package/types/logic-error.mjs.map +1 -1
  303. package/types/network-client.d.ts +10 -39
  304. package/types/network-client.js +3 -8
  305. package/types/network-client.js.map +1 -1
  306. package/types/network-client.mjs +4 -8
  307. package/types/network-client.mjs.map +1 -1
  308. package/types/testing.d.ts +13 -151
  309. package/types/transaction.d.ts +33 -128
  310. package/updatable-config.d.ts +57 -0
  311. package/updatable-config.js +80 -0
  312. package/updatable-config.js.map +1 -0
  313. package/updatable-config.mjs +80 -0
  314. package/updatable-config.mjs.map +1 -0
  315. package/util.js +1 -1
  316. package/util.js.map +1 -1
  317. package/util.mjs +1 -1
  318. package/util.mjs.map +1 -1
@@ -1,156 +1,18 @@
1
- import { Address } from "../packages/common/src/address.js";
2
- import { Transaction } from "../packages/transact/src/transactions/transaction.js";
3
- import { MultisigAccount } from "../packages/transact/src/multisig.js";
4
- import { LogicSigAccount } from "../packages/transact/src/logicsig.js";
5
- import { AddressWithSigners, AddressWithTransactionSigner } from "../packages/transact/src/signer.js";
6
- import { AlgodClient } from "../packages/algod_client/src/client.js";
7
- import { AlgoAmount } from "./amount.js";
8
- import { TransactionResponse } from "../packages/indexer_client/src/models/transaction-response.js";
9
- import { IndexerClient } from "../packages/indexer_client/src/client.js";
10
- import { KmdClient } from "../packages/kmd_client/src/client.js";
11
- import { AlgoConfig } from "./network-client.js";
12
- import { AlgorandClient } from "./algorand-client.js";
13
- import { TestLogger } from "../testing/test-logger.js";
14
- import { TransactionLogger } from "../testing/transaction-logger.js";
1
+ import { AlgoKitLogCaptureFixture as AlgoKitLogCaptureFixture$1, AlgorandFixture as AlgorandFixture$1, AlgorandFixtureConfig as AlgorandFixtureConfig$1, AlgorandTestAutomationContext as AlgorandTestAutomationContext$1, GetTestAccountParams as GetTestAccountParams$1, LogSnapshotConfig as LogSnapshotConfig$1 } from "../testing/types.js";
15
2
 
16
3
  //#region src/types/testing.d.ts
17
- /**
18
- * Test automation context.
19
- */
20
- interface AlgorandTestAutomationContext {
21
- /** An AlgorandClient instance loaded with the current context, including testAccount and any generated accounts loaded as signers */
22
- algorand: AlgorandClient;
23
- /** Algod client instance that will log transactions in `transactionLogger` */
24
- algod: AlgodClient;
25
- /** Indexer client instance */
26
- indexer: IndexerClient;
27
- /** KMD client instance */
28
- kmd: KmdClient;
29
- /** Transaction logger that will log transaction IDs for all transactions issued by `algod` */
30
- transactionLogger: TransactionLogger;
31
- /** Default, funded test account that is ephemerally created */
32
- testAccount: Address & AddressWithSigners;
33
- /** Generate and fund an additional ephemerally created account */
34
- generateAccount: (params: GetTestAccountParams) => Promise<Address & AddressWithSigners>;
35
- /** Wait for the indexer to catch up with all transactions logged by `transactionLogger` */
36
- waitForIndexer: () => Promise<void>;
37
- /** Wait for the indexer to catch up with the given transaction ID */
38
- waitForIndexerTransaction: (transactionId: string) => Promise<TransactionResponse>;
39
- }
40
- /**
41
- * Parameters for the `getTestAccount` function.
42
- */
43
- interface GetTestAccountParams {
44
- /** Initial funds to ensure the account has */
45
- initialFunds: AlgoAmount;
46
- /** Whether to suppress the log (which includes a mnemonic) or not (default: do not suppress the log) */
47
- suppressLog?: boolean;
48
- /** Optional override for how to get a test account; this allows you to retrieve accounts from a known or cached list of accounts. */
49
- accountGetter?: (algorand: AlgorandClient) => Promise<Address & AddressWithSigners>;
50
- }
51
- /** Configuration for creating an Algorand testing fixture. */
52
- interface AlgorandFixtureConfig extends Partial<AlgoConfig> {
53
- /** An optional algod client, if not specified then it will create one against `algodConfig` (if present) then environment variables defined network (if present) or default LocalNet. */
54
- algod?: AlgodClient;
55
- /** An optional indexer client, if not specified then it will create one against `indexerConfig` (if present) then environment variables defined network (if present) or default LocalNet. */
56
- indexer?: IndexerClient;
57
- /** An optional kmd client, if not specified then it will create one against `kmdConfig` (if present) then environment variables defined network (if present) or default LocalNet. */
58
- kmd?: KmdClient;
59
- /** The amount of funds to allocate to the default testing account, if not specified then it will get 10 ALGO. */
60
- testAccountFunding?: AlgoAmount;
61
- /** Optional override for how to get an account; this allows you to retrieve accounts from a known or cached list of accounts. */
62
- accountGetter?: (algorand: AlgorandClient) => Promise<Address & AddressWithSigners>;
63
- }
64
- /** An Algorand automated testing fixture */
65
- interface AlgorandFixture {
66
- /**
67
- * Retrieve the current context.
68
- * Useful with destructuring.
69
- *
70
- * If you haven't called `newScope` then this will throw an error.
71
- * @example
72
- * ```typescript
73
- * test('My test', () => {
74
- * const {algod, indexer, testAccount, ...} = fixture.context
75
- * })
76
- * ```
77
- */
78
- get context(): AlgorandTestAutomationContext;
79
- /**
80
- * Retrieve an `AlgorandClient` loaded with the current context, including testAccount and any generated accounts loaded as signers.
81
- */
82
- get algorand(): AlgorandClient;
83
- /**
84
- * @deprecated Use newScope instead.
85
- * Testing framework agnostic handler method to run before each test to prepare the `context` for that test with per test isolation.
86
- */
87
- beforeEach: () => Promise<void>;
88
- /**
89
- * Creates a new isolated fixture scope (clean transaction logger, AlgorandClient, testAccount, etc.).
90
- *
91
- * You can call this from any testing framework specific hook method to control when you want a new scope.
92
- *
93
- * @example Jest / vitest - per test isolation (beforeEach)
94
- * ```typescript
95
- * describe('MY MODULE', () => {
96
- * const fixture = algorandFixture()
97
- * beforeEach(fixture.newScope)
98
- *
99
- * test('MY TEST', async () => {
100
- * const { algorand, testAccount } = fixture.context
101
- *
102
- * // Test stuff!
103
- * })
104
- * })
105
- * ```
106
- *
107
- * @example Jest / vitest - test suite isolation (beforeAll)
108
- * ```typescript
109
- * describe('MY MODULE', () => {
110
- * const fixture = algorandFixture()
111
- * beforeAll(fixture.newScope)
112
- *
113
- * test('test1', async () => {
114
- * const { algorand, testAccount } = fixture.context
115
- *
116
- * // Test stuff!
117
- * })
118
- * test('test2', async () => {
119
- * const { algorand, testAccount } = fixture.context
120
- * // algorand and testAccount are the same as in test1
121
- * })
122
- * })
123
- * ```
124
- *
125
- */
126
- newScope: () => Promise<void>;
127
- }
128
- /** Configuration for preparing a captured log snapshot.
129
- * This helps ensure that the provided configuration items won't appear
130
- * with random values in the log snapshot, but rather will get substituted with predictable ids.
131
- */
132
- interface LogSnapshotConfig {
133
- /** Any transaction IDs or transactions to replace the ID for predictably */
134
- transactions?: (string | Transaction)[];
135
- /** Any accounts/addresses to replace the address for predictably */
136
- accounts?: (string | Address | LogicSigAccount | MultisigAccount | AddressWithTransactionSigner)[];
137
- /** Any app IDs to replace predictably */
138
- apps?: (string | number | bigint)[];
139
- /** Optional filter predicate to filter out logs */
140
- filterPredicate?: (log: string) => boolean;
141
- }
142
- interface AlgoKitLogCaptureFixture {
143
- /** The test logger instance for the current test */
144
- get testLogger(): TestLogger;
145
- /**
146
- * Testing framework agnostic handler method to run before each test to prepare the `testLogger` for that test.
147
- */
148
- beforeEach: () => void;
149
- /**
150
- * Testing framework agnostic handler method to run after each test to reset the logger.
151
- */
152
- afterEach: () => void;
153
- }
4
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/testing` instead */
5
+ type AlgorandTestAutomationContext = AlgorandTestAutomationContext$1;
6
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/testing` instead */
7
+ type GetTestAccountParams = GetTestAccountParams$1;
8
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/testing` instead */
9
+ type AlgorandFixtureConfig = AlgorandFixtureConfig$1;
10
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/testing` instead */
11
+ type AlgorandFixture = AlgorandFixture$1;
12
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/testing` instead */
13
+ type LogSnapshotConfig = LogSnapshotConfig$1;
14
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/testing` instead */
15
+ type AlgoKitLogCaptureFixture = AlgoKitLogCaptureFixture$1;
154
16
  //#endregion
155
17
  export { AlgoKitLogCaptureFixture, AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams, LogSnapshotConfig };
156
18
  //# sourceMappingURL=testing.d.ts.map
@@ -1,133 +1,38 @@
1
- import { Expand } from "../packages/common/src/expand.js";
2
- import { ABIReturn } from "../packages/abi/src/abi-method.js";
3
- import { Transaction } from "../packages/transact/src/transactions/transaction.js";
4
- import { AddressWithTransactionSigner, SendingAddress, TransactionSigner } from "../packages/transact/src/signer.js";
5
- import { PendingTransactionResponse } from "../packages/algod_client/src/models/pending-transaction-response.js";
6
- import { AlgoAmount } from "./amount.js";
7
- import { TransactionComposer } from "./composer.js";
1
+ import { AdditionalTransactionComposerContext as AdditionalTransactionComposerContext$1, Arc2TransactionNote as Arc2TransactionNote$1, ConfirmedTransactionResult as ConfirmedTransactionResult$1, ConfirmedTransactionResults as ConfirmedTransactionResults$1, SendParams as SendParams$1, SendSingleTransactionResult as SendSingleTransactionResult$1, SendTransactionComposerResults as SendTransactionComposerResults$1, SendTransactionFrom as SendTransactionFrom$1, SendTransactionParams as SendTransactionParams$1, SendTransactionResult as SendTransactionResult$1, SendTransactionResults as SendTransactionResults$1, TransactionComposerToSend as TransactionComposerToSend$1, TransactionGroupToSend as TransactionGroupToSend$1, TransactionNote as TransactionNote$1, TransactionNoteData as TransactionNoteData$1, TransactionToSign as TransactionToSign$1 } from "../transaction/types.js";
8
2
 
9
3
  //#region src/types/transaction.d.ts
10
- type TransactionNote = Uint8Array | TransactionNoteData | Arc2TransactionNote;
11
- type TransactionNoteData = string | null | undefined | number | any[] | Record<string, any>;
12
- /** ARC-0002 compatible transaction note components https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md */
13
- type Arc2TransactionNote = {
14
- dAppName: string;
15
- format: 'm' | 'b' | 'u';
16
- data: string;
17
- } | {
18
- dAppName: string;
19
- format: 'j';
20
- data: TransactionNoteData;
21
- };
22
- /** The sending configuration for a transaction */
23
- interface SendTransactionParams {
24
- /** Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain, unless `atc` specified)
25
- * and instead just return the raw transaction, e.g. so you can add it to a group of transactions */
26
- skipSending?: boolean;
27
- /** Whether to skip waiting for the submitted transaction (only relevant if `skipSending` is `false` or unset) */
28
- skipWaiting?: boolean;
29
- /** An optional `TransactionComposer` to add the transaction to, if specified then `skipSending: undefined` has the same effect as `skipSending: true` */
30
- transactionComposer?: TransactionComposer;
31
- /** Whether to suppress log messages from transaction send, default: do not suppress */
32
- suppressLog?: boolean;
33
- /** The flat fee you want to pay, useful for covering extra fees in a transaction group or app call */
34
- fee?: AlgoAmount;
35
- /** The maximum fee that you are happy to pay (default: unbounded) - if this is set it's possible the transaction could get rejected during network congestion */
36
- maxFee?: AlgoAmount;
37
- /** The maximum number of rounds to wait for confirmation, only applies if `skipWaiting` is `undefined` or `false`, default: wait up to 5 rounds */
38
- maxRoundsToWaitForConfirmation?: number;
39
- /** Whether to use simulate to automatically populate app call resources in the txn objects. Defaults to true when there are app calls in the group. */
40
- populateAppCallResources?: boolean;
41
- }
42
- /** Result from sending a single transaction. */
43
- type SendSingleTransactionResult = Expand<SendTransactionComposerResults & ConfirmedTransactionResult>;
44
- /** The result of sending a transaction */
45
- interface SendTransactionResult {
46
- /** The transaction */
47
- transaction: Transaction;
48
- /** The response if the transaction was sent and waited for */
49
- confirmation?: PendingTransactionResponse;
50
- }
51
- /** The result of preparing and/or sending multiple transactions */
52
- interface SendTransactionResults {
53
- /** The transactions that have been prepared and/or sent */
54
- transactions: Transaction[];
55
- /** The responses if the transactions were sent and waited for,
56
- * the index of the confirmation will match the index of the underlying transaction
57
- */
58
- confirmations?: PendingTransactionResponse[];
59
- }
60
- /** The result of preparing and/or sending multiple transactions using an `TransactionComposer` */
61
- interface SendTransactionComposerResults extends Omit<SendTransactionResults, 'confirmations'> {
62
- /** base64 encoded representation of the group ID of the group */
63
- groupId: string | undefined;
64
- /** The transaction IDs that have been prepared and/or sent */
65
- txIds: string[];
66
- /** If ABI method(s) were called the processed return values */
67
- returns?: ABIReturn[];
68
- /** The responses if the transactions were sent and waited for,
69
- * the index of the confirmation will match the index of the underlying transaction
70
- */
71
- confirmations: PendingTransactionResponse[];
72
- }
73
- /** The result of sending and confirming a transaction */
74
- interface ConfirmedTransactionResult extends SendTransactionResult {
75
- /** The response from sending and waiting for the transaction */
76
- confirmation: PendingTransactionResponse;
77
- }
78
- /** The result of sending and confirming one or more transactions, but where there is a primary transaction of interest */
79
- interface ConfirmedTransactionResults extends SendTransactionResult, SendTransactionResults {
80
- /** The response from sending and waiting for the primary transaction */
81
- confirmation: PendingTransactionResponse;
82
- /** The response from sending and waiting for the transactions */
83
- confirmations: PendingTransactionResponse[];
84
- }
85
- /**
86
- * @deprcated Use `SendingAddress` instead
87
- */
88
- type SendTransactionFrom = AddressWithTransactionSigner;
89
- /** Defines an unsigned transaction that will appear in a group of transactions along with its signing information */
90
- interface TransactionToSign {
91
- /** The unsigned transaction to sign and send */
92
- transaction: Transaction;
93
- /** The account to use to sign the transaction, either an account (with private key loaded) or a logic signature account */
94
- signer: AddressWithTransactionSigner | TransactionSigner;
95
- }
96
- /** A group of transactions to send together as an group
97
- * https://dev.algorand.co/concepts/transactions/atomic-txn-groups/
98
- */
99
- interface TransactionGroupToSend {
100
- /** Any parameters to control the semantics of the send to the network */
101
- sendParams?: Omit<SendTransactionParams, 'fee' | 'maxFee' | 'skipSending' | 'atc'>;
102
- /** The list of transactions to send, which can either be a raw transaction (in which case `signer` is required),
103
- * the async result of an AlgoKit utils method that returns a `SendTransactionResult` (saves unwrapping the promise, be sure to pass `skipSending: true`, `signer` is also required)
104
- * or the transaction with its signer (`signer` is ignored)
105
- **/
106
- transactions: (TransactionToSign | Transaction | Promise<SendTransactionResult>)[];
107
- /** Optional signer to pass in, required if at least one transaction provided is just the transaction, ignored otherwise */
108
- signer?: SendingAddress;
109
- }
110
- /** Parameters to configure transaction sending. */
111
- interface SendParams {
112
- /** The number of rounds to wait for confirmation. By default until the latest lastValid has past. */
113
- maxRoundsToWaitForConfirmation?: number;
114
- /** Whether to suppress log messages from transaction send, default: do not suppress. */
115
- suppressLog?: boolean;
116
- /** Whether to use simulate to automatically populate app call resources in the txn objects. Defaults to `Config.populateAppCallResources`. */
117
- populateAppCallResources?: boolean;
118
- /** Whether to use simulate to automatically calculate required app call inner transaction fees and cover them in the parent app call transaction fee */
119
- coverAppCallInnerTransactionFees?: boolean;
120
- }
121
- /** Additional context about the `TransactionComposer`. */
122
- interface AdditionalTransactionComposerContext {
123
- /** A map of transaction index in the `TransactionComposer` to the max fee that can be calculated for a transaction in the group */
124
- maxFees: Map<number, AlgoAmount>;
125
- }
126
- /** An `TransactionComposer` with transactions to send. */
127
- interface TransactionComposerToSend extends SendParams {
128
- /** The `TransactionComposer` with transactions loaded to send */
129
- transactionComposer: TransactionComposer;
130
- }
4
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
5
+ type TransactionNote = TransactionNote$1;
6
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
7
+ type TransactionNoteData = TransactionNoteData$1;
8
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
9
+ type Arc2TransactionNote = Arc2TransactionNote$1;
10
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
11
+ type SendTransactionParams = SendTransactionParams$1;
12
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
13
+ type SendSingleTransactionResult = SendSingleTransactionResult$1;
14
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
15
+ type SendTransactionResult = SendTransactionResult$1;
16
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
17
+ type SendTransactionResults = SendTransactionResults$1;
18
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
19
+ type SendTransactionComposerResults = SendTransactionComposerResults$1;
20
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
21
+ type ConfirmedTransactionResult = ConfirmedTransactionResult$1;
22
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
23
+ type ConfirmedTransactionResults = ConfirmedTransactionResults$1;
24
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
25
+ type SendTransactionFrom = SendTransactionFrom$1;
26
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
27
+ type TransactionToSign = TransactionToSign$1;
28
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
29
+ type TransactionGroupToSend = TransactionGroupToSend$1;
30
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
31
+ type SendParams = SendParams$1;
32
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
33
+ type AdditionalTransactionComposerContext = AdditionalTransactionComposerContext$1;
34
+ /** @deprecated Import from `@algorandfoundation/algokit-utils/transaction` instead */
35
+ type TransactionComposerToSend = TransactionComposerToSend$1;
131
36
  //#endregion
132
37
  export { AdditionalTransactionComposerContext, Arc2TransactionNote, ConfirmedTransactionResult, ConfirmedTransactionResults, SendParams, SendSingleTransactionResult, SendTransactionComposerResults, SendTransactionFrom, SendTransactionParams, SendTransactionResult, SendTransactionResults, TransactionComposerToSend, TransactionGroupToSend, TransactionNote, TransactionNoteData, TransactionToSign };
133
38
  //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1,57 @@
1
+ import { Logger } from "./packages/common/src/logger.js";
2
+ import { AsyncEventEmitter } from "./async-event-emitter.js";
3
+
4
+ //#region src/updatable-config.d.ts
5
+ /** The AlgoKit configuration type */
6
+ interface Config {
7
+ /** Logger */
8
+ logger: Logger;
9
+ /** Whether or not debug mode is enabled */
10
+ debug: boolean;
11
+ /** The path to the project root directory */
12
+ projectRoot: string | null;
13
+ /** Indicates whether to trace all operations */
14
+ traceAll: boolean;
15
+ /** The size of the trace buffer in megabytes */
16
+ traceBufferSizeMb: number;
17
+ /** The maximum depth to search for a specific file */
18
+ maxSearchDepth: number;
19
+ /**
20
+ * Whether to enable populateAppCallResources in sendParams by default.
21
+ * Default value is false.
22
+ */
23
+ populateAppCallResources: boolean;
24
+ events: AsyncEventEmitter;
25
+ }
26
+ /** Updatable AlgoKit config */
27
+ declare class UpdatableConfig implements Readonly<Config> {
28
+ private config;
29
+ get populateAppCallResources(): boolean;
30
+ get logger(): Logger;
31
+ get debug(): boolean;
32
+ get projectRoot(): string | null;
33
+ get traceAll(): boolean;
34
+ get traceBufferSizeMb(): number;
35
+ get maxSearchDepth(): number;
36
+ get events(): AsyncEventEmitter;
37
+ /**
38
+ * Returns the current logger, or the null logger if true is passed in to `returnNullLogger`
39
+ * @param returnNullLogger Whether or not to return the null logger
40
+ * @returns The requested logger
41
+ */
42
+ getLogger(returnNullLogger?: boolean): Logger;
43
+ /**
44
+ * Temporarily run with debug set to true.
45
+ * @param lambda A lambda expression with code to run with debug config set to true
46
+ */
47
+ withDebug(lambda: () => unknown): void;
48
+ constructor();
49
+ /**
50
+ * Update the AlgoKit configuration with your own configuration settings
51
+ * @param newConfig Partial or complete config to replace
52
+ */
53
+ configure(newConfig: Partial<Config>): void;
54
+ }
55
+ //#endregion
56
+ export { Config, UpdatableConfig };
57
+ //# sourceMappingURL=updatable-config.d.ts.map
@@ -0,0 +1,80 @@
1
+ const require_async_event_emitter = require('./async-event-emitter.js');
2
+ const require_logging = require('./logging.js');
3
+
4
+ //#region src/updatable-config.ts
5
+ /** Updatable AlgoKit config */
6
+ var UpdatableConfig = class {
7
+ config;
8
+ get populateAppCallResources() {
9
+ return this.config.populateAppCallResources;
10
+ }
11
+ get logger() {
12
+ return this.config.logger;
13
+ }
14
+ get debug() {
15
+ return this.config.debug;
16
+ }
17
+ get projectRoot() {
18
+ return this.config.projectRoot;
19
+ }
20
+ get traceAll() {
21
+ return this.config.traceAll;
22
+ }
23
+ get traceBufferSizeMb() {
24
+ return this.config.traceBufferSizeMb;
25
+ }
26
+ get maxSearchDepth() {
27
+ return this.config.maxSearchDepth;
28
+ }
29
+ get events() {
30
+ return this.config.events;
31
+ }
32
+ /**
33
+ * Returns the current logger, or the null logger if true is passed in to `returnNullLogger`
34
+ * @param returnNullLogger Whether or not to return the null logger
35
+ * @returns The requested logger
36
+ */
37
+ getLogger(returnNullLogger) {
38
+ if (returnNullLogger) return require_logging.nullLogger;
39
+ return this.logger;
40
+ }
41
+ /**
42
+ * Temporarily run with debug set to true.
43
+ * @param lambda A lambda expression with code to run with debug config set to true
44
+ */
45
+ withDebug(lambda) {
46
+ const original = this.config.debug;
47
+ try {
48
+ this.config.debug = true;
49
+ lambda();
50
+ } finally {
51
+ this.config.debug = original;
52
+ }
53
+ }
54
+ constructor() {
55
+ this.config = {
56
+ logger: require_logging.consoleLogger,
57
+ debug: false,
58
+ projectRoot: null,
59
+ traceAll: false,
60
+ traceBufferSizeMb: 256,
61
+ maxSearchDepth: 10,
62
+ populateAppCallResources: true,
63
+ events: new require_async_event_emitter.AsyncEventEmitter()
64
+ };
65
+ }
66
+ /**
67
+ * Update the AlgoKit configuration with your own configuration settings
68
+ * @param newConfig Partial or complete config to replace
69
+ */
70
+ configure(newConfig) {
71
+ this.config = {
72
+ ...this.config,
73
+ ...newConfig
74
+ };
75
+ }
76
+ };
77
+
78
+ //#endregion
79
+ exports.UpdatableConfig = UpdatableConfig;
80
+ //# sourceMappingURL=updatable-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updatable-config.js","names":["nullLogger","consoleLogger","AsyncEventEmitter"],"sources":["../src/updatable-config.ts"],"sourcesContent":["import { AsyncEventEmitter } from './async-event-emitter'\nimport { Logger, consoleLogger, nullLogger } from './logging'\n\n/** The AlgoKit configuration type */\nexport interface Config {\n /** Logger */\n logger: Logger\n /** Whether or not debug mode is enabled */\n debug: boolean\n /** The path to the project root directory */\n projectRoot: string | null\n /** Indicates whether to trace all operations */\n traceAll: boolean\n /** The size of the trace buffer in megabytes */\n traceBufferSizeMb: number\n /** The maximum depth to search for a specific file */\n maxSearchDepth: number\n /**\n * Whether to enable populateAppCallResources in sendParams by default.\n * Default value is false.\n */\n populateAppCallResources: boolean\n\n events: AsyncEventEmitter\n}\n\n/** Updatable AlgoKit config */\nexport class UpdatableConfig implements Readonly<Config> {\n private config: Config\n\n get populateAppCallResources() {\n return this.config.populateAppCallResources\n }\n\n get logger() {\n return this.config.logger\n }\n\n get debug() {\n return this.config.debug\n }\n\n get projectRoot() {\n return this.config.projectRoot\n }\n\n get traceAll() {\n return this.config.traceAll\n }\n\n get traceBufferSizeMb() {\n return this.config.traceBufferSizeMb\n }\n\n get maxSearchDepth() {\n return this.config.maxSearchDepth\n }\n\n get events() {\n return this.config.events\n }\n\n /**\n * Returns the current logger, or the null logger if true is passed in to `returnNullLogger`\n * @param returnNullLogger Whether or not to return the null logger\n * @returns The requested logger\n */\n getLogger(returnNullLogger?: boolean) {\n if (returnNullLogger) {\n return nullLogger\n }\n\n return this.logger\n }\n\n /**\n * Temporarily run with debug set to true.\n * @param lambda A lambda expression with code to run with debug config set to true\n */\n withDebug(lambda: () => unknown) {\n const original = this.config.debug\n try {\n this.config.debug = true\n lambda()\n } finally {\n this.config.debug = original\n }\n }\n\n constructor() {\n this.config = {\n logger: consoleLogger,\n debug: false,\n projectRoot: null,\n traceAll: false,\n traceBufferSizeMb: 256,\n maxSearchDepth: 10,\n populateAppCallResources: true,\n events: new AsyncEventEmitter(),\n }\n }\n\n /**\n * Update the AlgoKit configuration with your own configuration settings\n * @param newConfig Partial or complete config to replace\n */\n configure(newConfig: Partial<Config>) {\n this.config = { ...this.config, ...newConfig }\n }\n}\n"],"mappings":";;;;;AA2BA,IAAa,kBAAb,MAAyD;CACvD,AAAQ;CAER,IAAI,2BAA2B;AAC7B,SAAO,KAAK,OAAO;;CAGrB,IAAI,SAAS;AACX,SAAO,KAAK,OAAO;;CAGrB,IAAI,QAAQ;AACV,SAAO,KAAK,OAAO;;CAGrB,IAAI,cAAc;AAChB,SAAO,KAAK,OAAO;;CAGrB,IAAI,WAAW;AACb,SAAO,KAAK,OAAO;;CAGrB,IAAI,oBAAoB;AACtB,SAAO,KAAK,OAAO;;CAGrB,IAAI,iBAAiB;AACnB,SAAO,KAAK,OAAO;;CAGrB,IAAI,SAAS;AACX,SAAO,KAAK,OAAO;;;;;;;CAQrB,UAAU,kBAA4B;AACpC,MAAI,iBACF,QAAOA;AAGT,SAAO,KAAK;;;;;;CAOd,UAAU,QAAuB;EAC/B,MAAM,WAAW,KAAK,OAAO;AAC7B,MAAI;AACF,QAAK,OAAO,QAAQ;AACpB,WAAQ;YACA;AACR,QAAK,OAAO,QAAQ;;;CAIxB,cAAc;AACZ,OAAK,SAAS;GACZ,QAAQC;GACR,OAAO;GACP,aAAa;GACb,UAAU;GACV,mBAAmB;GACnB,gBAAgB;GAChB,0BAA0B;GAC1B,QAAQ,IAAIC,+CAAmB;GAChC;;;;;;CAOH,UAAU,WAA4B;AACpC,OAAK,SAAS;GAAE,GAAG,KAAK;GAAQ,GAAG;GAAW"}
@@ -0,0 +1,80 @@
1
+ import { AsyncEventEmitter } from "./async-event-emitter.mjs";
2
+ import { consoleLogger, nullLogger } from "./logging.mjs";
3
+
4
+ //#region src/updatable-config.ts
5
+ /** Updatable AlgoKit config */
6
+ var UpdatableConfig = class {
7
+ config;
8
+ get populateAppCallResources() {
9
+ return this.config.populateAppCallResources;
10
+ }
11
+ get logger() {
12
+ return this.config.logger;
13
+ }
14
+ get debug() {
15
+ return this.config.debug;
16
+ }
17
+ get projectRoot() {
18
+ return this.config.projectRoot;
19
+ }
20
+ get traceAll() {
21
+ return this.config.traceAll;
22
+ }
23
+ get traceBufferSizeMb() {
24
+ return this.config.traceBufferSizeMb;
25
+ }
26
+ get maxSearchDepth() {
27
+ return this.config.maxSearchDepth;
28
+ }
29
+ get events() {
30
+ return this.config.events;
31
+ }
32
+ /**
33
+ * Returns the current logger, or the null logger if true is passed in to `returnNullLogger`
34
+ * @param returnNullLogger Whether or not to return the null logger
35
+ * @returns The requested logger
36
+ */
37
+ getLogger(returnNullLogger) {
38
+ if (returnNullLogger) return nullLogger;
39
+ return this.logger;
40
+ }
41
+ /**
42
+ * Temporarily run with debug set to true.
43
+ * @param lambda A lambda expression with code to run with debug config set to true
44
+ */
45
+ withDebug(lambda) {
46
+ const original = this.config.debug;
47
+ try {
48
+ this.config.debug = true;
49
+ lambda();
50
+ } finally {
51
+ this.config.debug = original;
52
+ }
53
+ }
54
+ constructor() {
55
+ this.config = {
56
+ logger: consoleLogger,
57
+ debug: false,
58
+ projectRoot: null,
59
+ traceAll: false,
60
+ traceBufferSizeMb: 256,
61
+ maxSearchDepth: 10,
62
+ populateAppCallResources: true,
63
+ events: new AsyncEventEmitter()
64
+ };
65
+ }
66
+ /**
67
+ * Update the AlgoKit configuration with your own configuration settings
68
+ * @param newConfig Partial or complete config to replace
69
+ */
70
+ configure(newConfig) {
71
+ this.config = {
72
+ ...this.config,
73
+ ...newConfig
74
+ };
75
+ }
76
+ };
77
+
78
+ //#endregion
79
+ export { UpdatableConfig };
80
+ //# sourceMappingURL=updatable-config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updatable-config.mjs","names":[],"sources":["../src/updatable-config.ts"],"sourcesContent":["import { AsyncEventEmitter } from './async-event-emitter'\nimport { Logger, consoleLogger, nullLogger } from './logging'\n\n/** The AlgoKit configuration type */\nexport interface Config {\n /** Logger */\n logger: Logger\n /** Whether or not debug mode is enabled */\n debug: boolean\n /** The path to the project root directory */\n projectRoot: string | null\n /** Indicates whether to trace all operations */\n traceAll: boolean\n /** The size of the trace buffer in megabytes */\n traceBufferSizeMb: number\n /** The maximum depth to search for a specific file */\n maxSearchDepth: number\n /**\n * Whether to enable populateAppCallResources in sendParams by default.\n * Default value is false.\n */\n populateAppCallResources: boolean\n\n events: AsyncEventEmitter\n}\n\n/** Updatable AlgoKit config */\nexport class UpdatableConfig implements Readonly<Config> {\n private config: Config\n\n get populateAppCallResources() {\n return this.config.populateAppCallResources\n }\n\n get logger() {\n return this.config.logger\n }\n\n get debug() {\n return this.config.debug\n }\n\n get projectRoot() {\n return this.config.projectRoot\n }\n\n get traceAll() {\n return this.config.traceAll\n }\n\n get traceBufferSizeMb() {\n return this.config.traceBufferSizeMb\n }\n\n get maxSearchDepth() {\n return this.config.maxSearchDepth\n }\n\n get events() {\n return this.config.events\n }\n\n /**\n * Returns the current logger, or the null logger if true is passed in to `returnNullLogger`\n * @param returnNullLogger Whether or not to return the null logger\n * @returns The requested logger\n */\n getLogger(returnNullLogger?: boolean) {\n if (returnNullLogger) {\n return nullLogger\n }\n\n return this.logger\n }\n\n /**\n * Temporarily run with debug set to true.\n * @param lambda A lambda expression with code to run with debug config set to true\n */\n withDebug(lambda: () => unknown) {\n const original = this.config.debug\n try {\n this.config.debug = true\n lambda()\n } finally {\n this.config.debug = original\n }\n }\n\n constructor() {\n this.config = {\n logger: consoleLogger,\n debug: false,\n projectRoot: null,\n traceAll: false,\n traceBufferSizeMb: 256,\n maxSearchDepth: 10,\n populateAppCallResources: true,\n events: new AsyncEventEmitter(),\n }\n }\n\n /**\n * Update the AlgoKit configuration with your own configuration settings\n * @param newConfig Partial or complete config to replace\n */\n configure(newConfig: Partial<Config>) {\n this.config = { ...this.config, ...newConfig }\n }\n}\n"],"mappings":";;;;;AA2BA,IAAa,kBAAb,MAAyD;CACvD,AAAQ;CAER,IAAI,2BAA2B;AAC7B,SAAO,KAAK,OAAO;;CAGrB,IAAI,SAAS;AACX,SAAO,KAAK,OAAO;;CAGrB,IAAI,QAAQ;AACV,SAAO,KAAK,OAAO;;CAGrB,IAAI,cAAc;AAChB,SAAO,KAAK,OAAO;;CAGrB,IAAI,WAAW;AACb,SAAO,KAAK,OAAO;;CAGrB,IAAI,oBAAoB;AACtB,SAAO,KAAK,OAAO;;CAGrB,IAAI,iBAAiB;AACnB,SAAO,KAAK,OAAO;;CAGrB,IAAI,SAAS;AACX,SAAO,KAAK,OAAO;;;;;;;CAQrB,UAAU,kBAA4B;AACpC,MAAI,iBACF,QAAO;AAGT,SAAO,KAAK;;;;;;CAOd,UAAU,QAAuB;EAC/B,MAAM,WAAW,KAAK,OAAO;AAC7B,MAAI;AACF,QAAK,OAAO,QAAQ;AACpB,WAAQ;YACA;AACR,QAAK,OAAO,QAAQ;;;CAIxB,cAAc;AACZ,OAAK,SAAS;GACZ,QAAQ;GACR,OAAO;GACP,aAAa;GACb,UAAU;GACV,mBAAmB;GACnB,gBAAgB;GAChB,0BAA0B;GAC1B,QAAQ,IAAI,mBAAmB;GAChC;;;;;;CAOH,UAAU,WAA4B;AACpC,OAAK,SAAS;GAAE,GAAG,KAAK;GAAQ,GAAG;GAAW"}
package/util.js CHANGED
@@ -1,4 +1,4 @@
1
- const require_app = require('./types/app.js');
1
+ const require_app = require('./app.js');
2
2
 
3
3
  //#region src/util.ts
4
4
  /**
package/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","names":["APP_PAGE_MAX_SIZE"],"sources":["../src/util.ts"],"sourcesContent":["import { APP_PAGE_MAX_SIZE } from './types/app'\n\n/**\n * Converts a value which might be a number or a bigint into a number to be used with apis that don't support bigint.\n *\n * Throws an UnsafeConversionError if the conversion would result in an unsafe integer for the Number type\n * @param value\n */\nexport const toNumber = (value: number | bigint) => {\n if (typeof value === 'number') return value\n\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new UnsafeConversionError(\n `Cannot convert ${value} to a Number as it is larger than the maximum safe integer the Number type can hold.`,\n )\n } else if (value < BigInt(Number.MIN_SAFE_INTEGER)) {\n throw new UnsafeConversionError(\n `Cannot convert ${value} to a Number as it is smaller than the minimum safe integer the Number type can hold.`,\n )\n }\n return Number(value)\n}\n\nexport class UnsafeConversionError extends Error {}\n\n/**\n * Calculates the amount of funds to add to a wallet to bring it up to the minimum spending balance.\n * @param minSpendingBalance The minimum spending balance for the wallet\n * @param currentSpendingBalance The current spending balance for the wallet\n * @param minFundingIncrement The minimum amount of funds that can be added to the wallet\n * @returns The amount of funds to add to the wallet or null if the wallet is already above the minimum spending balance\n */\nexport const calculateFundAmount = (\n minSpendingBalance: bigint,\n currentSpendingBalance: bigint,\n minFundingIncrement: bigint,\n): bigint | null => {\n if (minSpendingBalance > currentSpendingBalance) {\n const minFundAmount = minSpendingBalance - currentSpendingBalance\n return BigInt(Math.max(Number(minFundAmount), Number(minFundingIncrement)))\n } else {\n return null\n }\n}\n\n/**\n * Checks if the current environment is Node.js\n *\n * @returns A boolean indicating whether the current environment is Node.js\n */\nexport const isNode = () => {\n return typeof process !== 'undefined' && process.versions != null && process.versions.node != null\n}\n\n/**\n * Returns the given array split into chunks of `batchSize` batches.\n * @param array The array to chunk\n * @param batchSize The size of batches to split the array into\n * @returns A generator that yields the array split into chunks of `batchSize` batches\n */\nexport function* chunkArray<T>(array: T[], batchSize: number): Generator<T[], void> {\n for (let i = 0; i < array.length; i += batchSize) yield array.slice(i, i + batchSize)\n}\n\n/**\n * Memoize calls to the given function in an in-memory map.\n * @param fn The function to memoize\n * @returns The memoized function\n */\nexport const memoize = <T = unknown, R = unknown>(fn: (val: T) => R) => {\n const cache = new Map()\n const cached = function (this: unknown, val: T) {\n return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val)\n }\n cached.cache = cache\n return cached as (val: T) => R\n}\n\nexport const binaryStartsWith = (base: Uint8Array, startsWith: Uint8Array): boolean => {\n if (startsWith.length > base.length) return false\n for (let i = 0; i < startsWith.length; i++) {\n if (base[i] !== startsWith[i]) return false\n }\n return true\n}\n\nexport const defaultJsonValueReplacer = (key: string, value: unknown) => {\n if (typeof value === 'bigint') {\n try {\n return toNumber(value)\n } catch {\n return value.toString()\n }\n }\n return value\n}\nexport const asJson = (\n value: unknown,\n replacer: (key: string, value: unknown) => unknown = defaultJsonValueReplacer,\n space?: string | number,\n) => {\n return JSON.stringify(value, replacer, space)\n}\n\n/** Calculate minimum number of extra program pages required for provided approval and clear state programs */\nexport const calculateExtraProgramPages = (approvalProgram: Uint8Array, clearStateProgram?: Uint8Array): number => {\n return Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0) - 1) / APP_PAGE_MAX_SIZE)\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,YAAY,UAA2B;AAClD,KAAI,OAAO,UAAU,SAAU,QAAO;AAEtC,KAAI,QAAQ,OAAO,OAAO,iBAAiB,CACzC,OAAM,IAAI,sBACR,kBAAkB,MAAM,sFACzB;UACQ,QAAQ,OAAO,OAAO,iBAAiB,CAChD,OAAM,IAAI,sBACR,kBAAkB,MAAM,uFACzB;AAEH,QAAO,OAAO,MAAM;;AAGtB,IAAa,wBAAb,cAA2C,MAAM;;;;;;;;AASjD,MAAa,uBACX,oBACA,wBACA,wBACkB;AAClB,KAAI,qBAAqB,wBAAwB;EAC/C,MAAM,gBAAgB,qBAAqB;AAC3C,SAAO,OAAO,KAAK,IAAI,OAAO,cAAc,EAAE,OAAO,oBAAoB,CAAC,CAAC;OAE3E,QAAO;;;;;;;;AAmBX,UAAiB,WAAc,OAAY,WAAyC;AAClF,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,UAAW,OAAM,MAAM,MAAM,GAAG,IAAI,UAAU;;;;;;;AAQvF,MAAa,WAAqC,OAAsB;CACtE,MAAM,wBAAQ,IAAI,KAAK;CACvB,MAAM,SAAS,SAAyB,KAAQ;AAC9C,SAAO,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,KAAK,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,MAAM,IAAI,IAAI;;AAE/F,QAAO,QAAQ;AACf,QAAO;;AAGT,MAAa,oBAAoB,MAAkB,eAAoC;AACrF,KAAI,WAAW,SAAS,KAAK,OAAQ,QAAO;AAC5C,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,KAAI,KAAK,OAAO,WAAW,GAAI,QAAO;AAExC,QAAO;;AAGT,MAAa,4BAA4B,KAAa,UAAmB;AACvE,KAAI,OAAO,UAAU,SACnB,KAAI;AACF,SAAO,SAAS,MAAM;SAChB;AACN,SAAO,MAAM,UAAU;;AAG3B,QAAO;;AAET,MAAa,UACX,OACA,WAAqD,0BACrD,UACG;AACH,QAAO,KAAK,UAAU,OAAO,UAAU,MAAM;;;AAI/C,MAAa,8BAA8B,iBAA6B,sBAA2C;AACjH,QAAO,KAAK,OAAO,gBAAgB,UAAU,mBAAmB,UAAU,KAAK,KAAKA,8BAAkB"}
1
+ {"version":3,"file":"util.js","names":["APP_PAGE_MAX_SIZE"],"sources":["../src/util.ts"],"sourcesContent":["import { APP_PAGE_MAX_SIZE } from './app'\n\n/**\n * Converts a value which might be a number or a bigint into a number to be used with apis that don't support bigint.\n *\n * Throws an UnsafeConversionError if the conversion would result in an unsafe integer for the Number type\n * @param value\n */\nexport const toNumber = (value: number | bigint) => {\n if (typeof value === 'number') return value\n\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new UnsafeConversionError(\n `Cannot convert ${value} to a Number as it is larger than the maximum safe integer the Number type can hold.`,\n )\n } else if (value < BigInt(Number.MIN_SAFE_INTEGER)) {\n throw new UnsafeConversionError(\n `Cannot convert ${value} to a Number as it is smaller than the minimum safe integer the Number type can hold.`,\n )\n }\n return Number(value)\n}\n\nexport class UnsafeConversionError extends Error {}\n\n/**\n * Calculates the amount of funds to add to a wallet to bring it up to the minimum spending balance.\n * @param minSpendingBalance The minimum spending balance for the wallet\n * @param currentSpendingBalance The current spending balance for the wallet\n * @param minFundingIncrement The minimum amount of funds that can be added to the wallet\n * @returns The amount of funds to add to the wallet or null if the wallet is already above the minimum spending balance\n */\nexport const calculateFundAmount = (\n minSpendingBalance: bigint,\n currentSpendingBalance: bigint,\n minFundingIncrement: bigint,\n): bigint | null => {\n if (minSpendingBalance > currentSpendingBalance) {\n const minFundAmount = minSpendingBalance - currentSpendingBalance\n return BigInt(Math.max(Number(minFundAmount), Number(minFundingIncrement)))\n } else {\n return null\n }\n}\n\n/**\n * Checks if the current environment is Node.js\n *\n * @returns A boolean indicating whether the current environment is Node.js\n */\nexport const isNode = () => {\n return typeof process !== 'undefined' && process.versions != null && process.versions.node != null\n}\n\n/**\n * Returns the given array split into chunks of `batchSize` batches.\n * @param array The array to chunk\n * @param batchSize The size of batches to split the array into\n * @returns A generator that yields the array split into chunks of `batchSize` batches\n */\nexport function* chunkArray<T>(array: T[], batchSize: number): Generator<T[], void> {\n for (let i = 0; i < array.length; i += batchSize) yield array.slice(i, i + batchSize)\n}\n\n/**\n * Memoize calls to the given function in an in-memory map.\n * @param fn The function to memoize\n * @returns The memoized function\n */\nexport const memoize = <T = unknown, R = unknown>(fn: (val: T) => R) => {\n const cache = new Map()\n const cached = function (this: unknown, val: T) {\n return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val)\n }\n cached.cache = cache\n return cached as (val: T) => R\n}\n\nexport const binaryStartsWith = (base: Uint8Array, startsWith: Uint8Array): boolean => {\n if (startsWith.length > base.length) return false\n for (let i = 0; i < startsWith.length; i++) {\n if (base[i] !== startsWith[i]) return false\n }\n return true\n}\n\nexport const defaultJsonValueReplacer = (key: string, value: unknown) => {\n if (typeof value === 'bigint') {\n try {\n return toNumber(value)\n } catch {\n return value.toString()\n }\n }\n return value\n}\nexport const asJson = (\n value: unknown,\n replacer: (key: string, value: unknown) => unknown = defaultJsonValueReplacer,\n space?: string | number,\n) => {\n return JSON.stringify(value, replacer, space)\n}\n\n/** Calculate minimum number of extra program pages required for provided approval and clear state programs */\nexport const calculateExtraProgramPages = (approvalProgram: Uint8Array, clearStateProgram?: Uint8Array): number => {\n return Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0) - 1) / APP_PAGE_MAX_SIZE)\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,YAAY,UAA2B;AAClD,KAAI,OAAO,UAAU,SAAU,QAAO;AAEtC,KAAI,QAAQ,OAAO,OAAO,iBAAiB,CACzC,OAAM,IAAI,sBACR,kBAAkB,MAAM,sFACzB;UACQ,QAAQ,OAAO,OAAO,iBAAiB,CAChD,OAAM,IAAI,sBACR,kBAAkB,MAAM,uFACzB;AAEH,QAAO,OAAO,MAAM;;AAGtB,IAAa,wBAAb,cAA2C,MAAM;;;;;;;;AASjD,MAAa,uBACX,oBACA,wBACA,wBACkB;AAClB,KAAI,qBAAqB,wBAAwB;EAC/C,MAAM,gBAAgB,qBAAqB;AAC3C,SAAO,OAAO,KAAK,IAAI,OAAO,cAAc,EAAE,OAAO,oBAAoB,CAAC,CAAC;OAE3E,QAAO;;;;;;;;AAmBX,UAAiB,WAAc,OAAY,WAAyC;AAClF,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,UAAW,OAAM,MAAM,MAAM,GAAG,IAAI,UAAU;;;;;;;AAQvF,MAAa,WAAqC,OAAsB;CACtE,MAAM,wBAAQ,IAAI,KAAK;CACvB,MAAM,SAAS,SAAyB,KAAQ;AAC9C,SAAO,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,KAAK,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,MAAM,IAAI,IAAI;;AAE/F,QAAO,QAAQ;AACf,QAAO;;AAGT,MAAa,oBAAoB,MAAkB,eAAoC;AACrF,KAAI,WAAW,SAAS,KAAK,OAAQ,QAAO;AAC5C,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,KAAI,KAAK,OAAO,WAAW,GAAI,QAAO;AAExC,QAAO;;AAGT,MAAa,4BAA4B,KAAa,UAAmB;AACvE,KAAI,OAAO,UAAU,SACnB,KAAI;AACF,SAAO,SAAS,MAAM;SAChB;AACN,SAAO,MAAM,UAAU;;AAG3B,QAAO;;AAET,MAAa,UACX,OACA,WAAqD,0BACrD,UACG;AACH,QAAO,KAAK,UAAU,OAAO,UAAU,MAAM;;;AAI/C,MAAa,8BAA8B,iBAA6B,sBAA2C;AACjH,QAAO,KAAK,OAAO,gBAAgB,UAAU,mBAAmB,UAAU,KAAK,KAAKA,8BAAkB"}
package/util.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { APP_PAGE_MAX_SIZE } from "./types/app.mjs";
1
+ import { APP_PAGE_MAX_SIZE } from "./app.mjs";
2
2
 
3
3
  //#region src/util.ts
4
4
  /**
package/util.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.mjs","names":[],"sources":["../src/util.ts"],"sourcesContent":["import { APP_PAGE_MAX_SIZE } from './types/app'\n\n/**\n * Converts a value which might be a number or a bigint into a number to be used with apis that don't support bigint.\n *\n * Throws an UnsafeConversionError if the conversion would result in an unsafe integer for the Number type\n * @param value\n */\nexport const toNumber = (value: number | bigint) => {\n if (typeof value === 'number') return value\n\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new UnsafeConversionError(\n `Cannot convert ${value} to a Number as it is larger than the maximum safe integer the Number type can hold.`,\n )\n } else if (value < BigInt(Number.MIN_SAFE_INTEGER)) {\n throw new UnsafeConversionError(\n `Cannot convert ${value} to a Number as it is smaller than the minimum safe integer the Number type can hold.`,\n )\n }\n return Number(value)\n}\n\nexport class UnsafeConversionError extends Error {}\n\n/**\n * Calculates the amount of funds to add to a wallet to bring it up to the minimum spending balance.\n * @param minSpendingBalance The minimum spending balance for the wallet\n * @param currentSpendingBalance The current spending balance for the wallet\n * @param minFundingIncrement The minimum amount of funds that can be added to the wallet\n * @returns The amount of funds to add to the wallet or null if the wallet is already above the minimum spending balance\n */\nexport const calculateFundAmount = (\n minSpendingBalance: bigint,\n currentSpendingBalance: bigint,\n minFundingIncrement: bigint,\n): bigint | null => {\n if (minSpendingBalance > currentSpendingBalance) {\n const minFundAmount = minSpendingBalance - currentSpendingBalance\n return BigInt(Math.max(Number(minFundAmount), Number(minFundingIncrement)))\n } else {\n return null\n }\n}\n\n/**\n * Checks if the current environment is Node.js\n *\n * @returns A boolean indicating whether the current environment is Node.js\n */\nexport const isNode = () => {\n return typeof process !== 'undefined' && process.versions != null && process.versions.node != null\n}\n\n/**\n * Returns the given array split into chunks of `batchSize` batches.\n * @param array The array to chunk\n * @param batchSize The size of batches to split the array into\n * @returns A generator that yields the array split into chunks of `batchSize` batches\n */\nexport function* chunkArray<T>(array: T[], batchSize: number): Generator<T[], void> {\n for (let i = 0; i < array.length; i += batchSize) yield array.slice(i, i + batchSize)\n}\n\n/**\n * Memoize calls to the given function in an in-memory map.\n * @param fn The function to memoize\n * @returns The memoized function\n */\nexport const memoize = <T = unknown, R = unknown>(fn: (val: T) => R) => {\n const cache = new Map()\n const cached = function (this: unknown, val: T) {\n return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val)\n }\n cached.cache = cache\n return cached as (val: T) => R\n}\n\nexport const binaryStartsWith = (base: Uint8Array, startsWith: Uint8Array): boolean => {\n if (startsWith.length > base.length) return false\n for (let i = 0; i < startsWith.length; i++) {\n if (base[i] !== startsWith[i]) return false\n }\n return true\n}\n\nexport const defaultJsonValueReplacer = (key: string, value: unknown) => {\n if (typeof value === 'bigint') {\n try {\n return toNumber(value)\n } catch {\n return value.toString()\n }\n }\n return value\n}\nexport const asJson = (\n value: unknown,\n replacer: (key: string, value: unknown) => unknown = defaultJsonValueReplacer,\n space?: string | number,\n) => {\n return JSON.stringify(value, replacer, space)\n}\n\n/** Calculate minimum number of extra program pages required for provided approval and clear state programs */\nexport const calculateExtraProgramPages = (approvalProgram: Uint8Array, clearStateProgram?: Uint8Array): number => {\n return Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0) - 1) / APP_PAGE_MAX_SIZE)\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,YAAY,UAA2B;AAClD,KAAI,OAAO,UAAU,SAAU,QAAO;AAEtC,KAAI,QAAQ,OAAO,OAAO,iBAAiB,CACzC,OAAM,IAAI,sBACR,kBAAkB,MAAM,sFACzB;UACQ,QAAQ,OAAO,OAAO,iBAAiB,CAChD,OAAM,IAAI,sBACR,kBAAkB,MAAM,uFACzB;AAEH,QAAO,OAAO,MAAM;;AAGtB,IAAa,wBAAb,cAA2C,MAAM;;;;;;;;AASjD,MAAa,uBACX,oBACA,wBACA,wBACkB;AAClB,KAAI,qBAAqB,wBAAwB;EAC/C,MAAM,gBAAgB,qBAAqB;AAC3C,SAAO,OAAO,KAAK,IAAI,OAAO,cAAc,EAAE,OAAO,oBAAoB,CAAC,CAAC;OAE3E,QAAO;;;;;;;;AAmBX,UAAiB,WAAc,OAAY,WAAyC;AAClF,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,UAAW,OAAM,MAAM,MAAM,GAAG,IAAI,UAAU;;;;;;;AAQvF,MAAa,WAAqC,OAAsB;CACtE,MAAM,wBAAQ,IAAI,KAAK;CACvB,MAAM,SAAS,SAAyB,KAAQ;AAC9C,SAAO,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,KAAK,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,MAAM,IAAI,IAAI;;AAE/F,QAAO,QAAQ;AACf,QAAO;;AAGT,MAAa,oBAAoB,MAAkB,eAAoC;AACrF,KAAI,WAAW,SAAS,KAAK,OAAQ,QAAO;AAC5C,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,KAAI,KAAK,OAAO,WAAW,GAAI,QAAO;AAExC,QAAO;;AAGT,MAAa,4BAA4B,KAAa,UAAmB;AACvE,KAAI,OAAO,UAAU,SACnB,KAAI;AACF,SAAO,SAAS,MAAM;SAChB;AACN,SAAO,MAAM,UAAU;;AAG3B,QAAO;;AAET,MAAa,UACX,OACA,WAAqD,0BACrD,UACG;AACH,QAAO,KAAK,UAAU,OAAO,UAAU,MAAM;;;AAI/C,MAAa,8BAA8B,iBAA6B,sBAA2C;AACjH,QAAO,KAAK,OAAO,gBAAgB,UAAU,mBAAmB,UAAU,KAAK,KAAK,kBAAkB"}
1
+ {"version":3,"file":"util.mjs","names":[],"sources":["../src/util.ts"],"sourcesContent":["import { APP_PAGE_MAX_SIZE } from './app'\n\n/**\n * Converts a value which might be a number or a bigint into a number to be used with apis that don't support bigint.\n *\n * Throws an UnsafeConversionError if the conversion would result in an unsafe integer for the Number type\n * @param value\n */\nexport const toNumber = (value: number | bigint) => {\n if (typeof value === 'number') return value\n\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new UnsafeConversionError(\n `Cannot convert ${value} to a Number as it is larger than the maximum safe integer the Number type can hold.`,\n )\n } else if (value < BigInt(Number.MIN_SAFE_INTEGER)) {\n throw new UnsafeConversionError(\n `Cannot convert ${value} to a Number as it is smaller than the minimum safe integer the Number type can hold.`,\n )\n }\n return Number(value)\n}\n\nexport class UnsafeConversionError extends Error {}\n\n/**\n * Calculates the amount of funds to add to a wallet to bring it up to the minimum spending balance.\n * @param minSpendingBalance The minimum spending balance for the wallet\n * @param currentSpendingBalance The current spending balance for the wallet\n * @param minFundingIncrement The minimum amount of funds that can be added to the wallet\n * @returns The amount of funds to add to the wallet or null if the wallet is already above the minimum spending balance\n */\nexport const calculateFundAmount = (\n minSpendingBalance: bigint,\n currentSpendingBalance: bigint,\n minFundingIncrement: bigint,\n): bigint | null => {\n if (minSpendingBalance > currentSpendingBalance) {\n const minFundAmount = minSpendingBalance - currentSpendingBalance\n return BigInt(Math.max(Number(minFundAmount), Number(minFundingIncrement)))\n } else {\n return null\n }\n}\n\n/**\n * Checks if the current environment is Node.js\n *\n * @returns A boolean indicating whether the current environment is Node.js\n */\nexport const isNode = () => {\n return typeof process !== 'undefined' && process.versions != null && process.versions.node != null\n}\n\n/**\n * Returns the given array split into chunks of `batchSize` batches.\n * @param array The array to chunk\n * @param batchSize The size of batches to split the array into\n * @returns A generator that yields the array split into chunks of `batchSize` batches\n */\nexport function* chunkArray<T>(array: T[], batchSize: number): Generator<T[], void> {\n for (let i = 0; i < array.length; i += batchSize) yield array.slice(i, i + batchSize)\n}\n\n/**\n * Memoize calls to the given function in an in-memory map.\n * @param fn The function to memoize\n * @returns The memoized function\n */\nexport const memoize = <T = unknown, R = unknown>(fn: (val: T) => R) => {\n const cache = new Map()\n const cached = function (this: unknown, val: T) {\n return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val)\n }\n cached.cache = cache\n return cached as (val: T) => R\n}\n\nexport const binaryStartsWith = (base: Uint8Array, startsWith: Uint8Array): boolean => {\n if (startsWith.length > base.length) return false\n for (let i = 0; i < startsWith.length; i++) {\n if (base[i] !== startsWith[i]) return false\n }\n return true\n}\n\nexport const defaultJsonValueReplacer = (key: string, value: unknown) => {\n if (typeof value === 'bigint') {\n try {\n return toNumber(value)\n } catch {\n return value.toString()\n }\n }\n return value\n}\nexport const asJson = (\n value: unknown,\n replacer: (key: string, value: unknown) => unknown = defaultJsonValueReplacer,\n space?: string | number,\n) => {\n return JSON.stringify(value, replacer, space)\n}\n\n/** Calculate minimum number of extra program pages required for provided approval and clear state programs */\nexport const calculateExtraProgramPages = (approvalProgram: Uint8Array, clearStateProgram?: Uint8Array): number => {\n return Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0) - 1) / APP_PAGE_MAX_SIZE)\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,YAAY,UAA2B;AAClD,KAAI,OAAO,UAAU,SAAU,QAAO;AAEtC,KAAI,QAAQ,OAAO,OAAO,iBAAiB,CACzC,OAAM,IAAI,sBACR,kBAAkB,MAAM,sFACzB;UACQ,QAAQ,OAAO,OAAO,iBAAiB,CAChD,OAAM,IAAI,sBACR,kBAAkB,MAAM,uFACzB;AAEH,QAAO,OAAO,MAAM;;AAGtB,IAAa,wBAAb,cAA2C,MAAM;;;;;;;;AASjD,MAAa,uBACX,oBACA,wBACA,wBACkB;AAClB,KAAI,qBAAqB,wBAAwB;EAC/C,MAAM,gBAAgB,qBAAqB;AAC3C,SAAO,OAAO,KAAK,IAAI,OAAO,cAAc,EAAE,OAAO,oBAAoB,CAAC,CAAC;OAE3E,QAAO;;;;;;;;AAmBX,UAAiB,WAAc,OAAY,WAAyC;AAClF,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,UAAW,OAAM,MAAM,MAAM,GAAG,IAAI,UAAU;;;;;;;AAQvF,MAAa,WAAqC,OAAsB;CACtE,MAAM,wBAAQ,IAAI,KAAK;CACvB,MAAM,SAAS,SAAyB,KAAQ;AAC9C,SAAO,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,KAAK,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,MAAM,IAAI,IAAI;;AAE/F,QAAO,QAAQ;AACf,QAAO;;AAGT,MAAa,oBAAoB,MAAkB,eAAoC;AACrF,KAAI,WAAW,SAAS,KAAK,OAAQ,QAAO;AAC5C,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,KAAI,KAAK,OAAO,WAAW,GAAI,QAAO;AAExC,QAAO;;AAGT,MAAa,4BAA4B,KAAa,UAAmB;AACvE,KAAI,OAAO,UAAU,SACnB,KAAI;AACF,SAAO,SAAS,MAAM;SAChB;AACN,SAAO,MAAM,UAAU;;AAG3B,QAAO;;AAET,MAAa,UACX,OACA,WAAqD,0BACrD,UACG;AACH,QAAO,KAAK,UAAU,OAAO,UAAU,MAAM;;;AAI/C,MAAa,8BAA8B,iBAA6B,sBAA2C;AACjH,QAAO,KAAK,OAAO,gBAAgB,UAAU,mBAAmB,UAAU,KAAK,KAAK,kBAAkB"}