@algorandfoundation/algokit-utils 7.0.0-beta.5 → 7.0.0-beta.7

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 (324) hide show
  1. package/README.md +2 -24
  2. package/account/account.d.ts +1 -2
  3. package/account/account.js.map +1 -1
  4. package/account/account.mjs.map +1 -1
  5. package/account/get-account-config-from-environment.d.ts +0 -1
  6. package/account/get-account-config-from-environment.js.map +1 -1
  7. package/account/get-account-config-from-environment.mjs.map +1 -1
  8. package/account/get-account.d.ts +0 -1
  9. package/account/get-account.js.map +1 -1
  10. package/account/get-account.mjs.map +1 -1
  11. package/account/get-dispenser-account.d.ts +0 -1
  12. package/account/get-dispenser-account.js.map +1 -1
  13. package/account/get-dispenser-account.mjs.map +1 -1
  14. package/account/index.d.ts +0 -1
  15. package/account/mnemonic-account.d.ts +0 -1
  16. package/account/mnemonic-account.js.map +1 -1
  17. package/account/mnemonic-account.mjs.map +1 -1
  18. package/amount.d.ts +0 -1
  19. package/amount.js.map +1 -1
  20. package/amount.mjs.map +1 -1
  21. package/app-client.d.ts +0 -1
  22. package/app-client.js.map +1 -1
  23. package/app-client.mjs.map +1 -1
  24. package/app-deploy.d.ts +0 -1
  25. package/app-deploy.js.map +1 -1
  26. package/app-deploy.mjs.map +1 -1
  27. package/app.d.ts +6 -7
  28. package/app.js +6 -6
  29. package/app.js.map +1 -1
  30. package/app.mjs +6 -6
  31. package/app.mjs.map +1 -1
  32. package/asset.d.ts +3 -4
  33. package/asset.js +3 -3
  34. package/asset.js.map +1 -1
  35. package/asset.mjs +3 -3
  36. package/asset.mjs.map +1 -1
  37. package/config.d.ts +0 -1
  38. package/config.js.map +1 -1
  39. package/config.mjs.map +1 -1
  40. package/debugging/debugging.d.ts +3 -5
  41. package/debugging/debugging.js +4 -127
  42. package/debugging/debugging.js.map +1 -1
  43. package/debugging/debugging.mjs +4 -108
  44. package/debugging/debugging.mjs.map +1 -1
  45. package/debugging/index.d.ts +0 -2
  46. package/dispenser-client.d.ts +0 -1
  47. package/dispenser-client.js.map +1 -1
  48. package/dispenser-client.mjs.map +1 -1
  49. package/index.d.ts +1 -1
  50. package/index.js +6 -2
  51. package/index.js.map +1 -1
  52. package/index.mjs +1 -1
  53. package/indexer-lookup.d.ts +0 -1
  54. package/indexer-lookup.js.map +1 -1
  55. package/indexer-lookup.mjs.map +1 -1
  56. package/localnet/get-kmd-wallet-account.d.ts +0 -1
  57. package/localnet/get-kmd-wallet-account.js.map +1 -1
  58. package/localnet/get-kmd-wallet-account.mjs.map +1 -1
  59. package/localnet/get-localnet-dispenser-account.d.ts +0 -1
  60. package/localnet/get-localnet-dispenser-account.js.map +1 -1
  61. package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
  62. package/localnet/get-or-create-kmd-wallet-account.d.ts +0 -1
  63. package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
  64. package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
  65. package/localnet/index.d.ts +0 -1
  66. package/localnet/is-localnet.d.ts +0 -1
  67. package/localnet/is-localnet.js.map +1 -1
  68. package/localnet/is-localnet.mjs.map +1 -1
  69. package/network-client.d.ts +0 -1
  70. package/network-client.js.map +1 -1
  71. package/network-client.mjs.map +1 -1
  72. package/package.json +1 -1
  73. package/testing/_asset.d.ts +0 -1
  74. package/testing/account.d.ts +0 -1
  75. package/testing/account.js.map +1 -1
  76. package/testing/account.mjs.map +1 -1
  77. package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -1
  78. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  79. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  80. package/testing/fixtures/algorand-fixture.d.ts +0 -1
  81. package/testing/fixtures/algorand-fixture.js +1 -1
  82. package/testing/fixtures/algorand-fixture.js.map +1 -1
  83. package/testing/fixtures/algorand-fixture.mjs +1 -1
  84. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  85. package/testing/fixtures/index.d.ts +0 -1
  86. package/testing/index.d.ts +0 -1
  87. package/testing/indexer.d.ts +0 -1
  88. package/testing/indexer.js.map +1 -1
  89. package/testing/indexer.mjs.map +1 -1
  90. package/testing/test-logger.d.ts +0 -1
  91. package/testing/test-logger.js.map +1 -1
  92. package/testing/test-logger.mjs.map +1 -1
  93. package/testing/transaction-logger.d.ts +0 -1
  94. package/testing/transaction-logger.js.map +1 -1
  95. package/testing/transaction-logger.mjs.map +1 -1
  96. package/transaction/index.d.ts +0 -1
  97. package/transaction/legacy-bridge.d.ts +3 -4
  98. package/transaction/legacy-bridge.js.map +1 -1
  99. package/transaction/legacy-bridge.mjs.map +1 -1
  100. package/transaction/perform-atomic-transaction-composer-simulate.d.ts +0 -1
  101. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  102. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  103. package/transaction/transaction.d.ts +1 -4
  104. package/transaction/transaction.js +26 -31
  105. package/transaction/transaction.js.map +1 -1
  106. package/transaction/transaction.mjs +26 -31
  107. package/transaction/transaction.mjs.map +1 -1
  108. package/transfer/index.d.ts +0 -1
  109. package/transfer/transfer-algos.d.ts +1 -2
  110. package/transfer/transfer-algos.js +1 -1
  111. package/transfer/transfer-algos.js.map +1 -1
  112. package/transfer/transfer-algos.mjs +1 -1
  113. package/transfer/transfer-algos.mjs.map +1 -1
  114. package/transfer/transfer.d.ts +1 -2
  115. package/transfer/transfer.js +1 -1
  116. package/transfer/transfer.js.map +1 -1
  117. package/transfer/transfer.mjs +1 -1
  118. package/transfer/transfer.mjs.map +1 -1
  119. package/types/account-manager.d.ts +13 -5
  120. package/types/account-manager.js +17 -3
  121. package/types/account-manager.js.map +1 -1
  122. package/types/account-manager.mjs +17 -3
  123. package/types/account-manager.mjs.map +1 -1
  124. package/types/account.d.ts +0 -1
  125. package/types/account.js.map +1 -1
  126. package/types/account.mjs.map +1 -1
  127. package/types/algo-http-client-with-retry.d.ts +0 -1
  128. package/types/algo-http-client-with-retry.js.map +1 -1
  129. package/types/algo-http-client-with-retry.mjs.map +1 -1
  130. package/types/algorand-client-interface.d.ts +1 -2
  131. package/types/algorand-client-transaction-creator.d.ts +30 -31
  132. package/types/algorand-client-transaction-creator.js +30 -30
  133. package/types/algorand-client-transaction-creator.js.map +1 -1
  134. package/types/algorand-client-transaction-creator.mjs +30 -30
  135. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  136. package/types/algorand-client-transaction-sender.d.ts +19 -20
  137. package/types/algorand-client-transaction-sender.js +2 -2
  138. package/types/algorand-client-transaction-sender.js.map +1 -1
  139. package/types/algorand-client-transaction-sender.mjs +2 -2
  140. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  141. package/types/algorand-client.d.ts +8 -9
  142. package/types/algorand-client.js +8 -8
  143. package/types/algorand-client.js.map +1 -1
  144. package/types/algorand-client.mjs +8 -8
  145. package/types/algorand-client.mjs.map +1 -1
  146. package/types/amount.d.ts +0 -1
  147. package/types/amount.js.map +1 -1
  148. package/types/amount.mjs.map +1 -1
  149. package/types/app-arc56.d.ts +60 -38
  150. package/types/app-arc56.js +37 -16
  151. package/types/app-arc56.js.map +1 -1
  152. package/types/app-arc56.mjs +37 -16
  153. package/types/app-arc56.mjs.map +1 -1
  154. package/types/app-client.d.ts +100 -75
  155. package/types/app-client.js +154 -101
  156. package/types/app-client.js.map +1 -1
  157. package/types/app-client.mjs +154 -101
  158. package/types/app-client.mjs.map +1 -1
  159. package/types/app-deployer.d.ts +2 -3
  160. package/types/app-deployer.js +24 -24
  161. package/types/app-deployer.js.map +1 -1
  162. package/types/app-deployer.mjs +24 -24
  163. package/types/app-deployer.mjs.map +1 -1
  164. package/types/app-factory.d.ts +141 -87
  165. package/types/app-factory.js +106 -34
  166. package/types/app-factory.js.map +1 -1
  167. package/types/app-factory.mjs +107 -35
  168. package/types/app-factory.mjs.map +1 -1
  169. package/types/app-manager.d.ts +0 -1
  170. package/types/app-manager.js.map +1 -1
  171. package/types/app-manager.mjs.map +1 -1
  172. package/types/app-spec.d.ts +0 -1
  173. package/types/app-spec.js +15 -9
  174. package/types/app-spec.js.map +1 -1
  175. package/types/app-spec.mjs +15 -9
  176. package/types/app-spec.mjs.map +1 -1
  177. package/types/app.d.ts +0 -1
  178. package/types/app.js.map +1 -1
  179. package/types/app.mjs.map +1 -1
  180. package/types/asset-manager.d.ts +3 -4
  181. package/types/asset-manager.js +3 -3
  182. package/types/asset-manager.js.map +1 -1
  183. package/types/asset-manager.mjs +3 -3
  184. package/types/asset-manager.mjs.map +1 -1
  185. package/types/asset.d.ts +0 -1
  186. package/types/async-event-emitter.d.ts +23 -0
  187. package/types/async-event-emitter.js +55 -0
  188. package/types/async-event-emitter.js.map +1 -0
  189. package/types/async-event-emitter.mjs +53 -0
  190. package/types/async-event-emitter.mjs.map +1 -0
  191. package/types/client-manager.d.ts +30 -9
  192. package/types/client-manager.js +6 -0
  193. package/types/client-manager.js.map +1 -1
  194. package/types/client-manager.mjs +6 -0
  195. package/types/client-manager.mjs.map +1 -1
  196. package/types/composer.d.ts +57 -5
  197. package/types/composer.js +30 -14
  198. package/types/composer.js.map +1 -1
  199. package/types/composer.mjs +30 -14
  200. package/types/composer.mjs.map +1 -1
  201. package/types/config.d.ts +3 -6
  202. package/types/config.js +5 -44
  203. package/types/config.js.map +1 -1
  204. package/types/config.mjs +5 -27
  205. package/types/config.mjs.map +1 -1
  206. package/types/debugging.d.ts +29 -102
  207. package/types/debugging.js +16 -109
  208. package/types/debugging.js.map +1 -1
  209. package/types/debugging.mjs +12 -107
  210. package/types/debugging.mjs.map +1 -1
  211. package/types/dispenser-client.d.ts +0 -1
  212. package/types/dispenser-client.js +5 -4
  213. package/types/dispenser-client.js.map +1 -1
  214. package/types/dispenser-client.mjs +5 -4
  215. package/types/dispenser-client.mjs.map +1 -1
  216. package/types/expand.d.ts +0 -1
  217. package/types/indexer.d.ts +0 -1
  218. package/types/indexer.js.map +1 -1
  219. package/types/indexer.mjs.map +1 -1
  220. package/types/kmd-account-manager.d.ts +0 -1
  221. package/types/kmd-account-manager.js +2 -2
  222. package/types/kmd-account-manager.js.map +1 -1
  223. package/types/kmd-account-manager.mjs +2 -2
  224. package/types/kmd-account-manager.mjs.map +1 -1
  225. package/types/logging.d.ts +0 -1
  226. package/types/logging.js.map +1 -1
  227. package/types/logging.mjs.map +1 -1
  228. package/types/logic-error.d.ts +0 -1
  229. package/types/logic-error.js.map +1 -1
  230. package/types/logic-error.mjs.map +1 -1
  231. package/types/network-client.d.ts +0 -1
  232. package/types/network-client.js.map +1 -1
  233. package/types/network-client.mjs.map +1 -1
  234. package/types/testing.d.ts +0 -1
  235. package/types/transaction.d.ts +4 -7
  236. package/types/transfer.d.ts +0 -1
  237. package/types/urlTokenBaseHTTPClient.d.ts +0 -1
  238. package/types/urlTokenBaseHTTPClient.js +1 -1
  239. package/types/urlTokenBaseHTTPClient.js.map +1 -1
  240. package/types/urlTokenBaseHTTPClient.mjs +1 -1
  241. package/types/urlTokenBaseHTTPClient.mjs.map +1 -1
  242. package/util.d.ts +0 -1
  243. package/util.js +0 -9
  244. package/util.js.map +1 -1
  245. package/util.mjs +1 -9
  246. package/util.mjs.map +1 -1
  247. package/account/account.d.ts.map +0 -1
  248. package/account/get-account-config-from-environment.d.ts.map +0 -1
  249. package/account/get-account.d.ts.map +0 -1
  250. package/account/get-dispenser-account.d.ts.map +0 -1
  251. package/account/index.d.ts.map +0 -1
  252. package/account/mnemonic-account.d.ts.map +0 -1
  253. package/amount.d.ts.map +0 -1
  254. package/app-client.d.ts.map +0 -1
  255. package/app-deploy.d.ts.map +0 -1
  256. package/app.d.ts.map +0 -1
  257. package/asset.d.ts.map +0 -1
  258. package/config.d.ts.map +0 -1
  259. package/debugging/debugging.d.ts.map +0 -1
  260. package/debugging/index.d.ts.map +0 -1
  261. package/debugging/simulate-and-persist-response.d.ts +0 -20
  262. package/debugging/simulate-and-persist-response.d.ts.map +0 -1
  263. package/debugging/simulate-and-persist-response.js +0 -108
  264. package/debugging/simulate-and-persist-response.js.map +0 -1
  265. package/debugging/simulate-and-persist-response.mjs +0 -89
  266. package/debugging/simulate-and-persist-response.mjs.map +0 -1
  267. package/dispenser-client.d.ts.map +0 -1
  268. package/index.d.ts.map +0 -1
  269. package/indexer-lookup.d.ts.map +0 -1
  270. package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
  271. package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
  272. package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
  273. package/localnet/index.d.ts.map +0 -1
  274. package/localnet/is-localnet.d.ts.map +0 -1
  275. package/network-client.d.ts.map +0 -1
  276. package/testing/_asset.d.ts.map +0 -1
  277. package/testing/account.d.ts.map +0 -1
  278. package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
  279. package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
  280. package/testing/fixtures/index.d.ts.map +0 -1
  281. package/testing/index.d.ts.map +0 -1
  282. package/testing/indexer.d.ts.map +0 -1
  283. package/testing/test-logger.d.ts.map +0 -1
  284. package/testing/transaction-logger.d.ts.map +0 -1
  285. package/transaction/index.d.ts.map +0 -1
  286. package/transaction/legacy-bridge.d.ts.map +0 -1
  287. package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
  288. package/transaction/transaction.d.ts.map +0 -1
  289. package/transfer/index.d.ts.map +0 -1
  290. package/transfer/transfer-algos.d.ts.map +0 -1
  291. package/transfer/transfer.d.ts.map +0 -1
  292. package/types/account-manager.d.ts.map +0 -1
  293. package/types/account.d.ts.map +0 -1
  294. package/types/algo-http-client-with-retry.d.ts.map +0 -1
  295. package/types/algorand-client-interface.d.ts.map +0 -1
  296. package/types/algorand-client-transaction-creator.d.ts.map +0 -1
  297. package/types/algorand-client-transaction-sender.d.ts.map +0 -1
  298. package/types/algorand-client.d.ts.map +0 -1
  299. package/types/amount.d.ts.map +0 -1
  300. package/types/app-arc56.d.ts.map +0 -1
  301. package/types/app-client.d.ts.map +0 -1
  302. package/types/app-deployer.d.ts.map +0 -1
  303. package/types/app-factory.d.ts.map +0 -1
  304. package/types/app-manager.d.ts.map +0 -1
  305. package/types/app-spec.d.ts.map +0 -1
  306. package/types/app.d.ts.map +0 -1
  307. package/types/asset-manager.d.ts.map +0 -1
  308. package/types/asset.d.ts.map +0 -1
  309. package/types/client-manager.d.ts.map +0 -1
  310. package/types/composer.d.ts.map +0 -1
  311. package/types/config.d.ts.map +0 -1
  312. package/types/debugging.d.ts.map +0 -1
  313. package/types/dispenser-client.d.ts.map +0 -1
  314. package/types/expand.d.ts.map +0 -1
  315. package/types/indexer.d.ts.map +0 -1
  316. package/types/kmd-account-manager.d.ts.map +0 -1
  317. package/types/logging.d.ts.map +0 -1
  318. package/types/logic-error.d.ts.map +0 -1
  319. package/types/network-client.d.ts.map +0 -1
  320. package/types/testing.d.ts.map +0 -1
  321. package/types/transaction.d.ts.map +0 -1
  322. package/types/transfer.d.ts.map +0 -1
  323. package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
  324. package/util.d.ts.map +0 -1
