@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
@@ -1,21 +1,27 @@
1
1
  'use strict';
2
2
 
3
+ var algosdk = require('algosdk');
4
+ var buffer = require('buffer');
3
5
  var config = require('../config.js');
6
+ var types_appManager = require('./app-manager.js');
4
7
 
8
+ const getMethodCallForLog = ({ method, args }) => {
9
+ return `${method.name}(${(args ?? []).map((a) => (a instanceof algosdk.Address ? a.toString() : typeof a === 'object' ? JSON.stringify(a, (_, v) => (typeof v === 'bigint' ? Number(v) : v instanceof algosdk.Address ? v.toString() : v instanceof Uint8Array ? buffer.Buffer.from(v).toString('base64') : v)) : a))})`;
10
+ };
5
11
  /** Orchestrates sending transactions for `AlgorandClient`. */
6
12
  class AlgorandClientTransactionSender {
7
13
  /**
8
14
  * Creates a new `AlgorandClientSender`
9
- * @param newGroup A lambda that starts a new `AlgoKitComposer` transaction group
15
+ * @param newGroup A lambda that starts a new `TransactionComposer` transaction group
10
16
  * @param assetManager An `AssetManager` instance
11
17
  */
12
- constructor(newGroup, assetManager) {
18
+ constructor(newGroup, assetManager, appManager) {
13
19
  /**
14
20
  * Send a payment transaction to transfer Algo between accounts.
15
21
  * @param params The parameters for the payment transaction
16
22
  * @example Basic example
17
23
  * ```typescript
18
- * const result = await algorandClient.send.payment({
24
+ * const result = await algorand.send.payment({
19
25
  * sender: 'SENDERADDRESS',
20
26
  * receiver: 'RECEIVERADDRESS',
21
27
  * amount: (4).algo(),
@@ -23,7 +29,7 @@ class AlgorandClientTransactionSender {
23
29
  * ```
24
30
  * @example Advanced example
25
31
  * ```typescript
26
- * const result = await algorandClient.send.payment({
32
+ * const result = await algorand.send.payment({
27
33
  * amount: (4).algo(),
28
34
  * receiver: 'RECEIVERADDRESS',
29
35
  * sender: 'SENDERADDRESS',
@@ -320,7 +326,7 @@ class AlgorandClientTransactionSender {
320
326
  *
321
327
  * @param params The parameters for the asset opt-out transaction
322
328
  *
323
- * @example Basic example (without creator)
329
+ * @example Basic example (without creator, will be retrieved from algod)
324
330
  * ```typescript
325
331
  * await algorand.send.assetOptOut({sender: "SENDERADDRESS", assetId: 123456n, ensureZeroBalance: true })
326
332
  * ```
@@ -362,7 +368,7 @@ class AlgorandClientTransactionSender {
362
368
  const accountAssetInfo = await this._assetManager.getAccountInformation(params.sender, params.assetId);
363
369
  balance = accountAssetInfo.balance;
364
370
  }
365
- catch (e) {
371
+ catch {
366
372
  throw new Error(`Account ${params.sender} is not opted-in to Asset ${params.assetId}; can't opt-out.`);
367
373
  }
368
374
  if (balance !== 0n) {
@@ -374,24 +380,424 @@ class AlgorandClientTransactionSender {
374
380
  preLog: (params, transaction) => `Opting ${params.sender} out of asset with ID ${params.assetId} to creator ${params.creator} via transaction ${transaction.txID()}`,
375
381
  })(params);
376
382
  };
383
+ /**
384
+ * Create a smart contract.
385
+ *
386
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
387
+ *
388
+ * @param params The parameters for the app creation transaction
389
+ * @example Basic example
390
+ * ```typescript
391
+ * const result = await algorand.send.appCreate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
392
+ * const createdAppId = result.appId
393
+ * ```
394
+ * @example Advanced example
395
+ * ```typescript
396
+ * await algorand.send.appCreate({
397
+ * sender: 'CREATORADDRESS',
398
+ * approvalProgram: "TEALCODE",
399
+ * clearStateProgram: "TEALCODE",
400
+ * schema: {
401
+ * globalInts: 1,
402
+ * globalByteSlices: 2,
403
+ * localInts: 3,
404
+ * localByteSlices: 4
405
+ * },
406
+ * extraProgramPages: 1,
407
+ * onComplete: algosdk.OnApplicationComplete.OptInOC,
408
+ * args: [new Uint8Array(1, 2, 3, 4)]
409
+ * accountReferences: ["ACCOUNT_1"]
410
+ * appReferences: [123n, 1234n]
411
+ * assetReferences: [12345n]
412
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
413
+ * lease: 'lease',
414
+ * note: 'note',
415
+ * // You wouldn't normally set this field
416
+ * firstValidRound: 1000n,
417
+ * validityWindow: 10,
418
+ * extraFee: (1000).microAlgo(),
419
+ * staticFee: (1000).microAlgo(),
420
+ * // Max fee doesn't make sense with extraFee AND staticFee
421
+ * // already specified, but here for completeness
422
+ * maxFee: (3000).microAlgo(),
423
+ * // Signer only needed if you want to provide one,
424
+ * // generally you'd register it with AlgorandClient
425
+ * // against the sender and not need to pass it in
426
+ * signer: transactionSigner,
427
+ * maxRoundsToWaitForConfirmation: 5,
428
+ * suppressLog: true,
429
+ *})
430
+ * ```
431
+ */
432
+ this.appCreate = this._sendAppCreateCall((c) => c.addAppCreate, {
433
+ postLog: (params, result) => `App created by ${params.sender} with ID ${result.confirmation.applicationIndex} via transaction ${result.txIds.at(-1)}`,
434
+ });
435
+ /**
436
+ * Update a smart contract.
437
+ *
438
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
439
+ *
440
+ * @param params The parameters for the app update transaction
441
+ * @example Basic example
442
+ * ```typescript
443
+ * await algorand.send.appUpdate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
444
+ * ```
445
+ * @example Advanced example
446
+ * ```typescript
447
+ * await algorand.send.appUpdate({
448
+ * sender: 'CREATORADDRESS',
449
+ * approvalProgram: "TEALCODE",
450
+ * clearStateProgram: "TEALCODE",
451
+ * onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
452
+ * args: [new Uint8Array(1, 2, 3, 4)]
453
+ * accountReferences: ["ACCOUNT_1"]
454
+ * appReferences: [123n, 1234n]
455
+ * assetReferences: [12345n]
456
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
457
+ * lease: 'lease',
458
+ * note: 'note',
459
+ * // You wouldn't normally set this field
460
+ * firstValidRound: 1000n,
461
+ * validityWindow: 10,
462
+ * extraFee: (1000).microAlgo(),
463
+ * staticFee: (1000).microAlgo(),
464
+ * // Max fee doesn't make sense with extraFee AND staticFee
465
+ * // already specified, but here for completeness
466
+ * maxFee: (3000).microAlgo(),
467
+ * // Signer only needed if you want to provide one,
468
+ * // generally you'd register it with AlgorandClient
469
+ * // against the sender and not need to pass it in
470
+ * signer: transactionSigner,
471
+ * maxRoundsToWaitForConfirmation: 5,
472
+ * suppressLog: true,
473
+ *})
474
+ * ```
475
+ */
476
+ this.appUpdate = this._sendAppUpdateCall((c) => c.addAppUpdate, {
477
+ postLog: (params, result) => `App ${params.appId} updated ${params.args ? ` with ${params.args.map((a) => buffer.Buffer.from(a).toString('base64'))}` : ''} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
478
+ });
479
+ /**
480
+ * Delete a smart contract.
481
+ *
482
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
483
+ *
484
+ * @param params The parameters for the app deletion transaction
485
+ * @example Basic example
486
+ * ```typescript
487
+ * await algorand.send.appDelete({ sender: 'CREATORADDRESS' })
488
+ * ```
489
+ * @example Advanced example
490
+ * ```typescript
491
+ * await algorand.send.appDelete({
492
+ * sender: 'CREATORADDRESS',
493
+ * onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
494
+ * args: [new Uint8Array(1, 2, 3, 4)]
495
+ * accountReferences: ["ACCOUNT_1"]
496
+ * appReferences: [123n, 1234n]
497
+ * assetReferences: [12345n]
498
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
499
+ * lease: 'lease',
500
+ * note: 'note',
501
+ * // You wouldn't normally set this field
502
+ * firstValidRound: 1000n,
503
+ * validityWindow: 10,
504
+ * extraFee: (1000).microAlgo(),
505
+ * staticFee: (1000).microAlgo(),
506
+ * // Max fee doesn't make sense with extraFee AND staticFee
507
+ * // already specified, but here for completeness
508
+ * maxFee: (3000).microAlgo(),
509
+ * // Signer only needed if you want to provide one,
510
+ * // generally you'd register it with AlgorandClient
511
+ * // against the sender and not need to pass it in
512
+ * signer: transactionSigner,
513
+ * maxRoundsToWaitForConfirmation: 5,
514
+ * suppressLog: true,
515
+ *})
516
+ * ```
517
+ */
518
+ this.appDelete = this._sendAppCall((c) => c.addAppDelete, {
519
+ postLog: (params, result) => `App ${params.appId} deleted ${params.args ? ` with ${params.args.map((a) => buffer.Buffer.from(a).toString('base64'))}` : ''} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
520
+ });
377
521
  /**
378
522
  * Call a smart contract.
379
523
  *
380
- * Note: you may prefer to use `algorandClient.client` to get an app client for more advanced functionality.
524
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
525
+ *
526
+ * @param params The parameters for the app call transaction
527
+ * @example Basic example
528
+ * ```typescript
529
+ * await algorand.send.appCall({ sender: 'CREATORADDRESS' })
530
+ * ```
531
+ * @example Advanced example
532
+ * ```typescript
533
+ * await algorand.send.appCall({
534
+ * sender: 'CREATORADDRESS',
535
+ * onComplete: algosdk.OnApplicationComplete.OptInOC,
536
+ * args: [new Uint8Array(1, 2, 3, 4)]
537
+ * accountReferences: ["ACCOUNT_1"]
538
+ * appReferences: [123n, 1234n]
539
+ * assetReferences: [12345n]
540
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
541
+ * lease: 'lease',
542
+ * note: 'note',
543
+ * // You wouldn't normally set this field
544
+ * firstValidRound: 1000n,
545
+ * validityWindow: 10,
546
+ * extraFee: (1000).microAlgo(),
547
+ * staticFee: (1000).microAlgo(),
548
+ * // Max fee doesn't make sense with extraFee AND staticFee
549
+ * // already specified, but here for completeness
550
+ * maxFee: (3000).microAlgo(),
551
+ * // Signer only needed if you want to provide one,
552
+ * // generally you'd register it with AlgorandClient
553
+ * // against the sender and not need to pass it in
554
+ * signer: transactionSigner,
555
+ * maxRoundsToWaitForConfirmation: 5,
556
+ * suppressLog: true,
557
+ *})
558
+ * ```
381
559
  */
382
- this.appCall = this._send((c) => c.addAppCall);
560
+ this.appCall = this._sendAppCall((c) => c.addAppCall, {
561
+ postLog: (params, result) => `App ${params.appId} called ${params.args ? ` with ${params.args.map((a) => buffer.Buffer.from(a).toString('base64'))}` : ''} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
562
+ });
383
563
  /**
384
- * Call a smart contract ABI method.
564
+ * Create a smart contract via an ABI method.
565
+ *
566
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
385
567
  *
386
- * Note: you may prefer to use `algorandClient.client` to get an app client for more advanced functionality.
568
+ * @param params The parameters for the app creation transaction
569
+ * @example Basic example
570
+ * ```typescript
571
+ * const method = new ABIMethod({
572
+ * name: 'method',
573
+ * args: [{ name: 'arg1', type: 'string' }],
574
+ * returns: { type: 'string' },
575
+ * })
576
+ * const result = await algorand.send.appCreateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
577
+ * const createdAppId = result.appId
578
+ * ```
579
+ * @example Advanced example
580
+ * ```typescript
581
+ * const method = new ABIMethod({
582
+ * name: 'method',
583
+ * args: [{ name: 'arg1', type: 'string' }],
584
+ * returns: { type: 'string' },
585
+ * })
586
+ * await algorand.send.appCreate({
587
+ * sender: 'CREATORADDRESS',
588
+ * method: method,
589
+ * args: ["arg1_value"],
590
+ * approvalProgram: "TEALCODE",
591
+ * clearStateProgram: "TEALCODE",
592
+ * schema: {
593
+ * globalInts: 1,
594
+ * globalByteSlices: 2,
595
+ * localInts: 3,
596
+ * localByteSlices: 4
597
+ * },
598
+ * extraProgramPages: 1,
599
+ * onComplete: algosdk.OnApplicationComplete.OptInOC,
600
+ * args: [new Uint8Array(1, 2, 3, 4)]
601
+ * accountReferences: ["ACCOUNT_1"]
602
+ * appReferences: [123n, 1234n]
603
+ * assetReferences: [12345n]
604
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
605
+ * lease: 'lease',
606
+ * note: 'note',
607
+ * // You wouldn't normally set this field
608
+ * firstValidRound: 1000n,
609
+ * validityWindow: 10,
610
+ * extraFee: (1000).microAlgo(),
611
+ * staticFee: (1000).microAlgo(),
612
+ * // Max fee doesn't make sense with extraFee AND staticFee
613
+ * // already specified, but here for completeness
614
+ * maxFee: (3000).microAlgo(),
615
+ * // Signer only needed if you want to provide one,
616
+ * // generally you'd register it with AlgorandClient
617
+ * // against the sender and not need to pass it in
618
+ * signer: transactionSigner,
619
+ * maxRoundsToWaitForConfirmation: 5,
620
+ * suppressLog: true,
621
+ *})
622
+ * ```
387
623
  */
388
- this.methodCall = this._send((c) => c.addMethodCall);
624
+ this.appCreateMethodCall = this._sendAppCreateCall((c) => c.addAppCreateMethodCall, {
625
+ postLog: (params, result) => `App created by ${params.sender} with ID ${result.confirmation.applicationIndex} via transaction ${result.txIds.at(-1)}`,
626
+ });
627
+ /**
628
+ * Update a smart contract via an ABI method.
629
+ *
630
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
631
+ *
632
+ * @param params The parameters for the app update transaction
633
+ * @example Basic example
634
+ * ```typescript
635
+ * const method = new ABIMethod({
636
+ * name: 'method',
637
+ * args: [{ name: 'arg1', type: 'string' }],
638
+ * returns: { type: 'string' },
639
+ * })
640
+ * await algorand.send.appUpdateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
641
+ * ```
642
+ * @example Advanced example
643
+ * ```typescript
644
+ * const method = new ABIMethod({
645
+ * name: 'method',
646
+ * args: [{ name: 'arg1', type: 'string' }],
647
+ * returns: { type: 'string' },
648
+ * })
649
+ * await algorand.send.appUpdateMethodCall({
650
+ * sender: 'CREATORADDRESS',
651
+ * method: method,
652
+ * args: ["arg1_value"],
653
+ * approvalProgram: "TEALCODE",
654
+ * clearStateProgram: "TEALCODE",
655
+ * onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
656
+ * args: [new Uint8Array(1, 2, 3, 4)]
657
+ * accountReferences: ["ACCOUNT_1"]
658
+ * appReferences: [123n, 1234n]
659
+ * assetReferences: [12345n]
660
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
661
+ * lease: 'lease',
662
+ * note: 'note',
663
+ * // You wouldn't normally set this field
664
+ * firstValidRound: 1000n,
665
+ * validityWindow: 10,
666
+ * extraFee: (1000).microAlgo(),
667
+ * staticFee: (1000).microAlgo(),
668
+ * // Max fee doesn't make sense with extraFee AND staticFee
669
+ * // already specified, but here for completeness
670
+ * maxFee: (3000).microAlgo(),
671
+ * // Signer only needed if you want to provide one,
672
+ * // generally you'd register it with AlgorandClient
673
+ * // against the sender and not need to pass it in
674
+ * signer: transactionSigner,
675
+ * maxRoundsToWaitForConfirmation: 5,
676
+ * suppressLog: true,
677
+ *})
678
+ * ```
679
+ */
680
+ this.appUpdateMethodCall = this._sendAppUpdateCall((c) => c.addAppUpdateMethodCall, {
681
+ postLog: (params, result) => `App ${params.appId} updated with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
682
+ });
683
+ /**
684
+ * Delete a smart contract via an ABI method.
685
+ *
686
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
687
+ *
688
+ * @param params The parameters for the app deletion transaction
689
+ * @example Basic example
690
+ * ```typescript
691
+ * const method = new ABIMethod({
692
+ * name: 'method',
693
+ * args: [{ name: 'arg1', type: 'string' }],
694
+ * returns: { type: 'string' },
695
+ * })
696
+ * await algorand.send.appDeleteMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
697
+ * ```
698
+ * @example Advanced example
699
+ * ```typescript
700
+ * const method = new ABIMethod({
701
+ * name: 'method',
702
+ * args: [{ name: 'arg1', type: 'string' }],
703
+ * returns: { type: 'string' },
704
+ * })
705
+ * await algorand.send.appDeleteMethodCall({
706
+ * sender: 'CREATORADDRESS',
707
+ * method: method,
708
+ * args: ["arg1_value"],
709
+ * onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
710
+ * args: [new Uint8Array(1, 2, 3, 4)]
711
+ * accountReferences: ["ACCOUNT_1"]
712
+ * appReferences: [123n, 1234n]
713
+ * assetReferences: [12345n]
714
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
715
+ * lease: 'lease',
716
+ * note: 'note',
717
+ * // You wouldn't normally set this field
718
+ * firstValidRound: 1000n,
719
+ * validityWindow: 10,
720
+ * extraFee: (1000).microAlgo(),
721
+ * staticFee: (1000).microAlgo(),
722
+ * // Max fee doesn't make sense with extraFee AND staticFee
723
+ * // already specified, but here for completeness
724
+ * maxFee: (3000).microAlgo(),
725
+ * // Signer only needed if you want to provide one,
726
+ * // generally you'd register it with AlgorandClient
727
+ * // against the sender and not need to pass it in
728
+ * signer: transactionSigner,
729
+ * maxRoundsToWaitForConfirmation: 5,
730
+ * suppressLog: true,
731
+ *})
732
+ * ```
733
+ */
734
+ this.appDeleteMethodCall = this._sendAppCall((c) => c.addAppDeleteMethodCall, {
735
+ postLog: (params, result) => `App ${params.appId} deleted with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
736
+ });
737
+ /**
738
+ * Call a smart contract via an ABI method.
739
+ *
740
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
741
+ *
742
+ * @param params The parameters for the app call transaction
743
+ * @example Basic example
744
+ * ```typescript
745
+ * const method = new ABIMethod({
746
+ * name: 'method',
747
+ * args: [{ name: 'arg1', type: 'string' }],
748
+ * returns: { type: 'string' },
749
+ * })
750
+ * await algorand.send.appCallMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
751
+ * ```
752
+ * @example Advanced example
753
+ * ```typescript
754
+ * const method = new ABIMethod({
755
+ * name: 'method',
756
+ * args: [{ name: 'arg1', type: 'string' }],
757
+ * returns: { type: 'string' },
758
+ * })
759
+ * await algorand.send.appCallMethodCall({
760
+ * sender: 'CREATORADDRESS',
761
+ * method: method,
762
+ * args: ["arg1_value"],
763
+ * onComplete: algosdk.OnApplicationComplete.OptInOC,
764
+ * args: [new Uint8Array(1, 2, 3, 4)]
765
+ * accountReferences: ["ACCOUNT_1"]
766
+ * appReferences: [123n, 1234n]
767
+ * assetReferences: [12345n]
768
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
769
+ * lease: 'lease',
770
+ * note: 'note',
771
+ * // You wouldn't normally set this field
772
+ * firstValidRound: 1000n,
773
+ * validityWindow: 10,
774
+ * extraFee: (1000).microAlgo(),
775
+ * staticFee: (1000).microAlgo(),
776
+ * // Max fee doesn't make sense with extraFee AND staticFee
777
+ * // already specified, but here for completeness
778
+ * maxFee: (3000).microAlgo(),
779
+ * // Signer only needed if you want to provide one,
780
+ * // generally you'd register it with AlgorandClient
781
+ * // against the sender and not need to pass it in
782
+ * signer: transactionSigner,
783
+ * maxRoundsToWaitForConfirmation: 5,
784
+ * suppressLog: true,
785
+ *})
786
+ * ```
787
+ */
788
+ this.appCallMethodCall = this._sendAppCall((c) => c.addAppCallMethodCall, {
789
+ postLog: (params, result) => `App ${params.appId} called with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
790
+ });
389
791
  /** Register an online key. */
390
792
  this.onlineKeyRegistration = this._send((c) => c.addOnlineKeyRegistration, {
391
793
  preLog: (params, transaction) => `Registering online key for ${params.sender} via transaction ${transaction.txID()}`,
392
794
  });
393
795
  this._newGroup = newGroup;
394
796
  this._assetManager = assetManager;
797
+ this._appManager = appManager;
798
+ }
799
+ newGroup() {
800
+ return this._newGroup();
395
801
  }
396
802
  _send(c, log) {
397
803
  return async (params) => {
@@ -402,12 +808,12 @@ class AlgorandClientTransactionSender {
402
808
  const transaction = (await composer.build()).transactions.at(-1).txn;
403
809
  config.Config.getLogger(params?.suppressLog).debug(log.preLog(params, transaction));
404
810
  }
405
- const rawResult = await composer.execute(params);
811
+ const rawResult = await composer.send(params);
406
812
  const result = {
407
813
  // Last item covers when a group is created by an app call with ABI transaction parameters
408
- transaction: rawResult.transactions[rawResult.transactions.length - 1],
409
- confirmation: rawResult.confirmations[rawResult.confirmations.length - 1],
410
- txId: rawResult.txIds[0],
814
+ transaction: rawResult.transactions.at(-1),
815
+ confirmation: rawResult.confirmations.at(-1),
816
+ txId: rawResult.txIds.at(-1),
411
817
  ...rawResult,
412
818
  };
413
819
  if (log?.postLog) {
@@ -416,6 +822,30 @@ class AlgorandClientTransactionSender {
416
822
  return result;
417
823
  };
418
824
  }
825
+ _sendAppCall(c, log) {
826
+ return async (params) => {
827
+ const result = await this._send(c, log)(params);
828
+ return { ...result, return: types_appManager.AppManager.getABIReturn(result.confirmation, 'method' in params ? params.method : undefined) };
829
+ };
830
+ }
831
+ _sendAppUpdateCall(c, log) {
832
+ return async (params) => {
833
+ const result = await this._sendAppCall(c, log)(params);
834
+ const compiledApproval = typeof params.approvalProgram === 'string' ? this._appManager.getCompilationResult(params.approvalProgram) : undefined;
835
+ const compiledClear = typeof params.clearStateProgram === 'string' ? this._appManager.getCompilationResult(params.clearStateProgram) : undefined;
836
+ return { ...result, compiledApproval, compiledClear };
837
+ };
838
+ }
839
+ _sendAppCreateCall(c, log) {
840
+ return async (params) => {
841
+ const result = await this._sendAppUpdateCall(c, log)(params);
842
+ return {
843
+ ...result,
844
+ appId: BigInt(result.confirmation.applicationIndex),
845
+ appAddress: algosdk.getApplicationAddress(result.confirmation.applicationIndex),
846
+ };
847
+ };
848
+ }
419
849
  }
420
850
 
421
851
  exports.AlgorandClientTransactionSender = AlgorandClientTransactionSender;