@algorandfoundation/algokit-utils 6.3.0-beta.1 → 7.0.0-alpha.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 (379) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -26
  3. package/account/account.d.ts +12 -10
  4. package/account/account.js +17 -14
  5. package/account/account.js.map +1 -1
  6. package/account/account.mjs +18 -15
  7. package/account/account.mjs.map +1 -1
  8. package/account/get-account-config-from-environment.d.ts +0 -1
  9. package/account/get-account-config-from-environment.js.map +1 -1
  10. package/account/get-account-config-from-environment.mjs.map +1 -1
  11. package/account/get-account.d.ts +2 -3
  12. package/account/get-account.js +1 -1
  13. package/account/get-account.js.map +1 -1
  14. package/account/get-account.mjs +1 -1
  15. package/account/get-account.mjs.map +1 -1
  16. package/account/get-dispenser-account.d.ts +2 -3
  17. package/account/get-dispenser-account.js +1 -1
  18. package/account/get-dispenser-account.js.map +1 -1
  19. package/account/get-dispenser-account.mjs +1 -1
  20. package/account/get-dispenser-account.mjs.map +1 -1
  21. package/account/index.d.ts +0 -1
  22. package/account/mnemonic-account.d.ts +1 -2
  23. package/account/mnemonic-account.js +1 -1
  24. package/account/mnemonic-account.js.map +1 -1
  25. package/account/mnemonic-account.mjs +1 -1
  26. package/account/mnemonic-account.mjs.map +1 -1
  27. package/amount.d.ts +15 -5
  28. package/amount.js +9 -2
  29. package/amount.js.map +1 -1
  30. package/amount.mjs +9 -3
  31. package/amount.mjs.map +1 -1
  32. package/app-client.d.ts +19 -5
  33. package/app-client.js +19 -4
  34. package/app-client.js.map +1 -1
  35. package/app-client.mjs +19 -4
  36. package/app-client.mjs.map +1 -1
  37. package/app-deploy.d.ts +18 -2
  38. package/app-deploy.js +159 -342
  39. package/app-deploy.js.map +1 -1
  40. package/app-deploy.mjs +163 -346
  41. package/app-deploy.mjs.map +1 -1
  42. package/app.d.ts +39 -3
  43. package/app.js +121 -371
  44. package/app.js.map +1 -1
  45. package/app.mjs +122 -372
  46. package/app.mjs.map +1 -1
  47. package/asset.d.ts +5 -6
  48. package/asset.js +5 -8
  49. package/asset.js.map +1 -1
  50. package/asset.mjs +5 -8
  51. package/asset.mjs.map +1 -1
  52. package/config.d.ts +0 -1
  53. package/config.js.map +1 -1
  54. package/config.mjs.map +1 -1
  55. package/debugging/debugging.d.ts +3 -5
  56. package/debugging/debugging.js +4 -128
  57. package/debugging/debugging.js.map +1 -1
  58. package/debugging/debugging.mjs +4 -109
  59. package/debugging/debugging.mjs.map +1 -1
  60. package/debugging/index.d.ts +0 -2
  61. package/dispenser-client.d.ts +0 -1
  62. package/dispenser-client.js.map +1 -1
  63. package/dispenser-client.mjs.map +1 -1
  64. package/index.d.ts +5 -4
  65. package/index.js +36 -26
  66. package/index.js.map +1 -1
  67. package/index.mjs +6 -5
  68. package/index.mjs.map +1 -1
  69. package/indexer-lookup.d.ts +10 -9
  70. package/indexer-lookup.js +14 -10
  71. package/indexer-lookup.js.map +1 -1
  72. package/indexer-lookup.mjs +14 -10
  73. package/indexer-lookup.mjs.map +1 -1
  74. package/localnet/get-kmd-wallet-account.d.ts +1 -2
  75. package/localnet/get-kmd-wallet-account.js +1 -1
  76. package/localnet/get-kmd-wallet-account.js.map +1 -1
  77. package/localnet/get-kmd-wallet-account.mjs +1 -1
  78. package/localnet/get-kmd-wallet-account.mjs.map +1 -1
  79. package/localnet/get-localnet-dispenser-account.d.ts +1 -2
  80. package/localnet/get-localnet-dispenser-account.js +1 -1
  81. package/localnet/get-localnet-dispenser-account.js.map +1 -1
  82. package/localnet/get-localnet-dispenser-account.mjs +1 -1
  83. package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
  84. package/localnet/get-or-create-kmd-wallet-account.d.ts +1 -2
  85. package/localnet/get-or-create-kmd-wallet-account.js +1 -1
  86. package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
  87. package/localnet/get-or-create-kmd-wallet-account.mjs +1 -1
  88. package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
  89. package/localnet/index.d.ts +0 -1
  90. package/localnet/is-localnet.d.ts +1 -2
  91. package/localnet/is-localnet.js +1 -1
  92. package/localnet/is-localnet.js.map +1 -1
  93. package/localnet/is-localnet.mjs +1 -1
  94. package/localnet/is-localnet.mjs.map +1 -1
  95. package/network-client.d.ts +3 -10
  96. package/network-client.js +4 -11
  97. package/network-client.js.map +1 -1
  98. package/network-client.mjs +4 -11
  99. package/network-client.mjs.map +1 -1
  100. package/package.json +3 -4
  101. package/testing/_asset.d.ts +2 -2
  102. package/testing/account.d.ts +4 -4
  103. package/testing/account.js +8 -2
  104. package/testing/account.js.map +1 -1
  105. package/testing/account.mjs +9 -3
  106. package/testing/account.mjs.map +1 -1
  107. package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -1
  108. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  109. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  110. package/testing/fixtures/algorand-fixture.d.ts +0 -1
  111. package/testing/fixtures/algorand-fixture.js +13 -14
  112. package/testing/fixtures/algorand-fixture.js.map +1 -1
  113. package/testing/fixtures/algorand-fixture.mjs +13 -14
  114. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  115. package/testing/fixtures/index.d.ts +0 -1
  116. package/testing/index.d.ts +0 -1
  117. package/testing/indexer.d.ts +0 -1
  118. package/testing/indexer.js.map +1 -1
  119. package/testing/indexer.mjs.map +1 -1
  120. package/testing/test-logger.d.ts +0 -1
  121. package/testing/test-logger.js +7 -3
  122. package/testing/test-logger.js.map +1 -1
  123. package/testing/test-logger.mjs +7 -3
  124. package/testing/test-logger.mjs.map +1 -1
  125. package/testing/transaction-logger.d.ts +0 -1
  126. package/testing/transaction-logger.js.map +1 -1
  127. package/testing/transaction-logger.mjs.map +1 -1
  128. package/transaction/index.d.ts +0 -1
  129. package/transaction/legacy-bridge.d.ts +31 -6
  130. package/transaction/legacy-bridge.js +101 -7
  131. package/transaction/legacy-bridge.js.map +1 -1
  132. package/transaction/legacy-bridge.mjs +101 -10
  133. package/transaction/legacy-bridge.mjs.map +1 -1
  134. package/transaction/perform-atomic-transaction-composer-simulate.d.ts +4 -2
  135. package/transaction/perform-atomic-transaction-composer-simulate.js +14 -9
  136. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  137. package/transaction/perform-atomic-transaction-composer-simulate.mjs +15 -10
  138. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  139. package/transaction/transaction.d.ts +38 -19
  140. package/transaction/transaction.js +217 -137
  141. package/transaction/transaction.js.map +1 -1
  142. package/transaction/transaction.mjs +218 -138
  143. package/transaction/transaction.mjs.map +1 -1
  144. package/transfer/index.d.ts +0 -1
  145. package/transfer/transfer-algos.d.ts +1 -2
  146. package/transfer/transfer-algos.js +1 -1
  147. package/transfer/transfer-algos.js.map +1 -1
  148. package/transfer/transfer-algos.mjs +1 -1
  149. package/transfer/transfer-algos.mjs.map +1 -1
  150. package/transfer/transfer.d.ts +1 -2
  151. package/transfer/transfer.js +6 -4
  152. package/transfer/transfer.js.map +1 -1
  153. package/transfer/transfer.mjs +6 -4
  154. package/transfer/transfer.mjs.map +1 -1
  155. package/types/account-manager.d.ts +33 -25
  156. package/types/account-manager.js +54 -31
  157. package/types/account-manager.js.map +1 -1
  158. package/types/account-manager.mjs +56 -33
  159. package/types/account-manager.mjs.map +1 -1
  160. package/types/account.d.ts +17 -9
  161. package/types/account.js +2 -2
  162. package/types/account.js.map +1 -1
  163. package/types/account.mjs +3 -3
  164. package/types/account.mjs.map +1 -1
  165. package/types/algo-http-client-with-retry.d.ts +1 -3
  166. package/types/algo-http-client-with-retry.js +33 -3
  167. package/types/algo-http-client-with-retry.js.map +1 -1
  168. package/types/algo-http-client-with-retry.mjs +32 -2
  169. package/types/algo-http-client-with-retry.mjs.map +1 -1
  170. package/types/algorand-client-interface.d.ts +28 -0
  171. package/types/algorand-client-interface.js +3 -0
  172. package/types/algorand-client-interface.js.map +1 -0
  173. package/types/algorand-client-interface.mjs +2 -0
  174. package/types/algorand-client-interface.mjs.map +1 -0
  175. package/types/algorand-client-transaction-creator.d.ts +452 -23
  176. package/types/algorand-client-transaction-creator.js +407 -23
  177. package/types/algorand-client-transaction-creator.js.map +1 -1
  178. package/types/algorand-client-transaction-creator.mjs +407 -23
  179. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  180. package/types/algorand-client-transaction-sender.d.ts +772 -47
  181. package/types/algorand-client-transaction-sender.js +445 -15
  182. package/types/algorand-client-transaction-sender.js.map +1 -1
  183. package/types/algorand-client-transaction-sender.mjs +445 -15
  184. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  185. package/types/algorand-client.d.ts +24 -17
  186. package/types/algorand-client.js +26 -16
  187. package/types/algorand-client.js.map +1 -1
  188. package/types/algorand-client.mjs +28 -15
  189. package/types/algorand-client.mjs.map +1 -1
  190. package/types/amount.d.ts +10 -11
  191. package/types/amount.js +7 -7
  192. package/types/amount.js.map +1 -1
  193. package/types/amount.mjs +7 -7
  194. package/types/amount.mjs.map +1 -1
  195. package/types/app-arc56.d.ts +359 -0
  196. package/types/app-arc56.js +184 -0
  197. package/types/app-arc56.js.map +1 -0
  198. package/types/app-arc56.mjs +175 -0
  199. package/types/app-arc56.mjs.map +1 -0
  200. package/types/app-client.d.ts +1508 -12
  201. package/types/app-client.js +1018 -29
  202. package/types/app-client.js.map +1 -1
  203. package/types/app-client.mjs +1020 -32
  204. package/types/app-client.mjs.map +1 -1
  205. package/types/app-deployer.d.ts +126 -0
  206. package/types/app-deployer.js +353 -0
  207. package/types/app-deployer.js.map +1 -0
  208. package/types/app-deployer.mjs +351 -0
  209. package/types/app-deployer.mjs.map +1 -0
  210. package/types/app-factory.d.ts +846 -0
  211. package/types/app-factory.js +410 -0
  212. package/types/app-factory.js.map +1 -0
  213. package/types/app-factory.mjs +408 -0
  214. package/types/app-factory.mjs.map +1 -0
  215. package/types/app-manager.d.ts +244 -0
  216. package/types/app-manager.js +423 -0
  217. package/types/app-manager.js.map +1 -0
  218. package/types/app-manager.mjs +421 -0
  219. package/types/app-manager.mjs.map +1 -0
  220. package/types/app-spec.d.ts +2 -1
  221. package/types/app-spec.js +127 -0
  222. package/types/app-spec.js.map +1 -1
  223. package/types/app-spec.mjs +126 -0
  224. package/types/app-spec.mjs.map +1 -1
  225. package/types/app.d.ts +57 -18
  226. package/types/app.js +1 -1
  227. package/types/app.js.map +1 -1
  228. package/types/app.mjs +1 -1
  229. package/types/app.mjs.map +1 -1
  230. package/types/asset-manager.d.ts +10 -10
  231. package/types/asset-manager.js +13 -17
  232. package/types/asset-manager.js.map +1 -1
  233. package/types/asset-manager.mjs +13 -17
  234. package/types/asset-manager.mjs.map +1 -1
  235. package/types/asset.d.ts +0 -1
  236. package/types/async-event-emitter.d.ts +14 -0
  237. package/types/async-event-emitter.js +50 -0
  238. package/types/async-event-emitter.js.map +1 -0
  239. package/types/async-event-emitter.mjs +48 -0
  240. package/types/async-event-emitter.mjs.map +1 -0
  241. package/types/client-manager.d.ts +135 -60
  242. package/types/client-manager.js +158 -44
  243. package/types/client-manager.js.map +1 -1
  244. package/types/client-manager.mjs +159 -45
  245. package/types/client-manager.mjs.map +1 -1
  246. package/types/composer.d.ts +271 -87
  247. package/types/composer.js +405 -125
  248. package/types/composer.js.map +1 -1
  249. package/types/composer.mjs +407 -125
  250. package/types/composer.mjs.map +1 -1
  251. package/types/config.d.ts +3 -6
  252. package/types/config.js +5 -44
  253. package/types/config.js.map +1 -1
  254. package/types/config.mjs +5 -27
  255. package/types/config.mjs.map +1 -1
  256. package/types/debugging.d.ts +29 -101
  257. package/types/debugging.js +16 -109
  258. package/types/debugging.js.map +1 -1
  259. package/types/debugging.mjs +12 -107
  260. package/types/debugging.mjs.map +1 -1
  261. package/types/dispenser-client.d.ts +2 -2
  262. package/types/dispenser-client.js +10 -5
  263. package/types/dispenser-client.js.map +1 -1
  264. package/types/dispenser-client.mjs +10 -5
  265. package/types/dispenser-client.mjs.map +1 -1
  266. package/types/expand.d.ts +7 -0
  267. package/types/expand.js +3 -0
  268. package/types/expand.js.map +1 -0
  269. package/types/expand.mjs +2 -0
  270. package/types/expand.mjs.map +1 -0
  271. package/types/indexer.d.ts +74 -756
  272. package/types/indexer.js.map +1 -1
  273. package/types/indexer.mjs.map +1 -1
  274. package/types/kmd-account-manager.d.ts +2 -3
  275. package/types/kmd-account-manager.js +3 -3
  276. package/types/kmd-account-manager.js.map +1 -1
  277. package/types/kmd-account-manager.mjs +4 -4
  278. package/types/kmd-account-manager.mjs.map +1 -1
  279. package/types/lifecycle-events.d.ts +10 -0
  280. package/types/lifecycle-events.js +8 -0
  281. package/types/lifecycle-events.js.map +1 -0
  282. package/types/lifecycle-events.mjs +8 -0
  283. package/types/lifecycle-events.mjs.map +1 -0
  284. package/types/logging.d.ts +0 -1
  285. package/types/logging.js.map +1 -1
  286. package/types/logging.mjs.map +1 -1
  287. package/types/logic-error.d.ts +2 -4
  288. package/types/logic-error.js +3 -3
  289. package/types/logic-error.js.map +1 -1
  290. package/types/logic-error.mjs +3 -3
  291. package/types/logic-error.mjs.map +1 -1
  292. package/types/network-client.d.ts +14 -2
  293. package/types/network-client.js.map +1 -1
  294. package/types/network-client.mjs.map +1 -1
  295. package/types/testing.d.ts +8 -10
  296. package/types/transaction.d.ts +17 -4
  297. package/types/transfer.d.ts +0 -1
  298. package/util.d.ts +2 -2
  299. package/util.js +11 -10
  300. package/util.js.map +1 -1
  301. package/util.mjs +11 -10
  302. package/util.mjs.map +1 -1
  303. package/account/account.d.ts.map +0 -1
  304. package/account/get-account-config-from-environment.d.ts.map +0 -1
  305. package/account/get-account.d.ts.map +0 -1
  306. package/account/get-dispenser-account.d.ts.map +0 -1
  307. package/account/index.d.ts.map +0 -1
  308. package/account/mnemonic-account.d.ts.map +0 -1
  309. package/amount.d.ts.map +0 -1
  310. package/app-client.d.ts.map +0 -1
  311. package/app-deploy.d.ts.map +0 -1
  312. package/app.d.ts.map +0 -1
  313. package/asset.d.ts.map +0 -1
  314. package/config.d.ts.map +0 -1
  315. package/debugging/debugging.d.ts.map +0 -1
  316. package/debugging/index.d.ts.map +0 -1
  317. package/debugging/simulate-and-persist-response.d.ts +0 -20
  318. package/debugging/simulate-and-persist-response.d.ts.map +0 -1
  319. package/debugging/simulate-and-persist-response.js +0 -108
  320. package/debugging/simulate-and-persist-response.js.map +0 -1
  321. package/debugging/simulate-and-persist-response.mjs +0 -89
  322. package/debugging/simulate-and-persist-response.mjs.map +0 -1
  323. package/dispenser-client.d.ts.map +0 -1
  324. package/index.d.ts.map +0 -1
  325. package/indexer-lookup.d.ts.map +0 -1
  326. package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
  327. package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
  328. package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
  329. package/localnet/index.d.ts.map +0 -1
  330. package/localnet/is-localnet.d.ts.map +0 -1
  331. package/network-client.d.ts.map +0 -1
  332. package/testing/_asset.d.ts.map +0 -1
  333. package/testing/account.d.ts.map +0 -1
  334. package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
  335. package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
  336. package/testing/fixtures/index.d.ts.map +0 -1
  337. package/testing/index.d.ts.map +0 -1
  338. package/testing/indexer.d.ts.map +0 -1
  339. package/testing/test-logger.d.ts.map +0 -1
  340. package/testing/transaction-logger.d.ts.map +0 -1
  341. package/transaction/index.d.ts.map +0 -1
  342. package/transaction/legacy-bridge.d.ts.map +0 -1
  343. package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
  344. package/transaction/transaction.d.ts.map +0 -1
  345. package/transfer/index.d.ts.map +0 -1
  346. package/transfer/transfer-algos.d.ts.map +0 -1
  347. package/transfer/transfer.d.ts.map +0 -1
  348. package/types/account-manager.d.ts.map +0 -1
  349. package/types/account.d.ts.map +0 -1
  350. package/types/algo-http-client-with-retry.d.ts.map +0 -1
  351. package/types/algorand-client-transaction-creator.d.ts.map +0 -1
  352. package/types/algorand-client-transaction-sender.d.ts.map +0 -1
  353. package/types/algorand-client.d.ts.map +0 -1
  354. package/types/amount.d.ts.map +0 -1
  355. package/types/app-client.d.ts.map +0 -1
  356. package/types/app-spec.d.ts.map +0 -1
  357. package/types/app.d.ts.map +0 -1
  358. package/types/asset-manager.d.ts.map +0 -1
  359. package/types/asset.d.ts.map +0 -1
  360. package/types/client-manager.d.ts.map +0 -1
  361. package/types/composer.d.ts.map +0 -1
  362. package/types/config.d.ts.map +0 -1
  363. package/types/debugging.d.ts.map +0 -1
  364. package/types/dispenser-client.d.ts.map +0 -1
  365. package/types/indexer.d.ts.map +0 -1
  366. package/types/kmd-account-manager.d.ts.map +0 -1
  367. package/types/logging.d.ts.map +0 -1
  368. package/types/logic-error.d.ts.map +0 -1
  369. package/types/network-client.d.ts.map +0 -1
  370. package/types/testing.d.ts.map +0 -1
  371. package/types/transaction.d.ts.map +0 -1
  372. package/types/transfer.d.ts.map +0 -1
  373. package/types/urlTokenBaseHTTPClient.d.ts +0 -41
  374. package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
  375. package/types/urlTokenBaseHTTPClient.js +0 -153
  376. package/types/urlTokenBaseHTTPClient.js.map +0 -1
  377. package/types/urlTokenBaseHTTPClient.mjs +0 -151
  378. package/types/urlTokenBaseHTTPClient.mjs.map +0 -1
  379. package/util.d.ts.map +0 -1
