@algorandfoundation/algokit-utils 7.0.0-beta.1 → 7.0.0-beta.10

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 (360) hide show
  1. package/README.md +3 -25
  2. package/account/account.d.ts +8 -9
  3. package/account/account.js +7 -7
  4. package/account/account.js.map +1 -1
  5. package/account/account.mjs +7 -7
  6. package/account/account.mjs.map +1 -1
  7. package/account/get-account-config-from-environment.d.ts +0 -1
  8. package/account/get-account-config-from-environment.js.map +1 -1
  9. package/account/get-account-config-from-environment.mjs.map +1 -1
  10. package/account/get-account.d.ts +2 -3
  11. package/account/get-account.js +1 -1
  12. package/account/get-account.js.map +1 -1
  13. package/account/get-account.mjs +1 -1
  14. package/account/get-account.mjs.map +1 -1
  15. package/account/get-dispenser-account.d.ts +1 -2
  16. package/account/get-dispenser-account.js +1 -1
  17. package/account/get-dispenser-account.js.map +1 -1
  18. package/account/get-dispenser-account.mjs +1 -1
  19. package/account/get-dispenser-account.mjs.map +1 -1
  20. package/account/index.d.ts +0 -1
  21. package/account/mnemonic-account.d.ts +1 -2
  22. package/account/mnemonic-account.js +1 -1
  23. package/account/mnemonic-account.js.map +1 -1
  24. package/account/mnemonic-account.mjs +1 -1
  25. package/account/mnemonic-account.mjs.map +1 -1
  26. package/amount.d.ts +14 -5
  27. package/amount.js +6 -0
  28. package/amount.js.map +1 -1
  29. package/amount.mjs +6 -0
  30. package/amount.mjs.map +1 -1
  31. package/app-client.d.ts +15 -1
  32. package/app-client.js +15 -0
  33. package/app-client.js.map +1 -1
  34. package/app-client.mjs +15 -0
  35. package/app-client.mjs.map +1 -1
  36. package/app-deploy.d.ts +18 -2
  37. package/app-deploy.js +140 -333
  38. package/app-deploy.js.map +1 -1
  39. package/app-deploy.mjs +143 -336
  40. package/app-deploy.mjs.map +1 -1
  41. package/app.d.ts +39 -3
  42. package/app.js +116 -369
  43. package/app.js.map +1 -1
  44. package/app.mjs +117 -370
  45. package/app.mjs.map +1 -1
  46. package/asset.d.ts +5 -6
  47. package/asset.js +5 -8
  48. package/asset.js.map +1 -1
  49. package/asset.mjs +5 -8
  50. package/asset.mjs.map +1 -1
  51. package/config.d.ts +0 -1
  52. package/config.js.map +1 -1
  53. package/config.mjs.map +1 -1
  54. package/debugging/debugging.d.ts +3 -5
  55. package/debugging/debugging.js +4 -128
  56. package/debugging/debugging.js.map +1 -1
  57. package/debugging/debugging.mjs +4 -109
  58. package/debugging/debugging.mjs.map +1 -1
  59. package/debugging/index.d.ts +0 -2
  60. package/dispenser-client.d.ts +0 -1
  61. package/dispenser-client.js.map +1 -1
  62. package/dispenser-client.mjs.map +1 -1
  63. package/index.d.ts +4 -4
  64. package/index.js +31 -26
  65. package/index.js.map +1 -1
  66. package/index.mjs +4 -4
  67. package/indexer-lookup.d.ts +0 -1
  68. package/indexer-lookup.js.map +1 -1
  69. package/indexer-lookup.mjs.map +1 -1
  70. package/localnet/get-kmd-wallet-account.d.ts +1 -2
  71. package/localnet/get-kmd-wallet-account.js +1 -1
  72. package/localnet/get-kmd-wallet-account.js.map +1 -1
  73. package/localnet/get-kmd-wallet-account.mjs +1 -1
  74. package/localnet/get-kmd-wallet-account.mjs.map +1 -1
  75. package/localnet/get-localnet-dispenser-account.d.ts +1 -2
  76. package/localnet/get-localnet-dispenser-account.js +1 -1
  77. package/localnet/get-localnet-dispenser-account.js.map +1 -1
  78. package/localnet/get-localnet-dispenser-account.mjs +1 -1
  79. package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
  80. package/localnet/get-or-create-kmd-wallet-account.d.ts +1 -2
  81. package/localnet/get-or-create-kmd-wallet-account.js +1 -1
  82. package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
  83. package/localnet/get-or-create-kmd-wallet-account.mjs +1 -1
  84. package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
  85. package/localnet/index.d.ts +0 -1
  86. package/localnet/is-localnet.d.ts +1 -2
  87. package/localnet/is-localnet.js +1 -1
  88. package/localnet/is-localnet.js.map +1 -1
  89. package/localnet/is-localnet.mjs +1 -1
  90. package/localnet/is-localnet.mjs.map +1 -1
  91. package/network-client.d.ts +2 -3
  92. package/network-client.js +2 -2
  93. package/network-client.js.map +1 -1
  94. package/network-client.mjs +2 -2
  95. package/network-client.mjs.map +1 -1
  96. package/package.json +1 -1
  97. package/testing/_asset.d.ts +0 -1
  98. package/testing/account.d.ts +0 -1
  99. package/testing/account.js.map +1 -1
  100. package/testing/account.mjs.map +1 -1
  101. package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -1
  102. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  103. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  104. package/testing/fixtures/algorand-fixture.d.ts +0 -1
  105. package/testing/fixtures/algorand-fixture.js +12 -12
  106. package/testing/fixtures/algorand-fixture.js.map +1 -1
  107. package/testing/fixtures/algorand-fixture.mjs +12 -12
  108. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  109. package/testing/fixtures/index.d.ts +0 -1
  110. package/testing/index.d.ts +0 -1
  111. package/testing/indexer.d.ts +0 -1
  112. package/testing/indexer.js.map +1 -1
  113. package/testing/indexer.mjs.map +1 -1
  114. package/testing/test-logger.d.ts +0 -1
  115. package/testing/test-logger.js +1 -3
  116. package/testing/test-logger.js.map +1 -1
  117. package/testing/test-logger.mjs +1 -3
  118. package/testing/test-logger.mjs.map +1 -1
  119. package/testing/transaction-logger.d.ts +0 -1
  120. package/testing/transaction-logger.js.map +1 -1
  121. package/testing/transaction-logger.mjs.map +1 -1
  122. package/transaction/index.d.ts +0 -1
  123. package/transaction/legacy-bridge.d.ts +31 -6
  124. package/transaction/legacy-bridge.js +100 -6
  125. package/transaction/legacy-bridge.js.map +1 -1
  126. package/transaction/legacy-bridge.mjs +99 -8
  127. package/transaction/legacy-bridge.mjs.map +1 -1
  128. package/transaction/perform-atomic-transaction-composer-simulate.d.ts +0 -1
  129. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  130. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  131. package/transaction/transaction.d.ts +41 -6
  132. package/transaction/transaction.js +107 -45
  133. package/transaction/transaction.js.map +1 -1
  134. package/transaction/transaction.mjs +107 -46
  135. package/transaction/transaction.mjs.map +1 -1
  136. package/transfer/index.d.ts +0 -1
  137. package/transfer/transfer-algos.d.ts +1 -2
  138. package/transfer/transfer-algos.js +1 -1
  139. package/transfer/transfer-algos.js.map +1 -1
  140. package/transfer/transfer-algos.mjs +1 -1
  141. package/transfer/transfer-algos.mjs.map +1 -1
  142. package/transfer/transfer.d.ts +1 -2
  143. package/transfer/transfer.js +3 -3
  144. package/transfer/transfer.js.map +1 -1
  145. package/transfer/transfer.mjs +3 -3
  146. package/transfer/transfer.mjs.map +1 -1
  147. package/types/account-manager.d.ts +14 -6
  148. package/types/account-manager.js +18 -4
  149. package/types/account-manager.js.map +1 -1
  150. package/types/account-manager.mjs +18 -4
  151. package/types/account-manager.mjs.map +1 -1
  152. package/types/account.d.ts +0 -1
  153. package/types/account.js.map +1 -1
  154. package/types/account.mjs.map +1 -1
  155. package/types/algo-http-client-with-retry.d.ts +0 -1
  156. package/types/algo-http-client-with-retry.js.map +1 -1
  157. package/types/algo-http-client-with-retry.mjs.map +1 -1
  158. package/types/algorand-client-interface.d.ts +28 -0
  159. package/types/algorand-client-interface.js +3 -0
  160. package/types/algorand-client-interface.js.map +1 -0
  161. package/types/algorand-client-interface.mjs +2 -0
  162. package/types/algorand-client-interface.mjs.map +1 -0
  163. package/types/algorand-client-transaction-creator.d.ts +450 -21
  164. package/types/algorand-client-transaction-creator.js +406 -22
  165. package/types/algorand-client-transaction-creator.js.map +1 -1
  166. package/types/algorand-client-transaction-creator.mjs +406 -22
  167. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  168. package/types/algorand-client-transaction-sender.d.ts +758 -33
  169. package/types/algorand-client-transaction-sender.js +444 -14
  170. package/types/algorand-client-transaction-sender.js.map +1 -1
  171. package/types/algorand-client-transaction-sender.mjs +444 -14
  172. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  173. package/types/algorand-client.d.ts +18 -10
  174. package/types/algorand-client.js +23 -10
  175. package/types/algorand-client.js.map +1 -1
  176. package/types/algorand-client.mjs +23 -10
  177. package/types/algorand-client.mjs.map +1 -1
  178. package/types/amount.d.ts +10 -11
  179. package/types/amount.js +7 -7
  180. package/types/amount.js.map +1 -1
  181. package/types/amount.mjs +7 -7
  182. package/types/amount.mjs.map +1 -1
  183. package/types/app-arc56.d.ts +348 -0
  184. package/types/app-arc56.js +184 -0
  185. package/types/app-arc56.js.map +1 -0
  186. package/types/app-arc56.mjs +175 -0
  187. package/types/app-arc56.mjs.map +1 -0
  188. package/types/app-client.d.ts +1496 -9
  189. package/types/app-client.js +903 -21
  190. package/types/app-client.js.map +1 -1
  191. package/types/app-client.mjs +904 -23
  192. package/types/app-client.mjs.map +1 -1
  193. package/types/app-deployer.d.ts +126 -0
  194. package/types/app-deployer.js +354 -0
  195. package/types/app-deployer.js.map +1 -0
  196. package/types/app-deployer.mjs +352 -0
  197. package/types/app-deployer.mjs.map +1 -0
  198. package/types/app-factory.d.ts +846 -0
  199. package/types/app-factory.js +411 -0
  200. package/types/app-factory.js.map +1 -0
  201. package/types/app-factory.mjs +409 -0
  202. package/types/app-factory.mjs.map +1 -0
  203. package/types/app-manager.d.ts +244 -0
  204. package/types/app-manager.js +334 -0
  205. package/types/app-manager.js.map +1 -0
  206. package/types/app-manager.mjs +332 -0
  207. package/types/app-manager.mjs.map +1 -0
  208. package/types/app-spec.d.ts +2 -1
  209. package/types/app-spec.js +121 -0
  210. package/types/app-spec.js.map +1 -1
  211. package/types/app-spec.mjs +120 -0
  212. package/types/app-spec.mjs.map +1 -1
  213. package/types/app.d.ts +53 -13
  214. package/types/app.js +1 -1
  215. package/types/app.js.map +1 -1
  216. package/types/app.mjs +1 -1
  217. package/types/app.mjs.map +1 -1
  218. package/types/asset-manager.d.ts +4 -4
  219. package/types/asset-manager.js +3 -4
  220. package/types/asset-manager.js.map +1 -1
  221. package/types/asset-manager.mjs +3 -4
  222. package/types/asset-manager.mjs.map +1 -1
  223. package/types/asset.d.ts +0 -1
  224. package/types/async-event-emitter.d.ts +23 -0
  225. package/types/async-event-emitter.js +55 -0
  226. package/types/async-event-emitter.js.map +1 -0
  227. package/types/async-event-emitter.mjs +53 -0
  228. package/types/async-event-emitter.mjs.map +1 -0
  229. package/types/client-manager.d.ts +133 -51
  230. package/types/client-manager.js +147 -23
  231. package/types/client-manager.js.map +1 -1
  232. package/types/client-manager.mjs +148 -24
  233. package/types/client-manager.mjs.map +1 -1
  234. package/types/composer.d.ts +232 -49
  235. package/types/composer.js +307 -65
  236. package/types/composer.js.map +1 -1
  237. package/types/composer.mjs +308 -66
  238. package/types/composer.mjs.map +1 -1
  239. package/types/config.d.ts +3 -6
  240. package/types/config.js +5 -44
  241. package/types/config.js.map +1 -1
  242. package/types/config.mjs +5 -27
  243. package/types/config.mjs.map +1 -1
  244. package/types/debugging.d.ts +29 -101
  245. package/types/debugging.js +16 -109
  246. package/types/debugging.js.map +1 -1
  247. package/types/debugging.mjs +12 -107
  248. package/types/debugging.mjs.map +1 -1
  249. package/types/dispenser-client.d.ts +1 -2
  250. package/types/dispenser-client.js +6 -5
  251. package/types/dispenser-client.js.map +1 -1
  252. package/types/dispenser-client.mjs +6 -5
  253. package/types/dispenser-client.mjs.map +1 -1
  254. package/types/expand.d.ts +7 -0
  255. package/types/expand.js +3 -0
  256. package/types/expand.js.map +1 -0
  257. package/types/expand.mjs +2 -0
  258. package/types/expand.mjs.map +1 -0
  259. package/types/indexer.d.ts +0 -1
  260. package/types/indexer.js.map +1 -1
  261. package/types/indexer.mjs.map +1 -1
  262. package/types/kmd-account-manager.d.ts +0 -1
  263. package/types/kmd-account-manager.js +2 -2
  264. package/types/kmd-account-manager.js.map +1 -1
  265. package/types/kmd-account-manager.mjs +2 -2
  266. package/types/kmd-account-manager.mjs.map +1 -1
  267. package/types/logging.d.ts +0 -1
  268. package/types/logging.js.map +1 -1
  269. package/types/logging.mjs.map +1 -1
  270. package/types/logic-error.d.ts +0 -1
  271. package/types/logic-error.js.map +1 -1
  272. package/types/logic-error.mjs.map +1 -1
  273. package/types/network-client.d.ts +13 -1
  274. package/types/network-client.js.map +1 -1
  275. package/types/network-client.mjs.map +1 -1
  276. package/types/testing.d.ts +3 -4
  277. package/types/transaction.d.ts +17 -4
  278. package/types/transfer.d.ts +0 -1
  279. package/types/urlTokenBaseHTTPClient.d.ts +0 -1
  280. package/types/urlTokenBaseHTTPClient.js +1 -1
  281. package/types/urlTokenBaseHTTPClient.js.map +1 -1
  282. package/types/urlTokenBaseHTTPClient.mjs +1 -1
  283. package/types/urlTokenBaseHTTPClient.mjs.map +1 -1
  284. package/util.d.ts +2 -2
  285. package/util.js +11 -10
  286. package/util.js.map +1 -1
  287. package/util.mjs +11 -10
  288. package/util.mjs.map +1 -1
  289. package/account/account.d.ts.map +0 -1
  290. package/account/get-account-config-from-environment.d.ts.map +0 -1
  291. package/account/get-account.d.ts.map +0 -1
  292. package/account/get-dispenser-account.d.ts.map +0 -1
  293. package/account/index.d.ts.map +0 -1
  294. package/account/mnemonic-account.d.ts.map +0 -1
  295. package/amount.d.ts.map +0 -1
  296. package/app-client.d.ts.map +0 -1
  297. package/app-deploy.d.ts.map +0 -1
  298. package/app.d.ts.map +0 -1
  299. package/asset.d.ts.map +0 -1
  300. package/config.d.ts.map +0 -1
  301. package/debugging/debugging.d.ts.map +0 -1
  302. package/debugging/index.d.ts.map +0 -1
  303. package/debugging/simulate-and-persist-response.d.ts +0 -20
  304. package/debugging/simulate-and-persist-response.d.ts.map +0 -1
  305. package/debugging/simulate-and-persist-response.js +0 -108
  306. package/debugging/simulate-and-persist-response.js.map +0 -1
  307. package/debugging/simulate-and-persist-response.mjs +0 -89
  308. package/debugging/simulate-and-persist-response.mjs.map +0 -1
  309. package/dispenser-client.d.ts.map +0 -1
  310. package/index.d.ts.map +0 -1
  311. package/indexer-lookup.d.ts.map +0 -1
  312. package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
  313. package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
  314. package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
  315. package/localnet/index.d.ts.map +0 -1
  316. package/localnet/is-localnet.d.ts.map +0 -1
  317. package/network-client.d.ts.map +0 -1
  318. package/testing/_asset.d.ts.map +0 -1
  319. package/testing/account.d.ts.map +0 -1
  320. package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
  321. package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
  322. package/testing/fixtures/index.d.ts.map +0 -1
  323. package/testing/index.d.ts.map +0 -1
  324. package/testing/indexer.d.ts.map +0 -1
  325. package/testing/test-logger.d.ts.map +0 -1
  326. package/testing/transaction-logger.d.ts.map +0 -1
  327. package/transaction/index.d.ts.map +0 -1
  328. package/transaction/legacy-bridge.d.ts.map +0 -1
  329. package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
  330. package/transaction/transaction.d.ts.map +0 -1
  331. package/transfer/index.d.ts.map +0 -1
  332. package/transfer/transfer-algos.d.ts.map +0 -1
  333. package/transfer/transfer.d.ts.map +0 -1
  334. package/types/account-manager.d.ts.map +0 -1
  335. package/types/account.d.ts.map +0 -1
  336. package/types/algo-http-client-with-retry.d.ts.map +0 -1
  337. package/types/algorand-client-transaction-creator.d.ts.map +0 -1
  338. package/types/algorand-client-transaction-sender.d.ts.map +0 -1
  339. package/types/algorand-client.d.ts.map +0 -1
  340. package/types/amount.d.ts.map +0 -1
  341. package/types/app-client.d.ts.map +0 -1
  342. package/types/app-spec.d.ts.map +0 -1
  343. package/types/app.d.ts.map +0 -1
  344. package/types/asset-manager.d.ts.map +0 -1
  345. package/types/asset.d.ts.map +0 -1
  346. package/types/client-manager.d.ts.map +0 -1
  347. package/types/composer.d.ts.map +0 -1
  348. package/types/config.d.ts.map +0 -1
  349. package/types/debugging.d.ts.map +0 -1
  350. package/types/dispenser-client.d.ts.map +0 -1
  351. package/types/indexer.d.ts.map +0 -1
  352. package/types/kmd-account-manager.d.ts.map +0 -1
  353. package/types/logging.d.ts.map +0 -1
  354. package/types/logic-error.d.ts.map +0 -1
  355. package/types/network-client.d.ts.map +0 -1
  356. package/types/testing.d.ts.map +0 -1
  357. package/types/transaction.d.ts.map +0 -1
  358. package/types/transfer.d.ts.map +0 -1
  359. package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
  360. package/util.d.ts.map +0 -1
