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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/_virtual/_rolldown/runtime.js +33 -0
  2. package/_virtual/_rolldown/runtime.mjs +13 -0
  3. package/account/account.d.ts +25 -30
  4. package/account/account.js +151 -146
  5. package/account/account.js.map +1 -1
  6. package/account/account.mjs +149 -144
  7. package/account/account.mjs.map +1 -1
  8. package/account/get-account-config-from-environment.d.ts +7 -2
  9. package/account/get-account-config-from-environment.js +19 -21
  10. package/account/get-account-config-from-environment.js.map +1 -1
  11. package/account/get-account-config-from-environment.mjs +19 -19
  12. package/account/get-account-config-from-environment.mjs.map +1 -1
  13. package/account/get-account.d.ts +14 -12
  14. package/account/get-account.js +56 -59
  15. package/account/get-account.js.map +1 -1
  16. package/account/get-account.mjs +56 -57
  17. package/account/get-account.mjs.map +1 -1
  18. package/account/get-dispenser-account.d.ts +9 -5
  19. package/account/get-dispenser-account.js +20 -18
  20. package/account/get-dispenser-account.js.map +1 -1
  21. package/account/get-dispenser-account.mjs +20 -16
  22. package/account/get-dispenser-account.mjs.map +1 -1
  23. package/account/mnemonic-account.d.ts +7 -3
  24. package/account/mnemonic-account.js +17 -17
  25. package/account/mnemonic-account.js.map +1 -1
  26. package/account/mnemonic-account.mjs +15 -15
  27. package/account/mnemonic-account.mjs.map +1 -1
  28. package/amount.d.ts +40 -35
  29. package/amount.js +33 -34
  30. package/amount.js.map +1 -1
  31. package/amount.mjs +33 -32
  32. package/amount.mjs.map +1 -1
  33. package/app-client.d.ts +10 -6
  34. package/app-client.js +91 -86
  35. package/app-client.js.map +1 -1
  36. package/app-client.mjs +91 -84
  37. package/app-client.mjs.map +1 -1
  38. package/app-deploy.d.ts +26 -24
  39. package/app-deploy.js +235 -253
  40. package/app-deploy.js.map +1 -1
  41. package/app-deploy.mjs +233 -251
  42. package/app-deploy.mjs.map +1 -1
  43. package/app.d.ts +45 -46
  44. package/app.js +253 -271
  45. package/app.js.map +1 -1
  46. package/app.mjs +249 -267
  47. package/app.mjs.map +1 -1
  48. package/asset.d.ts +16 -12
  49. package/asset.js +116 -122
  50. package/asset.js.map +1 -1
  51. package/asset.mjs +116 -120
  52. package/asset.mjs.map +1 -1
  53. package/config.d.ts +7 -2
  54. package/config.js +5 -7
  55. package/config.js.map +1 -1
  56. package/config.mjs +5 -4
  57. package/config.mjs.map +1 -1
  58. package/debugging/debugging.d.ts +5 -1
  59. package/debugging/debugging.js +11 -11
  60. package/debugging/debugging.js.map +1 -1
  61. package/debugging/debugging.mjs +11 -9
  62. package/debugging/debugging.mjs.map +1 -1
  63. package/dispenser-client.d.ts +7 -2
  64. package/dispenser-client.js +23 -24
  65. package/dispenser-client.js.map +1 -1
  66. package/dispenser-client.mjs +23 -22
  67. package/dispenser-client.mjs.map +1 -1
  68. package/index.d.ts +27 -18
  69. package/index.js +140 -143
  70. package/index.mjs +27 -29
  71. package/indexer-lookup.d.ts +18 -11
  72. package/indexer-lookup.js +112 -120
  73. package/indexer-lookup.js.map +1 -1
  74. package/indexer-lookup.mjs +105 -118
  75. package/indexer-lookup.mjs.map +1 -1
  76. package/localnet/get-kmd-wallet-account.d.ts +9 -7
  77. package/localnet/get-kmd-wallet-account.js +28 -26
  78. package/localnet/get-kmd-wallet-account.js.map +1 -1
  79. package/localnet/get-kmd-wallet-account.mjs +28 -24
  80. package/localnet/get-kmd-wallet-account.mjs.map +1 -1
  81. package/localnet/get-localnet-dispenser-account.d.ts +7 -5
  82. package/localnet/get-localnet-dispenser-account.js +17 -15
  83. package/localnet/get-localnet-dispenser-account.js.map +1 -1
  84. package/localnet/get-localnet-dispenser-account.mjs +17 -13
  85. package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
  86. package/localnet/get-or-create-kmd-wallet-account.d.ts +10 -8
  87. package/localnet/get-or-create-kmd-wallet-account.js +28 -26
  88. package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
  89. package/localnet/get-or-create-kmd-wallet-account.mjs +28 -24
  90. package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
  91. package/localnet/is-localnet.d.ts +7 -3
  92. package/localnet/is-localnet.js +9 -10
  93. package/localnet/is-localnet.js.map +1 -1
  94. package/localnet/is-localnet.mjs +9 -8
  95. package/localnet/is-localnet.mjs.map +1 -1
  96. package/network-client.d.ts +17 -15
  97. package/network-client.js +115 -116
  98. package/network-client.js.map +1 -1
  99. package/network-client.mjs +115 -114
  100. package/network-client.mjs.map +1 -1
  101. package/package.json +12 -3
  102. package/testing/account.d.ts +11 -9
  103. package/testing/account.js +31 -33
  104. package/testing/account.js.map +1 -1
  105. package/testing/account.mjs +29 -31
  106. package/testing/account.mjs.map +1 -1
  107. package/testing/fixtures/algokit-log-capture-fixture.d.ts +7 -2
  108. package/testing/fixtures/algokit-log-capture-fixture.js +36 -41
  109. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  110. package/testing/fixtures/algokit-log-capture-fixture.mjs +36 -39
  111. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  112. package/testing/fixtures/algorand-fixture.d.ts +9 -4
  113. package/testing/fixtures/algorand-fixture.js +67 -62
  114. package/testing/fixtures/algorand-fixture.js.map +1 -1
  115. package/testing/fixtures/algorand-fixture.mjs +66 -59
  116. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  117. package/testing/index.d.ts +7 -5
  118. package/testing/index.js +13 -18
  119. package/testing/index.mjs +7 -7
  120. package/testing/indexer.d.ts +5 -1
  121. package/testing/indexer.js +28 -37
  122. package/testing/indexer.js.map +1 -1
  123. package/testing/indexer.mjs +28 -35
  124. package/testing/indexer.mjs.map +1 -1
  125. package/testing/test-logger.d.ts +41 -36
  126. package/testing/test-logger.js +71 -76
  127. package/testing/test-logger.js.map +1 -1
  128. package/testing/test-logger.mjs +71 -74
  129. package/testing/test-logger.mjs.map +1 -1
  130. package/testing/transaction-logger.d.ts +30 -27
  131. package/testing/transaction-logger.js +77 -93
  132. package/testing/transaction-logger.js.map +1 -1
  133. package/testing/transaction-logger.mjs +74 -90
  134. package/testing/transaction-logger.mjs.map +1 -1
  135. package/transaction/legacy-bridge.js +100 -111
  136. package/transaction/legacy-bridge.js.map +1 -1
  137. package/transaction/legacy-bridge.mjs +97 -108
  138. package/transaction/legacy-bridge.mjs.map +1 -1
  139. package/transaction/perform-atomic-transaction-composer-simulate.d.ts +7 -5
  140. package/transaction/perform-atomic-transaction-composer-simulate.js +31 -36
  141. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  142. package/transaction/perform-atomic-transaction-composer-simulate.mjs +28 -33
  143. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  144. package/transaction/transaction.d.ts +34 -35
  145. package/transaction/transaction.js +716 -914
  146. package/transaction/transaction.js.map +1 -1
  147. package/transaction/transaction.mjs +713 -911
  148. package/transaction/transaction.mjs.map +1 -1
  149. package/transfer/transfer-algos.d.ts +9 -5
  150. package/transfer/transfer-algos.js +26 -27
  151. package/transfer/transfer-algos.js.map +1 -1
  152. package/transfer/transfer-algos.mjs +26 -25
  153. package/transfer/transfer-algos.mjs.map +1 -1
  154. package/transfer/transfer.d.ts +11 -8
  155. package/transfer/transfer.js +94 -100
  156. package/transfer/transfer.js.map +1 -1
  157. package/transfer/transfer.mjs +94 -98
  158. package/transfer/transfer.mjs.map +1 -1
  159. package/types/account-manager.d.ts +432 -429
  160. package/types/account-manager.js +591 -602
  161. package/types/account-manager.js.map +1 -1
  162. package/types/account-manager.mjs +587 -599
  163. package/types/account-manager.mjs.map +1 -1
  164. package/types/account.d.ts +192 -202
  165. package/types/account.js +91 -88
  166. package/types/account.js.map +1 -1
  167. package/types/account.mjs +88 -86
  168. package/types/account.mjs.map +1 -1
  169. package/types/algo-http-client-with-retry.d.ts +15 -10
  170. package/types/algo-http-client-with-retry.js +70 -92
  171. package/types/algo-http-client-with-retry.js.map +1 -1
  172. package/types/algo-http-client-with-retry.mjs +69 -90
  173. package/types/algo-http-client-with-retry.mjs.map +1 -1
  174. package/types/algorand-client-transaction-creator.d.ts +778 -771
  175. package/types/algorand-client-transaction-creator.js +733 -732
  176. package/types/algorand-client-transaction-creator.js.map +1 -1
  177. package/types/algorand-client-transaction-creator.mjs +732 -730
  178. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  179. package/types/algorand-client-transaction-sender.d.ts +1090 -1360
  180. package/types/algorand-client-transaction-sender.js +930 -961
  181. package/types/algorand-client-transaction-sender.js.map +1 -1
  182. package/types/algorand-client-transaction-sender.mjs +927 -959
  183. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  184. package/types/algorand-client.d.ts +239 -236
  185. package/types/algorand-client.js +322 -320
  186. package/types/algorand-client.js.map +1 -1
  187. package/types/algorand-client.mjs +321 -318
  188. package/types/algorand-client.mjs.map +1 -1
  189. package/types/amount.d.ts +47 -43
  190. package/types/amount.js +66 -70
  191. package/types/amount.js.map +1 -1
  192. package/types/amount.mjs +63 -68
  193. package/types/amount.mjs.map +1 -1
  194. package/types/app-arc56.d.ts +235 -272
  195. package/types/app-arc56.js +124 -170
  196. package/types/app-arc56.js.map +1 -1
  197. package/types/app-arc56.mjs +121 -168
  198. package/types/app-arc56.mjs.map +1 -1
  199. package/types/app-client.d.ts +1128 -2009
  200. package/types/app-client.js +1633 -1791
  201. package/types/app-client.js.map +1 -1
  202. package/types/app-client.mjs +1624 -1783
  203. package/types/app-client.mjs.map +1 -1
  204. package/types/app-deployer.d.ts +139 -141
  205. package/types/app-deployer.js +344 -384
  206. package/types/app-deployer.js.map +1 -1
  207. package/types/app-deployer.mjs +341 -382
  208. package/types/app-deployer.mjs.map +1 -1
  209. package/types/app-factory.d.ts +762 -932
  210. package/types/app-factory.js +496 -488
  211. package/types/app-factory.js.map +1 -1
  212. package/types/app-factory.mjs +491 -484
  213. package/types/app-factory.mjs.map +1 -1
  214. package/types/app-manager.d.ts +304 -310
  215. package/types/app-manager.js +422 -475
  216. package/types/app-manager.js.map +1 -1
  217. package/types/app-manager.mjs +419 -473
  218. package/types/app-manager.mjs.map +1 -1
  219. package/types/app-spec.d.ts +118 -117
  220. package/types/app-spec.js +125 -135
  221. package/types/app-spec.js.map +1 -1
  222. package/types/app-spec.mjs +121 -132
  223. package/types/app-spec.mjs.map +1 -1
  224. package/types/app.d.ts +229 -241
  225. package/types/app.js +36 -28
  226. package/types/app.js.map +1 -1
  227. package/types/app.mjs +33 -26
  228. package/types/app.mjs.map +1 -1
  229. package/types/asset-manager.d.ts +204 -199
  230. package/types/asset-manager.js +165 -174
  231. package/types/asset-manager.js.map +1 -1
  232. package/types/asset-manager.mjs +164 -172
  233. package/types/asset-manager.mjs.map +1 -1
  234. package/types/asset.d.ts +95 -91
  235. package/types/asset.js +0 -3
  236. package/types/asset.mjs +0 -2
  237. package/types/async-event-emitter.d.ts +18 -13
  238. package/types/async-event-emitter.js +37 -49
  239. package/types/async-event-emitter.js.map +1 -1
  240. package/types/async-event-emitter.mjs +36 -47
  241. package/types/async-event-emitter.mjs.map +1 -1
  242. package/types/client-manager.d.ts +453 -451
  243. package/types/client-manager.js +602 -598
  244. package/types/client-manager.js.map +1 -1
  245. package/types/client-manager.mjs +597 -594
  246. package/types/client-manager.mjs.map +1 -1
  247. package/types/composer.d.ts +1211 -1258
  248. package/types/composer.js +1436 -1498
  249. package/types/composer.js.map +1 -1
  250. package/types/composer.mjs +1430 -1493
  251. package/types/composer.mjs.map +1 -1
  252. package/types/config.d.ts +53 -48
  253. package/types/config.js +78 -77
  254. package/types/config.js.map +1 -1
  255. package/types/config.mjs +77 -75
  256. package/types/config.mjs.map +1 -1
  257. package/types/debugging.d.ts +25 -23
  258. package/types/debugging.js +9 -11
  259. package/types/debugging.js.map +1 -1
  260. package/types/debugging.mjs +8 -9
  261. package/types/debugging.mjs.map +1 -1
  262. package/types/dispenser-client.d.ts +57 -52
  263. package/types/dispenser-client.js +120 -141
  264. package/types/dispenser-client.js.map +1 -1
  265. package/types/dispenser-client.mjs +119 -139
  266. package/types/dispenser-client.mjs.map +1 -1
  267. package/types/expand.d.ts +5 -3
  268. package/types/expand.js +0 -3
  269. package/types/expand.mjs +0 -2
  270. package/types/indexer.d.ts +104 -100
  271. package/types/indexer.js +36 -31
  272. package/types/indexer.js.map +1 -1
  273. package/types/indexer.mjs +32 -30
  274. package/types/indexer.mjs.map +1 -1
  275. package/types/instance-of.d.ts +5 -3
  276. package/types/instance-of.js +0 -3
  277. package/types/instance-of.mjs +0 -2
  278. package/types/kmd-account-manager.d.ts +75 -70
  279. package/types/kmd-account-manager.js +150 -184
  280. package/types/kmd-account-manager.js.map +1 -1
  281. package/types/kmd-account-manager.mjs +147 -182
  282. package/types/kmd-account-manager.mjs.map +1 -1
  283. package/types/lifecycle-events.d.ts +13 -8
  284. package/types/lifecycle-events.js +10 -7
  285. package/types/lifecycle-events.js.map +1 -1
  286. package/types/lifecycle-events.mjs +9 -7
  287. package/types/lifecycle-events.mjs.map +1 -1
  288. package/types/logging.d.ts +15 -11
  289. package/types/logging.js +30 -31
  290. package/types/logging.js.map +1 -1
  291. package/types/logging.mjs +29 -29
  292. package/types/logging.mjs.map +1 -1
  293. package/types/logic-error.d.ts +33 -29
  294. package/types/logic-error.js +50 -49
  295. package/types/logic-error.js.map +1 -1
  296. package/types/logic-error.mjs +49 -47
  297. package/types/logic-error.mjs.map +1 -1
  298. package/types/network-client.d.ts +32 -27
  299. package/types/network-client.js +10 -9
  300. package/types/network-client.js.map +1 -1
  301. package/types/network-client.mjs +9 -7
  302. package/types/network-client.mjs.map +1 -1
  303. package/types/testing.d.ts +131 -132
  304. package/types/testing.js +0 -3
  305. package/types/testing.mjs +0 -2
  306. package/types/transaction.d.ts +110 -110
  307. package/types/transaction.js +0 -3
  308. package/types/transaction.mjs +0 -2
  309. package/types/transfer.d.ts +70 -66
  310. package/types/transfer.js +0 -3
  311. package/types/transfer.mjs +0 -2
  312. package/util.js +73 -118
  313. package/util.js.map +1 -1
  314. package/util.mjs +73 -116
  315. package/util.mjs.map +1 -1
  316. package/account/index.d.ts +0 -5
  317. package/debugging/index.d.ts +0 -1
  318. package/index.js.map +0 -1
  319. package/index.mjs.map +0 -1
  320. package/localnet/index.d.ts +0 -4
  321. package/testing/_asset.d.ts +0 -3
  322. package/testing/fixtures/index.d.ts +0 -2
  323. package/testing/index.js.map +0 -1
  324. package/testing/index.mjs.map +0 -1
  325. package/transaction/index.d.ts +0 -2
  326. package/transaction/legacy-bridge.d.ts +0 -35
  327. package/transfer/index.d.ts +0 -2
  328. package/types/asset.js.map +0 -1
  329. package/types/asset.mjs.map +0 -1
  330. package/types/expand.js.map +0 -1
  331. package/types/expand.mjs.map +0 -1
  332. package/types/instance-of.js.map +0 -1
  333. package/types/instance-of.mjs.map +0 -1
  334. package/types/testing.js.map +0 -1
  335. package/types/testing.mjs.map +0 -1
  336. package/types/transaction.js.map +0 -1
  337. package/types/transaction.mjs.map +0 -1
  338. package/types/transfer.js.map +0 -1
  339. package/types/transfer.mjs.map +0 -1
  340. package/util.d.ts +0 -48