package/app.mjs CHANGED
@@ -1,197 +1,80 @@
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
- var modelsv2 = algosdk.modelsv2;
11
8
  var OnApplicationComplete = algosdk.OnApplicationComplete;
12
- var SourceMap = algosdk.SourceMap;
13
9
  /**
10
+ * @deprecated Use `algorand.send.appCreate()` / `algorand.createTransaction.appCreate()` / `algorand.send.appCreateMethodCall()`
11
+ * / `algorand.createTransaction.appCreateMethodCall()` instead
12
+ *
14
13
  * Creates a smart contract app, returns the details of the created app.
15
14
  * @param create The parameters to create the app with
16
15
  * @param algod An algod client
17
16
  * @returns The details of the created app, or the transaction to create it if `skipSending` and the compilation result
18
17
  */
19
18
  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
- }
19
+ const onComplete = getAppOnCompleteAction(create.onCompleteAction);
20
+ if (onComplete === algosdk.OnApplicationComplete.ClearStateOC) {
21
+ throw new Error('Cannot create an app with on-complete action of ClearState');
121
22
  }
23
+ const result = create.args?.method
24
+ ? await legacySendAppTransactionBridge(algod, create.from, create.args, create, {
25
+ sender: getSenderAddress(create.from),
26
+ onComplete,
27
+ approvalProgram: create.approvalProgram,
28
+ clearStateProgram: create.clearStateProgram,
29
+ method: create.args.method instanceof ABIMethod ? create.args.method : new ABIMethod(create.args.method),
30
+ extraProgramPages: create.schema.extraPages,
31
+ schema: create.schema,
32
+ }, (c) => c.appCreateMethodCall, (c) => c.appCreateMethodCall)
33
+ : await legacySendAppTransactionBridge(algod, create.from, create.args, create, {
34
+ sender: getSenderAddress(create.from),
35
+ onComplete,
36
+ approvalProgram: create.approvalProgram,
37
+ clearStateProgram: create.clearStateProgram,
38
+ extraProgramPages: create.schema.extraPages,
39
+ schema: create.schema,
40
+ }, (c) => c.appCreate, (c) => c.appCreate);
41
+ return {
42
+ ...result,
43
+ appId: 'appId' in result ? Number(result.appId) : 0,
44
+ appAddress: 'appAddress' in result ? result.appAddress.toString() : '',
45
+ };
122
46
  }