package/app.mjs CHANGED
@@ -1,197 +1,77 @@
1
1
  import algosdk from 'algosdk';
2
- import { Buffer } from 'buffer';
3
- import { Config } from './config.mjs';
4
- import { getAtomicTransactionComposerTransactions, controlFees, getTransactionParams, encodeTransactionNote, sendAtomicTransactionComposer, getSenderAddress, sendTransaction, encodeLease, getSenderTransactionSigner } from './transaction/transaction.mjs';
5
- import { APP_PAGE_MAX_SIZE } from './types/app.mjs';
2
+ import { legacySendAppTransactionBridge, _getAppArgsForABICall, _getBoxReference } from './transaction/legacy-bridge.mjs';
3
+ import { getSenderAddress, encodeLease } from './transaction/transaction.mjs';
4
+ import { AppManager } from './types/app-manager.mjs';
6
5
  import { toNumber } from './util.mjs';
7
6
 
8
7
  var ABIMethod = algosdk.ABIMethod;
9
- var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
10
8
  var modelsv2 = algosdk.modelsv2;
11
9
  var OnApplicationComplete = algosdk.OnApplicationComplete;
12
- var SourceMap = algosdk.SourceMap;
13
10
  /**
11
+ * @deprecated Use `algorand.send.appCreate()` / `algorand.createTransaction.appCreate()` / `algorand.send.appCreateMethodCall()`
12
+ * / `algorand.createTransaction.appCreateMethodCall()` instead
13
+ *
14
14
  * Creates a smart contract app, returns the details of the created app.
15
15
  * @param create The parameters to create the app with
16
16
  * @param algod An algod client
17
17
  * @returns The details of the created app, or the transaction to create it if `skipSending` and the compilation result
18
18
  */