@@ -5,15 +5,13 @@ var buffer = require('buffer');
5
5
  var app = require('../app.js');
6
6
  var appDeploy = require('../app-deploy.js');
7
7
  var config = require('../config.js');
8
- var debugging = require('../debugging/debugging.js');
9
8
  var legacyBridge = require('../transaction/legacy-bridge.js');
10
9
  var transaction = require('../transaction/transaction.js');
11
10
  var util = require('../util.js');
12
11
  var types_app = require('./app.js');
13
12
  var types_appArc56 = require('./app-arc56.js');
14
- var types_appManager = require('./app-manager.js');
15
13
  var types_appSpec = require('./app-spec.js');
16
- var types_debugging = require('./debugging.js');
14
+ var types_asyncEventEmitter = require('./async-event-emitter.js');
17
15
  var types_logicError = require('./logic-error.js');
18
16
 
19
17
  var ABIMethod = algosdk.ABIMethod;
@@ -61,10 +59,19 @@ class AppClient {
61
59
  this._boxStateMethods = this.getBoxMethods();
62
60
  this._paramsMethods = {
63
61
  ...this.getMethodCallParamsMethods(),
62
+ /** Get parameters to define bare (raw) transactions to the current app */
64
63
  bare: this.getBareParamsMethods(),
65
64
  };
66
- this._transactionsMethods = { ...this.getMethodCallTransactionsMethods(), bare: this.getBareTransactionsMethods() };
67
- this._sendMethods = { ...this.getMethodCallSendMethods(), bare: this.getBareSendMethods() };
65
+ this._createTransactionsMethods = {
66
+ ...this.getMethodCallCreateTransactionMethods(),
67
+ /** Get transactions for bare (raw) calls to the current app */
68
+ bare: this.getBareCreateTransactionMethods(),
69
+ };
70
+ this._sendMethods = {
71
+ ...this.getMethodCallSendMethods(),
72
+ /** Send bare (raw) transactions to the current app */
73
+ bare: this.getBareSendMethods(),
74
+ };
68
75
  }