123
47
  /**
48
+ * @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
49
+ * / `algorand.createTransaction.appUpdateMethodCall()` instead
50
+ *
124
51
  * Updates a smart contract app.
125
52
  * @param update The parameters to update the app with
126
53
  * @param algod An algod client
127
54
  * @returns The transaction send result and the compilation result
128
55
  */
129
56
  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
- }
186
- }
187
- function attachATC(sendParams) {
188
- if (sendParams.atc) {
189
- sendParams.skipSending = true;
190
- }
191
- sendParams.atc = sendParams.atc ?? new AtomicTransactionComposer();
192
- return sendParams.atc;
57
+ return update.args?.method
58
+ ? await legacySendAppTransactionBridge(algod, update.from, update.args, update, {
59
+ appId: BigInt(update.appId),
60
+ sender: getSenderAddress(update.from),
61
+ onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
62
+ approvalProgram: update.approvalProgram,
63
+ clearStateProgram: update.clearStateProgram,
64
+ method: update.args.method instanceof ABIMethod ? update.args.method : new ABIMethod(update.args.method),
65
+ }, (c) => c.appUpdateMethodCall, (c) => c.appUpdateMethodCall)
66
+ : await legacySendAppTransactionBridge(algod, update.from, update.args, update, {
67
+ appId: BigInt(update.appId),
68
+ sender: getSenderAddress(update.from),
69
+ onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
70
+ approvalProgram: update.approvalProgram,
71
+ clearStateProgram: update.clearStateProgram,
72
+ }, (c) => c.appUpdate, (c) => c.appUpdate);
193
73
  }