package/util.mjs CHANGED
@@ -1,144 +1,101 @@
1
- import { ABIArrayStaticType, ABIArrayDynamicType, ABIByteType, ABITupleType, ABIUintType } from 'algosdk';
2
- import { APP_PAGE_MAX_SIZE } from './types/app.mjs';
3
-
1
+ import { APP_PAGE_MAX_SIZE } from "./types/app.mjs";
2
+ import { ABIArrayDynamicType, ABIArrayStaticType, ABIByteType, ABITupleType, ABIUintType } from "algosdk";
3
+ //#region src/util.ts
4
4
  /**
5
- * Converts a value which might be a number or a bigint into a number to be used with apis that don't support bigint.
6
- *
7
- * Throws an UnsafeConversionError if the conversion would result in an unsafe integer for the Number type
8
- * @param value
9
- */
5
+ * Converts a value which might be a number or a bigint into a number to be used with apis that don't support bigint.
6
+ *
7
+ * Throws an UnsafeConversionError if the conversion would result in an unsafe integer for the Number type
8
+ * @param value
9
+ */
10
10
  const toNumber = (value) => {
11
- if (typeof value === 'number')
12
- return value;
13
- if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
14
- throw new UnsafeConversionError(`Cannot convert ${value} to a Number as it is larger than the maximum safe integer the Number type can hold.`);
15
- }
16
- else if (value < BigInt(Number.MIN_SAFE_INTEGER)) {
17
- throw new UnsafeConversionError(`Cannot convert ${value} to a Number as it is smaller than the minimum safe integer the Number type can hold.`);
18
- }
19
- return Number(value);
11
+ if (typeof value === "number") return value;
12
+ if (value > BigInt(Number.MAX_SAFE_INTEGER)) throw new UnsafeConversionError(`Cannot convert ${value} to a Number as it is larger than the maximum safe integer the Number type can hold.`);
13
+ else if (value < BigInt(Number.MIN_SAFE_INTEGER)) throw new UnsafeConversionError(`Cannot convert ${value} to a Number as it is smaller than the minimum safe integer the Number type can hold.`);
14
+ return Number(value);
20
15
  };
