@algorandfoundation/algokit-utils 9.2.0 → 9.2.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 -771
  175. package/types/algorand-client-transaction-creator.js +733 -732
  176. package/types/algorand-client-transaction-creator.js.map +1 -1
  177. package/types/algorand-client-transaction-creator.mjs +732 -730
  178. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  179. package/types/algorand-client-transaction-sender.d.ts +1090 -1360
  180. package/types/algorand-client-transaction-sender.js +930 -961
  181. package/types/algorand-client-transaction-sender.js.map +1 -1
  182. package/types/algorand-client-transaction-sender.mjs +927 -959
  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 -2009
  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 -932
  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 +304 -310
  215. package/types/app-manager.js +422 -475
  216. package/types/app-manager.js.map +1 -1
  217. package/types/app-manager.mjs +419 -473
  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 -1258
  248. package/types/composer.js +1436 -1498
  249. package/types/composer.js.map +1 -1
  250. package/types/composer.mjs +1430 -1493
  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,963 +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
- * rejectVersion: 1,
433
- * // Signer only needed if you want to provide one,
434
- * // generally you'd register it with AlgorandClient
435
- * // against the sender and not need to pass it in
436
- * signer: transactionSigner,
437
- * maxRoundsToWaitForConfirmation: 5,
438
- * suppressLog: true,
439
- *})
440
- * ```
441
- * @returns The result of the app create transaction and the transaction that was sent
442
- */
443
- this.appCreate = this._sendAppCreateCall((c) => c.addAppCreate, {
444
- postLog: (params, result) => `App created by ${params.sender} with ID ${result.confirmation.applicationIndex} via transaction ${result.txIds.at(-1)}`,
445
- });
446
- /**
447
- * Update a smart contract.
448
- *
449
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
450
- *
451
- * @param params The parameters for the app update transaction
452
- * @example Basic example
453
- * ```typescript
454
- * await algorand.send.appUpdate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
455
- * ```
456
- * @example Advanced example
457
- * ```typescript
458
- * await algorand.send.appUpdate({
459
- * sender: 'CREATORADDRESS',
460
- * approvalProgram: "TEALCODE",
461
- * clearStateProgram: "TEALCODE",
462
- * onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
463
- * args: [new Uint8Array(1, 2, 3, 4)]
464
- * accountReferences: ["ACCOUNT_1"]
465
- * appReferences: [123n, 1234n]
466
- * assetReferences: [12345n]
467
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
468
- * accessReferences: [{ appId: 1234n }]
469
- * lease: 'lease',
470
- * note: 'note',
471
- * // You wouldn't normally set this field
472
- * firstValidRound: 1000n,
473
- * validityWindow: 10,
474
- * extraFee: (1000).microAlgo(),
475
- * staticFee: (1000).microAlgo(),
476
- * // Max fee doesn't make sense with extraFee AND staticFee
477
- * // already specified, but here for completeness
478
- * maxFee: (3000).microAlgo(),
479
- * rejectVersion: 1,
480
- * // Signer only needed if you want to provide one,
481
- * // generally you'd register it with AlgorandClient
482
- * // against the sender and not need to pass it in
483
- * signer: transactionSigner,
484
- * maxRoundsToWaitForConfirmation: 5,
485
- * suppressLog: true,
486
- *})
487
- * ```
488
- * @returns The result of the app update transaction and the transaction that was sent
489
- */
490
- this.appUpdate = this._sendAppUpdateCall((c) => c.addAppUpdate, {
491
- 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)}`,
492
- });
493
- /**
494
- * Delete a smart contract.
495
- *
496
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
497
- *
498
- * @param params The parameters for the app deletion transaction
499
- * @example Basic example
500
- * ```typescript
501
- * await algorand.send.appDelete({ sender: 'CREATORADDRESS' })
502
- * ```
503
- * @example Advanced example
504
- * ```typescript
505
- * await algorand.send.appDelete({
506
- * sender: 'CREATORADDRESS',
507
- * onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
508
- * args: [new Uint8Array(1, 2, 3, 4)]
509
- * accountReferences: ["ACCOUNT_1"]
510
- * appReferences: [123n, 1234n]
511
- * assetReferences: [12345n]
512
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
513
- * accessReferences: [{ appId: 1234n }]
514
- * lease: 'lease',
515
- * note: 'note',
516
- * // You wouldn't normally set this field
517
- * firstValidRound: 1000n,
518
- * validityWindow: 10,
519
- * extraFee: (1000).microAlgo(),
520
- * staticFee: (1000).microAlgo(),
521
- * // Max fee doesn't make sense with extraFee AND staticFee
522
- * // already specified, but here for completeness
523
- * maxFee: (3000).microAlgo(),
524
- * rejectVersion: 1,
525
- * // Signer only needed if you want to provide one,
526
- * // generally you'd register it with AlgorandClient
527
- * // against the sender and not need to pass it in
528
- * signer: transactionSigner,
529
- * maxRoundsToWaitForConfirmation: 5,
530
- * suppressLog: true,
531
- *})
532
- * ```
533
- * @returns The result of the app delete transaction and the transaction that was sent
534
- */
535
- this.appDelete = this._sendAppCall((c) => c.addAppDelete, {
536
- 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)}`,
537
- });
538
- /**
539
- * Call a smart contract.
540
- *
541
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
542
- *
543
- * @param params The parameters for the app call transaction
544
- * @example Basic example
545
- * ```typescript
546
- * await algorand.send.appCall({ sender: 'CREATORADDRESS' })
547
- * ```
548
- * @example Advanced example
549
- * ```typescript
550
- * await algorand.send.appCall({
551
- * sender: 'CREATORADDRESS',
552
- * onComplete: algosdk.OnApplicationComplete.OptInOC,
553
- * args: [new Uint8Array(1, 2, 3, 4)]
554
- * accountReferences: ["ACCOUNT_1"]
555
- * appReferences: [123n, 1234n]
556
- * assetReferences: [12345n]
557
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
558
- * accessReferences: [{ appId: 1234n }]
559
- * lease: 'lease',
560
- * note: 'note',
561
- * // You wouldn't normally set this field
562
- * firstValidRound: 1000n,
563
- * validityWindow: 10,
564
- * extraFee: (1000).microAlgo(),
565
- * staticFee: (1000).microAlgo(),
566
- * // Max fee doesn't make sense with extraFee AND staticFee
567
- * // already specified, but here for completeness
568
- * maxFee: (3000).microAlgo(),
569
- * rejectVersion: 1,
570
- * // Signer only needed if you want to provide one,
571
- * // generally you'd register it with AlgorandClient
572
- * // against the sender and not need to pass it in
573
- * signer: transactionSigner,
574
- * maxRoundsToWaitForConfirmation: 5,
575
- * suppressLog: true,
576
- *})
577
- * ```
578
- * @returns The result of the app call transaction and the transaction that was sent
579
- */
580
- this.appCall = this._sendAppCall((c) => c.addAppCall, {
581
- 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)}`,
582
- });
583
- /**
584
- * Create a smart contract via an ABI method.
585
- *
586
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
587
- *
588
- * @param params The parameters for the app creation transaction
589
- * @example Basic example
590
- * ```typescript
591
- * const method = new ABIMethod({
592
- * name: 'method',
593
- * args: [{ name: 'arg1', type: 'string' }],
594
- * returns: { type: 'string' },
595
- * })
596
- * const result = await algorand.send.appCreateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
597
- * const createdAppId = result.appId
598
- * ```
599
- * @example Advanced example
600
- * ```typescript
601
- * const method = new ABIMethod({
602
- * name: 'method',
603
- * args: [{ name: 'arg1', type: 'string' }],
604
- * returns: { type: 'string' },
605
- * })
606
- * await algorand.send.appCreateMethodCall({
607
- * sender: 'CREATORADDRESS',
608
- * method: method,
609
- * args: ["arg1_value"],
610
- * approvalProgram: "TEALCODE",
611
- * clearStateProgram: "TEALCODE",
612
- * schema: {
613
- * globalInts: 1,
614
- * globalByteSlices: 2,
615
- * localInts: 3,
616
- * localByteSlices: 4
617
- * },
618
- * extraProgramPages: 1,
619
- * onComplete: algosdk.OnApplicationComplete.OptInOC,
620
- * args: [new Uint8Array(1, 2, 3, 4)]
621
- * accountReferences: ["ACCOUNT_1"]
622
- * appReferences: [123n, 1234n]
623
- * assetReferences: [12345n]
624
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
625
- * accessReferences: [{ appId: 1234n }]
626
- * lease: 'lease',
627
- * note: 'note',
628
- * // You wouldn't normally set this field
629
- * firstValidRound: 1000n,
630
- * validityWindow: 10,
631
- * extraFee: (1000).microAlgo(),
632
- * staticFee: (1000).microAlgo(),
633
- * // Max fee doesn't make sense with extraFee AND staticFee
634
- * // already specified, but here for completeness
635
- * maxFee: (3000).microAlgo(),
636
- * rejectVersion: 1,
637
- * // Signer only needed if you want to provide one,
638
- * // generally you'd register it with AlgorandClient
639
- * // against the sender and not need to pass it in
640
- * signer: transactionSigner,
641
- * maxRoundsToWaitForConfirmation: 5,
642
- * suppressLog: true,
643
- *})
644
- * ```
645
- * @returns The result of the application ABI method create transaction and the transaction that was sent
646
- */
647
- this.appCreateMethodCall = this._sendAppCreateCall((c) => c.addAppCreateMethodCall, {
648
- postLog: (params, result) => `App created by ${params.sender} with ID ${result.confirmation.applicationIndex} via transaction ${result.txIds.at(-1)}`,
649
- });
650
- /**
651
- * Update a smart contract via an ABI method.
652
- *
653
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
654
- *
655
- * @param params The parameters for the app update transaction
656
- * @example Basic example
657
- * ```typescript
658
- * const method = new ABIMethod({
659
- * name: 'method',
660
- * args: [{ name: 'arg1', type: 'string' }],
661
- * returns: { type: 'string' },
662
- * })
663
- * await algorand.send.appUpdateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
664
- * ```
665
- * @example Advanced example
666
- * ```typescript
667
- * const method = new ABIMethod({
668
- * name: 'method',
669
- * args: [{ name: 'arg1', type: 'string' }],
670
- * returns: { type: 'string' },
671
- * })
672
- * await algorand.send.appUpdateMethodCall({
673
- * sender: 'CREATORADDRESS',
674
- * method: method,
675
- * args: ["arg1_value"],
676
- * approvalProgram: "TEALCODE",
677
- * clearStateProgram: "TEALCODE",
678
- * onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
679
- * args: [new Uint8Array(1, 2, 3, 4)]
680
- * accountReferences: ["ACCOUNT_1"]
681
- * appReferences: [123n, 1234n]
682
- * assetReferences: [12345n]
683
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
684
- * accessReferences: [{ appId: 1234n }]
685
- * lease: 'lease',
686
- * note: 'note',
687
- * // You wouldn't normally set this field
688
- * firstValidRound: 1000n,
689
- * validityWindow: 10,
690
- * extraFee: (1000).microAlgo(),
691
- * staticFee: (1000).microAlgo(),
692
- * // Max fee doesn't make sense with extraFee AND staticFee
693
- * // already specified, but here for completeness
694
- * maxFee: (3000).microAlgo(),
695
- * rejectVersion: 1,
696
- * // Signer only needed if you want to provide one,
697
- * // generally you'd register it with AlgorandClient
698
- * // against the sender and not need to pass it in
699
- * signer: transactionSigner,
700
- * maxRoundsToWaitForConfirmation: 5,
701
- * suppressLog: true,
702
- *})
703
- * ```
704
- * @returns The result of the application ABI method update transaction and the transaction that was sent
705
- */
706
- this.appUpdateMethodCall = this._sendAppUpdateCall((c) => c.addAppUpdateMethodCall, {
707
- postLog: (params, result) => `App ${params.appId} updated with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
708
- });
709
- /**
710
- * Delete a smart contract via an ABI method.
711
- *
712
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
713
- *
714
- * @param params The parameters for the app deletion transaction
715
- * @example Basic example
716
- * ```typescript
717
- * const method = new ABIMethod({
718
- * name: 'method',
719
- * args: [{ name: 'arg1', type: 'string' }],
720
- * returns: { type: 'string' },
721
- * })
722
- * await algorand.send.appDeleteMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
723
- * ```
724
- * @example Advanced example
725
- * ```typescript
726
- * const method = new ABIMethod({
727
- * name: 'method',
728
- * args: [{ name: 'arg1', type: 'string' }],
729
- * returns: { type: 'string' },
730
- * })
731
- * await algorand.send.appDeleteMethodCall({
732
- * sender: 'CREATORADDRESS',
733
- * method: method,
734
- * args: ["arg1_value"],
735
- * onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
736
- * args: [new Uint8Array(1, 2, 3, 4)]
737
- * accountReferences: ["ACCOUNT_1"]
738
- * appReferences: [123n, 1234n]
739
- * assetReferences: [12345n]
740
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
741
- * accessReferences: [{ appId: 1234n }]
742
- * lease: 'lease',
743
- * note: 'note',
744
- * // You wouldn't normally set this field
745
- * firstValidRound: 1000n,
746
- * validityWindow: 10,
747
- * extraFee: (1000).microAlgo(),
748
- * staticFee: (1000).microAlgo(),
749
- * // Max fee doesn't make sense with extraFee AND staticFee
750
- * // already specified, but here for completeness
751
- * maxFee: (3000).microAlgo(),
752
- * rejectVersion: 1,
753
- * // Signer only needed if you want to provide one,
754
- * // generally you'd register it with AlgorandClient
755
- * // against the sender and not need to pass it in
756
- * signer: transactionSigner,
757
- * maxRoundsToWaitForConfirmation: 5,
758
- * suppressLog: true,
759
- *})
760
- * ```
761
- * @returns The result of the application ABI method delete transaction and the transaction that was sent
762
- */
763
- this.appDeleteMethodCall = this._sendAppCall((c) => c.addAppDeleteMethodCall, {
764
- postLog: (params, result) => `App ${params.appId} deleted with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
765
- });
766
- /**
767
- * Call a smart contract via an ABI method.
768
- *
769
- * Note: you may prefer to use `algorand.client` to get an app client for more advanced functionality.
770
- *
771
- * @param params The parameters for the app call transaction
772
- * @example Basic example
773
- * ```typescript
774
- * const method = new ABIMethod({
775
- * name: 'method',
776
- * args: [{ name: 'arg1', type: 'string' }],
777
- * returns: { type: 'string' },
778
- * })
779
- * await algorand.send.appCallMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
780
- * ```
781
- * @example Advanced example
782
- * ```typescript
783
- * const method = new ABIMethod({
784
- * name: 'method',
785
- * args: [{ name: 'arg1', type: 'string' }],
786
- * returns: { type: 'string' },
787
- * })
788
- * await algorand.send.appCallMethodCall({
789
- * sender: 'CREATORADDRESS',
790
- * method: method,
791
- * args: ["arg1_value"],
792
- * onComplete: algosdk.OnApplicationComplete.OptInOC,
793
- * args: [new Uint8Array(1, 2, 3, 4)]
794
- * accountReferences: ["ACCOUNT_1"]
795
- * appReferences: [123n, 1234n]
796
- * assetReferences: [12345n]
797
- * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
798
- * accessReferences: [{ appId: 1234n }]
799
- * lease: 'lease',
800
- * note: 'note',
801
- * // You wouldn't normally set this field
802
- * firstValidRound: 1000n,
803
- * validityWindow: 10,
804
- * extraFee: (1000).microAlgo(),
805
- * staticFee: (1000).microAlgo(),
806
- * // Max fee doesn't make sense with extraFee AND staticFee
807
- * // already specified, but here for completeness
808
- * maxFee: (3000).microAlgo(),
809
- * rejectVersion: 1,
810
- * // Signer only needed if you want to provide one,
811
- * // generally you'd register it with AlgorandClient
812
- * // against the sender and not need to pass it in
813
- * signer: transactionSigner,
814
- * maxRoundsToWaitForConfirmation: 5,
815
- * suppressLog: true,
816
- *})
817
- * ```
818
- * @returns The result of the application ABI method call transaction and the transaction that was sent
819
- */
820
- this.appCallMethodCall = this._sendAppCall((c) => c.addAppCallMethodCall, {
821
- postLog: (params, result) => `App ${params.appId} called with ${getMethodCallForLog(params)} by ${params.sender} via transaction ${result.txIds.at(-1)}`,
822
- });
823
- /**
824
- * Register an online key.
825
- * @param params The parameters for the key registration transaction
826
- * @example Basic example
827
- * ```typescript
828
- * const result = await algorand.send.onlineKeyRegistration({
829
- * sender: 'SENDERADDRESS',
830
- * voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
831
- * selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
832
- * stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
833
- * voteFirst: 1n,
834
- * voteLast: 1000n,
835
- * voteKeyDilution: 1n,
836
- * })
837
- * ```
838
- * @example Advanced example
839
- * ```typescript
840
- * const result = await algorand.send.onlineKeyRegistration({
841
- * sender: 'SENDERADDRESS',
842
- * voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
843
- * selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
844
- * stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
845
- * voteFirst: 1n,
846
- * voteLast: 1000n,
847
- * voteKeyDilution: 1n,
848
- * lease: 'lease',
849
- * note: 'note',
850
- * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
851
- * rekeyTo: 'REKEYTOADDRESS',
852
- * // You wouldn't normally set this field
853
- * firstValidRound: 1000n,
854
- * validityWindow: 10,
855
- * extraFee: (1000).microAlgo(),
856
- * staticFee: (1000).microAlgo(),
857
- * // Max fee doesn't make sense with extraFee AND staticFee
858
- * // already specified, but here for completeness
859
- * maxFee: (3000).microAlgo(),
860
- * })
861
- * ```
862
- * @returns The result of the online key registration transaction and the transaction that was sent
863
- */
864
- this.onlineKeyRegistration = this._send((c) => c.addOnlineKeyRegistration, {
865
- preLog: (params, transaction) => `Registering online key for ${params.sender} via transaction ${transaction.txID()}`,
866
- });
867
- /**
868
- * Register an offline key.
869
- * @param params The parameters for the key registration transaction
870
- * @example Basic example
871
- * ```typescript
872
- * const result = await algorand.send.offlineKeyRegistration({
873
- * sender: 'SENDERADDRESS',
874
- * })
875
- * ```
876
- * @example Advanced example
877
- * ```typescript
878
- * const result = await algorand.send.offlineKeyRegistration({
879
- * sender: 'SENDERADDRESS',
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 offline key registration transaction and the transaction that was sent
895
- */
896
- this.offlineKeyRegistration = this._send((c) => c.addOfflineKeyRegistration, {
897
- preLog: (params, transaction) => `Registering offline key for ${params.sender} via transaction ${transaction.txID()}`,
898
- });
899
- this._newGroup = newGroup;
900
- this._assetManager = assetManager;
901
- this._appManager = appManager;
902
- }
903
- /**
904
- * Start a new `TransactionComposer` transaction group
905
- * @returns A new instance of `TransactionComposer`.
906
- * @example
907
- * const composer = AlgorandClient.mainNet().send.newGroup();
908
- * const result = await composer.addTransaction(payment).send()
909
- */
910
- newGroup() {
911
- return this._newGroup();
912
- }
913
- _send(c, log) {
914
- return async (params) => {
915
- const composer = this._newGroup();
916
- // Ensure `this` is properly populated
917
- c(composer).apply(composer, [params]);
918
- if (log?.preLog) {
919
- const transaction = (await composer.build()).transactions.at(-1).txn;
920
- Config.getLogger(params?.suppressLog).debug(log.preLog(params, transaction));
921
- }
922
- const rawResult = await composer.send(params);
923
- const result = {
924
- // Last item covers when a group is created by an app call with ABI transaction parameters
925
- transaction: rawResult.transactions.at(-1),
926
- confirmation: rawResult.confirmations.at(-1),
927
- txId: rawResult.txIds.at(-1),
928
- ...rawResult,
929
- };
930
- if (log?.postLog) {
931
- Config.getLogger(params?.suppressLog).debug(log.postLog(params, result));
932
- }
933
- return result;
934
- };
935
- }
936
- _sendAppCall(c, log) {
937
- return async (params) => {
938
- const result = await this._send(c, log)(params);
939
- return { ...result, return: AppManager.getABIReturn(result.confirmation, 'method' in params ? params.method : undefined) };
940
- };
941
- }
942
- _sendAppUpdateCall(c, log) {
943
- return async (params) => {
944
- const result = await this._sendAppCall(c, log)(params);
945
- const compiledApproval = typeof params.approvalProgram === 'string' ? this._appManager.getCompilationResult(params.approvalProgram) : undefined;
946
- const compiledClear = typeof params.clearStateProgram === 'string' ? this._appManager.getCompilationResult(params.clearStateProgram) : undefined;
947
- return { ...result, compiledApproval, compiledClear };
948
- };
949
- }
950
- _sendAppCreateCall(c, log) {
951
- return async (params) => {
952
- const result = await this._sendAppUpdateCall(c, log)(params);
953
- return {
954
- ...result,
955
- appId: BigInt(result.confirmation.applicationIndex),
956
- appAddress: algosdk.getApplicationAddress(result.confirmation.applicationIndex),
957
- };
958
- };
959
- }
960
- }
961
-
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
962
929
  export { AlgorandClientTransactionSender };
963
- //# sourceMappingURL=algorand-client-transaction-sender.mjs.map
930
+
931
+ //# sourceMappingURL=algorand-client-transaction-sender.mjs.map