194
- /** Returns an `algosdk.OnApplicationComplete` for the given onCompleteAction.
74
+ /**
75
+ * @deprecated Use `algosdk.OnApplicationComplete` directly instead.
76
+ *
77
+ * Returns a `algosdk.OnApplicationComplete` for the given onCompleteAction.
195
78
  *
196
79
  * If given `undefined` will return `OnApplicationComplete.NoOpOC`.
197
80
  *
@@ -224,77 +107,39 @@ function getAppOnCompleteAction(onCompletionAction) {
224
107
  }
225
108
  }
226
109
  /**
110
+ * @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
111
+ * / `algorand.createTransaction.appUpdateMethodCall()` instead
112
+ *
227
113
  * Issues a call to a given app.
228
114
  * @param call The call details.
229
115
  * @param algod An algod client
230
116
  * @returns The result of the call
231
117
  */
232
118
  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
- };
119
+ const onComplete = getAppOnCompleteAction(call.callType);
120
+ if (onComplete === algosdk.OnApplicationComplete.UpdateApplicationOC) {
121
+ throw new Error('Cannot execute an app call with on-complete action of Update');
260
122
  }
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}`);
123
+ if (call.args?.method && onComplete === algosdk.OnApplicationComplete.ClearStateOC) {
124
+ throw new Error('Cannot execute an ABI method call with on-complete action of ClearState');
288
125
  }
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
- };
126
+ return call.args?.method
127
+ ? await legacySendAppTransactionBridge(algod, call.from, call.args, call, {
128
+ appId: BigInt(call.appId),
129
+ sender: getSenderAddress(call.from),
130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
+ onComplete: onComplete,
132
+ method: call.args.method instanceof ABIMethod ? call.args.method : new ABIMethod(call.args.method),
133
+ }, (c) => c.appCallMethodCall, (c) => c.appCallMethodCall)
134
+ : await legacySendAppTransactionBridge(algod, call.from, call.args, call, {
135
+ appId: BigInt(call.appId),
136
+ sender: getSenderAddress(call.from),
137
+ onComplete,
138
+ }, (c) => c.appCall, (c) => c.appCall);
296
139
  }
297
140
  /**
141
+ * @deprecated Use `AppManager.getABIReturn` instead.
142
+ *
298
143
  * Returns any ABI return values for the given app call arguments and transaction confirmation.
299
144
  * @param args The arguments that were used for the call
300
145
  * @param confirmation The transaction confirmation from algod
@@ -305,43 +150,22 @@ function getABIReturn(args, confirmation) {
305
150
  return undefined;
306
151
  }
307
152
  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;
153
+ return AppManager.getABIReturn(confirmation, method);
330
154
  }
331
155
  /**
156
+ * @deprecated Use `algorand.app.getGlobalState` instead.
157
+ *
332
158
  * Returns the current global state values for the given app ID
333
159
  * @param appId The ID of the app return global state for
334
160
  * @param algod An algod client instance
335
161
  * @returns The current global state
336
162
  */
337
163
  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);
164
+ return await new AppManager(algod).getGlobalState(BigInt(appId));
343
165
  }
344
166
  /**
167
+ * @deprecated Use `algorand.app.getLocalState` instead.
168
+ *
345
169
  * Returns the current global state values for the given app ID and account
346
170
  * @param appId The ID of the app return global state for
347
171
  * @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 +173,20 @@ async function getAppGlobalState(appId, algod) {
349
173
  * @returns The current local state for the given (app, account) combination
350
174
  */
351
175
  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);
176
+ return new AppManager(algod).getLocalState(BigInt(appId), getSenderAddress(account));
358
177
  }
359
178
  /**
179
+ * @deprecated Use `algorand.app.getBoxNames` instead.
360
180
  * Returns the names of the boxes for the given app.
361
181
  * @param appId The ID of the app return box names for
362
182
  * @param algod An algod client instance
363
183
  * @returns The current box names
364
184
  */
365
185
  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
- });
186
+ return new AppManager(algod).getBoxNames(BigInt(appId));
374
187
  }
375
188
  /**
189
+ * @deprecated Use `algorand.app.getBoxValue` instead.
376
190
  * Returns the value of the given box name for the given app.
377
191
  * @param appId The ID of the app return box names for
378
192
  * @param boxName The name of the box to return either as a string, binary array or `BoxName`
@@ -380,11 +194,10 @@ async function getAppBoxNames(appId, algod) {
380
194
  * @returns The current box value as a byte array
381
195
  */
382
196
  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;
197
+ return new AppManager(algod).getBoxValue(BigInt(appId), typeof boxName !== 'string' && 'name' in boxName ? boxName.nameRaw : boxName);
386
198
  }
387
199
  /**
200
+ * @deprecated Use `algorand.app.getBoxValues` instead.
388
201
  * Returns the value of the given box names for the given app.
389
202
  * @param appId The ID of the app return box names for
390
203
  * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`