19
19
  async function createApp(create, algod) {
20
- const { from, approvalProgram: approval, clearStateProgram: clear, schema, note, transactionParams, args, onCompleteAction, ...sendParams } = create;
21
- const compiledApproval = typeof approval === 'string' ? await compileTeal(approval, algod) : undefined;
22
- const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : approval;
23
- const compiledClear = typeof clear === 'string' ? await compileTeal(clear, algod) : undefined;
24
- const clearProgram = compiledClear ? compiledClear.compiledBase64ToBytes : clear;
25
- if (args && args.method) {
26
- const atc = attachATC(sendParams);
27
- const before = getAtomicTransactionComposerTransactions(atc);
28
- atc.addMethodCall({
29
- appID: 0,
30
- approvalProgram: approvalProgram,
31
- clearProgram: clearProgram,
32
- numLocalInts: schema.localInts,
33
- numLocalByteSlices: schema.localByteSlices,
34
- numGlobalInts: schema.globalInts,
35
- numGlobalByteSlices: schema.globalByteSlices,
36
- extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / APP_PAGE_MAX_SIZE),
37
- onComplete: getAppOnCompleteAction(onCompleteAction),
38
- suggestedParams: controlFees(await getTransactionParams(transactionParams, algod), sendParams),
39
- note: encodeTransactionNote(note),
40
- ...(await getAppArgsForABICall(args, from)),
41
- });
42
- if (sendParams.skipSending) {
43
- const after = atc.clone().buildGroup();
44
- return {
45
- transaction: after[after.length - 1].txn,
46
- transactions: after.slice(before.length).map((t) => t.txn),
47
- appId: 0,
48
- appAddress: '',
49
- compiledApproval,
50
- compiledClear,
51
- };
52
- }
53
- const result = await sendAtomicTransactionComposer({ atc, sendParams }, algod);
54
- const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined;
55
- if (confirmation) {
56
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
57
- const appId = confirmation.applicationIndex;
58
- Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${getSenderAddress(from)}`);
59
- return {
60
- transactions: result.transactions,
61
- confirmations: result.confirmations,
62
- return: confirmation ? getABIReturn(args, confirmation) : undefined,
63
- transaction: result.transactions[result.transactions.length - 1],
64
- confirmation: confirmation,
65
- appId,
66
- appAddress: algosdk.getApplicationAddress(appId),
67
- compiledApproval,
68
- compiledClear,
69
- };
70
- }
71
- else {
72
- return {
73
- transactions: result.transactions,
74
- confirmations: result.confirmations,
75
- return: confirmation ? getABIReturn(args, confirmation) : undefined,
76
- transaction: result.transactions[result.transactions.length - 1],
77
- confirmation: confirmation,
78
- appId: 0,
79
- appAddress: '',
80
- compiledApproval,
81
- compiledClear,
82
- };
83
- }
84
- }
85
- else {
86
- const transaction = algosdk.makeApplicationCreateTxnFromObject({
87
- approvalProgram: approvalProgram,
88
- clearProgram: clearProgram,
89
- numLocalInts: schema.localInts,
90
- numLocalByteSlices: schema.localByteSlices,
91
- numGlobalInts: schema.globalInts,
92
- numGlobalByteSlices: schema.globalByteSlices,
93
- extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / APP_PAGE_MAX_SIZE),
94
- onComplete: getAppOnCompleteAction(onCompleteAction),
95
- suggestedParams: await getTransactionParams(transactionParams, algod),
96
- from: getSenderAddress(from),
97
- note: encodeTransactionNote(note),
98
- ...getAppArgsForTransaction(args),
99
- rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : getSenderAddress(args.rekeyTo)) : undefined,
100
- });
101
- const { confirmation } = await sendTransaction({ transaction, from, sendParams }, algod);
102
- if (confirmation) {
103
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
104
- const appId = confirmation.applicationIndex;
105
- Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${getSenderAddress(from)}`);
106
- return {
107
- transaction,
108
- transactions: [transaction],
109
- confirmation,
110
- confirmations: confirmation ? [confirmation] : undefined,
111
- appId,
112
- appAddress: algosdk.getApplicationAddress(appId),
113
- return: getABIReturn(args, confirmation),
114
- compiledApproval,
115
- compiledClear,
116
- };
117
- }
118
- else {
119
- return { transaction, transactions: [transaction], appId: 0, appAddress: '', compiledApproval, compiledClear };
120
- }
20
+ const onComplete = getAppOnCompleteAction(create.onCompleteAction);
21
+ if (onComplete === algosdk.OnApplicationComplete.ClearStateOC) {
22
+ throw new Error('Cannot create an app with on-complete action of ClearState');
121
23
  }