21
- class UnsafeConversionError extends Error {
22
- }
16
+ var UnsafeConversionError = class extends Error {};
23
17
  /**
24
- * Calculates the amount of funds to add to a wallet to bring it up to the minimum spending balance.
25
- * @param minSpendingBalance The minimum spending balance for the wallet
26
- * @param currentSpendingBalance The current spending balance for the wallet
27
- * @param minFundingIncrement The minimum amount of funds that can be added to the wallet
28
- * @returns The amount of funds to add to the wallet or null if the wallet is already above the minimum spending balance
29
- */
18
+ * Calculates the amount of funds to add to a wallet to bring it up to the minimum spending balance.
19
+ * @param minSpendingBalance The minimum spending balance for the wallet
20
+ * @param currentSpendingBalance The current spending balance for the wallet
21
+ * @param minFundingIncrement The minimum amount of funds that can be added to the wallet
22
+ * @returns The amount of funds to add to the wallet or null if the wallet is already above the minimum spending balance
23
+ */
30
24
  const calculateFundAmount = (minSpendingBalance, currentSpendingBalance, minFundingIncrement) => {
31
- if (minSpendingBalance > currentSpendingBalance) {
32
- const minFundAmount = minSpendingBalance - currentSpendingBalance;
33
- return BigInt(Math.max(Number(minFundAmount), Number(minFundingIncrement)));
34
- }
35
- else {
36
- return null;
37
- }
25
+ if (minSpendingBalance > currentSpendingBalance) {
26
+ const minFundAmount = minSpendingBalance - currentSpendingBalance;
27
+ return BigInt(Math.max(Number(minFundAmount), Number(minFundingIncrement)));
28
+ } else return null;
38
29
  };
