@algorandfoundation/algokit-utils 9.2.0-beta.9 → 9.2.1-beta.1

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 (340) hide show
  1. package/_virtual/_rolldown/runtime.js +33 -0
  2. package/_virtual/_rolldown/runtime.mjs +13 -0
  3. package/account/account.d.ts +25 -30
  4. package/account/account.js +151 -146
  5. package/account/account.js.map +1 -1
  6. package/account/account.mjs +149 -144
  7. package/account/account.mjs.map +1 -1
  8. package/account/get-account-config-from-environment.d.ts +7 -2
  9. package/account/get-account-config-from-environment.js +19 -21
  10. package/account/get-account-config-from-environment.js.map +1 -1
  11. package/account/get-account-config-from-environment.mjs +19 -19
  12. package/account/get-account-config-from-environment.mjs.map +1 -1
  13. package/account/get-account.d.ts +14 -12
  14. package/account/get-account.js +56 -59
  15. package/account/get-account.js.map +1 -1
  16. package/account/get-account.mjs +56 -57
  17. package/account/get-account.mjs.map +1 -1
  18. package/account/get-dispenser-account.d.ts +9 -5
  19. package/account/get-dispenser-account.js +20 -18
  20. package/account/get-dispenser-account.js.map +1 -1
  21. package/account/get-dispenser-account.mjs +20 -16
  22. package/account/get-dispenser-account.mjs.map +1 -1
  23. package/account/mnemonic-account.d.ts +7 -3
  24. package/account/mnemonic-account.js +17 -17
  25. package/account/mnemonic-account.js.map +1 -1
  26. package/account/mnemonic-account.mjs +15 -15
  27. package/account/mnemonic-account.mjs.map +1 -1
  28. package/amount.d.ts +40 -35
  29. package/amount.js +33 -34
  30. package/amount.js.map +1 -1
  31. package/amount.mjs +33 -32
  32. package/amount.mjs.map +1 -1
  33. package/app-client.d.ts +10 -6
  34. package/app-client.js +91 -86
  35. package/app-client.js.map +1 -1
  36. package/app-client.mjs +91 -84
  37. package/app-client.mjs.map +1 -1
  38. package/app-deploy.d.ts +26 -24
  39. package/app-deploy.js +235 -253
  40. package/app-deploy.js.map +1 -1
  41. package/app-deploy.mjs +233 -251
  42. package/app-deploy.mjs.map +1 -1
  43. package/app.d.ts +45 -46
  44. package/app.js +253 -271
  45. package/app.js.map +1 -1
  46. package/app.mjs +249 -267
  47. package/app.mjs.map +1 -1
  48. package/asset.d.ts +16 -12
  49. package/asset.js +116 -122
  50. package/asset.js.map +1 -1
  51. package/asset.mjs +116 -120
  52. package/asset.mjs.map +1 -1
  53. package/config.d.ts +7 -2
  54. package/config.js +5 -7
  55. package/config.js.map +1 -1
  56. package/config.mjs +5 -4
  57. package/config.mjs.map +1 -1
  58. package/debugging/debugging.d.ts +5 -1
  59. package/debugging/debugging.js +11 -11
  60. package/debugging/debugging.js.map +1 -1
  61. package/debugging/debugging.mjs +11 -9
  62. package/debugging/debugging.mjs.map +1 -1
  63. package/dispenser-client.d.ts +7 -2
  64. package/dispenser-client.js +23 -24
  65. package/dispenser-client.js.map +1 -1
  66. package/dispenser-client.mjs +23 -22
  67. package/dispenser-client.mjs.map +1 -1
  68. package/index.d.ts +27 -18
  69. package/index.js +140 -143
  70. package/index.mjs +27 -29
  71. package/indexer-lookup.d.ts +18 -11
  72. package/indexer-lookup.js +112 -120
  73. package/indexer-lookup.js.map +1 -1
  74. package/indexer-lookup.mjs +105 -118
  75. package/indexer-lookup.mjs.map +1 -1
  76. package/localnet/get-kmd-wallet-account.d.ts +9 -7
  77. package/localnet/get-kmd-wallet-account.js +28 -26
  78. package/localnet/get-kmd-wallet-account.js.map +1 -1
  79. package/localnet/get-kmd-wallet-account.mjs +28 -24
  80. package/localnet/get-kmd-wallet-account.mjs.map +1 -1
  81. package/localnet/get-localnet-dispenser-account.d.ts +7 -5
  82. package/localnet/get-localnet-dispenser-account.js +17 -15
  83. package/localnet/get-localnet-dispenser-account.js.map +1 -1
  84. package/localnet/get-localnet-dispenser-account.mjs +17 -13
  85. package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
  86. package/localnet/get-or-create-kmd-wallet-account.d.ts +10 -8
  87. package/localnet/get-or-create-kmd-wallet-account.js +28 -26
  88. package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
  89. package/localnet/get-or-create-kmd-wallet-account.mjs +28 -24
  90. package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
  91. package/localnet/is-localnet.d.ts +7 -3
  92. package/localnet/is-localnet.js +9 -10
  93. package/localnet/is-localnet.js.map +1 -1
  94. package/localnet/is-localnet.mjs +9 -8
  95. package/localnet/is-localnet.mjs.map +1 -1
  96. package/network-client.d.ts +17 -15
  97. package/network-client.js +115 -116
  98. package/network-client.js.map +1 -1
  99. package/network-client.mjs +115 -114
  100. package/network-client.mjs.map +1 -1
  101. package/package.json +12 -3
  102. package/testing/account.d.ts +11 -9
  103. package/testing/account.js +31 -33
  104. package/testing/account.js.map +1 -1
  105. package/testing/account.mjs +29 -31
  106. package/testing/account.mjs.map +1 -1
  107. package/testing/fixtures/algokit-log-capture-fixture.d.ts +7 -2
  108. package/testing/fixtures/algokit-log-capture-fixture.js +36 -41
  109. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  110. package/testing/fixtures/algokit-log-capture-fixture.mjs +36 -39
  111. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  112. package/testing/fixtures/algorand-fixture.d.ts +9 -4
  113. package/testing/fixtures/algorand-fixture.js +67 -62
  114. package/testing/fixtures/algorand-fixture.js.map +1 -1
  115. package/testing/fixtures/algorand-fixture.mjs +66 -59
  116. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  117. package/testing/index.d.ts +7 -5
  118. package/testing/index.js +13 -18
  119. package/testing/index.mjs +7 -7
  120. package/testing/indexer.d.ts +5 -1
  121. package/testing/indexer.js +28 -37
  122. package/testing/indexer.js.map +1 -1
  123. package/testing/indexer.mjs +28 -35
  124. package/testing/indexer.mjs.map +1 -1
  125. package/testing/test-logger.d.ts +41 -36
  126. package/testing/test-logger.js +71 -76
  127. package/testing/test-logger.js.map +1 -1
  128. package/testing/test-logger.mjs +71 -74
  129. package/testing/test-logger.mjs.map +1 -1
  130. package/testing/transaction-logger.d.ts +30 -27
  131. package/testing/transaction-logger.js +77 -93
  132. package/testing/transaction-logger.js.map +1 -1
  133. package/testing/transaction-logger.mjs +74 -90
  134. package/testing/transaction-logger.mjs.map +1 -1
  135. package/transaction/legacy-bridge.js +100 -111
  136. package/transaction/legacy-bridge.js.map +1 -1
  137. package/transaction/legacy-bridge.mjs +97 -108
  138. package/transaction/legacy-bridge.mjs.map +1 -1
  139. package/transaction/perform-atomic-transaction-composer-simulate.d.ts +7 -5
  140. package/transaction/perform-atomic-transaction-composer-simulate.js +31 -36
  141. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  142. package/transaction/perform-atomic-transaction-composer-simulate.mjs +28 -33
  143. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  144. package/transaction/transaction.d.ts +34 -35
  145. package/transaction/transaction.js +716 -914
  146. package/transaction/transaction.js.map +1 -1
  147. package/transaction/transaction.mjs +713 -911
  148. package/transaction/transaction.mjs.map +1 -1
  149. package/transfer/transfer-algos.d.ts +9 -5
  150. package/transfer/transfer-algos.js +26 -27
  151. package/transfer/transfer-algos.js.map +1 -1
  152. package/transfer/transfer-algos.mjs +26 -25
  153. package/transfer/transfer-algos.mjs.map +1 -1
  154. package/transfer/transfer.d.ts +11 -8
  155. package/transfer/transfer.js +94 -100
  156. package/transfer/transfer.js.map +1 -1
  157. package/transfer/transfer.mjs +94 -98
  158. package/transfer/transfer.mjs.map +1 -1
  159. package/types/account-manager.d.ts +432 -429
  160. package/types/account-manager.js +591 -602
  161. package/types/account-manager.js.map +1 -1
  162. package/types/account-manager.mjs +587 -599
  163. package/types/account-manager.mjs.map +1 -1
  164. package/types/account.d.ts +192 -202
  165. package/types/account.js +91 -88
  166. package/types/account.js.map +1 -1
  167. package/types/account.mjs +88 -86
  168. package/types/account.mjs.map +1 -1
  169. package/types/algo-http-client-with-retry.d.ts +15 -10
  170. package/types/algo-http-client-with-retry.js +70 -92
  171. package/types/algo-http-client-with-retry.js.map +1 -1
  172. package/types/algo-http-client-with-retry.mjs +69 -90
  173. package/types/algo-http-client-with-retry.mjs.map +1 -1
  174. package/types/algorand-client-transaction-creator.d.ts +778 -761
  175. package/types/algorand-client-transaction-creator.js +733 -724
  176. package/types/algorand-client-transaction-creator.js.map +1 -1
  177. package/types/algorand-client-transaction-creator.mjs +732 -722
  178. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  179. package/types/algorand-client-transaction-sender.d.ts +1090 -1268
  180. package/types/algorand-client-transaction-sender.js +930 -953
  181. package/types/algorand-client-transaction-sender.js.map +1 -1
  182. package/types/algorand-client-transaction-sender.mjs +927 -951
  183. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  184. package/types/algorand-client.d.ts +239 -236
  185. package/types/algorand-client.js +322 -320
  186. package/types/algorand-client.js.map +1 -1
  187. package/types/algorand-client.mjs +321 -318
  188. package/types/algorand-client.mjs.map +1 -1
  189. package/types/amount.d.ts +47 -43
  190. package/types/amount.js +66 -70
  191. package/types/amount.js.map +1 -1
  192. package/types/amount.mjs +63 -68
  193. package/types/amount.mjs.map +1 -1
  194. package/types/app-arc56.d.ts +235 -272
  195. package/types/app-arc56.js +124 -170
  196. package/types/app-arc56.js.map +1 -1
  197. package/types/app-arc56.mjs +121 -168
  198. package/types/app-arc56.mjs.map +1 -1
  199. package/types/app-client.d.ts +1128 -1972
  200. package/types/app-client.js +1633 -1791
  201. package/types/app-client.js.map +1 -1
  202. package/types/app-client.mjs +1624 -1783
  203. package/types/app-client.mjs.map +1 -1
  204. package/types/app-deployer.d.ts +139 -141
  205. package/types/app-deployer.js +344 -384
  206. package/types/app-deployer.js.map +1 -1
  207. package/types/app-deployer.mjs +341 -382
  208. package/types/app-deployer.mjs.map +1 -1
  209. package/types/app-factory.d.ts +762 -914
  210. package/types/app-factory.js +496 -488
  211. package/types/app-factory.js.map +1 -1
  212. package/types/app-factory.mjs +491 -484
  213. package/types/app-factory.mjs.map +1 -1
  214. package/types/app-manager.d.ts +307 -311
  215. package/types/app-manager.js +422 -474
  216. package/types/app-manager.js.map +1 -1
  217. package/types/app-manager.mjs +419 -472
  218. package/types/app-manager.mjs.map +1 -1
  219. package/types/app-spec.d.ts +118 -117
  220. package/types/app-spec.js +125 -135
  221. package/types/app-spec.js.map +1 -1
  222. package/types/app-spec.mjs +121 -132
  223. package/types/app-spec.mjs.map +1 -1
  224. package/types/app.d.ts +229 -241
  225. package/types/app.js +36 -28
  226. package/types/app.js.map +1 -1
  227. package/types/app.mjs +33 -26
  228. package/types/app.mjs.map +1 -1
  229. package/types/asset-manager.d.ts +204 -199
  230. package/types/asset-manager.js +165 -174
  231. package/types/asset-manager.js.map +1 -1
  232. package/types/asset-manager.mjs +164 -172
  233. package/types/asset-manager.mjs.map +1 -1
  234. package/types/asset.d.ts +95 -91
  235. package/types/asset.js +0 -3
  236. package/types/asset.mjs +0 -2
  237. package/types/async-event-emitter.d.ts +18 -13
  238. package/types/async-event-emitter.js +37 -49
  239. package/types/async-event-emitter.js.map +1 -1
  240. package/types/async-event-emitter.mjs +36 -47
  241. package/types/async-event-emitter.mjs.map +1 -1
  242. package/types/client-manager.d.ts +453 -451
  243. package/types/client-manager.js +602 -598
  244. package/types/client-manager.js.map +1 -1
  245. package/types/client-manager.mjs +597 -594
  246. package/types/client-manager.mjs.map +1 -1
  247. package/types/composer.d.ts +1211 -1248
  248. package/types/composer.js +1436 -1487
  249. package/types/composer.js.map +1 -1
  250. package/types/composer.mjs +1430 -1482
  251. package/types/composer.mjs.map +1 -1
  252. package/types/config.d.ts +53 -48
  253. package/types/config.js +78 -77
  254. package/types/config.js.map +1 -1
  255. package/types/config.mjs +77 -75
  256. package/types/config.mjs.map +1 -1
  257. package/types/debugging.d.ts +25 -23
  258. package/types/debugging.js +9 -11
  259. package/types/debugging.js.map +1 -1
  260. package/types/debugging.mjs +8 -9
  261. package/types/debugging.mjs.map +1 -1
  262. package/types/dispenser-client.d.ts +57 -52
  263. package/types/dispenser-client.js +120 -141
  264. package/types/dispenser-client.js.map +1 -1
  265. package/types/dispenser-client.mjs +119 -139
  266. package/types/dispenser-client.mjs.map +1 -1
  267. package/types/expand.d.ts +5 -3
  268. package/types/expand.js +0 -3
  269. package/types/expand.mjs +0 -2
  270. package/types/indexer.d.ts +104 -100
  271. package/types/indexer.js +36 -31
  272. package/types/indexer.js.map +1 -1
  273. package/types/indexer.mjs +32 -30
  274. package/types/indexer.mjs.map +1 -1
  275. package/types/instance-of.d.ts +5 -3
  276. package/types/instance-of.js +0 -3
  277. package/types/instance-of.mjs +0 -2
  278. package/types/kmd-account-manager.d.ts +75 -70
  279. package/types/kmd-account-manager.js +150 -184
  280. package/types/kmd-account-manager.js.map +1 -1
  281. package/types/kmd-account-manager.mjs +147 -182
  282. package/types/kmd-account-manager.mjs.map +1 -1
  283. package/types/lifecycle-events.d.ts +13 -8
  284. package/types/lifecycle-events.js +10 -7
  285. package/types/lifecycle-events.js.map +1 -1
  286. package/types/lifecycle-events.mjs +9 -7
  287. package/types/lifecycle-events.mjs.map +1 -1
  288. package/types/logging.d.ts +15 -11
  289. package/types/logging.js +30 -31
  290. package/types/logging.js.map +1 -1
  291. package/types/logging.mjs +29 -29
  292. package/types/logging.mjs.map +1 -1
  293. package/types/logic-error.d.ts +33 -29
  294. package/types/logic-error.js +50 -49
  295. package/types/logic-error.js.map +1 -1
  296. package/types/logic-error.mjs +49 -47
  297. package/types/logic-error.mjs.map +1 -1
  298. package/types/network-client.d.ts +32 -27
  299. package/types/network-client.js +10 -9
  300. package/types/network-client.js.map +1 -1
  301. package/types/network-client.mjs +9 -7
  302. package/types/network-client.mjs.map +1 -1
  303. package/types/testing.d.ts +131 -132
  304. package/types/testing.js +0 -3
  305. package/types/testing.mjs +0 -2
  306. package/types/transaction.d.ts +110 -110
  307. package/types/transaction.js +0 -3
  308. package/types/transaction.mjs +0 -2
  309. package/types/transfer.d.ts +70 -66
  310. package/types/transfer.js +0 -3
  311. package/types/transfer.mjs +0 -2
  312. package/util.js +73 -118
  313. package/util.js.map +1 -1
  314. package/util.mjs +73 -116
  315. package/util.mjs.map +1 -1
  316. package/account/index.d.ts +0 -5
  317. package/debugging/index.d.ts +0 -1
  318. package/index.js.map +0 -1
  319. package/index.mjs.map +0 -1
  320. package/localnet/index.d.ts +0 -4
  321. package/testing/_asset.d.ts +0 -3
  322. package/testing/fixtures/index.d.ts +0 -2
  323. package/testing/index.js.map +0 -1
  324. package/testing/index.mjs.map +0 -1
  325. package/transaction/index.d.ts +0 -2
  326. package/transaction/legacy-bridge.d.ts +0 -35
  327. package/transfer/index.d.ts +0 -2
  328. package/types/asset.js.map +0 -1
  329. package/types/asset.mjs.map +0 -1
  330. package/types/expand.js.map +0 -1
  331. package/types/expand.mjs.map +0 -1
  332. package/types/instance-of.js.map +0 -1
  333. package/types/instance-of.mjs.map +0 -1
  334. package/types/testing.js.map +0 -1
  335. package/types/testing.mjs.map +0 -1
  336. package/types/transaction.js.map +0 -1
  337. package/types/transaction.mjs.map +0 -1
  338. package/types/transfer.js.map +0 -1
  339. package/types/transfer.mjs.map +0 -1
  340. package/util.d.ts +0 -48