24
+ const result = create.args?.method
25
+ ? await legacySendAppTransactionBridge(algod, create.from, create.args, create, {
26
+ sender: getSenderAddress(create.from),
27
+ onComplete,
28
+ approvalProgram: create.approvalProgram,
29
+ clearStateProgram: create.clearStateProgram,
30
+ method: create.args.method instanceof ABIMethod ? create.args.method : new ABIMethod(create.args.method),
31
+ extraProgramPages: create.schema.extraPages,
32
+ schema: create.schema,
33
+ }, (c) => c.appCreateMethodCall, (c) => c.appCreateMethodCall)
34
+ : await legacySendAppTransactionBridge(algod, create.from, create.args, create, {
35
+ sender: getSenderAddress(create.from),
36
+ onComplete,
37
+ approvalProgram: create.approvalProgram,
38
+ clearStateProgram: create.clearStateProgram,
39
+ extraProgramPages: create.schema.extraPages,
40
+ schema: create.schema,
41
+ }, (c) => c.appCreate, (c) => c.appCreate);
42
+ return { ...result, appId: 'appId' in result ? Number(result.appId) : 0, appAddress: 'appAddress' in result ? result.appAddress : '' };
122
43
  }
123
44
  /**
45
+ * @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
46
+ * / `algorand.createTransaction.appUpdateMethodCall()` instead
47
+ *
124
48
  * Updates a smart contract app.
125
49
  * @param update The parameters to update the app with
126
50
  * @param algod An algod client
127
51
  * @returns The transaction send result and the compilation result
128
52
  */