39
30
  /**
40
- * Returns the given array split into chunks of `batchSize` batches.
41
- * @param array The array to chunk
42
- * @param batchSize The size of batches to split the array into
43
- * @returns A generator that yields the array split into chunks of `batchSize` batches
44
- */
31
+ * Returns the given array split into chunks of `batchSize` batches.
32
+ * @param array The array to chunk
33
+ * @param batchSize The size of batches to split the array into
34
+ * @returns A generator that yields the array split into chunks of `batchSize` batches
35
+ */
45
36
  function* chunkArray(array, batchSize) {
46
- for (let i = 0; i < array.length; i += batchSize)
47
- yield array.slice(i, i + batchSize);
37
+ for (let i = 0; i < array.length; i += batchSize) yield array.slice(i, i + batchSize);
48
38
  }
49
39
  /**
50
- * Memoize calls to the given function in an in-memory map.
51
- * @param fn The function to memoize
52
- * @returns The memoized function
53
- */
40
+ * Memoize calls to the given function in an in-memory map.
41
+ * @param fn The function to memoize
42
+ * @returns The memoized function
43
+ */
54
44
  const memoize = (fn) => {
55
- const cache = new Map();
56
- const cached = function (val) {
57
- return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
58
- };
59
- cached.cache = cache;
60
- return cached;
45
+ const cache = /* @__PURE__ */ new Map();
46
+ const cached = function(val) {
47
+ return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
48
+ };
49
+ cached.cache = cache;
50
+ return cached;
61
51
  };