@@ -1,955 +1,931 @@
1
- import algosdk from 'algosdk';
2
- import { Buffer } from 'buffer';
3
- import { Config } from '../config.mjs';
4
- import { asJson, defaultJsonValueReplacer } from '../util.mjs';
5
- import { AppManager } from './app-manager.mjs';
6
-
1
+ import { Config } from "../config.mjs";
2
+ import { asJson, defaultJsonValueReplacer } from "../util.mjs";
3
+ import { AppManager } from "./app-manager.mjs";
4
+ import algosdk from "algosdk";
5
+ import { Buffer } from "buffer";
6
+ //#region src/types/algorand-client-transaction-sender.ts
7
7
  const getMethodCallForLog = ({ method, args }) => {
8
- return `${method.name}(${(args ?? []).map((a) => typeof a === 'object'
9
- ? asJson(a, (k, v) => {
10
- const newV = defaultJsonValueReplacer(k, v);
11
- return newV instanceof Uint8Array ? Buffer.from(newV).toString('base64') : newV;
12
- })
13
- : a)})`;
8
+ return `${method.name}(${(args ?? []).map((a) => typeof a === "object" ? asJson(a, (k, v) => {
9
+ const newV = defaultJsonValueReplacer(k, v);
10
+ return newV instanceof Uint8Array ? Buffer.from(newV).toString("base64") : newV;
11
+ }) : a)})`;
14
12
  };
15
13
  /** Orchestrates sending transactions for `AlgorandClient`. */
