@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
@@ -1,76 +1,80 @@
1
- import algosdk from 'algosdk';
2
- import { AlgoAmount } from './amount';
3
- import { TestNetDispenserApiClient } from './dispenser-client';
4
- import { SendTransactionFrom, SendTransactionParams, TransactionNote } from './transaction';
5
- import SuggestedParams = algosdk.SuggestedParams;
1
+ import { AlgoAmount } from "./amount.js";
2
+ import { SendTransactionFrom, SendTransactionParams, TransactionNote } from "./transaction.js";
3
+ import { TestNetDispenserApiClient } from "./dispenser-client.js";
4
+ import algosdk from "algosdk";
5
+
6
+ //#region src/types/transfer.d.ts
6
7
  /** @deprecated Parameters for `transferAlgos` call. */
7
- export interface AlgoTransferParams extends SendTransactionParams {
8
- /** The account that will send the Algo */
9
- from: SendTransactionFrom;
10
- /** The account / account address that will receive the Algo */
11
- to: SendTransactionFrom | string;
12
- /** The amount to send */
13
- amount: AlgoAmount;
14
- /** Optional transaction parameters */
15
- transactionParams?: SuggestedParams;
16
- /** The (optional) transaction note */
17
- note?: TransactionNote;
18
- /** An (optional) [transaction lease](https://dev.algorand.co/concepts/transactions/leases) to apply */
19
- lease?: string | Uint8Array;
8
+ interface AlgoTransferParams extends SendTransactionParams {
9
+ /** The account that will send the Algo */
10
+ from: SendTransactionFrom;
11
+ /** The account / account address that will receive the Algo */
12
+ to: SendTransactionFrom | string;
13
+ /** The amount to send */
14
+ amount: AlgoAmount;
15
+ /** Optional transaction parameters */
16
+ transactionParams?: SuggestedParams;
17
+ /** The (optional) transaction note */
18
+ note?: TransactionNote;
19
+ /** An (optional) [transaction lease](https://dev.algorand.co/concepts/transactions/leases) to apply */
20
+ lease?: string | Uint8Array;
20
21
  }
21
22
  /** @deprecated Parameters for `rekeyAccount` call. */
22
- export interface AlgoRekeyParams extends SendTransactionParams {
23
- /** The account that will be rekeyed */
24
- from: SendTransactionFrom;
25
- /** The account / account address that will have the private key that is authorised to transact on behalf of the from account from now on */
26
- rekeyTo: SendTransactionFrom | string;
27
- /** Optional transaction parameters */
28
- transactionParams?: SuggestedParams;
29
- /** The (optional) transaction note */
30
- note?: TransactionNote;
31
- /** An (optional) [transaction lease](https://dev.algorand.co/concepts/transactions/leases) to apply */
32
- lease?: string | Uint8Array;
23
+ interface AlgoRekeyParams extends SendTransactionParams {
24
+ /** The account that will be rekeyed */
25
+ from: SendTransactionFrom;
26
+ /** The account / account address that will have the private key that is authorised to transact on behalf of the from account from now on */
27
+ rekeyTo: SendTransactionFrom | string;
28
+ /** Optional transaction parameters */
29
+ transactionParams?: SuggestedParams;
30
+ /** The (optional) transaction note */
31
+ note?: TransactionNote;
32
+ /** An (optional) [transaction lease](https://dev.algorand.co/concepts/transactions/leases) to apply */
33
+ lease?: string | Uint8Array;
33
34
  }
34
35
  /** @deprecated Parameters for `ensureFunded` call. */
35
- export interface EnsureFundedParams extends SendTransactionParams {
36
- /** The account to fund */
37
- accountToFund: SendTransactionFrom | string;
38
- /** The account to use as a funding source, will default to using the dispenser account returned by `algokit.getDispenserAccount` */
39
- fundingSource?: SendTransactionFrom | TestNetDispenserApiClient;
40
- /** The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement) */
41
- minSpendingBalance: AlgoAmount;
42
- /** When issuing a funding amount, the minimum amount to transfer (avoids many small transfers if this gets called often on an active account) */
43
- minFundingIncrement?: AlgoAmount;
44
- /** Optional transaction parameters */
45
- transactionParams?: SuggestedParams;
46
- /** The (optional) transaction note, default: "Funding account to meet minimum requirement" */
47
- note?: TransactionNote;
48
- /** An (optional) [transaction lease](https://dev.algorand.co/concepts/transactions/leases) to apply */
49
- lease?: string | Uint8Array;
36
+ interface EnsureFundedParams extends SendTransactionParams {
37
+ /** The account to fund */
38
+ accountToFund: SendTransactionFrom | string;
39
+ /** The account to use as a funding source, will default to using the dispenser account returned by `algokit.getDispenserAccount` */
40
+ fundingSource?: SendTransactionFrom | TestNetDispenserApiClient;
41
+ /** The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement) */
42
+ minSpendingBalance: AlgoAmount;
43
+ /** When issuing a funding amount, the minimum amount to transfer (avoids many small transfers if this gets called often on an active account) */
44
+ minFundingIncrement?: AlgoAmount;
45
+ /** Optional transaction parameters */
46
+ transactionParams?: SuggestedParams;
47
+ /** The (optional) transaction note, default: "Funding account to meet minimum requirement" */
48
+ note?: TransactionNote;
49
+ /** An (optional) [transaction lease](https://dev.algorand.co/concepts/transactions/leases) to apply */
50
+ lease?: string | Uint8Array;
50
51
  }
51
52
  /** @deprecated Parameters for `transferAsset` call. */
52
- export interface TransferAssetParams extends SendTransactionParams {
53
- /** The account that will send the asset */
54
- from: SendTransactionFrom;
55
- /** The account / account address that will receive the asset */
56
- to: SendTransactionFrom | string;
57
- /** The asset id that will be transfered */
58
- assetId: number;
59
- /** The amount to send as the smallest divisible unit value */
60
- amount: number | bigint;
61
- /** Optional transaction parameters */
62
- transactionParams?: SuggestedParams;
63
- /** An address of a target account from which to perform a clawback operation. Please note, in such cases senderAccount must be equal to clawback field on ASA metadata. */
64
- clawbackFrom?: SendTransactionFrom | string;
65
- /** The (optional) transaction note */
66
- note?: TransactionNote;
67
- /** An (optional) [transaction lease](https://dev.algorand.co/concepts/transactions/leases) to apply */
68
- lease?: string | Uint8Array;
53
+ interface TransferAssetParams extends SendTransactionParams {
54
+ /** The account that will send the asset */
55
+ from: SendTransactionFrom;
56
+ /** The account / account address that will receive the asset */
57
+ to: SendTransactionFrom | string;
58
+ /** The asset id that will be transfered */
59
+ assetId: number;
60
+ /** The amount to send as the smallest divisible unit value */
61
+ amount: number | bigint;
62
+ /** Optional transaction parameters */
63
+ transactionParams?: SuggestedParams;
64
+ /** An address of a target account from which to perform a clawback operation. Please note, in such cases senderAccount must be equal to clawback field on ASA metadata. */
65
+ clawbackFrom?: SendTransactionFrom | string;
66
+ /** The (optional) transaction note */
67
+ note?: TransactionNote;
68
+ /** An (optional) [transaction lease](https://dev.algorand.co/concepts/transactions/leases) to apply */
69
+ lease?: string | Uint8Array;
69
70
  }
70
71
  /** @deprecated */
71
- export interface EnsureFundedReturnType {
72
- /** The transaction */
73
- transactionId: string;
74
- /** The response if the transaction was sent and waited for */
75
- amount: number;
72
+ interface EnsureFundedReturnType {
73
+ /** The transaction */
74
+ transactionId: string;
75
+ /** The response if the transaction was sent and waited for */
76
+ amount: number;
76
77
  }
78
+ //#endregion
79
+ export { AlgoRekeyParams, AlgoTransferParams, EnsureFundedParams, EnsureFundedReturnType, TransferAssetParams };
80
+ //# sourceMappingURL=transfer.d.ts.map
package/types/transfer.js CHANGED
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- //# sourceMappingURL=transfer.js.map
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=transfer.mjs.map
package/util.js CHANGED
@@ -1,147 +1,101 @@
1
- 'use strict';
2
-
3
- var algosdk = require('algosdk');
4
- var types_app = require('./types/app.js');
5
-
1
+ const require_app = require("./types/app.js");
2
+ let algosdk = require("algosdk");
3
+ //#region src/util.ts
6
4
  /**
7
- * Converts a value which might be a number or a bigint into a number to be used with apis that don't support bigint.
8
- *
9
- * Throws an UnsafeConversionError if the conversion would result in an unsafe integer for the Number type
10
- * @param value
11
- */
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
+ */
12
10
  const toNumber = (value) => {
13
- if (typeof value === 'number')
14
- return value;
15
- if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
16
- throw new UnsafeConversionError(`Cannot convert ${value} to a Number as it is larger than the maximum safe integer the Number type can hold.`);
17
- }
18
- else if (value < BigInt(Number.MIN_SAFE_INTEGER)) {
19
- throw new UnsafeConversionError(`Cannot convert ${value} to a Number as it is smaller than the minimum safe integer the Number type can hold.`);
20
- }
21
- 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);
22
15
  };
23
- class UnsafeConversionError extends Error {
24
- }
16
+ var UnsafeConversionError = class extends Error {};
25
17
  /**
26
- * Calculates the amount of funds to add to a wallet to bring it up to the minimum spending balance.
27
- * @param minSpendingBalance The minimum spending balance for the wallet
28
- * @param currentSpendingBalance The current spending balance for the wallet
29
- * @param minFundingIncrement The minimum amount of funds that can be added to the wallet
30
- * @returns The amount of funds to add to the wallet or null if the wallet is already above the minimum spending balance
31
- */
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
+ */
32
24
  const calculateFundAmount = (minSpendingBalance, currentSpendingBalance, minFundingIncrement) => {
33
- if (minSpendingBalance > currentSpendingBalance) {
34
- const minFundAmount = minSpendingBalance - currentSpendingBalance;
35
- return BigInt(Math.max(Number(minFundAmount), Number(minFundingIncrement)));
36
- }
37
- else {
38
- return null;
39
- }
25
+ if (minSpendingBalance > currentSpendingBalance) {
26
+ const minFundAmount = minSpendingBalance - currentSpendingBalance;
27
+ return BigInt(Math.max(Number(minFundAmount), Number(minFundingIncrement)));
28
+ } else return null;
40
29
  };
41
30
  /**
42
- * Returns the given array split into chunks of `batchSize` batches.
43
- * @param array The array to chunk
44
- * @param batchSize The size of batches to split the array into
45
- * @returns A generator that yields the array split into chunks of `batchSize` batches
46
- */
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
+ */
47
36
  function* chunkArray(array, batchSize) {
48
- for (let i = 0; i < array.length; i += batchSize)
49
- yield array.slice(i, i + batchSize);
37
+ for (let i = 0; i < array.length; i += batchSize) yield array.slice(i, i + batchSize);
50
38
  }
51
39
  /**
52
- * Memoize calls to the given function in an in-memory map.
53
- * @param fn The function to memoize
54
- * @returns The memoized function
55
- */
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
+ */
56
44
  const memoize = (fn) => {
57
- const cache = new Map();
58
- const cached = function (val) {
59
- return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
60
- };
61
- cached.cache = cache;
62
- 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;
63
51
  };
64
52
  const binaryStartsWith = (base, startsWith) => {
65
- if (startsWith.length > base.length)
66
- return false;
67
- for (let i = 0; i < startsWith.length; i++) {
68
- if (base[i] !== startsWith[i])
69
- return false;
70
- }
71
- 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;
72
56
  };
73
57
  const defaultJsonValueReplacer = (key, value) => {
74
- if (typeof value === 'bigint') {
75
- try {
76
- return toNumber(value);
77
- }
78
- catch {
79
- return value.toString();
80
- }
81
- }
82
- return value;
58
+ if (typeof value === "bigint") try {
59
+ return toNumber(value);
60
+ } catch {
61
+ return value.toString();
62
+ }
63
+ return value;
83
64
  };
84
65
  const asJson = (value, replacer = defaultJsonValueReplacer, space) => {
85
- return JSON.stringify(value, replacer, space);
66
+ return JSON.stringify(value, replacer, space);
86
67
  };
87
68
  /** Calculate minimum number of extra program pages required for provided approval and clear state programs */
88
69
  const calculateExtraProgramPages = (approvalProgram, clearStateProgram) => {
89
- return Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0) - 1) / types_app.APP_PAGE_MAX_SIZE);
70
+ return Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0) - 1) / require_app.APP_PAGE_MAX_SIZE);
90
71
  };