@@ -392,74 +205,50 @@ async function getAppBoxValue(appId, boxName, algod) {
392
205
  * @returns The current box values as a byte array in the same order as the passed in box names
393
206
  */
394
207
  async function getAppBoxValues(appId, boxNames, algod) {
395
- return await Promise.all(boxNames.map(async (boxName) => await getAppBoxValue(appId, boxName, algod)));
208
+ return new AppManager(algod).getBoxValues(BigInt(appId), boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)));
396
209
  }
397
210
  /**
211
+ * @deprecated Use `algorand.app.getBoxValueFromABIType` instead.
398
212
  * Returns the value of the given box name for the given app decoded based on the given ABI type.
399
213
  * @param request The parameters for the box value request
400
214
  * @param algod An algod client instance
401
215
  * @returns The current box value as an ABI value
402
216
  */
403
217
  async function getAppBoxValueFromABIType(request, algod) {
404
- const { appId, boxName, type } = request;
405
- const value = await getAppBoxValue(appId, boxName, algod);
406
- return type.decode(value);
218
+ return new AppManager(algod).getBoxValueFromABIType({
219
+ appId: BigInt(request.appId),
220
+ boxName: typeof request.boxName !== 'string' && 'name' in request.boxName ? request.boxName.nameRaw : request.boxName,
221
+ type: request.type,
222
+ });
407
223
  }