62
52
  const binaryStartsWith = (base, startsWith) => {
63
- if (startsWith.length > base.length)
64
- return false;
65
- for (let i = 0; i < startsWith.length; i++) {
66
- if (base[i] !== startsWith[i])
67
- return false;
68
- }
69
- return true;
53
+ if (startsWith.length > base.length) return false;
54
+ for (let i = 0; i < startsWith.length; i++) if (base[i] !== startsWith[i]) return false;
55
+ return true;
70
56
  };
71
57
  const defaultJsonValueReplacer = (key, value) => {
72
- if (typeof value === 'bigint') {
73
- try {
74
- return toNumber(value);
75
- }
76
- catch {
77
- return value.toString();
78
- }
79
- }
80
- return value;
58
+ if (typeof value === "bigint") try {
59
+ return toNumber(value);
60
+ } catch {
61
+ return value.toString();
62
+ }
63
+ return value;
81
64
  };
82
65
  const asJson = (value, replacer = defaultJsonValueReplacer, space) => {
83
- return JSON.stringify(value, replacer, space);
66
+ return JSON.stringify(value, replacer, space);
84
67
  };
85
68
  /** Calculate minimum number of extra program pages required for provided approval and clear state programs */
86
69
  const calculateExtraProgramPages = (approvalProgram, clearStateProgram) => {
87
- return Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0) - 1) / APP_PAGE_MAX_SIZE);
70
+ return Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0) - 1) / APP_PAGE_MAX_SIZE);
88
71
  };
89
72
  /** Take a decoded ABI value and convert all byte arrays (including nested ones) from number[] to Uint8Arrays */
90
73
  function convertAbiByteArrays(value, type) {
91
- // Return value as is if the type doesn't have any bytes or if it's already an Uint8Array
92
- if (!type.toString().includes('byte') || value instanceof Uint8Array) {
93
- return value;
94
- }
95
- // Handle byte arrays (byte[N] or byte[])
96
- if ((type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType) &&
97
- type.childType instanceof ABIByteType &&
98
- Array.isArray(value)) {
99
- return new Uint8Array(value);
100
- }
101
- // Handle other arrays (for nested structures)
102
- if ((type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType) && Array.isArray(value)) {
103
- const result = [];
104
- for (let i = 0; i < value.length; i++) {
105
- result.push(convertAbiByteArrays(value[i], type.childType));
106
- }
107
- return result;
108
- }
109
- // Handle tuples (for nested structures)
110
- if (type instanceof ABITupleType && Array.isArray(value)) {
111
- const result = [];
112
- for (let i = 0; i < value.length && i < type.childTypes.length; i++) {
113
- result.push(convertAbiByteArrays(value[i], type.childTypes[i]));
114
- }
115
- return result;
116
- }
117
- // For other types, return the value as is
118
- return value;
74
+ if (!type.toString().includes("byte") || value instanceof Uint8Array) return value;
75
+ if ((type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType) && type.childType instanceof ABIByteType && Array.isArray(value)) return new Uint8Array(value);
76
+ if ((type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType) && Array.isArray(value)) {
77
+ const result = [];
78
+ for (let i = 0; i < value.length; i++) result.push(convertAbiByteArrays(value[i], type.childType));
79
+ return result;
80
+ }
81
+ if (type instanceof ABITupleType && Array.isArray(value)) {
82
+ const result = [];
83
+ for (let i = 0; i < value.length && i < type.childTypes.length; i++) result.push(convertAbiByteArrays(value[i], type.childTypes[i]));
84
+ return result;
85
+ }
86
+ return value;
119
87
  }