129
53
  async function updateApp(update, algod) {
130
- const { appId, from, approvalProgram: approval, clearStateProgram: clear, note, transactionParams, args, ...sendParams } = update;
131
- const compiledApproval = typeof approval === 'string' ? await compileTeal(approval, algod) : undefined;
132
- const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : approval;
133
- const compiledClear = typeof clear === 'string' ? await compileTeal(clear, algod) : undefined;
134
- const clearProgram = compiledClear ? compiledClear.compiledBase64ToBytes : clear;
135
- Config.getLogger(sendParams.suppressLog).debug(`Updating app ${appId}`);
136
- if (args && args.method) {
137
- const atc = attachATC(sendParams);
138
- const before = getAtomicTransactionComposerTransactions(atc);
139
- atc.addMethodCall({
140
- appID: toNumber(appId),
141
- onComplete: OnApplicationComplete.UpdateApplicationOC,
142
- approvalProgram: approvalProgram,
143
- clearProgram: clearProgram,
144
- suggestedParams: controlFees(await getTransactionParams(transactionParams, algod), sendParams),
145
- note: encodeTransactionNote(note),
146
- ...(await getAppArgsForABICall(args, from)),
147
- });
148
- if (sendParams.skipSending) {
149
- const after = atc.clone().buildGroup();
150
- return {
151
- transaction: after[after.length - 1].txn,
152
- transactions: after.slice(before.length).map((t) => t.txn),
153
- };
154
- }
155
- const result = await sendAtomicTransactionComposer({ atc, sendParams }, algod);
156
- const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined;
157
- return {
158
- transactions: result.transactions,
159
- confirmations: result.confirmations,
160
- return: confirmation ? getABIReturn(args, confirmation) : undefined,
161
- transaction: result.transactions[result.transactions.length - 1],
162
- confirmation: confirmation,
163
- };
164
- }
165
- else {
166
- const transaction = algosdk.makeApplicationUpdateTxnFromObject({
167
- appIndex: toNumber(appId),
168
- approvalProgram: approvalProgram,
169
- clearProgram: clearProgram,
170
- suggestedParams: await getTransactionParams(transactionParams, algod),
171
- from: getSenderAddress(from),
172
- note: encodeTransactionNote(note),
173
- ...getAppArgsForTransaction(args),
174
- rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : getSenderAddress(args.rekeyTo)) : undefined,
175
- });
176
- const result = await sendTransaction({ transaction, from, sendParams }, algod);
177
- return {
178
- ...result,
179
- transactions: [result.transaction],
180
- confirmations: result.confirmation ? [result.confirmation] : undefined,
181
- return: getABIReturn(args, result.confirmation),
182
- compiledApproval,
183
- compiledClear,
184
- };
185
- }
54
+ return update.args?.method
55
+ ? await legacySendAppTransactionBridge(algod, update.from, update.args, update, {
56
+ appId: BigInt(update.appId),
57
+ sender: getSenderAddress(update.from),
58
+ onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
59
+ approvalProgram: update.approvalProgram,
60
+ clearStateProgram: update.clearStateProgram,
61
+ method: update.args.method instanceof ABIMethod ? update.args.method : new ABIMethod(update.args.method),
62
+ }, (c) => c.appUpdateMethodCall, (c) => c.appUpdateMethodCall)
63
+ : await legacySendAppTransactionBridge(algod, update.from, update.args, update, {
64
+ appId: BigInt(update.appId),
65
+ sender: getSenderAddress(update.from),
66
+ onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
67
+ approvalProgram: update.approvalProgram,
68
+ clearStateProgram: update.clearStateProgram,
69
+ }, (c) => c.appUpdate, (c) => c.appUpdate);
186
70
  }