16
- class AlgorandClientTransactionSender {
17
- /**
18
- * Creates a new `AlgorandClientSender`
19
- * @param newGroup A lambda that starts a new `TransactionComposer` transaction group
20
- * @param assetManager An `AssetManager` instance
21
- * @param appManager An `AppManager` instance
22
- * @example
23
- * ```typescript
24
- * const transactionSender = new AlgorandClientTransactionSender(() => new TransactionComposer(), assetManager, appManager)
25
- * ```
26
- */
27
- constructor(newGroup, assetManager, appManager) {
28
- /**
29
- * Send a payment transaction to transfer Algo between accounts.
30
- * @param params The parameters for the payment transaction
31
- * @example Basic example
32
- * ```typescript
33
- * const result = await algorand.send.payment({
34
- * sender: 'SENDERADDRESS',
35
- * receiver: 'RECEIVERADDRESS',
36
- * amount: (4).algo(),
37
- * })
38
- * ```
39
- * @example Advanced example
40
- * ```typescript
41
- * const result = await algorand.send.payment({
42
- * amount: (4).algo(),
43
- * receiver: 'RECEIVERADDRESS',
44
- * sender: 'SENDERADDRESS',
45
- * closeRemainderTo: 'CLOSEREMAINDERTOADDRESS',
46
- * lease: 'lease',
47
- * note: 'note',
48
- * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
49
- * rekeyTo: 'REKEYTOADDRESS',
50
- * // You wouldn't normally set this field
51
- * firstValidRound: 1000n,
52
- * validityWindow: 10,
53
- * extraFee: (1000).microAlgo(),
54
- * staticFee: (1000).microAlgo(),
55
- * // Max fee doesn't make sense with extraFee AND staticFee
56
- * // already specified, but here for completeness
57
- * maxFee: (3000).microAlgo(),
58
- * // Signer only needed if you want to provide one,
59
- * // generally you'd register it with AlgorandClient
60
- * // against the sender and not need to pass it in
61
- * signer: transactionSigner,
62
- * maxRoundsToWaitForConfirmation: 5,
63
- * suppressLog: true,
64
- * })
65
- * ```
66
- * @returns The result of the payment transaction and the transaction that was sent
67
- */
68
- this.payment = this._send((c) => c.addPayment, {
69
- preLog: (params, transaction) => `Sending ${params.amount.microAlgo} µALGO from ${params.sender} to ${params.receiver} via transaction ${transaction.txID()}`,
70
- });
71
- /**
72
- * Create a new Algorand Standard Asset.
73
- *
74
- * The account that sends this transaction will automatically be
75
- * opted in to the asset and will hold all units after creation.
76
- *
77
- * @param params The parameters for the asset creation transaction
78
- *
79
- * @example Basic example
80
- * ```typescript
81
- * await algorand.send.assetCreate({ sender: "CREATORADDRESS", total: 100n})
82
- * ```
83
- * @example Advanced example
84
- * ```typescript
85
- * await algorand.send.assetCreate({
86
- * sender: 'CREATORADDRESS',
87
- * total: 100n,
88
- * decimals: 2,
89
- * assetName: 'asset',
90
- * unitName: 'unit',
91
- * url: 'url',
92
- * metadataHash: 'metadataHash',
93
- * defaultFrozen: false,
94
- * manager: 'MANAGERADDRESS',
95
- * reserve: 'RESERVEADDRESS',
96
- * freeze: 'FREEZEADDRESS',
97
- * clawback: 'CLAWBACKADDRESS',
98
- * lease: 'lease',
99
- * note: 'note',
100
- * // You wouldn't normally set this field
101
- * firstValidRound: 1000n,
102
- * validityWindow: 10,
103
- * extraFee: (1000).microAlgo(),
104
- * staticFee: (1000).microAlgo(),
105
- * // Max fee doesn't make sense with extraFee AND staticFee
106
- * // already specified, but here for completeness
107
- * maxFee: (3000).microAlgo(),
108
- * // Signer only needed if you want to provide one,
109
- * // generally you'd register it with AlgorandClient
110
- * // against the sender and not need to pass it in
111
- * signer: transactionSigner,
112
- * maxRoundsToWaitForConfirmation: 5,
113
- * suppressLog: true,
114
- * })
115
- * ```
116
- * @returns The result of the asset create transaction and the transaction that was sent
117
- */
118
- this.assetCreate = async (params) => {
119
- const result = await this._send((c) => c.addAssetCreate, {
120
- postLog: (params, result) => `Created asset${params.assetName ? ` ${params.assetName}` : ''}${params.unitName ? ` (${params.unitName})` : ''} with ${params.total} units and ${params.decimals ?? 0} decimals created by ${params.sender} with ID ${result.confirmation.assetIndex} via transaction ${result.txIds.at(-1)}`,
121
- })(params);
122
- return { ...result, assetId: BigInt(result.confirmation.assetIndex ?? 0) };
123
- };
124
- /**
125
- * Configure an existing Algorand Standard Asset.
126
- *
127
- * **Note:** The manager, reserve, freeze, and clawback addresses
128
- * are immutably empty if they are not set. If manager is not set then
129
- * all fields are immutable from that point forward.
130
- *
131
- * @param params The parameters for the asset config transaction
132
- *
133
- * @example Basic example
134
- * ```typescript
135
- * await algorand.send.assetConfig({ sender: "MANAGERADDRESS", assetId: 123456n, manager: "MANAGERADDRESS" })
136
- * ```
137
- * @example Advanced example
138
- * ```typescript
139
- * await algorand.send.assetConfig({
140
- * sender: 'MANAGERADDRESS',
141
- * assetId: 123456n,
142
- * manager: 'MANAGERADDRESS',
143
- * reserve: 'RESERVEADDRESS',
144
- * freeze: 'FREEZEADDRESS',
145
- * clawback: 'CLAWBACKADDRESS',
146
- * lease: 'lease',
147
- * note: 'note',
148
- * // You wouldn't normally set this field
149
- * firstValidRound: 1000n,
150
- * validityWindow: 10,
151
- * extraFee: (1000).microAlgo(),
152
- * staticFee: (1000).microAlgo(),
153
- * // Max fee doesn't make sense with extraFee AND staticFee
154
- * // already specified, but here for completeness
155
- * maxFee: (3000).microAlgo(),
156
- * // Signer only needed if you want to provide one,
157
- * // generally you'd register it with AlgorandClient
158
- * // against the sender and not need to pass it in
159
- * signer: transactionSigner,
160
- * maxRoundsToWaitForConfirmation: 5,
161
- * suppressLog: true,
162
- * })
163
- * ```
164
- * @returns The result of the asset config transaction and the transaction that was sent
165
- */
166
- this.assetConfig = this._send((c) => c.addAssetConfig, {
167
- preLog: (params, transaction) => `Configuring asset with ID ${params.assetId} via transaction ${transaction.txID()}`,
168
- });
169
- /**
170
- * Freeze or unfreeze an Algorand Standard Asset for an account.
171
- *
172
- * @param params The parameters for the asset freeze transaction
173
- *
174
- * @example Basic example
175
- * ```typescript
176
- * await algorand.send.assetFreeze({ sender: "MANAGERADDRESS", assetId: 123456n, account: "ACCOUNTADDRESS", frozen: true })
177
- * ```
178
- * @example Advanced example
179
- * ```typescript
180
- * await algorand.send.assetFreeze({
181
- * sender: 'MANAGERADDRESS',
182
- * assetId: 123456n,
183
- * account: 'ACCOUNTADDRESS',
184
- * frozen: true,
185
- * lease: 'lease',
186
- * note: 'note',
187
- * // You wouldn't normally set this field
188
- * firstValidRound: 1000n,
189
- * validityWindow: 10,
190
- * extraFee: (1000).microAlgo(),
191
- * staticFee: (1000).microAlgo(),
192
- * // Max fee doesn't make sense with extraFee AND staticFee
193
- * // already specified, but here for completeness
194
- * maxFee: (3000).microAlgo(),
195
- * // Signer only needed if you want to provide one,
196
- * // generally you'd register it with AlgorandClient
197
- * // against the sender and not need to pass it in
198
- * signer: transactionSigner,
199
- * maxRoundsToWaitForConfirmation: 5,
200
- * suppressLog: true,
201
- * })
202
- * ```
203
- * @returns The result of the asset freeze transaction and the transaction that was sent
204
- */
205
- this.assetFreeze = this._send((c) => c.addAssetFreeze, {
206
- preLog: (params, transaction) => `Freezing asset with ID ${params.assetId} via transaction ${transaction.txID()}`,
207
- });
208
- /**
209
- * Destroys an Algorand Standard Asset.
210
- *
211
- * Created assets can be destroyed only by the asset manager account.
212
- * All of the assets must be owned by the creator of the asset before
213
- * the asset can be deleted.
214
- *
215
- * @param params The parameters for the asset destroy transaction
216
- *
217
- * @example Basic example
218
- * ```typescript
219
- * await algorand.send.assetDestroy({ sender: "MANAGERADDRESS", assetId: 123456n })
220
- * ```
221
- * @example Advanced example
222
- * ```typescript
223
- * await algorand.send.assetDestroy({
224
- * sender: 'MANAGERADDRESS',
225
- * assetId: 123456n,
226
- * lease: 'lease',
227
- * note: 'note',
228
- * // You wouldn't normally set this field
229
- * firstValidRound: 1000n,
230
- * validityWindow: 10,
231
- * extraFee: (1000).microAlgo(),
232
- * staticFee: (1000).microAlgo(),
233
- * // Max fee doesn't make sense with extraFee AND staticFee
234
- * // already specified, but here for completeness
235
- * maxFee: (3000).microAlgo(),
236
- * // Signer only needed if you want to provide one,
237
- * // generally you'd register it with AlgorandClient
238
- * // against the sender and not need to pass it in
239
- * signer: transactionSigner,
240
- * maxRoundsToWaitForConfirmation: 5,
241
- * suppressLog: true,
242
- * })
243
- * ```
244
- * @returns The result of the asset destroy transaction and the transaction that was sent
245
- */
246
- this.assetDestroy = this._send((c) => c.addAssetDestroy, {
247
- preLog: (params, transaction) => `Destroying asset with ID ${params.assetId} via transaction ${transaction.txID()}`,
248
- });
249
- /**
250
- * Transfer an Algorand Standard Asset.
251
- *
252
- * @param params The parameters for the asset transfer transaction
253
- *
254
- * @example Basic example
255
- * ```typescript
256
- * await algorand.send.assetTransfer({ sender: "HOLDERADDRESS", assetId: 123456n, amount: 1n, receiver: "RECEIVERADDRESS" })
257
- * ```
258
- * @example Advanced example (with clawback)
259
- * ```typescript
260
- * await algorand.send.assetTransfer({
261
- * sender: 'CLAWBACKADDRESS',
262
- * assetId: 123456n,
263
- * amount: 1n,
264
- * receiver: 'RECEIVERADDRESS',
265
- * clawbackTarget: 'HOLDERADDRESS',
266
- * // This field needs to be used with caution
267
- * closeAssetTo: 'ADDRESSTOCLOSETO'
268
- * lease: 'lease',
269
- * note: 'note',
270
- * // You wouldn't normally set this field
271
- * firstValidRound: 1000n,
272
- * validityWindow: 10,
273
- * extraFee: (1000).microAlgo(),
274
- * staticFee: (1000).microAlgo(),
275
- * // Max fee doesn't make sense with extraFee AND staticFee
276
- * // already specified, but here for completeness
277
- * maxFee: (3000).microAlgo(),
278
- * // Signer only needed if you want to provide one,
279
- * // generally you'd register it with AlgorandClient
280
- * // against the sender and not need to pass it in
281
- * signer: transactionSigner,
282
- * maxRoundsToWaitForConfirmation: 5,
283
- * suppressLog: true,
284
- * })
285
- * ```
286
- * @returns The result of the asset transfer transaction and the transaction that was sent
287
- */
288
- this.assetTransfer = this._send((c) => c.addAssetTransfer, {
289
- preLog: (params, transaction) => `Transferring ${params.amount} units of asset with ID ${params.assetId} from ${params.sender} to ${params.receiver} via transaction ${transaction.txID()}`,
290
- });
291
- /**
292
- * Opt an account into an Algorand Standard Asset.
293
- *
294
- * @param params The parameters for the asset opt-in transaction
295
- *
296
- * @example Basic example
297
- * ```typescript
298
- * await algorand.send.assetOptIn({ sender: "SENDERADDRESS", assetId: 123456n })
299
- * ```
300
- * @example Advanced example
301
- * ```typescript
302
- * await algorand.send.assetOptIn({
303
- * sender: 'SENDERADDRESS',
304
- * assetId: 123456n,
305
- * lease: 'lease',
306
- * note: 'note',
307
- * // You wouldn't normally set this field
308
- * firstValidRound: 1000n,
309
- * validityWindow: 10,
310
- * extraFee: (1000).microAlgo(),
311
- * staticFee: (1000).microAlgo(),
312
- * // Max fee doesn't make sense with extraFee AND staticFee
313
- * // already specified, but here for completeness
314
- * maxFee: (3000).microAlgo(),
315
- * // Signer only needed if you want to provide one,
316
- * // generally you'd register it with AlgorandClient
317
- * // against the sender and not need to pass it in
318
- * signer: transactionSigner,
319
- * maxRoundsToWaitForConfirmation: 5,
320
- * suppressLog: true,
321
- * })
322
- * ```
323
- * @returns The result of the asset opt-in transaction and the transaction that was sent
324
- */
325
- this.assetOptIn = this._send((c) => c.addAssetOptIn, {
326
- preLog: (params, transaction) => `Opting in ${params.sender} to asset with ID ${params.assetId} via transaction ${transaction.txID()}`,
327
- });
328
- /**
329
- * Opt an account out of an Algorand Standard Asset.
330
- *
331
- * *Note:* If the account has a balance of the asset,
332
- * it will not be able to opt-out unless `ensureZeroBalance`
333
- * is set to `false` (but then the account will lose the assets).
334
- *
335
- * @param params The parameters for the asset opt-out transaction
336
- *
337
- * @example Basic example (without creator, will be retrieved from algod)
338
- * ```typescript
339
- * await algorand.send.assetOptOut({ sender: "SENDERADDRESS", assetId: 123456n, ensureZeroBalance: true })
340
- * ```
341
- * @example Basic example (with creator)
342
- * ```typescript
343
- * await algorand.send.assetOptOut({ sender: "SENDERADDRESS", creator: "CREATORADDRESS", assetId: 123456n, ensureZeroBalance: true })
344
- * ```
345
- * @example Advanced example
346
- * ```typescript
347
- * await algorand.send.assetOptOut({
348
- * sender: 'SENDERADDRESS',
349
- * assetId: 123456n,
350
- * creator: 'CREATORADDRESS',
351
- * ensureZeroBalance: true,
352
- * lease: 'lease',
353
- * note: 'note',
354
- * // You wouldn't normally set this field
355
- * firstValidRound: 1000n,
356
- * validityWindow: 10,
357
- * extraFee: (1000).microAlgo(),
358
- * staticFee: (1000).microAlgo(),
359
- * // Max fee doesn't make sense with extraFee AND staticFee
360
- * // already specified, but here for completeness
361
- * maxFee: (3000).microAlgo(),
362
- * // Signer only needed if you want to provide one,
363
- * // generally you'd register it with AlgorandClient
364
- * // against the sender and not need to pass it in
365
- * signer: transactionSigner,
366
- * maxRoundsToWaitForConfirmation: 5,
367
- * suppressLog: true,
368
- * })
369
- * ```
370
- * @returns The result of the asset opt-out transaction and the transaction that was sent
371
- */
372
- this.assetOptOut = async (params) => {
373
- if (params.ensureZeroBalance) {
374
- let balance = 0n;
375
- try {
376
- const accountAssetInfo = await this._assetManager.getAccountInformation(params.sender, params.assetId);
377
- balance = accountAssetInfo.balance;
378
- }
379
- catch {
380
- throw new Error(`Account ${params.sender} is not opted-in to Asset ${params.assetId}; can't opt-out.`);
381
- }
382
- if (balance !== 0n) {
383
- throw new Error(`Account ${params.sender} does not have a zero balance for Asset ${params.assetId}; can't opt-out.`);
384
- }
385
- }
386
- params.creator = params.creator ?? (await this._assetManager.getById(params.assetId)).creator;
387
- return await this._send((c) => c.addAssetOptOut, {
388
- preLog: (params, transaction) => `Opting ${params.sender} out of asset with ID ${params.assetId} to creator ${params.creator} via transaction ${transaction.txID()}`,
389
- })(params);
390
- };
391
- /**
392
- * Create a smart contract.
393
- *
394
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
395
- *
396
- * @param params The parameters for the app creation transaction
397
- * @example Basic example
398
- * ```typescript
399
- * const result = await algorand.send.appCreate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
400
- * const createdAppId = result.appId
401
- * ```
402
- * @example Advanced example
403
- * ```typescript
404
- * await algorand.send.appCreate({
405
- * sender: 'CREATORADDRESS',
406
- * approvalProgram: "TEALCODE",
407
- * clearStateProgram: "TEALCODE",
408
- * schema: {
409
- * globalInts: 1,
410
- * globalByteSlices: 2,
411
- * localInts: 3,
412
- * localByteSlices: 4
413
- * },
414
- * extraProgramPages: 1,
415
- * onComplete: algosdk.OnApplicationComplete.OptInOC,
416
- * args: [new Uint8Array(1, 2, 3, 4)]
417
- * accountReferences: ["ACCOUNT_1"]
418
- * appReferences: [123n, 1234n]
419
- * assetReferences: [12345n]
420
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
421
- * accessReferences: [{ appId: 1234n }]
422
- * lease: 'lease',
423
- * note: 'note',
424
- * // You wouldn't normally set this field
425
- * firstValidRound: 1000n,
426
- * validityWindow: 10,
427
- * extraFee: (1000).microAlgo(),
428
- * staticFee: (1000).microAlgo(),
429
- * // Max fee doesn't make sense with extraFee AND staticFee
430
- * // already specified, but here for completeness
431
- * maxFee: (3000).microAlgo(),
432
- * // Signer only needed if you want to provide one,
433
- * // generally you'd register it with AlgorandClient
434
- * // against the sender and not need to pass it in
435
- * signer: transactionSigner,
436
- * maxRoundsToWaitForConfirmation: 5,
437
- * suppressLog: true,
438
- *})
439
- * ```
440
- * @returns The result of the app create transaction and the transaction that was sent
441
- */
442
- this.appCreate = this._sendAppCreateCall((c) => c.addAppCreate, {
443
- postLog: (params, result) => `App created by ${params.sender} with ID ${result.confirmation.applicationIndex} via transaction ${result.txIds.at(-1)}`,
444
- });
445
- /**
446
- * Update a smart contract.
447
- *
448
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
449
- *
450
- * @param params The parameters for the app update transaction
451
- * @example Basic example
452
- * ```typescript
453
- * await algorand.send.appUpdate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
454
- * ```
455
- * @example Advanced example
456
- * ```typescript
457
- * await algorand.send.appUpdate({
458
- * sender: 'CREATORADDRESS',
459
- * approvalProgram: "TEALCODE",
460
- * clearStateProgram: "TEALCODE",
461
- * onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
462
- * args: [new Uint8Array(1, 2, 3, 4)]
463
- * accountReferences: ["ACCOUNT_1"]
464
- * appReferences: [123n, 1234n]
465
- * assetReferences: [12345n]
466
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
467
- * accessReferences: [{ appId: 1234n }]
468
- * lease: 'lease',
469
- * note: 'note',
470
- * // You wouldn't normally set this field
471
- * firstValidRound: 1000n,
472
- * validityWindow: 10,
473
- * extraFee: (1000).microAlgo(),
474
- * staticFee: (1000).microAlgo(),
475
- * // Max fee doesn't make sense with extraFee AND staticFee
476
- * // already specified, but here for completeness
477
- * maxFee: (3000).microAlgo(),
478
- * // Signer only needed if you want to provide one,
479
- * // generally you'd register it with AlgorandClient
480
- * // against the sender and not need to pass it in
481
- * signer: transactionSigner,
482
- * maxRoundsToWaitForConfirmation: 5,
483
- * suppressLog: true,
484
- *})
485
- * ```
486
- * @returns The result of the app update transaction and the transaction that was sent
487
- */
488
- this.appUpdate = this._sendAppUpdateCall((c) => c.addAppUpdate, {
489
- postLog: (params, result) => `App ${params.appId} updated ${params.args ? ` with ${params.args.map((a) => Buffer.from(a).toString('base64'))}` : ''} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
490
- });
491
- /**
492
- * Delete a smart contract.
493
- *
494
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
495
- *
496
- * @param params The parameters for the app deletion transaction
497
- * @example Basic example
498
- * ```typescript
499
- * await algorand.send.appDelete({ sender: 'CREATORADDRESS' })
500
- * ```
501
- * @example Advanced example
502
- * ```typescript
503
- * await algorand.send.appDelete({
504
- * sender: 'CREATORADDRESS',
505
- * onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
506
- * args: [new Uint8Array(1, 2, 3, 4)]
507
- * accountReferences: ["ACCOUNT_1"]
508
- * appReferences: [123n, 1234n]
509
- * assetReferences: [12345n]
510
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
511
- * accessReferences: [{ appId: 1234n }]
512
- * lease: 'lease',
513
- * note: 'note',
514
- * // You wouldn't normally set this field
515
- * firstValidRound: 1000n,
516
- * validityWindow: 10,
517
- * extraFee: (1000).microAlgo(),
518
- * staticFee: (1000).microAlgo(),
519
- * // Max fee doesn't make sense with extraFee AND staticFee
520
- * // already specified, but here for completeness
521
- * maxFee: (3000).microAlgo(),
522
- * // Signer only needed if you want to provide one,
523
- * // generally you'd register it with AlgorandClient
524
- * // against the sender and not need to pass it in
525
- * signer: transactionSigner,
526
- * maxRoundsToWaitForConfirmation: 5,
527
- * suppressLog: true,
528
- *})
529
- * ```
530
- * @returns The result of the app delete transaction and the transaction that was sent
531
- */
532
- this.appDelete = this._sendAppCall((c) => c.addAppDelete, {
533
- postLog: (params, result) => `App ${params.appId} deleted ${params.args ? ` with ${params.args.map((a) => Buffer.from(a).toString('base64'))}` : ''} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
534
- });
535
- /**
536
- * Call a smart contract.
537
- *
538
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
539
- *
540
- * @param params The parameters for the app call transaction
541
- * @example Basic example
542
- * ```typescript
543
- * await algorand.send.appCall({ sender: 'CREATORADDRESS' })
544
- * ```
545
- * @example Advanced example
546
- * ```typescript
547
- * await algorand.send.appCall({
548
- * sender: 'CREATORADDRESS',
549
- * onComplete: algosdk.OnApplicationComplete.OptInOC,
550
- * args: [new Uint8Array(1, 2, 3, 4)]
551
- * accountReferences: ["ACCOUNT_1"]
552
- * appReferences: [123n, 1234n]
553
- * assetReferences: [12345n]
554
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
555
- * accessReferences: [{ appId: 1234n }]
556
- * lease: 'lease',
557
- * note: 'note',
558
- * // You wouldn't normally set this field
559
- * firstValidRound: 1000n,
560
- * validityWindow: 10,
561
- * extraFee: (1000).microAlgo(),
562
- * staticFee: (1000).microAlgo(),
563
- * // Max fee doesn't make sense with extraFee AND staticFee
564
- * // already specified, but here for completeness
565
- * maxFee: (3000).microAlgo(),
566
- * // Signer only needed if you want to provide one,
567
- * // generally you'd register it with AlgorandClient
568
- * // against the sender and not need to pass it in
569
- * signer: transactionSigner,
570
- * maxRoundsToWaitForConfirmation: 5,
571
- * suppressLog: true,
572
- *})
573
- * ```
574
- * @returns The result of the app call transaction and the transaction that was sent
575
- */
576
- this.appCall = this._sendAppCall((c) => c.addAppCall, {
577
- postLog: (params, result) => `App ${params.appId} called ${params.args ? ` with ${params.args.map((a) => Buffer.from(a).toString('base64'))}` : ''} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
578
- });
579
- /**
580
- * Create a smart contract via an ABI method.
581
- *
582
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
583
- *
584
- * @param params The parameters for the app creation transaction
585
- * @example Basic example
586
- * ```typescript
587
- * const method = new ABIMethod({
588
- * name: 'method',
589
- * args: [{ name: 'arg1', type: 'string' }],
590
- * returns: { type: 'string' },
591
- * })
592
- * const result = await algorand.send.appCreateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
593
- * const createdAppId = result.appId
594
- * ```
595
- * @example Advanced example
596
- * ```typescript
597
- * const method = new ABIMethod({
598
- * name: 'method',
599
- * args: [{ name: 'arg1', type: 'string' }],
600
- * returns: { type: 'string' },
601
- * })
602
- * await algorand.send.appCreateMethodCall({
603
- * sender: 'CREATORADDRESS',
604
- * method: method,
605
- * args: ["arg1_value"],
606
- * approvalProgram: "TEALCODE",
607
- * clearStateProgram: "TEALCODE",
608
- * schema: {
609
- * globalInts: 1,
610
- * globalByteSlices: 2,
611
- * localInts: 3,
612
- * localByteSlices: 4
613
- * },
614
- * extraProgramPages: 1,
615
- * onComplete: algosdk.OnApplicationComplete.OptInOC,
616
- * args: [new Uint8Array(1, 2, 3, 4)]
617
- * accountReferences: ["ACCOUNT_1"]
618
- * appReferences: [123n, 1234n]
619
- * assetReferences: [12345n]
620
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
621
- * accessReferences: [{ appId: 1234n }]
622
- * lease: 'lease',
623
- * note: 'note',
624
- * // You wouldn't normally set this field
625
- * firstValidRound: 1000n,
626
- * validityWindow: 10,
627
- * extraFee: (1000).microAlgo(),
628
- * staticFee: (1000).microAlgo(),
629
- * // Max fee doesn't make sense with extraFee AND staticFee
630
- * // already specified, but here for completeness
631
- * maxFee: (3000).microAlgo(),
632
- * // Signer only needed if you want to provide one,
633
- * // generally you'd register it with AlgorandClient
634
- * // against the sender and not need to pass it in
635
- * signer: transactionSigner,
636
- * maxRoundsToWaitForConfirmation: 5,
637
- * suppressLog: true,
638
- *})
639
- * ```
640
- * @returns The result of the application ABI method create transaction and the transaction that was sent
641
- */
642
- this.appCreateMethodCall = this._sendAppCreateCall((c) => c.addAppCreateMethodCall, {
643
- postLog: (params, result) => `App created by ${params.sender} with ID ${result.confirmation.applicationIndex} via transaction ${result.txIds.at(-1)}`,
644
- });
645
- /**
646
- * Update a smart contract via an ABI method.
647
- *
648
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
649
- *
650
- * @param params The parameters for the app update transaction
651
- * @example Basic example
652
- * ```typescript
653
- * const method = new ABIMethod({
654
- * name: 'method',
655
- * args: [{ name: 'arg1', type: 'string' }],
656
- * returns: { type: 'string' },
657
- * })
658
- * await algorand.send.appUpdateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
659
- * ```
660
- * @example Advanced example
661
- * ```typescript
662
- * const method = new ABIMethod({
663
- * name: 'method',
664
- * args: [{ name: 'arg1', type: 'string' }],
665
- * returns: { type: 'string' },
666
- * })
667
- * await algorand.send.appUpdateMethodCall({
668
- * sender: 'CREATORADDRESS',
669
- * method: method,
670
- * args: ["arg1_value"],
671
- * approvalProgram: "TEALCODE",
672
- * clearStateProgram: "TEALCODE",
673
- * onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
674
- * args: [new Uint8Array(1, 2, 3, 4)]
675
- * accountReferences: ["ACCOUNT_1"]
676
- * appReferences: [123n, 1234n]
677
- * assetReferences: [12345n]
678
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
679
- * accessReferences: [{ appId: 1234n }]
680
- * lease: 'lease',
681
- * note: 'note',
682
- * // You wouldn't normally set this field
683
- * firstValidRound: 1000n,
684
- * validityWindow: 10,
685
- * extraFee: (1000).microAlgo(),
686
- * staticFee: (1000).microAlgo(),
687
- * // Max fee doesn't make sense with extraFee AND staticFee
688
- * // already specified, but here for completeness
689
- * maxFee: (3000).microAlgo(),
690
- * // Signer only needed if you want to provide one,
691
- * // generally you'd register it with AlgorandClient
692
- * // against the sender and not need to pass it in
693
- * signer: transactionSigner,
694
- * maxRoundsToWaitForConfirmation: 5,
695
- * suppressLog: true,
696
- *})
697
- * ```
698
- * @returns The result of the application ABI method update transaction and the transaction that was sent
699
- */
700
- this.appUpdateMethodCall = this._sendAppUpdateCall((c) => c.addAppUpdateMethodCall, {
701
- postLog: (params, result) => `App ${params.appId} updated with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
702
- });
703
- /**
704
- * Delete a smart contract via an ABI method.
705
- *
706
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
707
- *
708
- * @param params The parameters for the app deletion transaction
709
- * @example Basic example
710
- * ```typescript
711
- * const method = new ABIMethod({
712
- * name: 'method',
713
- * args: [{ name: 'arg1', type: 'string' }],
714
- * returns: { type: 'string' },
715
- * })
716
- * await algorand.send.appDeleteMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
717
- * ```
718
- * @example Advanced example
719
- * ```typescript
720
- * const method = new ABIMethod({
721
- * name: 'method',
722
- * args: [{ name: 'arg1', type: 'string' }],
723
- * returns: { type: 'string' },
724
- * })
725
- * await algorand.send.appDeleteMethodCall({
726
- * sender: 'CREATORADDRESS',
727
- * method: method,
728
- * args: ["arg1_value"],
729
- * onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
730
- * args: [new Uint8Array(1, 2, 3, 4)]
731
- * accountReferences: ["ACCOUNT_1"]
732
- * appReferences: [123n, 1234n]
733
- * assetReferences: [12345n]
734
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
735
- * accessReferences: [{ appId: 1234n }]
736
- * lease: 'lease',
737
- * note: 'note',
738
- * // You wouldn't normally set this field
739
- * firstValidRound: 1000n,
740
- * validityWindow: 10,
741
- * extraFee: (1000).microAlgo(),
742
- * staticFee: (1000).microAlgo(),
743
- * // Max fee doesn't make sense with extraFee AND staticFee
744
- * // already specified, but here for completeness
745
- * maxFee: (3000).microAlgo(),
746
- * // Signer only needed if you want to provide one,
747
- * // generally you'd register it with AlgorandClient
748
- * // against the sender and not need to pass it in
749
- * signer: transactionSigner,
750
- * maxRoundsToWaitForConfirmation: 5,
751
- * suppressLog: true,
752
- *})
753
- * ```
754
- * @returns The result of the application ABI method delete transaction and the transaction that was sent
755
- */
756
- this.appDeleteMethodCall = this._sendAppCall((c) => c.addAppDeleteMethodCall, {
757
- postLog: (params, result) => `App ${params.appId} deleted with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
758
- });
759
- /**
760
- * Call a smart contract via an ABI method.
761
- *
762
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
763
- *
764
- * @param params The parameters for the app call transaction
765
- * @example Basic example
766
- * ```typescript
767
- * const method = new ABIMethod({
768
- * name: 'method',
769
- * args: [{ name: 'arg1', type: 'string' }],
770
- * returns: { type: 'string' },
771
- * })
772
- * await algorand.send.appCallMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
773
- * ```
774
- * @example Advanced example
775
- * ```typescript
776
- * const method = new ABIMethod({
777
- * name: 'method',
778
- * args: [{ name: 'arg1', type: 'string' }],
779
- * returns: { type: 'string' },
780
- * })
781
- * await algorand.send.appCallMethodCall({
782
- * sender: 'CREATORADDRESS',
783
- * method: method,
784
- * args: ["arg1_value"],
785
- * onComplete: algosdk.OnApplicationComplete.OptInOC,
786
- * args: [new Uint8Array(1, 2, 3, 4)]
787
- * accountReferences: ["ACCOUNT_1"]
788
- * appReferences: [123n, 1234n]
789
- * assetReferences: [12345n]
790
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
791
- * accessReferences: [{ appId: 1234n }]
792
- * lease: 'lease',
793
- * note: 'note',
794
- * // You wouldn't normally set this field
795
- * firstValidRound: 1000n,
796
- * validityWindow: 10,
797
- * extraFee: (1000).microAlgo(),
798
- * staticFee: (1000).microAlgo(),
799
- * // Max fee doesn't make sense with extraFee AND staticFee
800
- * // already specified, but here for completeness
801
- * maxFee: (3000).microAlgo(),
802
- * // Signer only needed if you want to provide one,
803
- * // generally you'd register it with AlgorandClient
804
- * // against the sender and not need to pass it in
805
- * signer: transactionSigner,
806
- * maxRoundsToWaitForConfirmation: 5,
807
- * suppressLog: true,
808
- *})
809
- * ```
810
- * @returns The result of the application ABI method call transaction and the transaction that was sent
811
- */
812
- this.appCallMethodCall = this._sendAppCall((c) => c.addAppCallMethodCall, {
813
- postLog: (params, result) => `App ${params.appId} called with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
814
- });
815
- /**
816
- * Register an online key.
817
- * @param params The parameters for the key registration transaction
818
- * @example Basic example
819
- * ```typescript
820
- * const result = await algorand.send.onlineKeyRegistration({
821
- * sender: 'SENDERADDRESS',
822
- * voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
823
- * selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
824
- * stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
825
- * voteFirst: 1n,
826
- * voteLast: 1000n,
827
- * voteKeyDilution: 1n,
828
- * })
829
- * ```
830
- * @example Advanced example
831
- * ```typescript
832
- * const result = await algorand.send.onlineKeyRegistration({
833
- * sender: 'SENDERADDRESS',
834
- * voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
835
- * selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
836
- * stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
837
- * voteFirst: 1n,
838
- * voteLast: 1000n,
839
- * voteKeyDilution: 1n,
840
- * lease: 'lease',
841
- * note: 'note',
842
- * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
843
- * rekeyTo: 'REKEYTOADDRESS',
844
- * // You wouldn't normally set this field
845
- * firstValidRound: 1000n,
846
- * validityWindow: 10,
847
- * extraFee: (1000).microAlgo(),
848
- * staticFee: (1000).microAlgo(),
849
- * // Max fee doesn't make sense with extraFee AND staticFee
850
- * // already specified, but here for completeness
851
- * maxFee: (3000).microAlgo(),
852
- * })
853
- * ```
854
- * @returns The result of the online key registration transaction and the transaction that was sent
855
- */
856
- this.onlineKeyRegistration = this._send((c) => c.addOnlineKeyRegistration, {
857
- preLog: (params, transaction) => `Registering online key for ${params.sender} via transaction ${transaction.txID()}`,
858
- });
859
- /**
860
- * Register an offline key.
861
- * @param params The parameters for the key registration transaction
862
- * @example Basic example
863
- * ```typescript
864
- * const result = await algorand.send.offlineKeyRegistration({
865
- * sender: 'SENDERADDRESS',
866
- * })
867
- * ```
868
- * @example Advanced example
869
- * ```typescript
870
- * const result = await algorand.send.offlineKeyRegistration({
871
- * sender: 'SENDERADDRESS',
872
- * lease: 'lease',
873
- * note: 'note',
874
- * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
875
- * rekeyTo: 'REKEYTOADDRESS',
876
- * // You wouldn't normally set this field
877
- * firstValidRound: 1000n,
878
- * validityWindow: 10,
879
- * extraFee: (1000).microAlgo(),
880
- * staticFee: (1000).microAlgo(),
881
- * // Max fee doesn't make sense with extraFee AND staticFee
882
- * // already specified, but here for completeness
883
- * maxFee: (3000).microAlgo(),
884
- * })
885
- * ```
886
- * @returns The result of the offline key registration transaction and the transaction that was sent
887
- */
888
- this.offlineKeyRegistration = this._send((c) => c.addOfflineKeyRegistration, {
889
- preLog: (params, transaction) => `Registering offline key for ${params.sender} via transaction ${transaction.txID()}`,
890
- });
891
- this._newGroup = newGroup;
892
- this._assetManager = assetManager;
893
- this._appManager = appManager;
894
- }
895
- /**
896
- * Start a new `TransactionComposer` transaction group
897
- * @returns A new instance of `TransactionComposer`.
898
- * @example
899
- * const composer = AlgorandClient.mainNet().send.newGroup();
900
- * const result = await composer.addTransaction(payment).send()
901
- */
902
- newGroup() {
903
- return this._newGroup();
904
- }
905
- _send(c, log) {
906
- return async (params) => {
907
- const composer = this._newGroup();
908
- // Ensure `this` is properly populated
909
- c(composer).apply(composer, [params]);
910
- if (log?.preLog) {
911
- const transaction = (await composer.build()).transactions.at(-1).txn;
912
- Config.getLogger(params?.suppressLog).debug(log.preLog(params, transaction));
913
- }
914
- const rawResult = await composer.send(params);
915
- const result = {
916
- // Last item covers when a group is created by an app call with ABI transaction parameters
917
- transaction: rawResult.transactions.at(-1),
918
- confirmation: rawResult.confirmations.at(-1),
919
- txId: rawResult.txIds.at(-1),
920
- ...rawResult,
921
- };
922
- if (log?.postLog) {
923
- Config.getLogger(params?.suppressLog).debug(log.postLog(params, result));
924
- }
925
- return result;
926
- };
927
- }
928
- _sendAppCall(c, log) {
929
- return async (params) => {
930
- const result = await this._send(c, log)(params);
931
- return { ...result, return: AppManager.getABIReturn(result.confirmation, 'method' in params ? params.method : undefined) };
932
- };
933
- }
934
- _sendAppUpdateCall(c, log) {
935
- return async (params) => {
936
- const result = await this._sendAppCall(c, log)(params);
937
- const compiledApproval = typeof params.approvalProgram === 'string' ? this._appManager.getCompilationResult(params.approvalProgram) : undefined;
938
- const compiledClear = typeof params.clearStateProgram === 'string' ? this._appManager.getCompilationResult(params.clearStateProgram) : undefined;
939
- return { ...result, compiledApproval, compiledClear };
940
- };
941
- }
942
- _sendAppCreateCall(c, log) {
943
- return async (params) => {
944
- const result = await this._sendAppUpdateCall(c, log)(params);
945
- return {
946
- ...result,
947
- appId: BigInt(result.confirmation.applicationIndex),
948
- appAddress: algosdk.getApplicationAddress(result.confirmation.applicationIndex),
949
- };
950
- };
951
- }
952
- }
953
-
14
+ var AlgorandClientTransactionSender = class {
15
+ _newGroup;
16
+ _assetManager;
17
+ _appManager;
18
+ /**
19
+ * Creates a new `AlgorandClientSender`
20
+ * @param newGroup A lambda that starts a new `TransactionComposer` transaction group
21
+ * @param assetManager An `AssetManager` instance
22
+ * @param appManager An `AppManager` instance
23
+ * @example
24
+ * ```typescript
25
+ * const transactionSender = new AlgorandClientTransactionSender(() => new TransactionComposer(), assetManager, appManager)
26
+ * ```
27
+ */
28
+ constructor(newGroup, assetManager, appManager) {
29
+ this._newGroup = newGroup;
30
+ this._assetManager = assetManager;
31
+ this._appManager = appManager;
32
+ }
33
+ /**
34
+ * Start a new `TransactionComposer` transaction group
35
+ * @returns A new instance of `TransactionComposer`.
36
+ * @example
37
+ * const composer = AlgorandClient.mainNet().send.newGroup();
38
+ * const result = await composer.addTransaction(payment).send()
39
+ */
40
+ newGroup() {
41
+ return this._newGroup();
42
+ }
43
+ _send(c, log) {
44
+ return async (params) => {
45
+ const composer = this._newGroup();
46
+ c(composer).apply(composer, [params]);
47
+ if (log?.preLog) {
48
+ const transaction = (await composer.build()).transactions.at(-1).txn;
49
+ Config.getLogger(params?.suppressLog).debug(log.preLog(params, transaction));
50
+ }
51
+ const rawResult = await composer.send(params);
52
+ const result = {
53
+ transaction: rawResult.transactions.at(-1),
54
+ confirmation: rawResult.confirmations.at(-1),
55
+ txId: rawResult.txIds.at(-1),
56
+ ...rawResult
57
+ };
58
+ if (log?.postLog) Config.getLogger(params?.suppressLog).debug(log.postLog(params, result));
59
+ return result;
60
+ };
61
+ }
62
+ _sendAppCall(c, log) {
63
+ return async (params) => {
64
+ const result = await this._send(c, log)(params);
65
+ return {
66
+ ...result,
67
+ return: AppManager.getABIReturn(result.confirmation, "method" in params ? params.method : void 0)
68
+ };
69
+ };
70
+ }
71
+ _sendAppUpdateCall(c, log) {
72
+ return async (params) => {
73
+ const result = await this._sendAppCall(c, log)(params);
74
+ const compiledApproval = typeof params.approvalProgram === "string" ? this._appManager.getCompilationResult(params.approvalProgram) : void 0;
75
+ const compiledClear = typeof params.clearStateProgram === "string" ? this._appManager.getCompilationResult(params.clearStateProgram) : void 0;
76
+ return {
77
+ ...result,
78
+ compiledApproval,
79
+ compiledClear
80
+ };
81
+ };
82
+ }
83
+ _sendAppCreateCall(c, log) {
84
+ return async (params) => {
85
+ const result = await this._sendAppUpdateCall(c, log)(params);
86
+ return {
87
+ ...result,
88
+ appId: BigInt(result.confirmation.applicationIndex),
89
+ appAddress: algosdk.getApplicationAddress(result.confirmation.applicationIndex)
90
+ };
91
+ };
92
+ }
93
+ /**
94
+ * Send a payment transaction to transfer Algo between accounts.
95
+ * @param params The parameters for the payment transaction
96
+ * @example Basic example
97
+ * ```typescript
98
+ * const result = await algorand.send.payment({
99
+ * sender: 'SENDERADDRESS',
100
+ * receiver: 'RECEIVERADDRESS',
101
+ * amount: (4).algo(),
102
+ * })
103
+ * ```
104
+ * @example Advanced example
105
+ * ```typescript
106
+ * const result = await algorand.send.payment({
107
+ * amount: (4).algo(),
108
+ * receiver: 'RECEIVERADDRESS',
109
+ * sender: 'SENDERADDRESS',
110
+ * closeRemainderTo: 'CLOSEREMAINDERTOADDRESS',
111
+ * lease: 'lease',
112
+ * note: 'note',
113
+ * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
114
+ * rekeyTo: 'REKEYTOADDRESS',
115
+ * // You wouldn't normally set this field
116
+ * firstValidRound: 1000n,
117
+ * validityWindow: 10,
118
+ * extraFee: (1000).microAlgo(),
119
+ * staticFee: (1000).microAlgo(),
120
+ * // Max fee doesn't make sense with extraFee AND staticFee
121
+ * // already specified, but here for completeness
122
+ * maxFee: (3000).microAlgo(),
123
+ * // Signer only needed if you want to provide one,
124
+ * // generally you'd register it with AlgorandClient
125
+ * // against the sender and not need to pass it in
126
+ * signer: transactionSigner,
127
+ * maxRoundsToWaitForConfirmation: 5,
128
+ * suppressLog: true,
129
+ * })
130
+ * ```
131
+ * @returns The result of the payment transaction and the transaction that was sent
132
+ */
133
+ payment = this._send((c) => c.addPayment, { preLog: (params, transaction) => `Sending ${params.amount.microAlgo} µALGO from ${params.sender} to ${params.receiver} via transaction ${transaction.txID()}` });
134
+ /**
135
+ * Create a new Algorand Standard Asset.
136
+ *
137
+ * The account that sends this transaction will automatically be
138
+ * opted in to the asset and will hold all units after creation.
139
+ *
140
+ * @param params The parameters for the asset creation transaction
141
+ *
142
+ * @example Basic example
143
+ * ```typescript
144
+ * await algorand.send.assetCreate({ sender: "CREATORADDRESS", total: 100n})
145
+ * ```
146
+ * @example Advanced example
147
+ * ```typescript
148
+ * await algorand.send.assetCreate({
149
+ * sender: 'CREATORADDRESS',
150
+ * total: 100n,
151
+ * decimals: 2,
152
+ * assetName: 'asset',
153
+ * unitName: 'unit',
154
+ * url: 'url',
155
+ * metadataHash: 'metadataHash',
156
+ * defaultFrozen: false,
157
+ * manager: 'MANAGERADDRESS',
158
+ * reserve: 'RESERVEADDRESS',
159
+ * freeze: 'FREEZEADDRESS',
160
+ * clawback: 'CLAWBACKADDRESS',
161
+ * lease: 'lease',
162
+ * note: 'note',
163
+ * // You wouldn't normally set this field
164
+ * firstValidRound: 1000n,
165
+ * validityWindow: 10,
166
+ * extraFee: (1000).microAlgo(),
167
+ * staticFee: (1000).microAlgo(),
168
+ * // Max fee doesn't make sense with extraFee AND staticFee
169
+ * // already specified, but here for completeness
170
+ * maxFee: (3000).microAlgo(),
171
+ * // Signer only needed if you want to provide one,
172
+ * // generally you'd register it with AlgorandClient
173
+ * // against the sender and not need to pass it in
174
+ * signer: transactionSigner,
175
+ * maxRoundsToWaitForConfirmation: 5,
176
+ * suppressLog: true,
177
+ * })
178
+ * ```
179
+ * @returns The result of the asset create transaction and the transaction that was sent
180
+ */
181
+ assetCreate = async (params) => {
182
+ const result = await this._send((c) => c.addAssetCreate, { postLog: (params, result) => `Created asset${params.assetName ? ` ${params.assetName}` : ""}${params.unitName ? ` (${params.unitName})` : ""} with ${params.total} units and ${params.decimals ?? 0} decimals created by ${params.sender} with ID ${result.confirmation.assetIndex} via transaction ${result.txIds.at(-1)}` })(params);
183
+ return {
184
+ ...result,
185
+ assetId: BigInt(result.confirmation.assetIndex ?? 0)
186
+ };
187
+ };
188
+ /**
189
+ * Configure an existing Algorand Standard Asset.
190
+ *
191
+ * **Note:** The manager, reserve, freeze, and clawback addresses
192
+ * are immutably empty if they are not set. If manager is not set then
193
+ * all fields are immutable from that point forward.
194
+ *
195
+ * @param params The parameters for the asset config transaction
196
+ *
197
+ * @example Basic example
198
+ * ```typescript
199
+ * await algorand.send.assetConfig({ sender: "MANAGERADDRESS", assetId: 123456n, manager: "MANAGERADDRESS" })
200
+ * ```
201
+ * @example Advanced example
202
+ * ```typescript
203
+ * await algorand.send.assetConfig({
204
+ * sender: 'MANAGERADDRESS',
205
+ * assetId: 123456n,
206
+ * manager: 'MANAGERADDRESS',
207
+ * reserve: 'RESERVEADDRESS',
208
+ * freeze: 'FREEZEADDRESS',
209
+ * clawback: 'CLAWBACKADDRESS',
210
+ * lease: 'lease',
211
+ * note: 'note',
212
+ * // You wouldn't normally set this field
213
+ * firstValidRound: 1000n,
214
+ * validityWindow: 10,
215
+ * extraFee: (1000).microAlgo(),
216
+ * staticFee: (1000).microAlgo(),
217
+ * // Max fee doesn't make sense with extraFee AND staticFee
218
+ * // already specified, but here for completeness
219
+ * maxFee: (3000).microAlgo(),
220
+ * // Signer only needed if you want to provide one,
221
+ * // generally you'd register it with AlgorandClient
222
+ * // against the sender and not need to pass it in
223
+ * signer: transactionSigner,
224
+ * maxRoundsToWaitForConfirmation: 5,
225
+ * suppressLog: true,
226
+ * })
227
+ * ```
228
+ * @returns The result of the asset config transaction and the transaction that was sent
229
+ */
230
+ assetConfig = this._send((c) => c.addAssetConfig, { preLog: (params, transaction) => `Configuring asset with ID ${params.assetId} via transaction ${transaction.txID()}` });
231
+ /**
232
+ * Freeze or unfreeze an Algorand Standard Asset for an account.
233
+ *
234
+ * @param params The parameters for the asset freeze transaction
235
+ *
236
+ * @example Basic example
237
+ * ```typescript
238
+ * await algorand.send.assetFreeze({ sender: "MANAGERADDRESS", assetId: 123456n, account: "ACCOUNTADDRESS", frozen: true })
239
+ * ```
240
+ * @example Advanced example
241
+ * ```typescript
242
+ * await algorand.send.assetFreeze({
243
+ * sender: 'MANAGERADDRESS',
244
+ * assetId: 123456n,
245
+ * account: 'ACCOUNTADDRESS',
246
+ * frozen: true,
247
+ * lease: 'lease',
248
+ * note: 'note',
249
+ * // You wouldn't normally set this field
250
+ * firstValidRound: 1000n,
251
+ * validityWindow: 10,
252
+ * extraFee: (1000).microAlgo(),
253
+ * staticFee: (1000).microAlgo(),
254
+ * // Max fee doesn't make sense with extraFee AND staticFee
255
+ * // already specified, but here for completeness
256
+ * maxFee: (3000).microAlgo(),
257
+ * // Signer only needed if you want to provide one,
258
+ * // generally you'd register it with AlgorandClient
259
+ * // against the sender and not need to pass it in
260
+ * signer: transactionSigner,
261
+ * maxRoundsToWaitForConfirmation: 5,
262
+ * suppressLog: true,
263
+ * })
264
+ * ```
265
+ * @returns The result of the asset freeze transaction and the transaction that was sent
266
+ */
267
+ assetFreeze = this._send((c) => c.addAssetFreeze, { preLog: (params, transaction) => `Freezing asset with ID ${params.assetId} via transaction ${transaction.txID()}` });
268
+ /**
269
+ * Destroys an Algorand Standard Asset.
270
+ *
271
+ * Created assets can be destroyed only by the asset manager account.
272
+ * All of the assets must be owned by the creator of the asset before
273
+ * the asset can be deleted.
274
+ *
275
+ * @param params The parameters for the asset destroy transaction
276
+ *
277
+ * @example Basic example
278
+ * ```typescript
279
+ * await algorand.send.assetDestroy({ sender: "MANAGERADDRESS", assetId: 123456n })
280
+ * ```
281
+ * @example Advanced example
282
+ * ```typescript
283
+ * await algorand.send.assetDestroy({
284
+ * sender: 'MANAGERADDRESS',
285
+ * assetId: 123456n,
286
+ * lease: 'lease',
287
+ * note: 'note',
288
+ * // You wouldn't normally set this field
289
+ * firstValidRound: 1000n,
290
+ * validityWindow: 10,
291
+ * extraFee: (1000).microAlgo(),
292
+ * staticFee: (1000).microAlgo(),
293
+ * // Max fee doesn't make sense with extraFee AND staticFee
294
+ * // already specified, but here for completeness
295
+ * maxFee: (3000).microAlgo(),
296
+ * // Signer only needed if you want to provide one,
297
+ * // generally you'd register it with AlgorandClient
298
+ * // against the sender and not need to pass it in
299
+ * signer: transactionSigner,
300
+ * maxRoundsToWaitForConfirmation: 5,
301
+ * suppressLog: true,
302
+ * })
303
+ * ```
304
+ * @returns The result of the asset destroy transaction and the transaction that was sent
305
+ */
306
+ assetDestroy = this._send((c) => c.addAssetDestroy, { preLog: (params, transaction) => `Destroying asset with ID ${params.assetId} via transaction ${transaction.txID()}` });
307
+ /**
308
+ * Transfer an Algorand Standard Asset.
309
+ *
310
+ * @param params The parameters for the asset transfer transaction
311
+ *
312
+ * @example Basic example
313
+ * ```typescript
314
+ * await algorand.send.assetTransfer({ sender: "HOLDERADDRESS", assetId: 123456n, amount: 1n, receiver: "RECEIVERADDRESS" })
315
+ * ```
316
+ * @example Advanced example (with clawback)
317
+ * ```typescript
318
+ * await algorand.send.assetTransfer({
319
+ * sender: 'CLAWBACKADDRESS',
320
+ * assetId: 123456n,
321
+ * amount: 1n,
322
+ * receiver: 'RECEIVERADDRESS',
323
+ * clawbackTarget: 'HOLDERADDRESS',
324
+ * // This field needs to be used with caution
325
+ * closeAssetTo: 'ADDRESSTOCLOSETO'
326
+ * lease: 'lease',
327
+ * note: 'note',
328
+ * // You wouldn't normally set this field
329
+ * firstValidRound: 1000n,
330
+ * validityWindow: 10,
331
+ * extraFee: (1000).microAlgo(),
332
+ * staticFee: (1000).microAlgo(),
333
+ * // Max fee doesn't make sense with extraFee AND staticFee
334
+ * // already specified, but here for completeness
335
+ * maxFee: (3000).microAlgo(),
336
+ * // Signer only needed if you want to provide one,
337
+ * // generally you'd register it with AlgorandClient
338
+ * // against the sender and not need to pass it in
339
+ * signer: transactionSigner,
340
+ * maxRoundsToWaitForConfirmation: 5,
341
+ * suppressLog: true,
342
+ * })
343
+ * ```
344
+ * @returns The result of the asset transfer transaction and the transaction that was sent
345
+ */
346
+ assetTransfer = this._send((c) => c.addAssetTransfer, { preLog: (params, transaction) => `Transferring ${params.amount} units of asset with ID ${params.assetId} from ${params.sender} to ${params.receiver} via transaction ${transaction.txID()}` });
347
+ /**
348
+ * Opt an account into an Algorand Standard Asset.
349
+ *
350
+ * @param params The parameters for the asset opt-in transaction
351
+ *
352
+ * @example Basic example
353
+ * ```typescript
354
+ * await algorand.send.assetOptIn({ sender: "SENDERADDRESS", assetId: 123456n })
355
+ * ```
356
+ * @example Advanced example
357
+ * ```typescript
358
+ * await algorand.send.assetOptIn({
359
+ * sender: 'SENDERADDRESS',
360
+ * assetId: 123456n,
361
+ * lease: 'lease',
362
+ * note: 'note',
363
+ * // You wouldn't normally set this field
364
+ * firstValidRound: 1000n,
365
+ * validityWindow: 10,
366
+ * extraFee: (1000).microAlgo(),
367
+ * staticFee: (1000).microAlgo(),
368
+ * // Max fee doesn't make sense with extraFee AND staticFee
369
+ * // already specified, but here for completeness
370
+ * maxFee: (3000).microAlgo(),
371
+ * // Signer only needed if you want to provide one,
372
+ * // generally you'd register it with AlgorandClient
373
+ * // against the sender and not need to pass it in
374
+ * signer: transactionSigner,
375
+ * maxRoundsToWaitForConfirmation: 5,
376
+ * suppressLog: true,
377
+ * })
378
+ * ```
379
+ * @returns The result of the asset opt-in transaction and the transaction that was sent
380
+ */
381
+ assetOptIn = this._send((c) => c.addAssetOptIn, { preLog: (params, transaction) => `Opting in ${params.sender} to asset with ID ${params.assetId} via transaction ${transaction.txID()}` });
382
+ /**
383
+ * Opt an account out of an Algorand Standard Asset.
384
+ *
385
+ * *Note:* If the account has a balance of the asset,
386
+ * it will not be able to opt-out unless `ensureZeroBalance`
387
+ * is set to `false` (but then the account will lose the assets).
388
+ *
389
+ * @param params The parameters for the asset opt-out transaction
390
+ *
391
+ * @example Basic example (without creator, will be retrieved from algod)
392
+ * ```typescript
393
+ * await algorand.send.assetOptOut({ sender: "SENDERADDRESS", assetId: 123456n, ensureZeroBalance: true })
394
+ * ```
395
+ * @example Basic example (with creator)
396
+ * ```typescript
397
+ * await algorand.send.assetOptOut({ sender: "SENDERADDRESS", creator: "CREATORADDRESS", assetId: 123456n, ensureZeroBalance: true })
398
+ * ```
399
+ * @example Advanced example
400
+ * ```typescript
401
+ * await algorand.send.assetOptOut({
402
+ * sender: 'SENDERADDRESS',
403
+ * assetId: 123456n,
404
+ * creator: 'CREATORADDRESS',
405
+ * ensureZeroBalance: true,
406
+ * lease: 'lease',
407
+ * note: 'note',
408
+ * // You wouldn't normally set this field
409
+ * firstValidRound: 1000n,
410
+ * validityWindow: 10,
411
+ * extraFee: (1000).microAlgo(),
412
+ * staticFee: (1000).microAlgo(),
413
+ * // Max fee doesn't make sense with extraFee AND staticFee
414
+ * // already specified, but here for completeness
415
+ * maxFee: (3000).microAlgo(),
416
+ * // Signer only needed if you want to provide one,
417
+ * // generally you'd register it with AlgorandClient
418
+ * // against the sender and not need to pass it in
419
+ * signer: transactionSigner,
420
+ * maxRoundsToWaitForConfirmation: 5,
421
+ * suppressLog: true,
422
+ * })
423
+ * ```
424
+ * @returns The result of the asset opt-out transaction and the transaction that was sent
425
+ */
426
+ assetOptOut = async (params) => {
427
+ if (params.ensureZeroBalance) {
428
+ let balance = 0n;
429
+ try {
430
+ balance = (await this._assetManager.getAccountInformation(params.sender, params.assetId)).balance;
431
+ } catch {
432
+ throw new Error(`Account ${params.sender} is not opted-in to Asset ${params.assetId}; can't opt-out.`);
433
+ }
434
+ if (balance !== 0n) throw new Error(`Account ${params.sender} does not have a zero balance for Asset ${params.assetId}; can't opt-out.`);
435
+ }
436
+ params.creator = params.creator ?? (await this._assetManager.getById(params.assetId)).creator;
437
+ return await this._send((c) => c.addAssetOptOut, { preLog: (params, transaction) => `Opting ${params.sender} out of asset with ID ${params.assetId} to creator ${params.creator} via transaction ${transaction.txID()}` })(params);
438
+ };
439
+ /**
440
+ * Create a smart contract.
441
+ *
442
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
443
+ *
444
+ * @param params The parameters for the app creation transaction
445
+ * @example Basic example
446
+ * ```typescript
447
+ * const result = await algorand.send.appCreate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
448
+ * const createdAppId = result.appId
449
+ * ```
450
+ * @example Advanced example
451
+ * ```typescript
452
+ * await algorand.send.appCreate({
453
+ * sender: 'CREATORADDRESS',
454
+ * approvalProgram: "TEALCODE",
455
+ * clearStateProgram: "TEALCODE",
456
+ * schema: {
457
+ * globalInts: 1,
458
+ * globalByteSlices: 2,
459
+ * localInts: 3,
460
+ * localByteSlices: 4
461
+ * },
462
+ * extraProgramPages: 1,
463
+ * onComplete: algosdk.OnApplicationComplete.OptInOC,
464
+ * args: [new Uint8Array(1, 2, 3, 4)]
465
+ * accountReferences: ["ACCOUNT_1"]
466
+ * appReferences: [123n, 1234n]
467
+ * assetReferences: [12345n]
468
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
469
+ * accessReferences: [{ appId: 1234n }]
470
+ * lease: 'lease',
471
+ * note: 'note',
472
+ * // You wouldn't normally set this field
473
+ * firstValidRound: 1000n,
474
+ * validityWindow: 10,
475
+ * extraFee: (1000).microAlgo(),
476
+ * staticFee: (1000).microAlgo(),
477
+ * // Max fee doesn't make sense with extraFee AND staticFee
478
+ * // already specified, but here for completeness
479
+ * maxFee: (3000).microAlgo(),
480
+ * rejectVersion: 1,
481
+ * // Signer only needed if you want to provide one,
482
+ * // generally you'd register it with AlgorandClient
483
+ * // against the sender and not need to pass it in
484
+ * signer: transactionSigner,
485
+ * maxRoundsToWaitForConfirmation: 5,
486
+ * suppressLog: true,
487
+ *})
488
+ * ```
489
+ * @returns The result of the app create transaction and the transaction that was sent
490
+ */
491
+ appCreate = this._sendAppCreateCall((c) => c.addAppCreate, { postLog: (params, result) => `App created by ${params.sender} with ID ${result.confirmation.applicationIndex} via transaction ${result.txIds.at(-1)}` });
492
+ /**
493
+ * Update a smart contract.
494
+ *
495
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
496
+ *
497
+ * @param params The parameters for the app update transaction
498
+ * @example Basic example
499
+ * ```typescript
500
+ * await algorand.send.appUpdate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
501
+ * ```
502
+ * @example Advanced example
503
+ * ```typescript
504
+ * await algorand.send.appUpdate({
505
+ * sender: 'CREATORADDRESS',
506
+ * approvalProgram: "TEALCODE",
507
+ * clearStateProgram: "TEALCODE",
508
+ * onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
509
+ * args: [new Uint8Array(1, 2, 3, 4)]
510
+ * accountReferences: ["ACCOUNT_1"]
511
+ * appReferences: [123n, 1234n]
512
+ * assetReferences: [12345n]
513
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
514
+ * accessReferences: [{ appId: 1234n }]
515
+ * lease: 'lease',
516
+ * note: 'note',
517
+ * // You wouldn't normally set this field
518
+ * firstValidRound: 1000n,
519
+ * validityWindow: 10,
520
+ * extraFee: (1000).microAlgo(),
521
+ * staticFee: (1000).microAlgo(),
522
+ * // Max fee doesn't make sense with extraFee AND staticFee
523
+ * // already specified, but here for completeness
524
+ * maxFee: (3000).microAlgo(),
525
+ * rejectVersion: 1,
526
+ * // Signer only needed if you want to provide one,
527
+ * // generally you'd register it with AlgorandClient
528
+ * // against the sender and not need to pass it in
529
+ * signer: transactionSigner,
530
+ * maxRoundsToWaitForConfirmation: 5,
531
+ * suppressLog: true,
532
+ *})
533
+ * ```
534
+ * @returns The result of the app update transaction and the transaction that was sent
535
+ */
536
+ appUpdate = this._sendAppUpdateCall((c) => c.addAppUpdate, { postLog: (params, result) => `App ${params.appId} updated ${params.args ? ` with ${params.args.map((a) => Buffer.from(a).toString("base64"))}` : ""} by ${params.sender} via transaction ${result.txIds.at(-1)}` });
537
+ /**
538
+ * Delete a smart contract.
539
+ *
540
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
541
+ *
542
+ * @param params The parameters for the app deletion transaction
543
+ * @example Basic example
544
+ * ```typescript
545
+ * await algorand.send.appDelete({ sender: 'CREATORADDRESS' })
546
+ * ```
547
+ * @example Advanced example
548
+ * ```typescript
549
+ * await algorand.send.appDelete({
550
+ * sender: 'CREATORADDRESS',
551
+ * onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
552
+ * args: [new Uint8Array(1, 2, 3, 4)]
553
+ * accountReferences: ["ACCOUNT_1"]
554
+ * appReferences: [123n, 1234n]
555
+ * assetReferences: [12345n]
556
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
557
+ * accessReferences: [{ appId: 1234n }]
558
+ * lease: 'lease',
559
+ * note: 'note',
560
+ * // You wouldn't normally set this field
561
+ * firstValidRound: 1000n,
562
+ * validityWindow: 10,
563
+ * extraFee: (1000).microAlgo(),
564
+ * staticFee: (1000).microAlgo(),
565
+ * // Max fee doesn't make sense with extraFee AND staticFee
566
+ * // already specified, but here for completeness
567
+ * maxFee: (3000).microAlgo(),
568
+ * rejectVersion: 1,
569
+ * // Signer only needed if you want to provide one,
570
+ * // generally you'd register it with AlgorandClient
571
+ * // against the sender and not need to pass it in
572
+ * signer: transactionSigner,
573
+ * maxRoundsToWaitForConfirmation: 5,
574
+ * suppressLog: true,
575
+ *})
576
+ * ```
577
+ * @returns The result of the app delete transaction and the transaction that was sent
578
+ */
579
+ appDelete = this._sendAppCall((c) => c.addAppDelete, { postLog: (params, result) => `App ${params.appId} deleted ${params.args ? ` with ${params.args.map((a) => Buffer.from(a).toString("base64"))}` : ""} by ${params.sender} via transaction ${result.txIds.at(-1)}` });
580
+ /**
581
+ * Call a smart contract.
582
+ *
583
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
584
+ *
585
+ * @param params The parameters for the app call transaction
586
+ * @example Basic example
587
+ * ```typescript
588
+ * await algorand.send.appCall({ sender: 'CREATORADDRESS' })
589
+ * ```
590
+ * @example Advanced example
591
+ * ```typescript
592
+ * await algorand.send.appCall({
593
+ * sender: 'CREATORADDRESS',
594
+ * onComplete: algosdk.OnApplicationComplete.OptInOC,
595
+ * args: [new Uint8Array(1, 2, 3, 4)]
596
+ * accountReferences: ["ACCOUNT_1"]
597
+ * appReferences: [123n, 1234n]
598
+ * assetReferences: [12345n]
599
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
600
+ * accessReferences: [{ appId: 1234n }]
601
+ * lease: 'lease',
602
+ * note: 'note',
603
+ * // You wouldn't normally set this field
604
+ * firstValidRound: 1000n,
605
+ * validityWindow: 10,
606
+ * extraFee: (1000).microAlgo(),
607
+ * staticFee: (1000).microAlgo(),
608
+ * // Max fee doesn't make sense with extraFee AND staticFee
609
+ * // already specified, but here for completeness
610
+ * maxFee: (3000).microAlgo(),
611
+ * rejectVersion: 1,
612
+ * // Signer only needed if you want to provide one,
613
+ * // generally you'd register it with AlgorandClient
614
+ * // against the sender and not need to pass it in
615
+ * signer: transactionSigner,
616
+ * maxRoundsToWaitForConfirmation: 5,
617
+ * suppressLog: true,
618
+ *})
619
+ * ```
620
+ * @returns The result of the app call transaction and the transaction that was sent
621
+ */
622
+ appCall = this._sendAppCall((c) => c.addAppCall, { postLog: (params, result) => `App ${params.appId} called ${params.args ? ` with ${params.args.map((a) => Buffer.from(a).toString("base64"))}` : ""} by ${params.sender} via transaction ${result.txIds.at(-1)}` });
623
+ /**
624
+ * Create a smart contract via an ABI method.
625
+ *
626
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
627
+ *
628
+ * @param params The parameters for the app creation transaction
629
+ * @example Basic example
630
+ * ```typescript
631
+ * const method = new ABIMethod({
632
+ * name: 'method',
633
+ * args: [{ name: 'arg1', type: 'string' }],
634
+ * returns: { type: 'string' },
635
+ * })
636
+ * const result = await algorand.send.appCreateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
637
+ * const createdAppId = result.appId
638
+ * ```
639
+ * @example Advanced example
640
+ * ```typescript
641
+ * const method = new ABIMethod({
642
+ * name: 'method',
643
+ * args: [{ name: 'arg1', type: 'string' }],
644
+ * returns: { type: 'string' },
645
+ * })
646
+ * await algorand.send.appCreateMethodCall({
647
+ * sender: 'CREATORADDRESS',
648
+ * method: method,
649
+ * args: ["arg1_value"],
650
+ * approvalProgram: "TEALCODE",
651
+ * clearStateProgram: "TEALCODE",
652
+ * schema: {
653
+ * globalInts: 1,
654
+ * globalByteSlices: 2,
655
+ * localInts: 3,
656
+ * localByteSlices: 4
657
+ * },
658
+ * extraProgramPages: 1,
659
+ * onComplete: algosdk.OnApplicationComplete.OptInOC,
660
+ * args: [new Uint8Array(1, 2, 3, 4)]
661
+ * accountReferences: ["ACCOUNT_1"]
662
+ * appReferences: [123n, 1234n]
663
+ * assetReferences: [12345n]
664
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
665
+ * accessReferences: [{ appId: 1234n }]
666
+ * lease: 'lease',
667
+ * note: 'note',
668
+ * // You wouldn't normally set this field
669
+ * firstValidRound: 1000n,
670
+ * validityWindow: 10,
671
+ * extraFee: (1000).microAlgo(),
672
+ * staticFee: (1000).microAlgo(),
673
+ * // Max fee doesn't make sense with extraFee AND staticFee
674
+ * // already specified, but here for completeness
675
+ * maxFee: (3000).microAlgo(),
676
+ * rejectVersion: 1,
677
+ * // Signer only needed if you want to provide one,
678
+ * // generally you'd register it with AlgorandClient
679
+ * // against the sender and not need to pass it in
680
+ * signer: transactionSigner,
681
+ * maxRoundsToWaitForConfirmation: 5,
682
+ * suppressLog: true,
683
+ *})
684
+ * ```
685
+ * @returns The result of the application ABI method create transaction and the transaction that was sent
686
+ */
687
+ appCreateMethodCall = this._sendAppCreateCall((c) => c.addAppCreateMethodCall, { postLog: (params, result) => `App created by ${params.sender} with ID ${result.confirmation.applicationIndex} via transaction ${result.txIds.at(-1)}` });
688
+ /**
689
+ * Update a smart contract via an ABI method.
690
+ *
691
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
692
+ *
693
+ * @param params The parameters for the app update transaction
694
+ * @example Basic example
695
+ * ```typescript
696
+ * const method = new ABIMethod({
697
+ * name: 'method',
698
+ * args: [{ name: 'arg1', type: 'string' }],
699
+ * returns: { type: 'string' },
700
+ * })
701
+ * await algorand.send.appUpdateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
702
+ * ```
703
+ * @example Advanced example
704
+ * ```typescript
705
+ * const method = new ABIMethod({
706
+ * name: 'method',
707
+ * args: [{ name: 'arg1', type: 'string' }],
708
+ * returns: { type: 'string' },
709
+ * })
710
+ * await algorand.send.appUpdateMethodCall({
711
+ * sender: 'CREATORADDRESS',
712
+ * method: method,
713
+ * args: ["arg1_value"],
714
+ * approvalProgram: "TEALCODE",
715
+ * clearStateProgram: "TEALCODE",
716
+ * onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
717
+ * args: [new Uint8Array(1, 2, 3, 4)]
718
+ * accountReferences: ["ACCOUNT_1"]
719
+ * appReferences: [123n, 1234n]
720
+ * assetReferences: [12345n]
721
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
722
+ * accessReferences: [{ appId: 1234n }]
723
+ * lease: 'lease',
724
+ * note: 'note',
725
+ * // You wouldn't normally set this field
726
+ * firstValidRound: 1000n,
727
+ * validityWindow: 10,
728
+ * extraFee: (1000).microAlgo(),
729
+ * staticFee: (1000).microAlgo(),
730
+ * // Max fee doesn't make sense with extraFee AND staticFee
731
+ * // already specified, but here for completeness
732
+ * maxFee: (3000).microAlgo(),
733
+ * rejectVersion: 1,
734
+ * // Signer only needed if you want to provide one,
735
+ * // generally you'd register it with AlgorandClient
736
+ * // against the sender and not need to pass it in
737
+ * signer: transactionSigner,
738
+ * maxRoundsToWaitForConfirmation: 5,
739
+ * suppressLog: true,
740
+ *})
741
+ * ```
742
+ * @returns The result of the application ABI method update transaction and the transaction that was sent
743
+ */
744
+ appUpdateMethodCall = this._sendAppUpdateCall((c) => c.addAppUpdateMethodCall, { postLog: (params, result) => `App ${params.appId} updated with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}` });
745
+ /**
746
+ * Delete a smart contract via an ABI method.
747
+ *
748
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
749
+ *
750
+ * @param params The parameters for the app deletion transaction
751
+ * @example Basic example
752
+ * ```typescript
753
+ * const method = new ABIMethod({
754
+ * name: 'method',
755
+ * args: [{ name: 'arg1', type: 'string' }],
756
+ * returns: { type: 'string' },
757
+ * })
758
+ * await algorand.send.appDeleteMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
759
+ * ```
760
+ * @example Advanced example
761
+ * ```typescript
762
+ * const method = new ABIMethod({
763
+ * name: 'method',
764
+ * args: [{ name: 'arg1', type: 'string' }],
765
+ * returns: { type: 'string' },
766
+ * })
767
+ * await algorand.send.appDeleteMethodCall({
768
+ * sender: 'CREATORADDRESS',
769
+ * method: method,
770
+ * args: ["arg1_value"],
771
+ * onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
772
+ * args: [new Uint8Array(1, 2, 3, 4)]
773
+ * accountReferences: ["ACCOUNT_1"]
774
+ * appReferences: [123n, 1234n]
775
+ * assetReferences: [12345n]
776
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
777
+ * accessReferences: [{ appId: 1234n }]
778
+ * lease: 'lease',
779
+ * note: 'note',
780
+ * // You wouldn't normally set this field
781
+ * firstValidRound: 1000n,
782
+ * validityWindow: 10,
783
+ * extraFee: (1000).microAlgo(),
784
+ * staticFee: (1000).microAlgo(),
785
+ * // Max fee doesn't make sense with extraFee AND staticFee
786
+ * // already specified, but here for completeness
787
+ * maxFee: (3000).microAlgo(),
788
+ * rejectVersion: 1,
789
+ * // Signer only needed if you want to provide one,
790
+ * // generally you'd register it with AlgorandClient
791
+ * // against the sender and not need to pass it in
792
+ * signer: transactionSigner,
793
+ * maxRoundsToWaitForConfirmation: 5,
794
+ * suppressLog: true,
795
+ *})
796
+ * ```
797
+ * @returns The result of the application ABI method delete transaction and the transaction that was sent
798
+ */
799
+ appDeleteMethodCall = this._sendAppCall((c) => c.addAppDeleteMethodCall, { postLog: (params, result) => `App ${params.appId} deleted with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}` });
800
+ /**
801
+ * Call a smart contract via an ABI method.
802
+ *
803
+ * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
804
+ *
805
+ * @param params The parameters for the app call transaction
806
+ * @example Basic example
807
+ * ```typescript
808
+ * const method = new ABIMethod({
809
+ * name: 'method',
810
+ * args: [{ name: 'arg1', type: 'string' }],
811
+ * returns: { type: 'string' },
812
+ * })
813
+ * await algorand.send.appCallMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
814
+ * ```
815
+ * @example Advanced example
816
+ * ```typescript
817
+ * const method = new ABIMethod({
818
+ * name: 'method',
819
+ * args: [{ name: 'arg1', type: 'string' }],
820
+ * returns: { type: 'string' },
821
+ * })
822
+ * await algorand.send.appCallMethodCall({
823
+ * sender: 'CREATORADDRESS',
824
+ * method: method,
825
+ * args: ["arg1_value"],
826
+ * onComplete: algosdk.OnApplicationComplete.OptInOC,
827
+ * args: [new Uint8Array(1, 2, 3, 4)]
828
+ * accountReferences: ["ACCOUNT_1"]
829
+ * appReferences: [123n, 1234n]
830
+ * assetReferences: [12345n]
831
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
832
+ * accessReferences: [{ appId: 1234n }]
833
+ * lease: 'lease',
834
+ * note: 'note',
835
+ * // You wouldn't normally set this field
836
+ * firstValidRound: 1000n,
837
+ * validityWindow: 10,
838
+ * extraFee: (1000).microAlgo(),
839
+ * staticFee: (1000).microAlgo(),
840
+ * // Max fee doesn't make sense with extraFee AND staticFee
841
+ * // already specified, but here for completeness
842
+ * maxFee: (3000).microAlgo(),
843
+ * rejectVersion: 1,
844
+ * // Signer only needed if you want to provide one,
845
+ * // generally you'd register it with AlgorandClient
846
+ * // against the sender and not need to pass it in
847
+ * signer: transactionSigner,
848
+ * maxRoundsToWaitForConfirmation: 5,
849
+ * suppressLog: true,
850
+ *})
851
+ * ```
852
+ * @returns The result of the application ABI method call transaction and the transaction that was sent
853
+ */
854
+ appCallMethodCall = this._sendAppCall((c) => c.addAppCallMethodCall, { postLog: (params, result) => `App ${params.appId} called with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}` });
855
+ /**
856
+ * Register an online key.
857
+ * @param params The parameters for the key registration transaction
858
+ * @example Basic example
859
+ * ```typescript
860
+ * const result = await algorand.send.onlineKeyRegistration({
861
+ * sender: 'SENDERADDRESS',
862
+ * voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
863
+ * selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
864
+ * stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
865
+ * voteFirst: 1n,
866
+ * voteLast: 1000n,
867
+ * voteKeyDilution: 1n,
868
+ * })
869
+ * ```
870
+ * @example Advanced example
871
+ * ```typescript
872
+ * const result = await algorand.send.onlineKeyRegistration({
873
+ * sender: 'SENDERADDRESS',
874
+ * voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
875
+ * selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
876
+ * stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
877
+ * voteFirst: 1n,
878
+ * voteLast: 1000n,
879
+ * voteKeyDilution: 1n,
880
+ * lease: 'lease',
881
+ * note: 'note',
882
+ * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
883
+ * rekeyTo: 'REKEYTOADDRESS',
884
+ * // You wouldn't normally set this field
885
+ * firstValidRound: 1000n,
886
+ * validityWindow: 10,
887
+ * extraFee: (1000).microAlgo(),
888
+ * staticFee: (1000).microAlgo(),
889
+ * // Max fee doesn't make sense with extraFee AND staticFee
890
+ * // already specified, but here for completeness
891
+ * maxFee: (3000).microAlgo(),
892
+ * })
893
+ * ```
894
+ * @returns The result of the online key registration transaction and the transaction that was sent
895
+ */
896
+ onlineKeyRegistration = this._send((c) => c.addOnlineKeyRegistration, { preLog: (params, transaction) => `Registering online key for ${params.sender} via transaction ${transaction.txID()}` });
897
+ /**
898
+ * Register an offline key.
899
+ * @param params The parameters for the key registration transaction
900
+ * @example Basic example
901
+ * ```typescript
902
+ * const result = await algorand.send.offlineKeyRegistration({
903
+ * sender: 'SENDERADDRESS',
904
+ * })
905
+ * ```
906
+ * @example Advanced example
907
+ * ```typescript
908
+ * const result = await algorand.send.offlineKeyRegistration({
909
+ * sender: 'SENDERADDRESS',
910
+ * lease: 'lease',
911
+ * note: 'note',
912
+ * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
913
+ * rekeyTo: 'REKEYTOADDRESS',
914
+ * // You wouldn't normally set this field
915
+ * firstValidRound: 1000n,
916
+ * validityWindow: 10,
917
+ * extraFee: (1000).microAlgo(),
918
+ * staticFee: (1000).microAlgo(),
919
+ * // Max fee doesn't make sense with extraFee AND staticFee
920
+ * // already specified, but here for completeness
921
+ * maxFee: (3000).microAlgo(),
922
+ * })
923
+ * ```
924
+ * @returns The result of the offline key registration transaction and the transaction that was sent
925
+ */
926
+ offlineKeyRegistration = this._send((c) => c.addOfflineKeyRegistration, { preLog: (params, transaction) => `Registering offline key for ${params.sender} via transaction ${transaction.txID()}` });
927
+ };
928
+ //#endregion
954
929
  export { AlgorandClientTransactionSender };
955
- //# sourceMappingURL=algorand-client-transaction-sender.mjs.map
930
+
931
+ //# sourceMappingURL=algorand-client-transaction-sender.mjs.map