120
88
  /**
121
- * Convert bigint values to numbers for uint types with bit size < 53
122
- */
89
+ * Convert bigint values to numbers for uint types with bit size < 53
90
+ */
123
91
  const convertABIDecodedBigIntToNumber = (value, type) => {
124
- if (typeof value === 'bigint') {
125
- if (type instanceof ABIUintType) {
126
- return type.bitSize < 53 ? Number(value) : value;
127
- }
128
- else {
129
- return value;
130
- }
131
- }
132
- else if (Array.isArray(value) && (type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType)) {
133
- return value.map((v) => convertABIDecodedBigIntToNumber(v, type.childType));
134
- }
135
- else if (Array.isArray(value) && type instanceof ABITupleType) {
136
- return value.map((v, i) => convertABIDecodedBigIntToNumber(v, type.childTypes[i]));
137
- }
138
- else {
139
- return value;
140
- }
92
+ if (typeof value === "bigint") if (type instanceof ABIUintType) return type.bitSize < 53 ? Number(value) : value;
93
+ else return value;
94
+ else if (Array.isArray(value) && (type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType)) return value.map((v) => convertABIDecodedBigIntToNumber(v, type.childType));
95
+ else if (Array.isArray(value) && type instanceof ABITupleType) return value.map((v, i) => convertABIDecodedBigIntToNumber(v, type.childTypes[i]));
96
+ else return value;
141
97
  };
142
-
98
+ //#endregion
143
99
  export { UnsafeConversionError, asJson, binaryStartsWith, calculateExtraProgramPages, calculateFundAmount, chunkArray, convertABIDecodedBigIntToNumber, convertAbiByteArrays, defaultJsonValueReplacer, memoize, toNumber };