187
- function attachATC(sendParams) {
188
- if (sendParams.atc) {
189
- sendParams.skipSending = true;
190
- }
191
- sendParams.atc = sendParams.atc ?? new AtomicTransactionComposer();
192
- return sendParams.atc;
193
- }
194
- /** Returns an `algosdk.OnApplicationComplete` for the given onCompleteAction.
71
+ /**
72
+ * @deprecated Use `algosdk.OnApplicationComplete` directly instead.
73
+ *
74
+ * Returns a `algosdk.OnApplicationComplete` for the given onCompleteAction.
195
75
  *
196
76
  * If given `undefined` will return `OnApplicationComplete.NoOpOC`.
197
77
  *
@@ -224,77 +104,39 @@ function getAppOnCompleteAction(onCompletionAction) {
224
104
  }
225
105
  }
226
106
  /**
107
+ * @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
108
+ * / `algorand.createTransaction.appUpdateMethodCall()` instead
109
+ *
227
110
  * Issues a call to a given app.
228
111
  * @param call The call details.
229
112
  * @param algod An algod client
230
113
  * @returns The result of the call
231
114
  */
232
115
  async function callApp(call, algod) {
233
- const { appId, callType, from, args, note, transactionParams, ...sendParams } = call;
234
- if (args && args.method) {
235
- const atc = attachATC(sendParams);
236
- const before = getAtomicTransactionComposerTransactions(atc);
237
- atc.addMethodCall({
238
- appID: toNumber(appId),
239
- suggestedParams: controlFees(await getTransactionParams(transactionParams, algod), sendParams),
240
- note: encodeTransactionNote(note),
241
- onComplete: getAppOnCompleteAction(callType),
242
- ...(await getAppArgsForABICall(args, from)),
243
- });
244
- if (sendParams.skipSending) {
245
- const after = atc.clone().buildGroup();
246
- return {
247
- transaction: after[after.length - 1].txn,
248
- transactions: after.slice(before.length).map((t) => t.txn),
249
- };
250
- }
251
- const result = await sendAtomicTransactionComposer({ atc, sendParams }, algod);
252
- const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined;
253
- return {
254
- transactions: result.transactions,
255
- confirmations: result.confirmations,
256
- return: confirmation ? getABIReturn(args, confirmation) : undefined,
257
- transaction: result.transactions[result.transactions.length - 1],
258
- confirmation: confirmation,
259
- };
116
+ const onComplete = getAppOnCompleteAction(call.callType);
117
+ if (onComplete === algosdk.OnApplicationComplete.UpdateApplicationOC) {
118
+ throw new Error('Cannot execute an app call with on-complete action of Update');
260
119
  }
261
- const appCallParams = {
262
- appIndex: toNumber(appId),
263
- from: getSenderAddress(from),
264
- suggestedParams: await getTransactionParams(transactionParams, algod),
265
- ...getAppArgsForTransaction(args),
266
- note: encodeTransactionNote(note),
267
- rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : getSenderAddress(args.rekeyTo)) : undefined,
268
- };
269
- let transaction;
270
- switch (getAppOnCompleteAction(callType)) {
271
- case OnApplicationComplete.OptInOC:
272
- transaction = algosdk.makeApplicationOptInTxnFromObject(appCallParams);
273
- break;
274
- case OnApplicationComplete.ClearStateOC:
275
- transaction = algosdk.makeApplicationClearStateTxnFromObject(appCallParams);
276
- break;
277
- case OnApplicationComplete.CloseOutOC:
278
- transaction = algosdk.makeApplicationCloseOutTxnFromObject(appCallParams);
279
- break;
280
- case OnApplicationComplete.DeleteApplicationOC:
281
- transaction = algosdk.makeApplicationDeleteTxnFromObject(appCallParams);
282
- break;
283
- case OnApplicationComplete.NoOpOC:
284
- transaction = algosdk.makeApplicationNoOpTxnFromObject(appCallParams);
285
- break;
286
- default:
287
- throw new Error(`Received unexpected call type ${callType}`);
120
+ if (call.args?.method && onComplete === algosdk.OnApplicationComplete.ClearStateOC) {
121
+ throw new Error('Cannot execute an ABI method call with on-complete action of ClearState');
288
122
  }
289
- const result = await sendTransaction({ transaction, from, sendParams }, algod);
290
- return {
291
- ...result,
292
- transactions: [result.transaction],
293
- confirmations: result.confirmation ? [result.confirmation] : undefined,
294
- return: getABIReturn(args, result.confirmation),
295
- };
123
+ return call.args?.method
124
+ ? await legacySendAppTransactionBridge(algod, call.from, call.args, call, {
125
+ appId: BigInt(call.appId),
126
+ sender: getSenderAddress(call.from),
127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
+ onComplete: onComplete,
129
+ method: call.args.method instanceof ABIMethod ? call.args.method : new ABIMethod(call.args.method),
130
+ }, (c) => c.appCallMethodCall, (c) => c.appCallMethodCall)
131
+ : await legacySendAppTransactionBridge(algod, call.from, call.args, call, {
132
+ appId: BigInt(call.appId),
133
+ sender: getSenderAddress(call.from),
134
+ onComplete,
135
+ }, (c) => c.appCall, (c) => c.appCall);
296
136
  }
297
137
  /**
138
+ * @deprecated Use `AppManager.getABIReturn` instead.
139
+ *
298
140
  * Returns any ABI return values for the given app call arguments and transaction confirmation.
299
141
  * @param args The arguments that were used for the call
300
142
  * @param confirmation The transaction confirmation from algod
@@ -305,43 +147,22 @@ function getABIReturn(args, confirmation) {
305
147
  return undefined;
306
148
  }
307
149
  const method = 'txnCount' in args.method ? args.method : new ABIMethod(args.method);
308
- if (method.returns.type !== 'void' && confirmation) {
309
- // The parseMethodResponse method mutates the second parameter :(
310
- const resultDummy = {
311
- txID: '',
312
- method,
313
- rawReturnValue: new Uint8Array(),
314
- };
315
- const response = AtomicTransactionComposer.parseMethodResponse(method, resultDummy, confirmation);
316
- return !response.decodeError
317
- ? {
318
- rawReturnValue: response.rawReturnValue,
319
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
320
- returnValue: response.returnValue,
321
- decodeError: undefined,
322
- }
323
- : {
324
- rawReturnValue: undefined,
325
- returnValue: undefined,
326
- decodeError: response.decodeError,
327
- };
328
- }
329
- return undefined;
150
+ return AppManager.getABIReturn(confirmation, method);
330
151
  }
331
152
  /**
153
+ * @deprecated Use `algorand.app.getGlobalState` instead.
154
+ *
332
155
  * Returns the current global state values for the given app ID
333
156
  * @param appId The ID of the app return global state for
334
157
  * @param algod An algod client instance
335
158
  * @returns The current global state
336
159
  */
337
160
  async function getAppGlobalState(appId, algod) {
338
- const appInfo = await getAppById(appId, algod);
339
- if (!appInfo.params || !appInfo.params.globalState) {
340
- throw new Error("Couldn't find global state");
341
- }
342
- return decodeAppState(appInfo.params.globalState);
161
+ return await new AppManager(algod).getGlobalState(BigInt(appId));
343
162
  }
344
163
  /**
164
+ * @deprecated Use `algorand.app.getLocalState` instead.
165
+ *
345
166
  * Returns the current global state values for the given app ID and account
346
167
  * @param appId The ID of the app return global state for
347
168
  * @param account Either the string address of an account or an account object for the account to get local state for the given app
@@ -349,30 +170,20 @@ async function getAppGlobalState(appId, algod) {
349
170
  * @returns The current local state for the given (app, account) combination
350
171
  */
351
172
  async function getAppLocalState(appId, account, algod) {
352
- const accountAddress = typeof account === 'string' ? account : getSenderAddress(account);
353
- const appInfo = modelsv2.AccountApplicationResponse.from_obj_for_encoding(await algod.accountApplicationInformation(accountAddress, toNumber(appId)).do());
354
- if (!appInfo.appLocalState?.keyValue) {
355
- throw new Error("Couldn't find local state");
356
- }
357
- return decodeAppState(appInfo.appLocalState.keyValue);
173
+ return new AppManager(algod).getLocalState(BigInt(appId), getSenderAddress(account));
358
174
  }
359
175
  /**
176
+ * @deprecated Use `algorand.app.getBoxNames` instead.
360
177
  * Returns the names of the boxes for the given app.
361
178
  * @param appId The ID of the app return box names for
362
179
  * @param algod An algod client instance
363
180
  * @returns The current box names
364
181
  */
365
182
  async function getAppBoxNames(appId, algod) {
366
- const boxResult = await algod.getApplicationBoxes(toNumber(appId)).do();
367
- return boxResult.boxes.map((b) => {
368
- return {
369
- nameRaw: b.name,
370
- nameBase64: Buffer.from(b.name).toString('base64'),
371
- name: Buffer.from(b.name).toString('utf-8'),
372
- };
373
- });
183
+ return new AppManager(algod).getBoxNames(BigInt(appId));
374
184
  }
375
185
  /**
186
+ * @deprecated Use `algorand.app.getBoxValue` instead.
376
187
  * Returns the value of the given box name for the given app.
377
188
  * @param appId The ID of the app return box names for
378
189
  * @param boxName The name of the box to return either as a string, binary array or `BoxName`
@@ -380,11 +191,10 @@ async function getAppBoxNames(appId, algod) {
380
191
  * @returns The current box value as a byte array
381
192
  */
382
193
  async function getAppBoxValue(appId, boxName, algod) {
383
- const name = typeof boxName === 'string' ? new Uint8Array(Buffer.from(boxName, 'utf-8')) : 'name' in boxName ? boxName.nameRaw : boxName;
384
- const boxResult = await algod.getApplicationBoxByName(toNumber(appId), name).do();
385
- return boxResult.value;
194
+ return new AppManager(algod).getBoxValue(BigInt(appId), typeof boxName !== 'string' && 'name' in boxName ? boxName.nameRaw : boxName);
386
195
  }
387
196
  /**
197
+ * @deprecated Use `algorand.app.getBoxValues` instead.
388
198
  * Returns the value of the given box names for the given app.
389
199
  * @param appId The ID of the app return box names for
390
200
  * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`
@@ -392,74 +202,50 @@ async function getAppBoxValue(appId, boxName, algod) {
392
202
  * @returns The current box values as a byte array in the same order as the passed in box names
393
203
  */
394
204
  async function getAppBoxValues(appId, boxNames, algod) {
395
- return await Promise.all(boxNames.map(async (boxName) => await getAppBoxValue(appId, boxName, algod)));
205
+ return new AppManager(algod).getBoxValues(BigInt(appId), boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)));
396
206
  }