408
224
  /**
225
+ * @deprecated Use `algorand.app.getBoxValuesFromABIType` instead.
409
226
  * Returns the value of the given box names for the given app decoded based on the given ABI type.
410
227
  * @param request The parameters for the box value request
411
228
  * @param algod An algod client instance
412
229
  * @returns The current box values as an ABI value in the same order as the passed in box names
413
230
  */
414
231
  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)));
232
+ return new AppManager(algod).getBoxValuesFromABIType({
233
+ appId: BigInt(request.appId),
234
+ boxNames: request.boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)),
235
+ type: request.type,
236
+ });
417
237
  }
418
238
  /**
239
+ * @deprecated Use `AppManager.decodeAppState` instead.
240
+ *
419
241
  * Converts an array of global/local state values from the algod api to a more friendly
420
242
  * generic object keyed by the UTF-8 value of the key.
421
243
  * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`
422
244
  * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values
423
245
  */
424
246
  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;
247
+ return AppManager.decodeAppState(state.map(({ key, value }) => ({ key: Buffer.from(key, 'utf-8'), value })));
461
248
  }
462
249
  /**
250
+ * @deprecated Use `TransactionComposer` methods to construct transactions instead.
251
+ *
463
252
  * Returns the app args ready to load onto an app `Transaction` object
464
253
  * @param args The app call args
465
254
  * @returns The args ready to load into a `Transaction`
@@ -478,68 +267,32 @@ function getAppArgsForTransaction(args) {
478
267
  };
479
268
  }
480
269
  /**
270
+ * @deprecated Use `TransactionComposer` methods to construct transactions instead.
271
+ *
481
272
  * Returns the app args ready to load onto an ABI method call in `AtomicTransactionComposer`
482
273
  * @param args The ABI app call args
483
274
  * @param from The transaction signer
484
275
  * @returns The parameters ready to pass into `addMethodCall` within AtomicTransactionComposer
485
276
  */