144
- //# sourceMappingURL=util.mjs.map
100
+
101
+ //# sourceMappingURL=util.mjs.map
package/util.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.mjs","sources":["../src/util.ts"],"sourcesContent":["import { ABIArrayDynamicType, ABIArrayStaticType, ABIByteType, ABIReturnType, ABITupleType, ABIType, ABIUintType, ABIValue } from 'algosdk'\nimport { 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\n/** Take a decoded ABI value and convert all byte arrays (including nested ones) from number[] to Uint8Arrays */\nexport function convertAbiByteArrays(value: ABIValue, type: ABIReturnType): ABIValue {\n // Return value as is if the type doesn't have any bytes or if it's already an Uint8Array\n if (!type.toString().includes('byte') || value instanceof Uint8Array) {\n return value\n }\n\n // Handle byte arrays (byte[N] or byte[])\n if (\n (type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType) &&\n type.childType instanceof ABIByteType &&\n Array.isArray(value)\n ) {\n return new Uint8Array(value as number[])\n }\n\n // Handle other arrays (for nested structures)\n if ((type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType) && Array.isArray(value)) {\n const result = []\n for (let i = 0; i < value.length; i++) {\n result.push(convertAbiByteArrays(value[i], type.childType))\n }\n return result\n }\n\n // Handle tuples (for nested structures)\n if (type instanceof ABITupleType && Array.isArray(value)) {\n const result = []\n for (let i = 0; i < value.length && i < type.childTypes.length; i++) {\n result.push(convertAbiByteArrays(value[i], type.childTypes[i]))\n }\n return result\n }\n\n // For other types, return the value as is\n return value\n}\n\n/**\n * Convert bigint values to numbers for uint types with bit size < 53\n */\nexport const convertABIDecodedBigIntToNumber = (value: ABIValue, type: ABIType): ABIValue => {\n if (typeof value === 'bigint') {\n if (type instanceof ABIUintType) {\n return type.bitSize < 53 ? Number(value) : value\n } else {\n return value\n }\n } else if (Array.isArray(value) && (type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType)) {\n return value.map((v) => convertABIDecodedBigIntToNumber(v, type.childType))\n } else if (Array.isArray(value) && type instanceof ABITupleType) {\n return value.map((v, i) => convertABIDecodedBigIntToNumber(v, type.childTypes[i]))\n } else {\n return value\n }\n}\n"],"names":[],"mappings":";;;AAGA;;;;;AAKG;AACU,MAAA,QAAQ,GAAG,CAAC,KAAsB,KAAI;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,KAAK;IAE3C,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;AAC3C,QAAA,MAAM,IAAI,qBAAqB,CAC7B,kBAAkB,KAAK,CAAA,oFAAA,CAAsF,CAC9G;;SACI,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;AAClD,QAAA,MAAM,IAAI,qBAAqB,CAC7B,kBAAkB,KAAK,CAAA,qFAAA,CAAuF,CAC/G;;AAEH,IAAA,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB;AAEM,MAA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,mBAAmB,CAAC,EAAE;AAC9G,QAAA,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,+BAA+B,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;;SACtE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,YAAY,YAAY,EAAE;QAC/D,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,+BAA+B,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;;SAC7E;AACL,QAAA,OAAO,KAAK;;AAEhB;;;;"}
1
+ {"version":3,"file":"util.mjs","names":[],"sources":["../src/util.ts"],"sourcesContent":["import { ABIArrayDynamicType, ABIArrayStaticType, ABIByteType, ABIReturnType, ABITupleType, ABIType, ABIUintType, ABIValue } from 'algosdk'\nimport { 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\n/** Take a decoded ABI value and convert all byte arrays (including nested ones) from number[] to Uint8Arrays */\nexport function convertAbiByteArrays(value: ABIValue, type: ABIReturnType): ABIValue {\n // Return value as is if the type doesn't have any bytes or if it's already an Uint8Array\n if (!type.toString().includes('byte') || value instanceof Uint8Array) {\n return value\n }\n\n // Handle byte arrays (byte[N] or byte[])\n if (\n (type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType) &&\n type.childType instanceof ABIByteType &&\n Array.isArray(value)\n ) {\n return new Uint8Array(value as number[])\n }\n\n // Handle other arrays (for nested structures)\n if ((type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType) && Array.isArray(value)) {\n const result = []\n for (let i = 0; i < value.length; i++) {\n result.push(convertAbiByteArrays(value[i], type.childType))\n }\n return result\n }\n\n // Handle tuples (for nested structures)\n if (type instanceof ABITupleType && Array.isArray(value)) {\n const result = []\n for (let i = 0; i < value.length && i < type.childTypes.length; i++) {\n result.push(convertAbiByteArrays(value[i], type.childTypes[i]))\n }\n return result\n }\n\n // For other types, return the value as is\n return value\n}\n\n/**\n * Convert bigint values to numbers for uint types with bit size < 53\n */\nexport const convertABIDecodedBigIntToNumber = (value: ABIValue, type: ABIType): ABIValue => {\n if (typeof value === 'bigint') {\n if (type instanceof ABIUintType) {\n return type.bitSize < 53 ? Number(value) : value\n } else {\n return value\n }\n } else if (Array.isArray(value) && (type instanceof ABIArrayStaticType || type instanceof ABIArrayDynamicType)) {\n return value.map((v) => convertABIDecodedBigIntToNumber(v, type.childType))\n } else if (Array.isArray(value) && type instanceof ABITupleType) {\n return value.map((v, i) => convertABIDecodedBigIntToNumber(v, type.childTypes[i]))\n } else {\n return value\n }\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,YAAY,UAA2B;CAClD,IAAI,OAAO,UAAU,UAAU,OAAO;CAEtC,IAAI,QAAQ,OAAO,OAAO,gBAAgB,GACxC,MAAM,IAAI,sBACR,kBAAkB,MAAM,qFAC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
1
- export * from './account';
2
- export * from './get-account';
3
- export * from './get-account-config-from-environment';
4
- export * from './get-dispenser-account';
5
- export * from './mnemonic-account';
@@ -1 +0,0 @@
1
- export * from './debugging';
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/index.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +0,0 @@
1
- export * from './get-kmd-wallet-account';
2
- export * from './get-localnet-dispenser-account';
3
- export * from './get-or-create-kmd-wallet-account';
4
- export * from './is-localnet';
@@ -1,3 +0,0 @@
1
- import { Address } from 'algosdk';
2
- import { AlgorandClient } from '../types/algorand-client';
3
- export declare function generateTestAsset(algorand: AlgorandClient, sender: Address | string, total?: number): Promise<bigint>;
@@ -1,2 +0,0 @@
1
- export * from './algokit-log-capture-fixture';
2
- export * from './algorand-fixture';
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -1,2 +0,0 @@
1
- export * from './perform-atomic-transaction-composer-simulate';
2
- export * from './transaction';
@@ -1,35 +0,0 @@
1
- import algosdk from 'algosdk';
2
- import { AlgorandClientTransactionCreator } from '../types/algorand-client-transaction-creator';
3
- import { AlgorandClientTransactionSender } from '../types/algorand-client-transaction-sender';
4
- import { ABIAppCallArgs, BoxIdentifier as LegacyBoxIdentifier, BoxReference as LegacyBoxReference, RawAppCallArgs } from '../types/app';
5
- import { AppCallMethodCall, AppCallParams, AppCreateMethodCall, AppCreateParams, AppDeleteMethodCall, AppDeleteParams, AppUpdateMethodCall, AppUpdateParams, BuiltTransactions, CommonTransactionParams } from '../types/composer';
6
- import { SendParams, SendSingleTransactionResult, SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionNote } from '../types/transaction';
7
- import Algodv2 = algosdk.Algodv2;
8
- import Transaction = algosdk.Transaction;
9
- /** @deprecated Bridges between legacy `sendTransaction` behaviour and new `AlgorandClient` behaviour. */
10
- export declare function legacySendTransactionBridge<T extends CommonTransactionParams, TResult extends SendSingleTransactionResult>(algod: Algodv2, from: SendTransactionFrom, sendParams: SendTransactionParams, params: T, txn: ((c: AlgorandClientTransactionCreator) => (params: T) => Promise<Transaction>) | ((c: AlgorandClientTransactionCreator) => (params: T) => Promise<BuiltTransactions>), send: (c: AlgorandClientTransactionSender) => (params: T & SendParams) => Promise<TResult>, suggestedParams?: algosdk.SuggestedParams): Promise<(SendTransactionResult | TResult) & {
11
- transactions: Transaction[];
12
- }>;
13
- /** @deprecated Bridges between legacy `sendTransaction` behaviour for app transactions and new `AlgorandClient` behaviour. */
14
- export declare function legacySendAppTransactionBridge<T extends AppCreateParams | AppUpdateParams | AppDeleteParams | AppCallParams | AppCreateMethodCall | AppUpdateMethodCall | AppDeleteMethodCall | AppCallMethodCall, TResult extends SendSingleTransactionResult>(algod: Algodv2, from: SendTransactionFrom, appArgs: RawAppCallArgs | ABIAppCallArgs | undefined, sendParams: SendTransactionParams & {
15
- note?: TransactionNote;
16
- }, params: Omit<T, 'accountReferences' | 'appReferences' | 'assetReferences' | 'boxReferences' | 'args' | 'lease' | 'rekeyTo' | 'note'>, txn: ((c: AlgorandClientTransactionCreator) => (params: T) => Promise<Transaction>) | ((c: AlgorandClientTransactionCreator) => (params: T) => Promise<BuiltTransactions>), send: (c: AlgorandClientTransactionSender) => (params: T & SendParams) => Promise<TResult>, suggestedParams?: algosdk.SuggestedParams): Promise<(SendTransactionResult | TResult) & {
17
- transactions: Transaction[];
18
- }>;
19
- /**
20
- * @deprecated
21
- */
22
- export declare function _getAppArgsForABICall(args: ABIAppCallArgs, from: SendTransactionFrom): Promise<{
23
- method: algosdk.ABIMethod;
24
- sender: string;
25
- signer: algosdk.TransactionSigner;
26
- boxes: algosdk.BoxReference[] | undefined;
27
- lease: Uint8Array | undefined;
28
- appForeignApps: number[] | undefined;
29
- appForeignAssets: number[] | undefined;
30
- appAccounts: string[] | undefined;
31
- methodArgs: (string | number | bigint | boolean | algosdk.Address | Uint8Array | algosdk.ABIValue[] | algosdk.TransactionWithSigner)[];
32
- rekeyTo: string | undefined;
33
- }>;
34
- /** @deprecated */
35
- export declare function _getBoxReference(box: LegacyBoxIdentifier | LegacyBoxReference | algosdk.BoxReference): algosdk.BoxReference;
@@ -1,2 +0,0 @@
1
- export * from './transfer';
2
- export * from './transfer-algos';
@@ -1 +0,0 @@
1
- {"version":3,"file":"asset.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"asset.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"expand.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"expand.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"instance-of.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"instance-of.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"testing.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"testing.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transfer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transfer.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/util.d.ts DELETED
@@ -1,48 +0,0 @@
1
- import { ABIReturnType, ABIType, ABIValue } from 'algosdk';
2
- /**
3
- * Converts a value which might be a number or a bigint into a number to be used with apis that don't support bigint.
4
- *
5
- * Throws an UnsafeConversionError if the conversion would result in an unsafe integer for the Number type
6
- * @param value
7
- */
8
- export declare const toNumber: (value: number | bigint) => number;
9
- export declare class UnsafeConversionError extends Error {
10
- }
11
- /**
12
- * Calculates the amount of funds to add to a wallet to bring it up to the minimum spending balance.
13
- * @param minSpendingBalance The minimum spending balance for the wallet
14
- * @param currentSpendingBalance The current spending balance for the wallet
15
- * @param minFundingIncrement The minimum amount of funds that can be added to the wallet
16
- * @returns The amount of funds to add to the wallet or null if the wallet is already above the minimum spending balance
17
- */
18
- export declare const calculateFundAmount: (minSpendingBalance: bigint, currentSpendingBalance: bigint, minFundingIncrement: bigint) => bigint | null;
19
- /**
20
- * Checks if the current environment is Node.js
21
- *
22
- * @returns A boolean indicating whether the current environment is Node.js
23
- */
24
- export declare const isNode: () => boolean;
25
- /**
26
- * Returns the given array split into chunks of `batchSize` batches.
27
- * @param array The array to chunk
28
- * @param batchSize The size of batches to split the array into
29
- * @returns A generator that yields the array split into chunks of `batchSize` batches
30
- */
31
- export declare function chunkArray<T>(array: T[], batchSize: number): Generator<T[], void>;
32
- /**
33
- * Memoize calls to the given function in an in-memory map.
34
- * @param fn The function to memoize
35
- * @returns The memoized function
36
- */
37
- export declare const memoize: <T = unknown, R = unknown>(fn: (val: T) => R) => (val: T) => R;
38
- export declare const binaryStartsWith: (base: Uint8Array, startsWith: Uint8Array) => boolean;
39
- export declare const defaultJsonValueReplacer: (key: string, value: unknown) => unknown;
40
- export declare const asJson: (value: unknown, replacer?: (key: string, value: unknown) => unknown, space?: string | number) => string;
41
- /** Calculate minimum number of extra program pages required for provided approval and clear state programs */
42
- export declare const calculateExtraProgramPages: (approvalProgram: Uint8Array, clearStateProgram?: Uint8Array) => number;
43
- /** Take a decoded ABI value and convert all byte arrays (including nested ones) from number[] to Uint8Arrays */
44
- export declare function convertAbiByteArrays(value: ABIValue, type: ABIReturnType): ABIValue;
45
- /**
46
- * Convert bigint values to numbers for uint types with bit size < 53
47
- */
48
- export declare const convertABIDecodedBigIntToNumber: (value: ABIValue, type: ABIType) => ABIValue;