397
207
  /**
208
+ * @deprecated Use `algorand.app.getBoxValueFromABIType` instead.
398
209
  * Returns the value of the given box name for the given app decoded based on the given ABI type.
399
210
  * @param request The parameters for the box value request
400
211
  * @param algod An algod client instance
401
212
  * @returns The current box value as an ABI value
402
213
  */
403
214
  async function getAppBoxValueFromABIType(request, algod) {
404
- const { appId, boxName, type } = request;
405
- const value = await getAppBoxValue(appId, boxName, algod);
406
- return type.decode(value);
215
+ return new AppManager(algod).getBoxValueFromABIType({
216
+ appId: BigInt(request.appId),
217
+ boxName: typeof request.boxName !== 'string' && 'name' in request.boxName ? request.boxName.nameRaw : request.boxName,
218
+ type: request.type,
219
+ });
407
220
  }
408
221
  /**
222
+ * @deprecated Use `algorand.app.getBoxValuesFromABIType` instead.
409
223
  * Returns the value of the given box names for the given app decoded based on the given ABI type.
410
224
  * @param request The parameters for the box value request
411
225
  * @param algod An algod client instance
412
226
  * @returns The current box values as an ABI value in the same order as the passed in box names
413
227
  */
414
228
  async function getAppBoxValuesFromABIType(request, algod) {
415
- const { appId, boxNames, type } = request;
416
- return await Promise.all(boxNames.map(async (boxName) => await getAppBoxValueFromABIType({ appId, boxName, type }, algod)));
229
+ return new AppManager(algod).getBoxValuesFromABIType({
230
+ appId: BigInt(request.appId),
231
+ boxNames: request.boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)),
232
+ type: request.type,
233
+ });
417
234
  }
418
235
  /**
236
+ * @deprecated Use `AppManager.decodeAppState` instead.
237
+ *
419
238
  * Converts an array of global/local state values from the algod api to a more friendly
420
239
  * generic object keyed by the UTF-8 value of the key.
421
240
  * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`
422
241
  * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values
423
242
  */
