@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
@@ -3,15 +3,13 @@ import { Buffer } from 'buffer';
3
3
  import { compileTeal, createApp, updateApp, callApp, getAppGlobalState, getAppLocalState, getAppBoxNames, getAppBoxValue, getAppBoxValueFromABIType } from '../app.mjs';
4
4
  import { replaceDeployTimeControlParams, performTemplateSubstitution, deployApp, getCreatorAppsByName } from '../app-deploy.mjs';
5
5
  import { Config } from '../config.mjs';
6
- import { persistSourceMaps } from '../debugging/debugging.mjs';
7
6
  import { legacySendTransactionBridge } from '../transaction/legacy-bridge.mjs';
8
7
  import { getSenderAddress, encodeTransactionNote } from '../transaction/transaction.mjs';
9
8
  import { binaryStartsWith } from '../util.mjs';
10
9
  import { UPDATABLE_TEMPLATE_NAME, DELETABLE_TEMPLATE_NAME } from './app.mjs';
11
10
  import { getArc56Method, getArc56ReturnValue, getABITupleFromABIStruct, getABIDecodedValue, getABIEncodedValue } from './app-arc56.mjs';
12
- import { AppManager } from './app-manager.mjs';
13
11
  import { arc32ToArc56 } from './app-spec.mjs';
14
- import { PersistSourceMapInput } from './debugging.mjs';
12
+ import { EventType } from './async-event-emitter.mjs';
15
13
  import { LogicError } from './logic-error.mjs';
16
14
 
17
15
  var ABIMethod = algosdk.ABIMethod;
@@ -59,10 +57,19 @@ class AppClient {
59
57
  this._boxStateMethods = this.getBoxMethods();
60
58
  this._paramsMethods = {
61
59
  ...this.getMethodCallParamsMethods(),
60
+ /** Get parameters to define bare (raw) transactions to the current app */
62
61
  bare: this.getBareParamsMethods(),
63
62
  };
64
- this._transactionsMethods = { ...this.getMethodCallTransactionsMethods(), bare: this.getBareTransactionsMethods() };
65
- this._sendMethods = { ...this.getMethodCallSendMethods(), bare: this.getBareSendMethods() };
63
+ this._createTransactionsMethods = {
64
+ ...this.getMethodCallCreateTransactionMethods(),
65
+ /** Get transactions for bare (raw) calls to the current app */
66
+ bare: this.getBareCreateTransactionMethods(),
67
+ };
68
+ this._sendMethods = {
69
+ ...this.getMethodCallSendMethods(),
70
+ /** Send bare (raw) transactions to the current app */
71
+ bare: this.getBareSendMethods(),
72
+ };
66
73
  }
67
74
  /** Start a new `AlgoKitComposer` transaction group */