486
277
  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
- };
278
+ return _getAppArgsForABICall(args, from);
518
279
  }
519
280
  /**
281
+ * @deprecated Use `AppManager.getBoxReference()` instead.
282
+ *
520
283
  * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.
521
284
  * @param box The box to return a reference for
522
285
  * @returns The box reference ready to pass into a `Transaction`
523
286
  */
524
287
  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
- };
288
+ return _getBoxReference(box);
538
289
  }
539
290
  function _getAccountAddress(account) {
540
291
  return typeof account === 'string' ? account : algosdk.encodeAddress(account.publicKey);
541
292
  }
542
293
  /**
294
+ * @deprecated Use `algorand.app.getById` instead.
295
+ *
543
296
  * Gets the current data for the given app from algod.
544
297
  *
545
298
  * @param appId The id of the app
@@ -547,9 +300,11 @@ function _getAccountAddress(account) {
547
300
  * @returns The data about the app
548
301
  */
549
302
  async function getAppById(appId, algod) {
550
- return modelsv2.Application.from_obj_for_encoding(await algod.getApplicationByID(toNumber(appId)).do());
303
+ return await algod.getApplicationByID(toNumber(appId)).do();
551
304
  }
552
305
  /**
306
+ * @deprecated Use `algorand.app.compileTeal` instead.
307
+ *
553
308
  * Compiles the given TEAL using algod and returns the result, including source map.
554
309
  *
555
310
  * @param algod An algod client
@@ -557,16 +312,11 @@ async function getAppById(appId, algod) {
557
312
  * @returns The information about the compiled file
558
313
  */
559
314
  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
- };
315
+ return await new AppManager(algod).compileTeal(tealCode);
568
316
  }
569
317
  /**
318
+ * @deprecated Use `abiMethod.getSignature()` or `new ABIMethod(abiMethodParams).getSignature()` instead.
319
+ *
570
320
  * Returns the encoded ABI spec for a given ABI Method
571
321
  * @param method The method to return a signature for
572
322
  * @returns The encoded ABI method spec e.g. `method_name(uint64,string)string`