424
243
  function decodeAppState(state) {
425
- const stateValues = {};
426
- // Start with empty set
427
- for (const stateVal of state) {
428
- const keyBase64 = stateVal.key;
429
- const keyRaw = Buffer.from(keyBase64, 'base64');
430
- const key = keyRaw.toString('utf-8');
431
- const tealValue = stateVal.value;
432
- const dataTypeFlag = 'action' in tealValue ? tealValue.action : tealValue.type;
433
- let valueBase64;
434
- let valueRaw;
435
- switch (dataTypeFlag) {
436
- case 1:
437
- valueBase64 = tealValue.bytes ?? '';
438
- valueRaw = Buffer.from(valueBase64, 'base64');
439
- stateValues[key] = {
440
- keyRaw,
441
- keyBase64,
442
- valueRaw: new Uint8Array(valueRaw),
443
- valueBase64: valueBase64,
444
- value: valueRaw.toString('utf-8'),
445
- };
446
- break;
447
- case 2: {
448
- const value = tealValue.uint ?? 0;
449
- stateValues[key] = {
450
- keyRaw,
451
- keyBase64,
452
- value,
453
- };
454
- break;
455
- }
456
- default:
457
- throw new Error(`Received unknown state data type of ${dataTypeFlag}`);
458
- }
459
- }
460
- return stateValues;
244
+ return AppManager.decodeAppState(state);
461
245
  }
462
246
  /**
247
+ * @deprecated Use `AlgoKitComposer` methods to construct transactions instead.
248
+ *
463
249
  * Returns the app args ready to load onto an app `Transaction` object
464
250
  * @param args The app call args
465
251
  * @returns The args ready to load into a `Transaction`
@@ -478,68 +264,32 @@ function getAppArgsForTransaction(args) {
478
264
  };
479
265
  }
480
266
  /**
267
+ * @deprecated Use `AlgoKitComposer` methods to construct transactions instead.
268
+ *
481
269
  * Returns the app args ready to load onto an ABI method call in `AtomicTransactionComposer`
482
270
  * @param args The ABI app call args
483
271
  * @param from The transaction signer
484
272
  * @returns The parameters ready to pass into `addMethodCall` within AtomicTransactionComposer
485
273
  */
486
274
  async function getAppArgsForABICall(args, from) {
487
- const signer = getSenderTransactionSigner(from);
488
- const methodArgs = await Promise.all(('methodArgs' in args ? args.methodArgs : args)?.map(async (a, index) => {
489
- if (a === undefined) {
490
- throw new Error(`Argument at position ${index} does not have a value`);
491
- }
492
- if (typeof a !== 'object') {
493
- return a;
494
- }
495
- // Handle the various forms of transactions to wrangle them for ATC
496
- return 'txn' in a
497
- ? a
498
- : a instanceof Promise
499
- ? { txn: (await a).transaction, signer }
500
- : 'transaction' in a
501
- ? { txn: a.transaction, signer: 'signer' in a ? getSenderTransactionSigner(a.signer) : signer }
502
- : 'txID' in a
503
- ? { txn: a, signer }
504
- : a;
505
- }));
506
- return {
507
- method: 'txnCount' in args.method ? args.method : new ABIMethod(args.method),
508
- sender: getSenderAddress(from),
509
- signer: signer,
510
- boxes: args.boxes?.map(getBoxReference),
511
- lease: encodeLease(args.lease),
512
- appForeignApps: args.apps,
513
- appForeignAssets: args.assets,
514
- appAccounts: args.accounts?.map(_getAccountAddress),
515
- methodArgs: methodArgs,
516
- rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : getSenderAddress(args.rekeyTo)) : undefined,
517
- };
275
+ return _getAppArgsForABICall(args, from);
518
276
  }
519
277
  /**
278
+ * @deprecated Use `AppManager.getBoxReference()` instead.
279
+ *
520
280
  * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.
521
281
  * @param box The box to return a reference for
522
282
  * @returns The box reference ready to pass into a `Transaction`
523
283
  */
524
284
  function getBoxReference(box) {
525
- const encoder = new TextEncoder();
526
- if (typeof box === 'object' && 'appIndex' in box) {
527
- return box;
528
- }
529
- const ref = typeof box === 'object' && 'appId' in box ? box : { appId: 0, name: box };
530
- return {
531
- appIndex: ref.appId,
532
- name: typeof ref.name === 'string'
533
- ? encoder.encode(ref.name)
534
- : 'length' in ref.name
535
- ? ref.name
536
- : algosdk.decodeAddress(getSenderAddress(ref.name)).publicKey,
537
- };
285
+ return _getBoxReference(box);
538
286
  }
539
287
  function _getAccountAddress(account) {
540
288
  return typeof account === 'string' ? account : algosdk.encodeAddress(account.publicKey);
541
289
  }
542
290
  /**
291
+ * @deprecated Use `algorand.app.getById` instead.
292
+ *
543
293
  * Gets the current data for the given app from algod.
544
294
  *
545
295
  * @param appId The id of the app
@@ -550,6 +300,8 @@ async function getAppById(appId, algod) {
550
300
  return modelsv2.Application.from_obj_for_encoding(await algod.getApplicationByID(toNumber(appId)).do());
551
301
  }
552
302
  /**
303
+ * @deprecated Use `algorand.app.compileTeal` instead.
304
+ *
553
305
  * Compiles the given TEAL using algod and returns the result, including source map.
554
306
  *
555
307
  * @param algod An algod client
@@ -557,16 +309,11 @@ async function getAppById(appId, algod) {
557
309
  * @returns The information about the compiled file
558
310
  */
559
311
  async function compileTeal(tealCode, algod) {
560
- const compiled = await algod.compile(tealCode).sourcemap(true).do();
561
- return {
562
- teal: tealCode,
563
- compiled: compiled.result,
564
- compiledHash: compiled.hash,
565
- compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),
566
- sourceMap: new SourceMap(compiled['sourcemap']),
567
- };
312
+ return await new AppManager(algod).compileTeal(tealCode);
568
313
  }
569
314
  /**
315
+ * @deprecated Use `abiMethod.getSignature()` or `new ABIMethod(abiMethodParams).getSignature()` instead.
316
+ *
570
317
  * Returns the encoded ABI spec for a given ABI Method
571
318
  * @param method The method to return a signature for
572
319
  * @returns The encoded ABI method spec e.g. `method_name(uint64,string)string`