@algorandfoundation/algokit-utils 6.2.1-beta.1 → 6.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/account/account.d.ts +13 -5
  2. package/account/account.d.ts.map +1 -1
  3. package/account/account.js +26 -6
  4. package/account/account.js.map +1 -1
  5. package/account/account.mjs +26 -6
  6. package/account/account.mjs.map +1 -1
  7. package/account/get-account.d.ts +4 -4
  8. package/account/get-account.js +2 -2
  9. package/account/get-account.mjs +2 -2
  10. package/amount.d.ts +28 -6
  11. package/amount.d.ts.map +1 -1
  12. package/amount.js +31 -11
  13. package/amount.js.map +1 -1
  14. package/amount.mjs +30 -12
  15. package/amount.mjs.map +1 -1
  16. package/asset.d.ts +10 -0
  17. package/asset.d.ts.map +1 -1
  18. package/asset.js +71 -198
  19. package/asset.js.map +1 -1
  20. package/asset.mjs +72 -199
  21. package/asset.mjs.map +1 -1
  22. package/dispenser-client.d.ts +1 -1
  23. package/dispenser-client.js +2 -2
  24. package/dispenser-client.js.map +1 -1
  25. package/dispenser-client.mjs +2 -2
  26. package/dispenser-client.mjs.map +1 -1
  27. package/index.d.ts +4 -3
  28. package/index.d.ts.map +1 -1
  29. package/index.js +11 -8
  30. package/index.js.map +1 -1
  31. package/index.mjs +6 -4
  32. package/index.mjs.map +1 -1
  33. package/localnet/get-or-create-kmd-wallet-account.d.ts +1 -1
  34. package/localnet/get-or-create-kmd-wallet-account.js +1 -1
  35. package/localnet/get-or-create-kmd-wallet-account.mjs +1 -1
  36. package/package.json +3 -2
  37. package/testing/_asset.d.ts +2 -4
  38. package/testing/_asset.d.ts.map +1 -1
  39. package/testing/account.js +8 -2
  40. package/testing/account.js.map +1 -1
  41. package/testing/account.mjs +8 -2
  42. package/testing/account.mjs.map +1 -1
  43. package/testing/fixtures/algorand-fixture.d.ts +1 -1
  44. package/testing/fixtures/algorand-fixture.js +7 -2
  45. package/testing/fixtures/algorand-fixture.js.map +1 -1
  46. package/testing/fixtures/algorand-fixture.mjs +7 -2
  47. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  48. package/transaction/legacy-bridge.d.ts +10 -0
  49. package/transaction/legacy-bridge.d.ts.map +1 -0
  50. package/transaction/legacy-bridge.js +35 -0
  51. package/transaction/legacy-bridge.js.map +1 -0
  52. package/transaction/legacy-bridge.mjs +33 -0
  53. package/transaction/legacy-bridge.mjs.map +1 -0
  54. package/transaction/transaction.d.ts +1 -1
  55. package/transaction/transaction.js +5 -5
  56. package/transaction/transaction.js.map +1 -1
  57. package/transaction/transaction.mjs +5 -5
  58. package/transaction/transaction.mjs.map +1 -1
  59. package/transfer/transfer-algos.d.ts +4 -2
  60. package/transfer/transfer-algos.d.ts.map +1 -1
  61. package/transfer/transfer-algos.js +13 -22
  62. package/transfer/transfer-algos.js.map +1 -1
  63. package/transfer/transfer-algos.mjs +14 -23
  64. package/transfer/transfer-algos.mjs.map +1 -1
  65. package/transfer/transfer.d.ts +8 -1
  66. package/transfer/transfer.d.ts.map +1 -1
  67. package/transfer/transfer.js +57 -94
  68. package/transfer/transfer.js.map +1 -1
  69. package/transfer/transfer.mjs +58 -95
  70. package/transfer/transfer.mjs.map +1 -1
  71. package/types/account-manager.d.ts +141 -24
  72. package/types/account-manager.d.ts.map +1 -1
  73. package/types/account-manager.js +217 -44
  74. package/types/account-manager.js.map +1 -1
  75. package/types/account-manager.mjs +216 -43
  76. package/types/account-manager.mjs.map +1 -1
  77. package/types/account.d.ts +122 -7
  78. package/types/account.d.ts.map +1 -1
  79. package/types/account.js.map +1 -1
  80. package/types/account.mjs.map +1 -1
  81. package/types/algorand-client-transaction-creator.d.ts +289 -0
  82. package/types/algorand-client-transaction-creator.d.ts.map +1 -0
  83. package/types/algorand-client-transaction-creator.js +299 -0
  84. package/types/algorand-client-transaction-creator.js.map +1 -0
  85. package/types/algorand-client-transaction-creator.mjs +297 -0
  86. package/types/algorand-client-transaction-creator.mjs.map +1 -0
  87. package/types/algorand-client-transaction-sender.d.ts +433 -0
  88. package/types/algorand-client-transaction-sender.d.ts.map +1 -0
  89. package/types/algorand-client-transaction-sender.js +422 -0
  90. package/types/algorand-client-transaction-sender.js.map +1 -0
  91. package/types/algorand-client-transaction-sender.mjs +420 -0
  92. package/types/algorand-client-transaction-sender.mjs.map +1 -0
  93. package/types/algorand-client.d.ts +28 -78
  94. package/types/algorand-client.d.ts.map +1 -1
  95. package/types/algorand-client.js +33 -122
  96. package/types/algorand-client.js.map +1 -1
  97. package/types/algorand-client.mjs +34 -123
  98. package/types/algorand-client.mjs.map +1 -1
  99. package/types/amount.d.ts +18 -6
  100. package/types/amount.d.ts.map +1 -1
  101. package/types/amount.js +33 -10
  102. package/types/amount.js.map +1 -1
  103. package/types/amount.mjs +33 -10
  104. package/types/amount.mjs.map +1 -1
  105. package/types/app-client.d.ts +3 -3
  106. package/types/app-client.d.ts.map +1 -1
  107. package/types/app-client.js +7 -10
  108. package/types/app-client.js.map +1 -1
  109. package/types/app-client.mjs +8 -11
  110. package/types/app-client.mjs.map +1 -1
  111. package/types/asset-manager.d.ts +205 -0
  112. package/types/asset-manager.d.ts.map +1 -0
  113. package/types/asset-manager.js +180 -0
  114. package/types/asset-manager.js.map +1 -0
  115. package/types/asset-manager.mjs +178 -0
  116. package/types/asset-manager.mjs.map +1 -0
  117. package/types/asset.d.ts +4 -4
  118. package/types/asset.d.ts.map +1 -1
  119. package/types/client-manager.d.ts +40 -2
  120. package/types/client-manager.d.ts.map +1 -1
  121. package/types/client-manager.js +44 -3
  122. package/types/client-manager.js.map +1 -1
  123. package/types/client-manager.mjs +44 -3
  124. package/types/client-manager.mjs.map +1 -1
  125. package/types/composer.d.ts +226 -68
  126. package/types/composer.d.ts.map +1 -1
  127. package/types/composer.js +78 -64
  128. package/types/composer.js.map +1 -1
  129. package/types/composer.mjs +75 -64
  130. package/types/composer.mjs.map +1 -1
  131. package/types/dispenser-client.d.ts +12 -4
  132. package/types/dispenser-client.d.ts.map +1 -1
  133. package/types/dispenser-client.js +9 -9
  134. package/types/dispenser-client.js.map +1 -1
  135. package/types/dispenser-client.mjs +9 -9
  136. package/types/dispenser-client.mjs.map +1 -1
  137. package/types/indexer.d.ts +7 -7
  138. package/types/indexer.d.ts.map +1 -1
  139. package/types/kmd-account-manager.d.ts +3 -3
  140. package/types/kmd-account-manager.js +6 -6
  141. package/types/kmd-account-manager.js.map +1 -1
  142. package/types/kmd-account-manager.mjs +7 -7
  143. package/types/kmd-account-manager.mjs.map +1 -1
  144. package/types/network-client.d.ts +7 -1
  145. package/types/network-client.d.ts.map +1 -1
  146. package/types/network-client.js +10 -0
  147. package/types/network-client.js.map +1 -1
  148. package/types/network-client.mjs +9 -0
  149. package/types/network-client.mjs.map +1 -1
  150. package/types/testing.d.ts +1 -1
  151. package/types/testing.d.ts.map +1 -1
  152. package/types/transfer.d.ts +8 -7
  153. package/types/transfer.d.ts.map +1 -1
  154. package/util.d.ts +13 -0
  155. package/util.d.ts.map +1 -1
  156. package/util.js +25 -0
  157. package/util.js.map +1 -1
  158. package/util.mjs +24 -1
  159. package/util.mjs.map +1 -1