91
72
  /** Take a decoded ABI value and convert all byte arrays (including nested ones) from number[] to Uint8Arrays */
92
73
  function convertAbiByteArrays(value, type) {
93
- // Return value as is if the type doesn't have any bytes or if it's already an Uint8Array
94
- if (!type.toString().includes('byte') || value instanceof Uint8Array) {
95
- return value;
96
- }
97
- // Handle byte arrays (byte[N] or byte[])
98
- if ((type instanceof algosdk.ABIArrayStaticType || type instanceof algosdk.ABIArrayDynamicType) &&
99
- type.childType instanceof algosdk.ABIByteType &&
100
- Array.isArray(value)) {
101
- return new Uint8Array(value);
102
- }
103
- // Handle other arrays (for nested structures)
104
- if ((type instanceof algosdk.ABIArrayStaticType || type instanceof algosdk.ABIArrayDynamicType) && Array.isArray(value)) {
105
- const result = [];
106
- for (let i = 0; i < value.length; i++) {
107
- result.push(convertAbiByteArrays(value[i], type.childType));
108
- }
109
- return result;
110
- }
111
- // Handle tuples (for nested structures)
112
- if (type instanceof algosdk.ABITupleType && Array.isArray(value)) {
113
- const result = [];
114
- for (let i = 0; i < value.length && i < type.childTypes.length; i++) {
115
- result.push(convertAbiByteArrays(value[i], type.childTypes[i]));
116
- }
117
- return result;
118
- }
119
- // For other types, return the value as is
120
- return value;
74
+ if (!type.toString().includes("byte") || value instanceof Uint8Array) return value;
75
+ if ((type instanceof algosdk.ABIArrayStaticType || type instanceof algosdk.ABIArrayDynamicType) && type.childType instanceof algosdk.ABIByteType && Array.isArray(value)) return new Uint8Array(value);
76
+ if ((type instanceof algosdk.ABIArrayStaticType || type instanceof algosdk.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 algosdk.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;
121
87
  }
122
88
  /**
123
- * Convert bigint values to numbers for uint types with bit size < 53
124
- */
89
+ * Convert bigint values to numbers for uint types with bit size < 53
90
+ */
125
91
  const convertABIDecodedBigIntToNumber = (value, type) => {
126
- if (typeof value === 'bigint') {
127
- if (type instanceof algosdk.ABIUintType) {
128
- return type.bitSize < 53 ? Number(value) : value;
129
- }
130
- else {
131
- return value;
132
- }
133
- }
134
- else if (Array.isArray(value) && (type instanceof algosdk.ABIArrayStaticType || type instanceof algosdk.ABIArrayDynamicType)) {
135
- return value.map((v) => convertABIDecodedBigIntToNumber(v, type.childType));
136
- }
137
- else if (Array.isArray(value) && type instanceof algosdk.ABITupleType) {
138
- return value.map((v, i) => convertABIDecodedBigIntToNumber(v, type.childTypes[i]));
139
- }
140
- else {
141
- return value;
142
- }
92
+ if (typeof value === "bigint") if (type instanceof algosdk.ABIUintType) return type.bitSize < 53 ? Number(value) : value;
93
+ else return value;
94
+ else if (Array.isArray(value) && (type instanceof algosdk.ABIArrayStaticType || type instanceof algosdk.ABIArrayDynamicType)) return value.map((v) => convertABIDecodedBigIntToNumber(v, type.childType));
95
+ else if (Array.isArray(value) && type instanceof algosdk.ABITupleType) return value.map((v, i) => convertABIDecodedBigIntToNumber(v, type.childTypes[i]));
96
+ else return value;
143
97
  };
144
-
98
+ //#endregion
145
99
  exports.UnsafeConversionError = UnsafeConversionError;
146
100
  exports.asJson = asJson;
147
101
  exports.binaryStartsWith = binaryStartsWith;
@@ -153,4 +107,5 @@ exports.convertAbiByteArrays = convertAbiByteArrays;
153
107
  exports.defaultJsonValueReplacer = defaultJsonValueReplacer;
154
108
  exports.memoize = memoize;
155
109
  exports.toNumber = toNumber;
156
- //# sourceMappingURL=util.js.map
110
+
111
+ //# sourceMappingURL=util.js.map
package/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","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":["APP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C,EAAE,EAAE;AACnE,YAAA,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;;AAEjE,QAAA,OAAO,MAAM;;;AAIf,IAAA,OAAO,KAAK;AACd;AAEA;;AAEG;MACU,+BAA+B,GAAG,CAAC,KAAe,EAAE,IAAa,KAAc;AAC1F,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,IAAI,IAAI,YAAYC,mBAAW,EAAE;AAC/B,YAAA,OAAO,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK;;aAC3C;AACL,YAAA,OAAO,KAAK;;;AAET,SAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,YAAYJ,0BAAkB,IAAI,IAAI,YAAYC,2BAAmB,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,YAAYE,oBAAY,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.js","names":["APP_PAGE_MAX_SIZE","ABIArrayStaticType","ABIArrayDynamicType","ABIByteType","ABITupleType","ABIUintType"],"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,qFAC1B;MACK,IAAI,QAAQ,OAAO,OAAO,gBAAgB,GAC/C,MAAM,IAAI,sBACR,kBAAkB,MAAM,sFAC1B;CAEF,OAAO,OAAO,KAAK;AACrB;AAEA,IAAa,wBAAb,cAA2C,MAAM,CAAC;;;;;;;;AASlD,MAAa,uBACX,oBACA,wBACA,wBACkB;CAClB,IAAI,qBAAqB,wBAAwB;EAC/C,MAAM,gBAAgB,qBAAqB;EAC3C,OAAO,OAAO,KAAK,IAAI,OAAO,aAAa,GAAG,OAAO,mBAAmB,CAAC,CAAC;CAC5E,OACE,OAAO;AAEX;;;;;;;AAiBA,UAAiB,WAAc,OAAY,WAAyC;CAClF,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,WAAW,MAAM,MAAM,MAAM,GAAG,IAAI,SAAS;AACtF;;;;;;AAOA,MAAa,WAAqC,OAAsB;CACtE,MAAM,wBAAQ,I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