68
75
  newGroup() {
@@ -138,18 +145,33 @@ class AppClient {
138
145
  get appSpec() {
139
146
  return this._appSpec;
140
147
  }
141
- /** Get parameters to define transactions to the current app */
148
+ /** Get parameters to create transactions for the current app.
149
+ *
150
+ * A good mental model for this is that these parameters represent a deferred transaction creation.
151
+ * @example Create a transaction in the future using Algorand Client
152
+ * ```typescript
153
+ * const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
154
+ * // ...
155
+ * await algorand.send.AppMethodCall(myMethodCall)
156
+ * ```
157
+ * @example Define a nested transaction as an ABI argument
158
+ * ```typescript
159
+ * const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
160
+ * await appClient.send.call({method: 'my_method2', args: [myMethodCall]})
161
+ * ```
162
+ */
142
163
  get params() {
143
164
  return this._paramsMethods;
144
165
  }
145
- /** Get transactions for the current app */
146
- get transactions() {
147
- return this._transactionsMethods;
166
+ /** Create transactions for the current app */
167
+ get createTransaction() {
168
+ return this._createTransactionsMethods;
148
169
  }
149
- /** Send calls to the current app */
170
+ /** Send transactions to the current app */
150
171
  get send() {
151
172
  return this._sendMethods;
152
173
  }
174
+ /** Get state (local, global, box) from the current app */
153
175
  get state() {
154
176
  return {
155
177
  /**
@@ -169,6 +191,8 @@ class AppClient {
169
191
  }
170
192
  /**
171
193
  * Funds Algo into the app account for this app.
194
+ *
195
+ * An alias for `appClient.send.fundAppAccount(params)`.
172
196
  * @param params The parameters for the funding transaction
173
197
  * @returns The result of the funding
174
198
  */
@@ -281,7 +305,7 @@ class AppClient {
281
305
  this._clearSourceMap = new SourceMap(sourceMaps.clearSourceMap);
282
306
  }
283
307
  /**
284
- * Returns the ABI Method for the given method name string for the app represented by this application client instance
308
+ * Returns the ABI Method spec for the given method string for the app represented by this application client instance
285
309
  * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
286
310
  * e.g. `my_method` or `my_method(unit64,string)bytes`
287
311
  * @returns A tuple with: [ARC-56 `Method`, algosdk `ABIMethod`]
@@ -291,18 +315,37 @@ class AppClient {
291
315
  }
292
316
  /**
293
317
  * Checks for decode errors on the SendAppTransactionResult and maps the return value to the specified type
294
- * on the ARC-56 method.
318
+ * on the ARC-56 method, replacing the `return` property with the decoded type.
295
319
  *
296
- * If the return type is a struct then the struct will be returned.
320
+ * If the return type is an ARC-56 struct then the struct will be returned.
297
321
  *
298
322
  * @param result The SendAppTransactionResult to be mapped
299
323
  * @param method The method that was called
300
324
  * @returns The smart contract response with an updated return value
301
325
  */
302
- async parseMethodCallReturn(result, method) {
326
+ async processMethodCallReturn(result, method) {
303
327
  const resultValue = await result;
304
328
  return { ...resultValue, return: getArc56ReturnValue(resultValue.return, method, this._appSpec.structs) };
305
329
  }
330
+ /**
331
+ * Compiles the approval and clear state programs (if TEAL templates provided),
332
+ * performing any provided deploy-time parameter replacement and stores
333
+ * the source maps.
334
+ *
335
+ * If no TEAL templates provided it will use any byte code provided in the app spec.
336
+ *
337
+ * Will store any generated source maps for later use in debugging.
338
+ */
339
+ async compile(compilation) {
340
+ const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
341
+ if (result.compiledApproval) {
342
+ this._approvalSourceMap = result.compiledApproval.sourceMap;
343
+ }
344
+ if (result.compiledClear) {
345
+ this._clearSourceMap = result.compiledClear.sourceMap;
346
+ }
347
+ return result;
348
+ }
306
349
  /**
307
350
  * Takes an error that may include a logic error from a call to the current app and re-exposes the
308
351
  * error to include source code information via the source map and ARC-56 spec.
@@ -351,7 +394,9 @@ class AppClient {
351
394
  }
352
395
  return {
353
396
  approvalProgram: Buffer.from(appSpec.byteCode.approval, 'base64'),
397
+ compiledApproval: undefined,
354
398
  clearStateProgram: Buffer.from(appSpec.byteCode.clear, 'base64'),
399
+ compiledClear: undefined,
355
400
  };
356
401
  }
357
402
  const approvalTemplate = Buffer.from(appSpec.source.approval, 'base64').toString('utf-8');
@@ -361,15 +406,12 @@ class AppClient {
361
406
  });
362
407
  const clearTemplate = Buffer.from(appSpec.source.clear, 'base64').toString('utf-8');
363
408
  const compiledClear = await appManager.compileTealTemplate(clearTemplate, deployTimeParams);
364
- if (Config.debug && Config.projectRoot) {
365
- persistSourceMaps({
409
+ if (Config.debug) {
410
+ await Config.events.emitAsync(EventType.AppCompiled, {
366
411
  sources: [
367
- PersistSourceMapInput.fromCompiledTeal(compiledApproval, appSpec.name, 'approval.teal'),
368
- PersistSourceMapInput.fromCompiledTeal(compiledClear, appSpec.name, 'clear.teal'),
412
+ { compiledTeal: compiledApproval, appName: appSpec.name, fileName: 'approval' },
413
+ { compiledTeal: compiledClear, appName: appSpec.name, fileName: 'clear' },
369
414
  ],
370
- projectRoot: Config.projectRoot,
371
- appManager,
372
- withSources: true,
373
415
  });
374
416
  }
375
417
  return {
@@ -387,24 +429,53 @@ class AppClient {
387
429
  * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
388
430
  * e.g. `my_method` or `my_method(unit64,string)bytes`
389
431
  * @param args The arguments to the method with `undefined` for any that should be populated with a default value
390
- * @param appSpec The app spec for the app
391
432
  */
392
- static getABIArgsWithDefaultValues(methodNameOrSignature, args, appSpec) {
393
- const m = getArc56Method(methodNameOrSignature, appSpec);
394
- return args?.map((a, i) => {
433
+ async getABIArgsWithDefaultValues(methodNameOrSignature, args, sender) {
434
+ const m = getArc56Method(methodNameOrSignature, this._appSpec);
435
+ return await Promise.all(args?.map(async (a, i) => {
395
436
  const arg = m.args[i];
396
437
  if (a !== undefined) {
397
438
  // If a struct then convert to tuple for the underlying call
398
439
  return arg.struct && typeof a === 'object' && !Array.isArray(a)
399
- ? getABITupleFromABIStruct(a, appSpec.structs[arg.struct])
440
+ ? getABITupleFromABIStruct(a, this._appSpec.structs[arg.struct], this._appSpec.structs)
400
441
  : a;
401
442
  }
402
- // todo: expand this to match previous ApplicationClient implementation when ARC-56 spec is updated to support other default value options
403
443
  const defaultValue = arg.defaultValue;
404
- if (defaultValue)
405
- return getABIDecodedValue(Buffer.from(defaultValue, 'base64'), m.method.args[i].type, {});
444
+ if (defaultValue) {
445
+ switch (defaultValue.source) {
446
+ case 'literal':
447
+ if (typeof defaultValue.data === 'number')
448
+ return defaultValue.data;
449
+ return getABIDecodedValue(Buffer.from(defaultValue.data, 'base64'), m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
450
+ // todo: When ARC-56 supports ABI calls as default args
451
+ // case 'abi': {
452
+ // const method = this.getABIMethod(defaultValue.data as string)
453
+ // const result = await this.send.call({
454
+ // method: defaultValue.data as string,
455
+ // methodArgs: method.args.map(() => undefined),
456
+ // sender,
457
+ // })
458
+ // return result.return!
459
+ // }
460
+ case 'local':
461
+ case 'global': {
462
+ const state = defaultValue.source === 'global' ? await this.getGlobalState() : await this.getLocalState(sender);
463
+ const value = Object.values(state).find((s) => s.keyBase64 === defaultValue.data);
464
+ if (!value) {
465
+ 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`);
466
+ }
467
+ return 'valueRaw' in value
468
+ ? getABIDecodedValue(value.valueRaw, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs)
469
+ : value.value;
470
+ }
471
+ case 'box': {
472
+ const value = await this.getBoxValue(Buffer.from(defaultValue.data, 'base64'));
473
+ return getABIDecodedValue(value, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
474
+ }
475
+ }
476
+ }
406
477
  throw new Error(`No value provided for required argument ${arg.name ?? `arg${i + 1}`} in call to method ${m.name}`);
407
- });
478
+ }) ?? []);
408
479
  }
409
480
  getBareParamsMethods() {
410
481
  return {
@@ -437,31 +508,31 @@ class AppClient {
437
508
  },
438
509
  };
439
510
  }
440
- getBareTransactionsMethods() {
511
+ getBareCreateTransactionMethods() {
441
512
  return {
442
513
  /** Returns a transaction for an update call, including deploy-time TEAL template replacements and compilation if provided */
443
514
  update: async (params) => {
444
- return this._algorand.transactions.appUpdate(await this.params.bare.update(params));
515
+ return this._algorand.createTransaction.appUpdate(await this.params.bare.update(params));
445
516
  },
446
517
  /** Returns a transaction for an opt-in call */
447
518
  optIn: (params) => {
448
- return this._algorand.transactions.appCall(this.params.bare.optIn(params));
519
+ return this._algorand.createTransaction.appCall(this.params.bare.optIn(params));
449
520
  },
450
521
  /** Returns a transaction for a delete call */
451
522
  delete: (params) => {
452
- return this._algorand.transactions.appDelete(this.params.bare.delete(params));
523
+ return this._algorand.createTransaction.appDelete(this.params.bare.delete(params));
453
524
  },
454
525
  /** Returns a transaction for a clear state call */
455
526
  clearState: (params) => {
456
- return this._algorand.transactions.appCall(this.params.bare.clearState(params));
527
+ return this._algorand.createTransaction.appCall(this.params.bare.clearState(params));
457
528
  },
458
529
  /** Returns a transaction for a close out call */
459
530
  closeOut: (params) => {
460
- return this._algorand.transactions.appCall(this.params.bare.closeOut(params));
531
+ return this._algorand.createTransaction.appCall(this.params.bare.closeOut(params));
461
532
  },
462
533
  /** Returns a transaction for a call (defaults to no-op) */
463
534
  call: (params) => {
464
- return this._algorand.transactions.appCall(this.params.bare.call(params));
535
+ return this._algorand.createTransaction.appCall(this.params.bare.call(params));
465
536
  },
466
537
  };
467
538
  }
@@ -505,26 +576,26 @@ class AppClient {
505
576
  },
506
577
  /** Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided */
507
578
  update: async (params) => {
508
- return this.getABIParams({
579
+ return (await this.getABIParams({
509
580
  ...params,
510
581
  ...(await this.compile(params)),
511
- }, OnApplicationComplete.UpdateApplicationOC);
582
+ }, OnApplicationComplete.UpdateApplicationOC));
512
583
  },
513
584
  /** Return params for an opt-in ABI call */
514
- optIn: (params) => {
515
- return this.getABIParams(params, OnApplicationComplete.OptInOC);
585
+ optIn: async (params) => {
586
+ return (await this.getABIParams(params, OnApplicationComplete.OptInOC));
516
587
  },
517
588
  /** Return params for an delete ABI call */
518
- delete: (params) => {
519
- return this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC);
589
+ delete: async (params) => {
590
+ return (await this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC));
520
591
  },
521
592
  /** Return params for an close out ABI call */
522
- closeOut: (params) => {
523
- return this.getABIParams(params, OnApplicationComplete.CloseOutOC);
593
+ closeOut: async (params) => {
594
+ return (await this.getABIParams(params, OnApplicationComplete.CloseOutOC));
524
595
  },
525
596
  /** Return params for an ABI call */
526
- call: (params) => {
527
- return this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC);
597
+ call: async (params) => {
598
+ return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC));
528
599
  },
529
600
  };
530
601
  }
@@ -540,7 +611,7 @@ class AppClient {
540
611
  update: async (params) => {
541
612
  const compiled = await this.compile(params);
542
613
  return {
543
- ...(await this.handleCallErrors(async () => this.parseMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), getArc56Method(params.method, this._appSpec)))),
614
+ ...(await this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), getArc56Method(params.method, this._appSpec)))),
544
615
  ...compiled,
545
616
  };
546
617
  },
@@ -548,19 +619,19 @@ class AppClient {
548
619
  * Sign and send transactions for an opt-in ABI call
549
620
  */
550
621
  optIn: (params) => {
551
- return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appCallMethodCall(this.params.optIn(params)), getArc56Method(params.method, this._appSpec)));
622
+ return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), getArc56Method(params.method, this._appSpec)));
552
623
  },
553
624
  /**
554
625
  * Sign and send transactions for a delete ABI call
555
626
  */
556
627
  delete: (params) => {
557
- return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appDeleteMethodCall(this.params.delete(params)), getArc56Method(params.method, this._appSpec)));
628
+ return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), getArc56Method(params.method, this._appSpec)));
558
629
  },
559
630
  /**
560
631
  * Sign and send transactions for a close out ABI call
561
632
  */
562
633
  closeOut: (params) => {
563
- return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appCallMethodCall(this.params.closeOut(params)), getArc56Method(params.method, this._appSpec)));
634
+ return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), getArc56Method(params.method, this._appSpec)));
564
635
  },
565
636
  /**
566
637
  * Sign and send transactions for a call (defaults to no-op)
@@ -569,8 +640,11 @@ class AppClient {
569
640
  // Read-only call - do it via simulate
570
641
  if (params.onComplete === OnApplicationComplete.NoOpOC ||
571
642
  (!params.onComplete && getArc56Method(params.method, this._appSpec).method.readonly)) {
572
- const result = await this._algorand.newGroup().addAppCallMethodCall(this.params.call(params)).simulate();
573
- return this.parseMethodCallReturn({
643
+ const result = await this._algorand
644
+ .newGroup()
645
+ .addAppCallMethodCall(await this.params.call(params))
646
+ .simulate();
647
+ return this.processMethodCallReturn({
574
648
  ...result,
575
649
  transaction: result.transactions.at(-1),
576
650
  confirmation: result.confirmations.at(-1),
@@ -578,67 +652,48 @@ class AppClient {
578
652
  return: (result.returns?.length ?? 0 > 0) ? result.returns?.at(-1) : undefined,
579
653
  }, getArc56Method(params.method, this._appSpec));
580
654
  }
581
- return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appCallMethodCall(this.params.call(params)), getArc56Method(params.method, this._appSpec)));
655
+ return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(params)), getArc56Method(params.method, this._appSpec)));
582
656
  },
583
657
  };
584
658
  }
585
- getMethodCallTransactionsMethods() {
659
+ getMethodCallCreateTransactionMethods() {
586
660
  return {
587
661
  /** Return transaction for a payment transaction to fund the app account */
588
662
  fundAppAccount: (params) => {
589
- return this._algorand.transactions.payment(this.params.fundAppAccount(params));
663
+ return this._algorand.createTransaction.payment(this.params.fundAppAccount(params));
590
664
  },
591
665
  /**
592
666
  * Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
593
667
  */
594
668
  update: async (params) => {
595
- return this._algorand.transactions.appUpdateMethodCall(await this.params.update(params));
669
+ return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params));
596
670
  },
597
671
  /**
598
672
  * Return transactions for an opt-in ABI call
599
673
  */
600
- optIn: (params) => {
601
- return this._algorand.transactions.appCallMethodCall(this.params.optIn(params));
674
+ optIn: async (params) => {
675
+ return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params));
602
676
  },
603
677
  /**
604
678
  * Return transactions for a delete ABI call
605
679
  */
606
- delete: (params) => {
607
- return this._algorand.transactions.appDeleteMethodCall(this.params.delete(params));
680
+ delete: async (params) => {
681
+ return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params));
608
682
  },
609
683
  /**
610
684
  * Return transactions for a close out ABI call
611
685
  */
612
- closeOut: (params) => {
613
- return this._algorand.transactions.appCallMethodCall(this.params.closeOut(params));
686
+ closeOut: async (params) => {
687
+ return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params));
614
688
  },
615
689
  /**
616
690
  * Return transactions for an ABI call (defaults to no-op)
617
691
  */
618
- call: (params) => {
619
- return this._algorand.transactions.appCallMethodCall(this.params.call(params));
692
+ call: async (params) => {
693
+ return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params));
620
694
  },
621
695
  };
622
696
  }
623
- /**
624
- * Compiles the approval and clear state programs (if TEAL templates provided),
625
- * performing any provided deploy-time parameter replacement and stores
626
- * the source maps.
627
- *
628
- * If no TEAL templates provided it will use any byte code provided in the app spec.
629
- *
630
- * Will store any generated source maps for later use in debugging.
631
- */
632
- async compile(compilation) {
633
- const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
634
- if (result.compiledApproval) {
635
- this._approvalSourceMap = result.compiledApproval.sourceMap;
636
- }
637
- if (result.compiledClear) {
638
- this._clearSourceMap = result.compiledClear.sourceMap;
639
- }
640
- return result;
641
- }
642
697
  /** Returns the sender for a call, using the `defaultSender`
643
698
  * if none provided and throws an error if neither provided */
644
699
  getSender(sender) {
@@ -655,13 +710,14 @@ class AppClient {
655
710
  onComplete,
656
711
  };
657
712
  }
658
- getABIParams(params, onComplete) {
713
+ async getABIParams(params, onComplete) {
714
+ const sender = this.getSender(params.sender);
659
715
  const method = getArc56Method(params.method, this._appSpec);
660
- const args = AppClient.getABIArgsWithDefaultValues(params.method, params.args, this._appSpec);
716
+ const args = await this.getABIArgsWithDefaultValues(params.method, params.args, sender);
661
717
  return {
662
718
  ...params,
663
719
  appId: this._appId,
664
- sender: this.getSender(params.sender),
720
+ sender: sender,
665
721
  method,
666
722
  onComplete,
667
723
  args,
@@ -876,15 +932,12 @@ class ApplicationClient {
876
932
  const clear = performTemplateSubstitution(clearTemplate, deployTimeParams ?? this.deployTimeParams);
877
933
  const clearCompiled = await compileTeal(clear, this.algod);
878
934
  this._clearSourceMap = clearCompiled?.sourceMap;
879
- if (Config.debug && Config.projectRoot) {
880
- persistSourceMaps({
935
+ if (Config.debug) {
936
+ await Config.events.emitAsync(EventType.AppCompiled, {
881
937
  sources: [
882
- PersistSourceMapInput.fromCompiledTeal(approvalCompiled, this._appName, 'approval.teal'),
883
- PersistSourceMapInput.fromCompiledTeal(clearCompiled, this._appName, 'clear.teal'),
938
+ { compiledTeal: approvalCompiled, appName: this._appName, fileName: 'approval' },
939
+ { compiledTeal: clearCompiled, appName: this._appName, fileName: 'clear' },
884
940
  ],
885
- projectRoot: Config.projectRoot,
886
- appManager: new AppManager(this.algod),
887
- withSources: true,
888
941
  });
889
942
  }
890
943
  return { approvalCompiled, clearCompiled };
@@ -1044,7 +1097,7 @@ class ApplicationClient {
1044
1097
  }
1045
1098
  }
1046
1099
  /**
1047
- * @deprecated Use `appClient.send.update` or `appClient.transactions.update` from an `AppClient` instance instead.
1100
+ * @deprecated Use `appClient.send.update` or `appClient.createTransaction.update` from an `AppClient` instance instead.
1048
1101
  *
1049
1102
  * Updates the smart contract app.
1050
1103
  * @param update The parameters to update the app with
@@ -1078,7 +1131,7 @@ class ApplicationClient {
1078
1131
  }
1079
1132
  }
1080
1133
  /**
1081
- * @deprecated Use `appClient.send.call` or `appClient.transactions.call` from an `AppClient` instance instead.
1134
+ * @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
1082
1135
  *
1083
1136
  * Issues a no_op (normal) call to the app.
1084
1137
  * @param call The call details.
@@ -1113,7 +1166,7 @@ class ApplicationClient {
1113
1166
  return await this.callOfType(call, 'no_op');
1114
1167
  }
1115
1168
  /**
1116
- * @deprecated Use `appClient.send.optIn` or `appClient.transactions.optIn` from an `AppClient` instance instead.
1169
+ * @deprecated Use `appClient.send.optIn` or `appClient.createTransaction.optIn` from an `AppClient` instance instead.
1117
1170
  *
1118
1171
  * Issues a opt_in call to the app.
1119
1172
  * @param call The call details.
@@ -1123,7 +1176,7 @@ class ApplicationClient {
1123
1176
  return await this.callOfType(call, 'opt_in');
1124
1177
  }
1125
1178
  /**
1126
- * @deprecated Use `appClient.send.closeOut` or `appClient.transactions.closeOut` from an `AppClient` instance instead.
1179
+ * @deprecated Use `appClient.send.closeOut` or `appClient.createTransaction.closeOut` from an `AppClient` instance instead.
1127
1180
  *
1128
1181
  * Issues a close_out call to the app.
1129
1182
  * @param call The call details.
@@ -1133,7 +1186,7 @@ class ApplicationClient {
1133
1186
  return await this.callOfType(call, 'close_out');
1134
1187
  }
1135
1188
  /**
1136
- * @deprecated Use `appClient.send.clearState` or `appClient.transactions.clearState` from an `AppClient` instance instead.
1189
+ * @deprecated Use `appClient.send.clearState` or `appClient.createTransaction.clearState` from an `AppClient` instance instead.
1137
1190
  *
1138
1191
  * Issues a clear_state call to the app.
1139
1192
  * @param call The call details.
@@ -1143,7 +1196,7 @@ class ApplicationClient {
1143
1196
  return await this.callOfType(call, 'clear_state');
1144
1197
  }
1145
1198
  /**
1146
- * @deprecated Use `appClient.send.delete` or `appClient.transactions.delete` from an `AppClient` instance instead.
1199
+ * @deprecated Use `appClient.send.delete` or `appClient.createTransaction.delete` from an `AppClient` instance instead.
1147
1200
  *
1148
1201
  * Issues a delete_application call to the app.
1149
1202
  * @param call The call details.
@@ -1153,7 +1206,7 @@ class ApplicationClient {
1153
1206
  return await this.callOfType(call, 'delete_application');
1154
1207
  }
1155
1208
  /**
1156
- * @deprecated Use `appClient.send.call` or `appClient.transactions.call` from an `AppClient` instance instead.
1209
+ * @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
1157
1210
  *
1158
1211
  * Issues a call to the app with the given call type.
1159
1212
  * @param call The call details.