69
76
  /** Start a new `AlgoKitComposer` transaction group */
70
77
  newGroup() {
@@ -140,18 +147,33 @@ class AppClient {
140
147
  get appSpec() {
141
148
  return this._appSpec;
142
149
  }
143
- /** Get parameters to define transactions to the current app */
150
+ /** Get parameters to create transactions for the current app.
151
+ *
152
+ * A good mental model for this is that these parameters represent a deferred transaction creation.
153
+ * @example Create a transaction in the future using Algorand Client
154
+ * ```typescript
155
+ * const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
156
+ * // ...
157
+ * await algorand.send.AppMethodCall(myMethodCall)
158
+ * ```
159
+ * @example Define a nested transaction as an ABI argument
160
+ * ```typescript
161
+ * const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
162
+ * await appClient.send.call({method: 'my_method2', args: [myMethodCall]})
163
+ * ```
164
+ */
144
165
  get params() {
145
166
  return this._paramsMethods;
146
167
  }
147
- /** Get transactions for the current app */
148
- get transactions() {
149
- return this._transactionsMethods;
168
+ /** Create transactions for the current app */
169
+ get createTransaction() {
170
+ return this._createTransactionsMethods;
150
171
  }
151
- /** Send calls to the current app */
172
+ /** Send transactions to the current app */
152
173
  get send() {
153
174
  return this._sendMethods;
154
175
  }
176
+ /** Get state (local, global, box) from the current app */
155
177
  get state() {
156
178
  return {
157
179
  /**
@@ -171,6 +193,8 @@ class AppClient {
171
193
  }
172
194
  /**
173
195
  * Funds Algo into the app account for this app.
196
+ *
197
+ * An alias for `appClient.send.fundAppAccount(params)`.
174
198
  * @param params The parameters for the funding transaction
175
199
  * @returns The result of the funding
176
200
  */
@@ -283,7 +307,7 @@ class AppClient {
283
307
  this._clearSourceMap = new SourceMap(sourceMaps.clearSourceMap);
284
308
  }
285
309
  /**
286
- * Returns the ABI Method for the given method name string for the app represented by this application client instance
310
+ * Returns the ABI Method spec for the given method string for the app represented by this application client instance
287
311
  * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
288
312
  * e.g. `my_method` or `my_method(unit64,string)bytes`
289
313
  * @returns A tuple with: [ARC-56 `Method`, algosdk `ABIMethod`]
@@ -293,18 +317,37 @@ class AppClient {
293
317
  }
294
318
  /**
295
319
  * Checks for decode errors on the SendAppTransactionResult and maps the return value to the specified type
296
- * on the ARC-56 method.
320
+ * on the ARC-56 method, replacing the `return` property with the decoded type.
297
321
  *
298
- * If the return type is a struct then the struct will be returned.
322
+ * If the return type is an ARC-56 struct then the struct will be returned.
299
323
  *
300
324
  * @param result The SendAppTransactionResult to be mapped
301
325
  * @param method The method that was called
302
326
  * @returns The smart contract response with an updated return value
303
327
  */
304
- async parseMethodCallReturn(result, method) {
328
+ async processMethodCallReturn(result, method) {
305
329
  const resultValue = await result;
306
330
  return { ...resultValue, return: types_appArc56.getArc56ReturnValue(resultValue.return, method, this._appSpec.structs) };
307
331
  }
332
+ /**
333
+ * Compiles the approval and clear state programs (if TEAL templates provided),
334
+ * performing any provided deploy-time parameter replacement and stores
335
+ * the source maps.
336
+ *
337
+ * If no TEAL templates provided it will use any byte code provided in the app spec.
338
+ *
339
+ * Will store any generated source maps for later use in debugging.
340
+ */
341
+ async compile(compilation) {
342
+ const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
343
+ if (result.compiledApproval) {
344
+ this._approvalSourceMap = result.compiledApproval.sourceMap;
345
+ }
346
+ if (result.compiledClear) {
347
+ this._clearSourceMap = result.compiledClear.sourceMap;
348
+ }
349
+ return result;
350
+ }
308
351
  /**
309
352
  * Takes an error that may include a logic error from a call to the current app and re-exposes the
310
353
  * error to include source code information via the source map and ARC-56 spec.
@@ -353,7 +396,9 @@ class AppClient {
353
396
  }
354
397
  return {
355
398
  approvalProgram: buffer.Buffer.from(appSpec.byteCode.approval, 'base64'),
399
+ compiledApproval: undefined,
356
400
  clearStateProgram: buffer.Buffer.from(appSpec.byteCode.clear, 'base64'),
401
+ compiledClear: undefined,
357
402
  };
358
403
  }
359
404
  const approvalTemplate = buffer.Buffer.from(appSpec.source.approval, 'base64').toString('utf-8');
@@ -363,15 +408,12 @@ class AppClient {
363
408
  });
364
409
  const clearTemplate = buffer.Buffer.from(appSpec.source.clear, 'base64').toString('utf-8');
365
410
  const compiledClear = await appManager.compileTealTemplate(clearTemplate, deployTimeParams);
366
- if (config.Config.debug && config.Config.projectRoot) {
367
- debugging.persistSourceMaps({
411
+ if (config.Config.debug) {
412
+ await config.Config.events.emitAsync(types_asyncEventEmitter.EventType.AppCompiled, {
368
413
  sources: [
369
- types_debugging.PersistSourceMapInput.fromCompiledTeal(compiledApproval, appSpec.name, 'approval.teal'),
370
- types_debugging.PersistSourceMapInput.fromCompiledTeal(compiledClear, appSpec.name, 'clear.teal'),
414
+ { compiledTeal: compiledApproval, appName: appSpec.name, fileName: 'approval' },
415
+ { compiledTeal: compiledClear, appName: appSpec.name, fileName: 'clear' },
371
416
  ],
372
- projectRoot: config.Config.projectRoot,
373
- appManager,
374
- withSources: true,
375
417
  });
376
418
  }
377
419
  return {
@@ -389,24 +431,53 @@ class AppClient {
389
431
  * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
390
432
  * e.g. `my_method` or `my_method(unit64,string)bytes`
391
433
  * @param args The arguments to the method with `undefined` for any that should be populated with a default value
392
- * @param appSpec The app spec for the app
393
434
  */
394
- static getABIArgsWithDefaultValues(methodNameOrSignature, args, appSpec) {
395
- const m = types_appArc56.getArc56Method(methodNameOrSignature, appSpec);
396
- return args?.map((a, i) => {
435
+ async getABIArgsWithDefaultValues(methodNameOrSignature, args, sender) {
436
+ const m = types_appArc56.getArc56Method(methodNameOrSignature, this._appSpec);
437
+ return await Promise.all(args?.map(async (a, i) => {
397
438
  const arg = m.args[i];
398
439
  if (a !== undefined) {
399
440
  // If a struct then convert to tuple for the underlying call
400
441
  return arg.struct && typeof a === 'object' && !Array.isArray(a)
401
- ? types_appArc56.getABITupleFromABIStruct(a, appSpec.structs[arg.struct])
442
+ ? types_appArc56.getABITupleFromABIStruct(a, this._appSpec.structs[arg.struct], this._appSpec.structs)
402
443
  : a;
403
444
  }
404
- // todo: expand this to match previous ApplicationClient implementation when ARC-56 spec is updated to support other default value options
405
445
  const defaultValue = arg.defaultValue;
406
- if (defaultValue)
407
- return types_appArc56.getABIDecodedValue(buffer.Buffer.from(defaultValue, 'base64'), m.method.args[i].type, {});
446
+ if (defaultValue) {
447
+ switch (defaultValue.source) {
448
+ case 'literal':
449
+ if (typeof defaultValue.data === 'number')
450
+ return defaultValue.data;
451
+ return types_appArc56.getABIDecodedValue(buffer.Buffer.from(defaultValue.data, 'base64'), m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
452
+ // todo: When ARC-56 supports ABI calls as default args
453
+ // case 'abi': {
454
+ // const method = this.getABIMethod(defaultValue.data as string)
455
+ // const result = await this.send.call({
456
+ // method: defaultValue.data as string,
457
+ // methodArgs: method.args.map(() => undefined),
458
+ // sender,
459
+ // })
460
+ // return result.return!
461
+ // }
462
+ case 'local':
463
+ case 'global': {
464
+ const state = defaultValue.source === 'global' ? await this.getGlobalState() : await this.getLocalState(sender);
465
+ const value = Object.values(state).find((s) => s.keyBase64 === defaultValue.data);
466
+ if (!value) {
467
+ throw new Error(`Preparing default value for argument ${arg.name ?? `arg${i + 1}`} resulted in the failure: The key '${defaultValue.data}' could not be found in ${defaultValue.source} storage`);
468
+ }
469
+ return 'valueRaw' in value
470
+ ? types_appArc56.getABIDecodedValue(value.valueRaw, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs)
471
+ : value.value;
472
+ }
473
+ case 'box': {
474
+ const value = await this.getBoxValue(buffer.Buffer.from(defaultValue.data, 'base64'));
475
+ return types_appArc56.getABIDecodedValue(value, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
476
+ }
477
+ }
478
+ }
408
479
  throw new Error(`No value provided for required argument ${arg.name ?? `arg${i + 1}`} in call to method ${m.name}`);
409
- });
480
+ }) ?? []);
410
481
  }
411
482
  getBareParamsMethods() {
412
483
  return {
@@ -439,31 +510,31 @@ class AppClient {
439
510
  },
440
511
  };
441
512
  }
442
- getBareTransactionsMethods() {
513
+ getBareCreateTransactionMethods() {
443
514
  return {
444
515
  /** Returns a transaction for an update call, including deploy-time TEAL template replacements and compilation if provided */
445
516
  update: async (params) => {
446
- return this._algorand.transactions.appUpdate(await this.params.bare.update(params));
517
+ return this._algorand.createTransaction.appUpdate(await this.params.bare.update(params));
447
518
  },
448
519
  /** Returns a transaction for an opt-in call */
449
520
  optIn: (params) => {
450
- return this._algorand.transactions.appCall(this.params.bare.optIn(params));
521
+ return this._algorand.createTransaction.appCall(this.params.bare.optIn(params));
451
522
  },
452
523
  /** Returns a transaction for a delete call */
453
524
  delete: (params) => {
454
- return this._algorand.transactions.appDelete(this.params.bare.delete(params));
525
+ return this._algorand.createTransaction.appDelete(this.params.bare.delete(params));
455
526
  },
456
527
  /** Returns a transaction for a clear state call */
457
528
  clearState: (params) => {
458
- return this._algorand.transactions.appCall(this.params.bare.clearState(params));
529
+ return this._algorand.createTransaction.appCall(this.params.bare.clearState(params));
459
530
  },
460
531
  /** Returns a transaction for a close out call */
461
532
  closeOut: (params) => {
462
- return this._algorand.transactions.appCall(this.params.bare.closeOut(params));
533
+ return this._algorand.createTransaction.appCall(this.params.bare.closeOut(params));
463
534
  },
464
535
  /** Returns a transaction for a call (defaults to no-op) */
465
536
  call: (params) => {
466
- return this._algorand.transactions.appCall(this.params.bare.call(params));
537
+ return this._algorand.createTransaction.appCall(this.params.bare.call(params));
467
538
  },
468
539
  };
469
540
  }
@@ -507,26 +578,26 @@ class AppClient {
507
578
  },
508
579
  /** Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided */
509
580
  update: async (params) => {
510
- return this.getABIParams({
581
+ return (await this.getABIParams({
511
582
  ...params,
512
583
  ...(await this.compile(params)),
513
- }, OnApplicationComplete.UpdateApplicationOC);
584
+ }, OnApplicationComplete.UpdateApplicationOC));
514
585
  },
515
586
  /** Return params for an opt-in ABI call */
516
- optIn: (params) => {
517
- return this.getABIParams(params, OnApplicationComplete.OptInOC);
587
+ optIn: async (params) => {
588
+ return (await this.getABIParams(params, OnApplicationComplete.OptInOC));
518
589
  },
519
590
  /** Return params for an delete ABI call */
520
- delete: (params) => {
521
- return this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC);
591
+ delete: async (params) => {
592
+ return (await this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC));
522
593
  },
523
594
  /** Return params for an close out ABI call */
524
- closeOut: (params) => {
525
- return this.getABIParams(params, OnApplicationComplete.CloseOutOC);
595
+ closeOut: async (params) => {
596
+ return (await this.getABIParams(params, OnApplicationComplete.CloseOutOC));
526
597
  },
527
598
  /** Return params for an ABI call */
528
- call: (params) => {
529
- return this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC);
599
+ call: async (params) => {
600
+ return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC));
530
601
  },
531
602
  };
532
603
  }
@@ -542,7 +613,7 @@ class AppClient {
542
613
  update: async (params) => {
543
614
  const compiled = await this.compile(params);
544
615
  return {
545
- ...(await this.handleCallErrors(async () => this.parseMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), types_appArc56.getArc56Method(params.method, this._appSpec)))),
616
+ ...(await this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), types_appArc56.getArc56Method(params.method, this._appSpec)))),
546
617
  ...compiled,
547
618
  };
548
619
  },
@@ -550,19 +621,19 @@ class AppClient {
550
621
  * Sign and send transactions for an opt-in ABI call
551
622
  */
552
623
  optIn: (params) => {
553
- return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appCallMethodCall(this.params.optIn(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
624
+ return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
554
625
  },
555
626
  /**
556
627
  * Sign and send transactions for a delete ABI call
557
628
  */
558
629
  delete: (params) => {
559
- return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appDeleteMethodCall(this.params.delete(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
630
+ return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
560
631
  },
561
632
  /**
562
633
  * Sign and send transactions for a close out ABI call
563
634
  */
564
635
  closeOut: (params) => {
565
- return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appCallMethodCall(this.params.closeOut(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
636
+ return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
566
637
  },
567
638
  /**
568
639
  * Sign and send transactions for a call (defaults to no-op)
@@ -571,8 +642,11 @@ class AppClient {
571
642
  // Read-only call - do it via simulate
572
643
  if (params.onComplete === OnApplicationComplete.NoOpOC ||
573
644
  (!params.onComplete && types_appArc56.getArc56Method(params.method, this._appSpec).method.readonly)) {
574
- const result = await this._algorand.newGroup().addAppCallMethodCall(this.params.call(params)).simulate();
575
- return this.parseMethodCallReturn({
645
+ const result = await this._algorand
646
+ .newGroup()
647
+ .addAppCallMethodCall(await this.params.call(params))
648
+ .simulate();
649
+ return this.processMethodCallReturn({
576
650
  ...result,
577
651
  transaction: result.transactions.at(-1),
578
652
  confirmation: result.confirmations.at(-1),
@@ -580,67 +654,48 @@ class AppClient {
580
654
  return: (result.returns?.length ?? 0 > 0) ? result.returns?.at(-1) : undefined,
581
655
  }, types_appArc56.getArc56Method(params.method, this._appSpec));
582
656
  }
583
- return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appCallMethodCall(this.params.call(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
657
+ return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
584
658
  },
585
659
  };
586
660
  }
587
- getMethodCallTransactionsMethods() {
661
+ getMethodCallCreateTransactionMethods() {
588
662
  return {
589
663
  /** Return transaction for a payment transaction to fund the app account */
590
664
  fundAppAccount: (params) => {
591
- return this._algorand.transactions.payment(this.params.fundAppAccount(params));
665
+ return this._algorand.createTransaction.payment(this.params.fundAppAccount(params));
592
666
  },
593
667
  /**
594
668
  * Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
595
669
  */
596
670
  update: async (params) => {
597
- return this._algorand.transactions.appUpdateMethodCall(await this.params.update(params));
671
+ return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params));
598
672
  },
599
673
  /**
600
674
  * Return transactions for an opt-in ABI call
601
675
  */
602
- optIn: (params) => {
603
- return this._algorand.transactions.appCallMethodCall(this.params.optIn(params));
676
+ optIn: async (params) => {
677
+ return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params));
604
678
  },
605
679
  /**
606
680
  * Return transactions for a delete ABI call
607
681
  */
608
- delete: (params) => {
609
- return this._algorand.transactions.appDeleteMethodCall(this.params.delete(params));
682
+ delete: async (params) => {
683
+ return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params));
610
684
  },
611
685
  /**
612
686
  * Return transactions for a close out ABI call
613
687
  */
614
- closeOut: (params) => {
615
- return this._algorand.transactions.appCallMethodCall(this.params.closeOut(params));
688
+ closeOut: async (params) => {
689
+ return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params));
616
690
  },
617
691
  /**
618
692
  * Return transactions for an ABI call (defaults to no-op)
619
693
  */
620
- call: (params) => {
621
- return this._algorand.transactions.appCallMethodCall(this.params.call(params));
694
+ call: async (params) => {
695
+ return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params));
622
696
  },
623
697
  };
624
698
  }
625
- /**
626
- * Compiles the approval and clear state programs (if TEAL templates provided),
627
- * performing any provided deploy-time parameter replacement and stores
628
- * the source maps.
629
- *
630
- * If no TEAL templates provided it will use any byte code provided in the app spec.
631
- *
632
- * Will store any generated source maps for later use in debugging.
633
- */
634
- async compile(compilation) {
635
- const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
636
- if (result.compiledApproval) {
637
- this._approvalSourceMap = result.compiledApproval.sourceMap;
638
- }
639
- if (result.compiledClear) {
640
- this._clearSourceMap = result.compiledClear.sourceMap;
641
- }
642
- return result;
643
- }
644
699
  /** Returns the sender for a call, using the `defaultSender`
645
700
  * if none provided and throws an error if neither provided */
646
701
  getSender(sender) {
@@ -657,13 +712,14 @@ class AppClient {
657
712
  onComplete,
658
713
  };
659
714
  }
660
- getABIParams(params, onComplete) {
715
+ async getABIParams(params, onComplete) {
716
+ const sender = this.getSender(params.sender);
661
717
  const method = types_appArc56.getArc56Method(params.method, this._appSpec);
662
- const args = AppClient.getABIArgsWithDefaultValues(params.method, params.args, this._appSpec);
718
+ const args = await this.getABIArgsWithDefaultValues(params.method, params.args, sender);
663
719
  return {
664
720
  ...params,
665
721
  appId: this._appId,
666
- sender: this.getSender(params.sender),
722
+ sender: sender,
667
723
  method,
668
724
  onComplete,
669
725
  args,
@@ -878,15 +934,12 @@ class ApplicationClient {
878
934
  const clear = appDeploy.performTemplateSubstitution(clearTemplate, deployTimeParams ?? this.deployTimeParams);
879
935
  const clearCompiled = await app.compileTeal(clear, this.algod);
880
936
  this._clearSourceMap = clearCompiled?.sourceMap;
881
- if (config.Config.debug && config.Config.projectRoot) {
882
- debugging.persistSourceMaps({
937
+ if (config.Config.debug) {
938
+ await config.Config.events.emitAsync(types_asyncEventEmitter.EventType.AppCompiled, {
883
939
  sources: [
884
- types_debugging.PersistSourceMapInput.fromCompiledTeal(approvalCompiled, this._appName, 'approval.teal'),
885
- types_debugging.PersistSourceMapInput.fromCompiledTeal(clearCompiled, this._appName, 'clear.teal'),
940
+ { compiledTeal: approvalCompiled, appName: this._appName, fileName: 'approval' },
941
+ { compiledTeal: clearCompiled, appName: this._appName, fileName: 'clear' },
886
942
  ],
887
- projectRoot: config.Config.projectRoot,
888
- appManager: new types_appManager.AppManager(this.algod),
889
- withSources: true,
890
943
  });
891
944
  }
892
945
  return { approvalCompiled, clearCompiled };
@@ -1046,7 +1099,7 @@ class ApplicationClient {
1046
1099
  }
1047
1100
  }
1048
1101
  /**
1049
- * @deprecated Use `appClient.send.update` or `appClient.transactions.update` from an `AppClient` instance instead.
1102
+ * @deprecated Use `appClient.send.update` or `appClient.createTransaction.update` from an `AppClient` instance instead.
1050
1103
  *
1051
1104
  * Updates the smart contract app.
1052
1105
  * @param update The parameters to update the app with
@@ -1080,7 +1133,7 @@ class ApplicationClient {
1080
1133
  }
1081
1134
  }
1082
1135
  /**
1083
- * @deprecated Use `appClient.send.call` or `appClient.transactions.call` from an `AppClient` instance instead.
1136
+ * @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
1084
1137
  *
1085
1138
  * Issues a no_op (normal) call to the app.
1086
1139
  * @param call The call details.
@@ -1115,7 +1168,7 @@ class ApplicationClient {
1115
1168
  return await this.callOfType(call, 'no_op');
1116
1169
  }
1117
1170
  /**
1118
- * @deprecated Use `appClient.send.optIn` or `appClient.transactions.optIn` from an `AppClient` instance instead.
1171
+ * @deprecated Use `appClient.send.optIn` or `appClient.createTransaction.optIn` from an `AppClient` instance instead.
1119
1172
  *
1120
1173
  * Issues a opt_in call to the app.
1121
1174
  * @param call The call details.
@@ -1125,7 +1178,7 @@ class ApplicationClient {
1125
1178
  return await this.callOfType(call, 'opt_in');
1126
1179
  }
1127
1180
  /**
1128
- * @deprecated Use `appClient.send.closeOut` or `appClient.transactions.closeOut` from an `AppClient` instance instead.
1181
+ * @deprecated Use `appClient.send.closeOut` or `appClient.createTransaction.closeOut` from an `AppClient` instance instead.
1129
1182
  *
1130
1183
  * Issues a close_out call to the app.
1131
1184
  * @param call The call details.
@@ -1135,7 +1188,7 @@ class ApplicationClient {
1135
1188
  return await this.callOfType(call, 'close_out');
1136
1189
  }
1137
1190
  /**
1138
- * @deprecated Use `appClient.send.clearState` or `appClient.transactions.clearState` from an `AppClient` instance instead.
1191
+ * @deprecated Use `appClient.send.clearState` or `appClient.createTransaction.clearState` from an `AppClient` instance instead.
1139
1192
  *
1140
1193
  * Issues a clear_state call to the app.
1141
1194
  * @param call The call details.
@@ -1145,7 +1198,7 @@ class ApplicationClient {
1145
1198
  return await this.callOfType(call, 'clear_state');
1146
1199
  }
1147
1200
  /**
1148
- * @deprecated Use `appClient.send.delete` or `appClient.transactions.delete` from an `AppClient` instance instead.
1201
+ * @deprecated Use `appClient.send.delete` or `appClient.createTransaction.delete` from an `AppClient` instance instead.
1149
1202
  *
1150
1203
  * Issues a delete_application call to the app.
1151
1204
  * @param call The call details.
@@ -1155,7 +1208,7 @@ class ApplicationClient {
1155
1208
  return await this.callOfType(call, 'delete_application');
1156
1209
  }
1157
1210
  /**
1158
- * @deprecated Use `appClient.send.call` or `appClient.transactions.call` from an `AppClient` instance instead.
1211
+ * @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
1159
1212
  *
1160
1213
  * Issues a call to the app with the given call type.
1161
1214
  * @param call The call details.