algosdk 2.1.0 → 2.3.0
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.
- package/README.md +5 -7
- package/dist/browser/algosdk.min.js +1 -1
- package/dist/browser/algosdk.min.js.map +1 -1
- package/dist/cjs/client/v2/algod/algod.js +215 -23
- package/dist/cjs/client/v2/algod/algod.js.map +1 -1
- package/dist/cjs/client/v2/algod/getApplicationBoxByName.js +1 -1
- package/dist/cjs/client/v2/algod/getApplicationBoxes.js +1 -1
- package/dist/cjs/client/v2/algod/getBlockOffsetTimestamp.js +19 -0
- package/dist/cjs/client/v2/algod/getBlockOffsetTimestamp.js.map +1 -0
- package/dist/cjs/client/v2/algod/getSyncRound.js +19 -0
- package/dist/cjs/client/v2/algod/getSyncRound.js.map +1 -0
- package/dist/cjs/client/v2/algod/models/types.js +361 -8
- package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
- package/dist/cjs/client/v2/algod/ready.js +14 -0
- package/dist/cjs/client/v2/algod/ready.js.map +1 -0
- package/dist/cjs/client/v2/algod/setBlockOffsetTimestamp.js +22 -0
- package/dist/cjs/client/v2/algod/setBlockOffsetTimestamp.js.map +1 -0
- package/dist/cjs/client/v2/algod/setSyncRound.js +22 -0
- package/dist/cjs/client/v2/algod/setSyncRound.js.map +1 -0
- package/dist/cjs/client/v2/algod/simulateTransaction.js +73 -0
- package/dist/cjs/client/v2/algod/simulateTransaction.js.map +1 -0
- package/dist/cjs/client/v2/algod/suggestedParams.js +1 -0
- package/dist/cjs/client/v2/algod/suggestedParams.js.map +1 -1
- package/dist/cjs/client/v2/algod/unsetSyncRound.js +18 -0
- package/dist/cjs/client/v2/algod/unsetSyncRound.js.map +1 -0
- package/dist/cjs/composer.js +106 -18
- package/dist/cjs/composer.js.map +1 -1
- package/dist/cjs/encoding/encoding.js +14 -3
- package/dist/cjs/encoding/encoding.js.map +1 -1
- package/dist/cjs/main.js.map +1 -1
- package/dist/cjs/makeTxn.js.map +1 -1
- package/dist/cjs/signer.js +17 -1
- package/dist/cjs/signer.js.map +1 -1
- package/dist/cjs/transaction.js +16 -1
- package/dist/cjs/transaction.js.map +1 -1
- package/dist/esm/client/v2/algod/algod.js +192 -23
- package/dist/esm/client/v2/algod/algod.js.map +1 -1
- package/dist/esm/client/v2/algod/getApplicationBoxByName.js +1 -1
- package/dist/esm/client/v2/algod/getApplicationBoxes.js +1 -1
- package/dist/esm/client/v2/algod/getBlockOffsetTimestamp.js +13 -0
- package/dist/esm/client/v2/algod/getBlockOffsetTimestamp.js.map +1 -0
- package/dist/esm/client/v2/algod/getSyncRound.js +13 -0
- package/dist/esm/client/v2/algod/getSyncRound.js.map +1 -0
- package/dist/esm/client/v2/algod/models/types.js +351 -7
- package/dist/esm/client/v2/algod/models/types.js.map +1 -1
- package/dist/esm/client/v2/algod/ready.js +8 -0
- package/dist/esm/client/v2/algod/ready.js.map +1 -0
- package/dist/esm/client/v2/algod/setBlockOffsetTimestamp.js +16 -0
- package/dist/esm/client/v2/algod/setBlockOffsetTimestamp.js.map +1 -0
- package/dist/esm/client/v2/algod/setSyncRound.js +16 -0
- package/dist/esm/client/v2/algod/setSyncRound.js.map +1 -0
- package/dist/esm/client/v2/algod/simulateTransaction.js +42 -0
- package/dist/esm/client/v2/algod/simulateTransaction.js.map +1 -0
- package/dist/esm/client/v2/algod/suggestedParams.js +1 -0
- package/dist/esm/client/v2/algod/suggestedParams.js.map +1 -1
- package/dist/esm/client/v2/algod/unsetSyncRound.js +12 -0
- package/dist/esm/client/v2/algod/unsetSyncRound.js.map +1 -0
- package/dist/esm/composer.js +84 -19
- package/dist/esm/composer.js.map +1 -1
- package/dist/esm/encoding/encoding.js +12 -2
- package/dist/esm/encoding/encoding.js.map +1 -1
- package/dist/esm/main.js.map +1 -1
- package/dist/esm/makeTxn.js.map +1 -1
- package/dist/esm/signer.js +15 -0
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/transaction.js +14 -0
- package/dist/esm/transaction.js.map +1 -1
- package/dist/types/client/v2/algod/algod.d.ts +158 -23
- package/dist/types/client/v2/algod/getApplicationBoxByName.d.ts +1 -1
- package/dist/types/client/v2/algod/getApplicationBoxes.d.ts +1 -1
- package/dist/types/client/v2/algod/getBlockOffsetTimestamp.d.ts +6 -0
- package/dist/types/client/v2/algod/getSyncRound.d.ts +6 -0
- package/dist/types/client/v2/algod/models/types.d.ts +324 -14
- package/dist/types/client/v2/algod/ready.d.ts +4 -0
- package/dist/types/client/v2/algod/setBlockOffsetTimestamp.d.ts +9 -0
- package/dist/types/client/v2/algod/setSyncRound.d.ts +9 -0
- package/dist/types/client/v2/algod/simulateTransaction.d.ts +19 -0
- package/dist/types/client/v2/algod/suggestedParams.d.ts +3 -3
- package/dist/types/client/v2/algod/unsetSyncRound.d.ts +5 -0
- package/dist/types/composer.d.ts +31 -1
- package/dist/types/encoding/encoding.d.ts +7 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/makeTxn.d.ts +1 -3
- package/dist/types/signer.d.ts +5 -0
- package/dist/types/transaction.d.ts +9 -0
- package/dist/types/types/transactions/base.d.ts +6 -0
- package/dist/types/types/transactions/builder.d.ts +1 -1
- package/dist/types/types/utils.d.ts +1 -1
- package/package.json +2 -2
- package/src/client/v2/algod/algod.ts +199 -23
- package/src/client/v2/algod/getApplicationBoxByName.ts +1 -1
- package/src/client/v2/algod/getApplicationBoxes.ts +1 -1
- package/src/client/v2/algod/getBlockOffsetTimestamp.ts +17 -0
- package/src/client/v2/algod/getSyncRound.ts +17 -0
- package/src/client/v2/algod/models/types.ts +652 -12
- package/src/client/v2/algod/ready.ts +8 -0
- package/src/client/v2/algod/setBlockOffsetTimestamp.ts +20 -0
- package/src/client/v2/algod/setSyncRound.ts +20 -0
- package/src/client/v2/algod/simulateTransaction.ts +58 -0
- package/src/client/v2/algod/suggestedParams.ts +4 -3
- package/src/client/v2/algod/unsetSyncRound.ts +13 -0
- package/src/composer.ts +138 -31
- package/src/encoding/encoding.ts +13 -2
- package/src/main.ts +7 -0
- package/src/makeTxn.ts +2 -4
- package/src/signer.ts +18 -1
- package/src/transaction.ts +17 -0
- package/src/types/transactions/base.ts +7 -0
- package/src/types/transactions/builder.ts +4 -4
- package/src/types/utils.ts +1 -1
|
@@ -30,7 +30,16 @@ import {
|
|
|
30
30
|
} from '../../urlTokenBaseHTTPClient';
|
|
31
31
|
import LightBlockHeaderProof from './lightBlockHeaderProof';
|
|
32
32
|
import StateProof from './stateproof';
|
|
33
|
+
import SetSyncRound from './setSyncRound';
|
|
34
|
+
import GetSyncRound from './getSyncRound';
|
|
35
|
+
import SetBlockOffsetTimestamp from './setBlockOffsetTimestamp';
|
|
36
|
+
import GetBlockOffsetTimestamp from './getBlockOffsetTimestamp';
|
|
33
37
|
import Disassemble from './disassemble';
|
|
38
|
+
import SimulateRawTransactions from './simulateTransaction';
|
|
39
|
+
import { EncodedSignedTransaction } from '../../../types';
|
|
40
|
+
import * as encoding from '../../../encoding/encoding';
|
|
41
|
+
import Ready from './ready';
|
|
42
|
+
import UnsetSyncRound from './unsetSyncRound';
|
|
34
43
|
|
|
35
44
|
/**
|
|
36
45
|
* Algod client connects an application to the Algorand blockchain. The algod client requires a valid algod REST endpoint IP address and algod token from an Algorand node that is connected to the network you plan to interact with.
|
|
@@ -85,7 +94,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
85
94
|
* const health = await algodClient.healthCheck().do();
|
|
86
95
|
* ```
|
|
87
96
|
*
|
|
88
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
97
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-health)
|
|
89
98
|
* @category GET
|
|
90
99
|
*/
|
|
91
100
|
healthCheck() {
|
|
@@ -100,7 +109,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
100
109
|
* const versionsDetails = await algodClient.versionsCheck().do();
|
|
101
110
|
* ```
|
|
102
111
|
*
|
|
103
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
112
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-versions)
|
|
104
113
|
* @category GET
|
|
105
114
|
*/
|
|
106
115
|
versionsCheck() {
|
|
@@ -116,7 +125,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
116
125
|
* const result = await waitForConfirmation(algodClient, txid, 3);
|
|
117
126
|
* ```
|
|
118
127
|
*
|
|
119
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
128
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactions)
|
|
120
129
|
*
|
|
121
130
|
* @remarks
|
|
122
131
|
* Often used with {@linkcode waitForConfirmation}
|
|
@@ -136,7 +145,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
136
145
|
* const accountInfo = await algodClient.accountInformation(address).do();
|
|
137
146
|
* ```
|
|
138
147
|
*
|
|
139
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
148
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress)
|
|
140
149
|
* @param account - The address of the account to look up.
|
|
141
150
|
* @category GET
|
|
142
151
|
*/
|
|
@@ -154,7 +163,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
154
163
|
* const accountAssetInfo = await algodClient.accountAssetInformation(address, index).do();
|
|
155
164
|
* ```
|
|
156
165
|
*
|
|
157
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
166
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress)
|
|
158
167
|
* @param account - The address of the account to look up.
|
|
159
168
|
* @param index - The asset ID to look up.
|
|
160
169
|
* @category GET
|
|
@@ -178,7 +187,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
178
187
|
* const accountInfo = await algodClient.accountApplicationInformation(address, index).do();
|
|
179
188
|
* ```
|
|
180
189
|
*
|
|
181
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
190
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress)
|
|
182
191
|
* @param account - The address of the account to look up.
|
|
183
192
|
* @param index - The application ID to look up.
|
|
184
193
|
* @category GET
|
|
@@ -201,7 +210,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
201
210
|
* const block = await algodClient.block(roundNumber).do();
|
|
202
211
|
* ```
|
|
203
212
|
*
|
|
204
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
213
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksround)
|
|
205
214
|
* @param roundNumber - The round number of the block to get.
|
|
206
215
|
* @category GET
|
|
207
216
|
*/
|
|
@@ -218,7 +227,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
218
227
|
* const block = await algodClient.getBlockHash(roundNumber).do();
|
|
219
228
|
* ```
|
|
220
229
|
*
|
|
221
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
230
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksroundhash)
|
|
222
231
|
* @param roundNumber - The round number of the block to get.
|
|
223
232
|
* @category GET
|
|
224
233
|
*/
|
|
@@ -235,7 +244,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
235
244
|
* const pending = await algodClient.pendingTransactionInformation(txId).do();
|
|
236
245
|
* ```
|
|
237
246
|
*
|
|
238
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
247
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2transactionspendingtxid)
|
|
239
248
|
*
|
|
240
249
|
* @remarks
|
|
241
250
|
* <br><br>
|
|
@@ -271,7 +280,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
271
280
|
* .do();
|
|
272
281
|
* ```
|
|
273
282
|
*
|
|
274
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
283
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2transactionspending)
|
|
275
284
|
* @category GET
|
|
276
285
|
*/
|
|
277
286
|
pendingTransactionsInformation() {
|
|
@@ -298,7 +307,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
298
307
|
* .do();
|
|
299
308
|
* ```
|
|
300
309
|
*
|
|
301
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
310
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddresstransactionspending)
|
|
302
311
|
* @param address - The address of the sender.
|
|
303
312
|
* @category GET
|
|
304
313
|
*/
|
|
@@ -314,7 +323,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
314
323
|
* const status = await algodClient.status().do();
|
|
315
324
|
* ```
|
|
316
325
|
*
|
|
317
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
326
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2status)
|
|
318
327
|
* @category GET
|
|
319
328
|
*/
|
|
320
329
|
status() {
|
|
@@ -330,7 +339,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
330
339
|
* const statusAfterBlock = await algodClient.statusAfterBlock(round).do();
|
|
331
340
|
* ```
|
|
332
341
|
*
|
|
333
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
342
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2statuswait-for-block-afterround)
|
|
334
343
|
* @param round - The number of the round to wait for.
|
|
335
344
|
* @category GET
|
|
336
345
|
*/
|
|
@@ -353,7 +362,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
353
362
|
* });
|
|
354
363
|
* ```
|
|
355
364
|
*
|
|
356
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
365
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2transactionsparams)
|
|
357
366
|
*
|
|
358
367
|
* @remarks
|
|
359
368
|
* Often used with
|
|
@@ -372,7 +381,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
372
381
|
* const supplyDetails = await algodClient.supply().do();
|
|
373
382
|
* ```
|
|
374
383
|
*
|
|
375
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
384
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2ledgersupply)
|
|
376
385
|
* @category GET
|
|
377
386
|
*/
|
|
378
387
|
supply() {
|
|
@@ -388,7 +397,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
388
397
|
* const compiledSmartContract = await algodClient.compile(source).do();
|
|
389
398
|
* ```
|
|
390
399
|
*
|
|
391
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
400
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2tealcompile)
|
|
392
401
|
* @remarks
|
|
393
402
|
* This endpoint is only enabled when a node's configuration file sets `EnableDeveloperAPI` to true.
|
|
394
403
|
* @param source
|
|
@@ -424,7 +433,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
424
433
|
* const dryRunResult = await algodClient.dryrun(dr).do();
|
|
425
434
|
* ```
|
|
426
435
|
*
|
|
427
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
436
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2tealdryrun)
|
|
428
437
|
* @param dr
|
|
429
438
|
* @category POST
|
|
430
439
|
*/
|
|
@@ -442,7 +451,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
442
451
|
* const asset = await algodClient.getAssetByID(asset_id).do();
|
|
443
452
|
* ```
|
|
444
453
|
*
|
|
445
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
454
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2assetsasset-id)
|
|
446
455
|
* @param index - The asset ID to look up.
|
|
447
456
|
* @category GET
|
|
448
457
|
*/
|
|
@@ -460,7 +469,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
460
469
|
* const app = await algodClient.getApplicationByID(index).do();
|
|
461
470
|
* ```
|
|
462
471
|
*
|
|
463
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
472
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-id)
|
|
464
473
|
* @param index - The application ID to look up.
|
|
465
474
|
* @category GET
|
|
466
475
|
*/
|
|
@@ -479,7 +488,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
479
488
|
* const boxValue = boxResponse.value;
|
|
480
489
|
* ```
|
|
481
490
|
*
|
|
482
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
491
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idbox)
|
|
483
492
|
* @param index - The application ID to look up.
|
|
484
493
|
* @category GET
|
|
485
494
|
*/
|
|
@@ -502,7 +511,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
502
511
|
* const boxNames = boxesResponse.boxes.map(box => box.name);
|
|
503
512
|
* ```
|
|
504
513
|
*
|
|
505
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
514
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idboxes)
|
|
506
515
|
* @param index - The application ID to look up.
|
|
507
516
|
* @category GET
|
|
508
517
|
*/
|
|
@@ -518,7 +527,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
518
527
|
* const genesis = await algodClient.genesis().do();
|
|
519
528
|
* ```
|
|
520
529
|
*
|
|
521
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
530
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-genesis)
|
|
522
531
|
* @category GET
|
|
523
532
|
*/
|
|
524
533
|
genesis() {
|
|
@@ -535,7 +544,7 @@ export default class AlgodClient extends ServiceClient {
|
|
|
535
544
|
* const proof = await algodClient.getTransactionProof(round, txId).do();
|
|
536
545
|
* ```
|
|
537
546
|
*
|
|
538
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
547
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksroundtransactionstxidproof)
|
|
539
548
|
* @param round - The round in which the transaction appears.
|
|
540
549
|
* @param txID - The transaction ID for which to generate a proof.
|
|
541
550
|
* @category GET
|
|
@@ -575,4 +584,171 @@ export default class AlgodClient extends ServiceClient {
|
|
|
575
584
|
getStateProof(round: number) {
|
|
576
585
|
return new StateProof(this.c, this.intDecoding, round);
|
|
577
586
|
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Simulate a list of a signed transaction objects being sent to the network.
|
|
590
|
+
*
|
|
591
|
+
* #### Example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* const txn1 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn1Params);
|
|
594
|
+
* const txn2 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn2Params);
|
|
595
|
+
* const txgroup = algosdk.assignGroupID([txn1, txn2]);
|
|
596
|
+
*
|
|
597
|
+
* // Actually sign the first transaction
|
|
598
|
+
* const signedTxn1 = txgroup[0].signTxn(senderSk).blob;
|
|
599
|
+
* // Simulate does not require signed transactions -- use this method to encode an unsigned transaction
|
|
600
|
+
* const signedTxn2 = algosdk.encodeUnsignedSimulateTransaction(txgroup[1]);
|
|
601
|
+
*
|
|
602
|
+
* const resp = await client.simulateRawTransactions([signedTxn1, signedTxn2]).do();
|
|
603
|
+
* ```
|
|
604
|
+
*
|
|
605
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactionssimulate)
|
|
606
|
+
* @param stxOrStxs
|
|
607
|
+
* @category POST
|
|
608
|
+
*/
|
|
609
|
+
simulateRawTransactions(stxOrStxs: Uint8Array | Uint8Array[]) {
|
|
610
|
+
const txnObjects: EncodedSignedTransaction[] = [];
|
|
611
|
+
if (Array.isArray(stxOrStxs)) {
|
|
612
|
+
for (const stxn of stxOrStxs) {
|
|
613
|
+
txnObjects.push(encoding.decode(stxn) as EncodedSignedTransaction);
|
|
614
|
+
}
|
|
615
|
+
} else {
|
|
616
|
+
txnObjects.push(encoding.decode(stxOrStxs) as EncodedSignedTransaction);
|
|
617
|
+
}
|
|
618
|
+
const request = new modelsv2.SimulateRequest({
|
|
619
|
+
txnGroups: [
|
|
620
|
+
new modelsv2.SimulateRequestTransactionGroup({
|
|
621
|
+
txns: txnObjects,
|
|
622
|
+
}),
|
|
623
|
+
],
|
|
624
|
+
});
|
|
625
|
+
return this.simulateTransactions(request);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Simulate transactions being sent to the network.
|
|
630
|
+
*
|
|
631
|
+
* #### Example
|
|
632
|
+
* ```typescript
|
|
633
|
+
* const txn1 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn1Params);
|
|
634
|
+
* const txn2 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn2Params);
|
|
635
|
+
* const txgroup = algosdk.assignGroupID([txn1, txn2]);
|
|
636
|
+
*
|
|
637
|
+
* // Actually sign the first transaction
|
|
638
|
+
* const signedTxn1 = txgroup[0].signTxn(senderSk).blob;
|
|
639
|
+
* // Simulate does not require signed transactions -- use this method to encode an unsigned transaction
|
|
640
|
+
* const signedTxn2 = algosdk.encodeUnsignedSimulateTransaction(txgroup[1]);
|
|
641
|
+
*
|
|
642
|
+
* const request = new modelsv2.SimulateRequest({
|
|
643
|
+
* txnGroups: [
|
|
644
|
+
* new modelsv2.SimulateRequestTransactionGroup({
|
|
645
|
+
* // Must decode the signed txn bytes into an object
|
|
646
|
+
* txns: [algosdk.decodeObj(signedTxn1), algosdk.decodeObj(signedTxn2)]
|
|
647
|
+
* }),
|
|
648
|
+
* ],
|
|
649
|
+
* });
|
|
650
|
+
* const resp = await client.simulateRawTransactions(request).do();
|
|
651
|
+
* ```
|
|
652
|
+
*
|
|
653
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactionssimulate)
|
|
654
|
+
* @param request
|
|
655
|
+
* @category POST
|
|
656
|
+
*/
|
|
657
|
+
simulateTransactions(request: modelsv2.SimulateRequest) {
|
|
658
|
+
return new SimulateRawTransactions(this.c, request);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Set the offset (in seconds) applied to the block timestamp when creating new blocks in devmode.
|
|
663
|
+
*
|
|
664
|
+
* #### Example
|
|
665
|
+
* ```typesecript
|
|
666
|
+
* const offset = 60
|
|
667
|
+
* await client.setBlockOffsetTimestamp(offset).do();
|
|
668
|
+
* ```
|
|
669
|
+
*
|
|
670
|
+
[Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2devmodeblocksoffsetoffset)
|
|
671
|
+
* @param offset
|
|
672
|
+
* @category POST
|
|
673
|
+
*/
|
|
674
|
+
setBlockOffsetTimestamp(offset: number) {
|
|
675
|
+
return new SetBlockOffsetTimestamp(this.c, this.intDecoding, offset);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Get the offset (in seconds) applied to the block timestamp when creating new blocks in devmode.
|
|
680
|
+
*
|
|
681
|
+
* #### Example
|
|
682
|
+
* ```typesecript
|
|
683
|
+
* const currentOffset = await client.getBlockOffsetTimestamp().do();
|
|
684
|
+
* ```
|
|
685
|
+
*
|
|
686
|
+
[Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2devmodeblocksoffset)
|
|
687
|
+
* @category GET
|
|
688
|
+
*/
|
|
689
|
+
getBlockOffsetTimestamp() {
|
|
690
|
+
return new GetBlockOffsetTimestamp(this.c, this.intDecoding);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Set the sync round on the ledger (algod must have EnableFollowMode: true), restricting catchup.
|
|
695
|
+
*
|
|
696
|
+
* #### Example
|
|
697
|
+
* ```typesecript
|
|
698
|
+
* const round = 10000
|
|
699
|
+
* await client.setSyncRound(round).do();
|
|
700
|
+
* ```
|
|
701
|
+
*
|
|
702
|
+
[Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2ledgersyncround)
|
|
703
|
+
* @param round
|
|
704
|
+
* @category POST
|
|
705
|
+
*/
|
|
706
|
+
setSyncRound(round: number) {
|
|
707
|
+
return new SetSyncRound(this.c, this.intDecoding, round);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Un-Set the sync round on the ledger (algod must have EnableFollowMode: true), removing the restriction on catchup.
|
|
712
|
+
*
|
|
713
|
+
* #### Example
|
|
714
|
+
* ```typesecript
|
|
715
|
+
* await client.unsetSyncRound().do();
|
|
716
|
+
* ```
|
|
717
|
+
*
|
|
718
|
+
[Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#delete-v2ledgersync)
|
|
719
|
+
* @category DELETE
|
|
720
|
+
*/
|
|
721
|
+
unsetSyncRound() {
|
|
722
|
+
return new UnsetSyncRound(this.c, this.intDecoding);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Get the current sync round on the ledger (algod must have EnableFollowMode: true).
|
|
727
|
+
*
|
|
728
|
+
* #### Example
|
|
729
|
+
* ```typesecript
|
|
730
|
+
* const currentSyncRound = await client.getSyncRound().do();
|
|
731
|
+
* ```
|
|
732
|
+
*
|
|
733
|
+
[Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2ledgersync)
|
|
734
|
+
* @category GET
|
|
735
|
+
*/
|
|
736
|
+
getSyncRound() {
|
|
737
|
+
return new GetSyncRound(this.c, this.intDecoding);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Ready check which returns 200 OK if algod is healthy and caught up
|
|
742
|
+
*
|
|
743
|
+
* #### Example
|
|
744
|
+
* ```typesecript
|
|
745
|
+
* await client.ready().do();
|
|
746
|
+
* ```
|
|
747
|
+
*
|
|
748
|
+
[Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-ready)
|
|
749
|
+
* @category GET
|
|
750
|
+
*/
|
|
751
|
+
ready() {
|
|
752
|
+
return new Ready(this.c, this.intDecoding);
|
|
753
|
+
}
|
|
578
754
|
}
|
|
@@ -15,7 +15,7 @@ import { Box } from './models/types';
|
|
|
15
15
|
* const boxValue = boxResponse.value;
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
18
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idbox)
|
|
19
19
|
* @param index - The application ID to look up.
|
|
20
20
|
* @category GET
|
|
21
21
|
*/
|
|
@@ -13,7 +13,7 @@ import { BoxesResponse } from './models/types';
|
|
|
13
13
|
* const boxNames = boxesResponse.boxes.map(box => box.name);
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod
|
|
16
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idboxes)
|
|
17
17
|
* @param index - The application ID to look up.
|
|
18
18
|
* @category GET
|
|
19
19
|
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import JSONRequest from '../jsonrequest';
|
|
2
|
+
import { GetBlockTimeStampOffsetResponse } from './models/types';
|
|
3
|
+
|
|
4
|
+
export default class GetBlockOffsetTimestamp extends JSONRequest<
|
|
5
|
+
GetBlockTimeStampOffsetResponse,
|
|
6
|
+
Record<string, any>
|
|
7
|
+
> {
|
|
8
|
+
// eslint-disable-next-line class-methods-use-this
|
|
9
|
+
path() {
|
|
10
|
+
return `/v2/devmode/blocks/offset`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line class-methods-use-this
|
|
14
|
+
prepare(body: Record<string, any>): GetBlockTimeStampOffsetResponse {
|
|
15
|
+
return GetBlockTimeStampOffsetResponse.from_obj_for_encoding(body);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import JSONRequest from '../jsonrequest';
|
|
2
|
+
import { GetSyncRoundResponse } from './models/types';
|
|
3
|
+
|
|
4
|
+
export default class GetSyncRound extends JSONRequest<
|
|
5
|
+
GetSyncRoundResponse,
|
|
6
|
+
Record<string, any>
|
|
7
|
+
> {
|
|
8
|
+
// eslint-disable-next-line class-methods-use-this
|
|
9
|
+
path() {
|
|
10
|
+
return `/v2/ledger/sync`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line class-methods-use-this
|
|
14
|
+
prepare(body: Record<string, any>): GetSyncRoundResponse {
|
|
15
|
+
return GetSyncRoundResponse.from_obj_for_encoding(body);
|
|
16
|
+
}
|
|
17
|
+
}
|