@@ -0,0 +1,422 @@
1
+ 'use strict';
2
+
3
+ var config = require('../config.js');
4
+
5
+ /** Orchestrates sending transactions for `AlgorandClient`. */
6
+ class AlgorandClientTransactionSender {
7
+ /**
8
+ * Creates a new `AlgorandClientSender`
9
+ * @param newGroup A lambda that starts a new `AlgoKitComposer` transaction group
10
+ * @param assetManager An `AssetManager` instance
11
+ */
12
+ constructor(newGroup, assetManager) {
13
+ /**
14
+ * Send a payment transaction to transfer Algo between accounts.
15
+ * @param params The parameters for the payment transaction
16
+ * @example Basic example
17
+ * ```typescript
18
+ * const result = await algorandClient.send.payment({
19
+ * sender: 'SENDERADDRESS',
20
+ * receiver: 'RECEIVERADDRESS',
21
+ * amount: (4).algo(),
22
+ * })
23
+ * ```
24
+ * @example Advanced example
25
+ * ```typescript
26
+ * const result = await algorandClient.send.payment({
27
+ * amount: (4).algo(),
28
+ * receiver: 'RECEIVERADDRESS',
29
+ * sender: 'SENDERADDRESS',
30
+ * closeRemainderTo: 'CLOSEREMAINDERTOADDRESS',
31
+ * lease: 'lease',
32
+ * note: 'note',
33
+ * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
34
+ * rekeyTo: 'REKEYTOADDRESS',
35
+ * // You wouldn't normally set this field
36
+ * firstValidRound: 1000n,
37
+ * validityWindow: 10,
38
+ * extraFee: (1000).microAlgo(),
39
+ * staticFee: (1000).microAlgo(),
40
+ * // Max fee doesn't make sense with extraFee AND staticFee
41
+ * // already specified, but here for completeness
42
+ * maxFee: (3000).microAlgo(),
43
+ * // Signer only needed if you want to provide one,
44
+ * // generally you'd register it with AlgorandClient
45
+ * // against the sender and not need to pass it in
46
+ * signer: transactionSigner,
47
+ * maxRoundsToWaitForConfirmation: 5,
48
+ * suppressLog: true,
49
+ * })
50
+ * ```
51
+ *
52
+ * @returns The result of the transaction and the transaction that was sent
53
+ */
54
+ this.payment = this._send((c) => c.addPayment, {
55
+ preLog: (params, transaction) => `Sending ${params.amount.microAlgo} µALGO from ${params.sender} to ${params.receiver} via transaction ${transaction.txID()}`,
56
+ });
57
+ /**
58
+ * Create a new Algorand Standard Asset.
59
+ *
60
+ * The account that sends this transaction will automatically be
61
+ * opted in to the asset and will hold all units after creation.
62
+ *
63
+ * @param params The parameters for the asset creation transaction
64
+ *
65
+ * @example Basic example
66
+ * ```typescript
67
+ * await algorand.send.assetCreate({sender: "CREATORADDRESS", total: 100n})
68
+ * ```
69
+ * @example Advanced example
70
+ * ```typescript
71
+ * await algorand.send.assetCreate({
72
+ * sender: 'CREATORADDRESS',
73
+ * total: 100n,
74
+ * decimals: 2,
75
+ * assetName: 'asset',
76
+ * unitName: 'unit',
77
+ * url: 'url',
78
+ * metadataHash: 'metadataHash',
79
+ * defaultFrozen: false,
80
+ * manager: 'MANAGERADDRESS',
81
+ * reserve: 'RESERVEADDRESS',
82
+ * freeze: 'FREEZEADDRESS',
83
+ * clawback: 'CLAWBACKADDRESS',
84
+ * lease: 'lease',
85
+ * note: 'note',
86
+ * // You wouldn't normally set this field
87
+ * firstValidRound: 1000n,
88
+ * validityWindow: 10,
89
+ * extraFee: (1000).microAlgo(),
90
+ * staticFee: (1000).microAlgo(),
91
+ * // Max fee doesn't make sense with extraFee AND staticFee
92
+ * // already specified, but here for completeness
93
+ * maxFee: (3000).microAlgo(),
94
+ * // Signer only needed if you want to provide one,
95
+ * // generally you'd register it with AlgorandClient
96
+ * // against the sender and not need to pass it in
97
+ * signer: transactionSigner,
98
+ * maxRoundsToWaitForConfirmation: 5,
99
+ * suppressLog: true,
100
+ * })
101
+ * ```
102
+ * @returns The result of the transaction and the transaction that was sent
103
+ */
104
+ this.assetCreate = async (params) => {
105
+ const result = await this._send((c) => c.addAssetCreate, {
106
+ 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)}`,
107
+ })(params);
108
+ return { ...result, assetId: BigInt(result.confirmation.assetIndex ?? 0) };
109
+ };
110
+ /**
111
+ * Configure an existing Algorand Standard Asset.
112
+ *
113
+ * **Note:** The manager, reserve, freeze, and clawback addresses
114
+ * are immutably empty if they are not set. If manager is not set then
115
+ * all fields are immutable from that point forward.
116
+ *
117
+ * @param params The parameters for the asset config transaction
118
+ *
119
+ * @example Basic example
120
+ * ```typescript
121
+ * await algorand.send.assetConfig({sender: "MANAGERADDRESS", assetId: 123456n, manager: "MANAGERADDRESS" })
122
+ * ```
123
+ * @example Advanced example
124
+ * ```typescript
125
+ * await algorand.send.assetConfig({
126
+ * sender: 'MANAGERADDRESS',
127
+ * assetId: 123456n,
128
+ * manager: 'MANAGERADDRESS',
129
+ * reserve: 'RESERVEADDRESS',
130
+ * freeze: 'FREEZEADDRESS',
131
+ * clawback: 'CLAWBACKADDRESS',
132
+ * lease: 'lease',
133
+ * note: 'note',
134
+ * // You wouldn't normally set this field
135
+ * firstValidRound: 1000n,
136
+ * validityWindow: 10,
137
+ * extraFee: (1000).microAlgo(),
138
+ * staticFee: (1000).microAlgo(),
139
+ * // Max fee doesn't make sense with extraFee AND staticFee
140
+ * // already specified, but here for completeness
141
+ * maxFee: (3000).microAlgo(),
142
+ * // Signer only needed if you want to provide one,
143
+ * // generally you'd register it with AlgorandClient
144
+ * // against the sender and not need to pass it in
145
+ * signer: transactionSigner,
146
+ * maxRoundsToWaitForConfirmation: 5,
147
+ * suppressLog: true,
148
+ * })
149
+ * ```
150
+ * @returns The result of the transaction and the transaction that was sent
151
+ */
152
+ this.assetConfig = this._send((c) => c.addAssetConfig, {
153
+ preLog: (params, transaction) => `Configuring asset with ID ${params.assetId} via transaction ${transaction.txID()}`,
154
+ });
155
+ /**
156
+ * Freeze or unfreeze an Algorand Standard Asset for an account.
157
+ *
158
+ * @param params The parameters for the asset freeze transaction
159
+ *
160
+ * @example Basic example
161
+ * ```typescript
162
+ * await algorand.send.assetFreeze({sender: "MANAGERADDRESS", assetId: 123456n, account: "ACCOUNTADDRESS", frozen: true })
163
+ * ```
164
+ * @example Advanced example
165
+ * ```typescript
166
+ * await algorand.send.assetFreeze({
167
+ * sender: 'MANAGERADDRESS',
168
+ * assetId: 123456n,
169
+ * account: 'ACCOUNTADDRESS',
170
+ * frozen: true,
171
+ * lease: 'lease',
172
+ * note: 'note',
173
+ * // You wouldn't normally set this field
174
+ * firstValidRound: 1000n,
175
+ * validityWindow: 10,
176
+ * extraFee: (1000).microAlgo(),
177
+ * staticFee: (1000).microAlgo(),
178
+ * // Max fee doesn't make sense with extraFee AND staticFee
179
+ * // already specified, but here for completeness
180
+ * maxFee: (3000).microAlgo(),
181
+ * // Signer only needed if you want to provide one,
182
+ * // generally you'd register it with AlgorandClient
183
+ * // against the sender and not need to pass it in
184
+ * signer: transactionSigner,
185
+ * maxRoundsToWaitForConfirmation: 5,
186
+ * suppressLog: true,
187
+ * })
188
+ * ```
189
+ * @returns The result of the transaction and the transaction that was sent
190
+ */
191
+ this.assetFreeze = this._send((c) => c.addAssetFreeze, {
192
+ preLog: (params, transaction) => `Freezing asset with ID ${params.assetId} via transaction ${transaction.txID()}`,
193
+ });
194
+ /**
195
+ * Destroys an Algorand Standard Asset.
196
+ *
197
+ * Created assets can be destroyed only by the asset manager account.
198
+ * All of the assets must be owned by the creator of the asset before
199
+ * the asset can be deleted.
200
+ *
201
+ * @param params The parameters for the asset destroy transaction
202
+ *
203
+ * @example Basic example
204
+ * ```typescript
205
+ * await algorand.send.assetDestroy({sender: "MANAGERADDRESS", assetId: 123456n })
206
+ * ```
207
+ * @example Advanced example
208
+ * ```typescript
209
+ * await algorand.send.assetDestroy({
210
+ * sender: 'MANAGERADDRESS',
211
+ * assetId: 123456n,
212
+ * lease: 'lease',
213
+ * note: 'note',
214
+ * // You wouldn't normally set this field
215
+ * firstValidRound: 1000n,
216
+ * validityWindow: 10,
217
+ * extraFee: (1000).microAlgo(),
218
+ * staticFee: (1000).microAlgo(),
219
+ * // Max fee doesn't make sense with extraFee AND staticFee
220
+ * // already specified, but here for completeness
221
+ * maxFee: (3000).microAlgo(),
222
+ * // Signer only needed if you want to provide one,
223
+ * // generally you'd register it with AlgorandClient
224
+ * // against the sender and not need to pass it in
225
+ * signer: transactionSigner,
226
+ * maxRoundsToWaitForConfirmation: 5,
227
+ * suppressLog: true,
228
+ * })
229
+ * ```
230
+ * @returns The result of the transaction and the transaction that was sent
231
+ */
232
+ this.assetDestroy = this._send((c) => c.addAssetDestroy, {
233
+ preLog: (params, transaction) => `Destroying asset with ID ${params.assetId} via transaction ${transaction.txID()}`,
234
+ });
235
+ /**
236
+ * Transfer an Algorand Standard Asset.
237
+ *
238
+ * @param params The parameters for the asset transfer transaction
239
+ *
240
+ * @example Basic example
241
+ * ```typescript
242
+ * await algorand.send.assetTransfer({sender: "HOLDERADDRESS", assetId: 123456n, amount: 1n, receiver: "RECEIVERADDRESS" })
243
+ * ```
244
+ * @example Advanced example (with clawback)
245
+ * ```typescript
246
+ * await algorand.send.assetTransfer({
247
+ * sender: 'CLAWBACKADDRESS',
248
+ * assetId: 123456n,
249
+ * amount: 1n,
250
+ * receiver: 'RECEIVERADDRESS',
251
+ * clawbackTarget: 'HOLDERADDRESS',
252
+ * // This field needs to be used with caution
253
+ * closeAssetTo: 'ADDRESSTOCLOSETO'
254
+ * lease: 'lease',
255
+ * note: 'note',
256
+ * // You wouldn't normally set this field
257
+ * firstValidRound: 1000n,
258
+ * validityWindow: 10,
259
+ * extraFee: (1000).microAlgo(),
260
+ * staticFee: (1000).microAlgo(),
261
+ * // Max fee doesn't make sense with extraFee AND staticFee
262
+ * // already specified, but here for completeness
263
+ * maxFee: (3000).microAlgo(),
264
+ * // Signer only needed if you want to provide one,
265
+ * // generally you'd register it with AlgorandClient
266
+ * // against the sender and not need to pass it in
267
+ * signer: transactionSigner,
268
+ * maxRoundsToWaitForConfirmation: 5,
269
+ * suppressLog: true,
270
+ * })
271
+ * ```
272
+ * @returns The result of the transaction and the transaction that was sent
273
+ */
274
+ this.assetTransfer = this._send((c) => c.addAssetTransfer, {
275
+ preLog: (params, transaction) => `Transferring ${params.amount} units of asset with ID ${params.assetId} from ${params.sender} to ${params.receiver} via transaction ${transaction.txID()}`,
276
+ });
277
+ /**
278
+ * Opt an account into an Algorand Standard Asset.
279
+ *
280
+ * @param params The parameters for the asset opt-in transaction
281
+ *
282
+ * @example Basic example
283
+ * ```typescript
284
+ * await algorand.send.assetOptIn({sender: "SENDERADDRESS", assetId: 123456n })
285
+ * ```
286
+ * @example Advanced example
287
+ * ```typescript
288
+ * await algorand.send.assetOptIn({
289
+ * sender: 'SENDERADDRESS',
290
+ * assetId: 123456n,
291
+ * lease: 'lease',
292
+ * note: 'note',
293
+ * // You wouldn't normally set this field
294
+ * firstValidRound: 1000n,
295
+ * validityWindow: 10,
296
+ * extraFee: (1000).microAlgo(),
297
+ * staticFee: (1000).microAlgo(),
298
+ * // Max fee doesn't make sense with extraFee AND staticFee
299
+ * // already specified, but here for completeness
300
+ * maxFee: (3000).microAlgo(),
301
+ * // Signer only needed if you want to provide one,
302
+ * // generally you'd register it with AlgorandClient
303
+ * // against the sender and not need to pass it in
304
+ * signer: transactionSigner,
305
+ * maxRoundsToWaitForConfirmation: 5,
306
+ * suppressLog: true,
307
+ * })
308
+ * ```
309
+ * @returns The result of the transaction and the transaction that was sent
310
+ */
311
+ this.assetOptIn = this._send((c) => c.addAssetOptIn, {
312
+ preLog: (params, transaction) => `Opting in ${params.sender} to asset with ID ${params.assetId} via transaction ${transaction.txID()}`,
313
+ });
314
+ /**
315
+ * Opt an account out of an Algorand Standard Asset.
316
+ *
317
+ * *Note:* If the account has a balance of the asset,
318
+ * it will not be able to opt-out unless `ensureZeroBalance`
319
+ * is set to `false` (but then the account will lose the assets).
320
+ *
321
+ * @param params The parameters for the asset opt-out transaction
322
+ *
323
+ * @example Basic example (without creator)
324
+ * ```typescript
325
+ * await algorand.send.assetOptOut({sender: "SENDERADDRESS", assetId: 123456n, ensureZeroBalance: true })
326
+ * ```
327
+ * @example Basic example (with creator)
328
+ * ```typescript
329
+ * await algorand.send.assetOptOut({sender: "SENDERADDRESS", creator: "CREATORADDRESS", assetId: 123456n, ensureZeroBalance: true })
330
+ * ```
331
+ * @example Advanced example
332
+ * ```typescript
333
+ * await algorand.send.assetOptOut({
334
+ * sender: 'SENDERADDRESS',
335
+ * assetId: 123456n,
336
+ * creator: 'CREATORADDRESS',
337
+ * ensureZeroBalance: true,
338
+ * lease: 'lease',
339
+ * note: 'note',
340
+ * // You wouldn't normally set this field
341
+ * firstValidRound: 1000n,
342
+ * validityWindow: 10,
343
+ * extraFee: (1000).microAlgo(),
344
+ * staticFee: (1000).microAlgo(),
345
+ * // Max fee doesn't make sense with extraFee AND staticFee
346
+ * // already specified, but here for completeness
347
+ * maxFee: (3000).microAlgo(),
348
+ * // Signer only needed if you want to provide one,
349
+ * // generally you'd register it with AlgorandClient
350
+ * // against the sender and not need to pass it in
351
+ * signer: transactionSigner,
352
+ * maxRoundsToWaitForConfirmation: 5,
353
+ * suppressLog: true,
354
+ * })
355
+ * ```
356
+ * @returns The result of the transaction and the transaction that was sent
357
+ */
358
+ this.assetOptOut = async (params) => {
359
+ if (params.ensureZeroBalance) {
360
+ let balance = 0n;
361
+ try {
362
+ const accountAssetInfo = await this._assetManager.getAccountInformation(params.sender, params.assetId);
363
+ balance = accountAssetInfo.balance;
364
+ }
365
+ catch (e) {
366
+ throw new Error(`Account ${params.sender} is not opted-in to Asset ${params.assetId}; can't opt-out.`);
367
+ }
368
+ if (balance !== 0n) {
369
+ throw new Error(`Account ${params.sender} does not have a zero balance for Asset ${params.assetId}; can't opt-out.`);
370
+ }
371
+ }
372
+ params.creator = params.creator ?? (await this._assetManager.getById(params.assetId)).creator;
373
+ return await this._send((c) => c.addAssetOptOut, {
374
+ preLog: (params, transaction) => `Opting ${params.sender} out of asset with ID ${params.assetId} to creator ${params.creator} via transaction ${transaction.txID()}`,
375
+ })(params);
376
+ };
377
+ /**
378
+ * Call a smart contract.
379
+ *
380
+ * Note: you may prefer to use `algorandClient.client` to get an app client for more advanced functionality.
381
+ */
382
+ this.appCall = this._send((c) => c.addAppCall);
383
+ /**
384
+ * Call a smart contract ABI method.
385
+ *
386
+ * Note: you may prefer to use `algorandClient.client` to get an app client for more advanced functionality.
387
+ */
388
+ this.methodCall = this._send((c) => c.addMethodCall);
389
+ /** Register an online key. */
390
+ this.onlineKeyRegistration = this._send((c) => c.addOnlineKeyRegistration, {
391
+ preLog: (params, transaction) => `Registering online key for ${params.sender} via transaction ${transaction.txID()}`,
392
+ });
393
+ this._newGroup = newGroup;
394
+ this._assetManager = assetManager;
395
+ }
396
+ _send(c, log) {
397
+ return async (params) => {
398
+ const composer = this._newGroup();
399
+ // Ensure `this` is properly populated
400
+ c(composer).apply(composer, [params]);
401
+ if (log?.preLog) {
402
+ const transaction = (await composer.build()).transactions.at(-1).txn;
403
+ config.Config.getLogger(params?.suppressLog).debug(log.preLog(params, transaction));
404
+ }
405
+ const rawResult = await composer.execute(params);
406
+ const result = {
407
+ // Last item covers when a group is created by an app call with ABI transaction parameters
408
+ transaction: rawResult.transactions[rawResult.transactions.length - 1],
409
+ confirmation: rawResult.confirmations[rawResult.confirmations.length - 1],
410
+ txId: rawResult.txIds[0],
411
+ ...rawResult,
412
+ };
413
+ if (log?.postLog) {
414
+ config.Config.getLogger(params?.suppressLog).debug(log.postLog(params, result));
415
+ }
416
+ return result;
417
+ };
418
+ }
419
+ }
420
+
421
+ exports.AlgorandClientTransactionSender = AlgorandClientTransactionSender;
422
+ //# sourceMappingURL=algorand-client-transaction-sender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algorand-client-transaction-sender.js","sources":["../../src/types/algorand-client-transaction-sender.ts"],"sourcesContent":[null],"names":["Config"],"mappings":";;;;AAWA;MACa,+BAA+B,CAAA;AAI1C;;;;AAIG;IACH,WAAY,CAAA,QAA+B,EAAE,YAA0B,EAAA;AAwCvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCG;AACH,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE;YACxC,MAAM,EAAE,CAAC,MAAM,EAAE,WAAW,KAC1B,CAAA,QAAA,EAAW,MAAM,CAAC,MAAM,CAAC,SAAS,CAAA,YAAA,EAAe,MAAM,CAAC,MAAM,CAAA,IAAA,EAAO,MAAM,CAAC,QAAQ,CAAA,iBAAA,EAAoB,WAAW,CAAC,IAAI,EAAE,CAAE,CAAA;AAC/H,SAAA,CAAC,CAAA;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CG;AACH,QAAA,IAAA,CAAA,WAAW,GAAG,OAAO,MAAyC,KAAI;AAChE,YAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,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