@algorandfoundation/algokit-utils 10.0.0-alpha.5 → 10.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/algod-client/index.d.ts +1 -4
  2. package/package.json +1 -1
  3. package/packages/algod_client/src/models/block.d.ts +2 -2
  4. package/packages/algod_client/src/models/block.js +1 -1
  5. package/packages/algod_client/src/models/block.js.map +1 -1
  6. package/packages/algod_client/src/models/block.mjs +1 -1
  7. package/packages/algod_client/src/models/block.mjs.map +1 -1
  8. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.d.ts +3 -5
  9. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js +4 -6
  10. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js.map +1 -1
  11. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs +3 -5
  12. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs.map +1 -1
  13. package/packages/common/src/json.mjs +2 -2
  14. package/packages/common/src/json.mjs.map +1 -1
  15. package/packages/sdk/src/utils/utils.mjs +2 -2
  16. package/packages/sdk/src/utils/utils.mjs.map +1 -1
  17. package/packages/transact/src/multisig.d.ts +2 -2
  18. package/packages/transact/src/multisig.js +15 -15
  19. package/packages/transact/src/multisig.js.map +1 -1
  20. package/packages/transact/src/multisig.mjs +15 -15
  21. package/packages/transact/src/multisig.mjs.map +1 -1
  22. package/packages/transact/src/transactions/app-call.d.ts +8 -8
  23. package/packages/transact/src/transactions/app-call.js.map +1 -1
  24. package/packages/transact/src/transactions/app-call.mjs.map +1 -1
  25. package/packages/transact/src/transactions/reference-types-meta.d.ts +26 -0
  26. package/packages/transact/src/transactions/reference-types-meta.js +71 -0
  27. package/packages/transact/src/transactions/reference-types-meta.js.map +1 -0
  28. package/packages/transact/src/transactions/reference-types-meta.mjs +69 -0
  29. package/packages/transact/src/transactions/reference-types-meta.mjs.map +1 -0
  30. package/packages/transact/src/transactions/transaction-meta.js +22 -22
  31. package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
  32. package/packages/transact/src/transactions/transaction-meta.mjs +22 -22
  33. package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
  34. package/transact/index.d.ts +3 -2
  35. package/transact/index.js +4 -0
  36. package/transact/index.mjs +2 -1
  37. package/transactions/app-call.d.ts +2 -2
  38. package/transactions/app-call.js +15 -15
  39. package/transactions/app-call.js.map +1 -1
  40. package/transactions/app-call.mjs +15 -15
  41. package/transactions/app-call.mjs.map +1 -1
  42. package/transactions/asset-config.d.ts +1 -1
  43. package/transactions/asset-config.js +1 -1
  44. package/transactions/asset-config.js.map +1 -1
  45. package/transactions/asset-config.mjs +1 -1
  46. package/transactions/asset-config.mjs.map +1 -1
  47. package/types/algorand-client-transaction-creator.d.ts +81 -81
  48. package/types/algorand-client-transaction-sender.d.ts +84 -84
  49. package/types/app-client.d.ts +145 -145
  50. package/types/app-factory.d.ts +70 -70
  51. package/types/app-manager.js +5 -5
  52. package/types/app-manager.js.map +1 -1
  53. package/types/app-manager.mjs +5 -5
  54. package/types/app-manager.mjs.map +1 -1
  55. package/types/app-spec.js +12 -5
  56. package/types/app-spec.js.map +1 -1
  57. package/types/app-spec.mjs +12 -5
  58. package/types/app-spec.mjs.map +1 -1
  59. package/types/composer.js +3 -3
  60. package/types/composer.js.map +1 -1
  61. package/types/composer.mjs +3 -3
  62. package/types/composer.mjs.map +1 -1
  63. package/packages/algod_client/src/models/application-local-reference.d.ts +0 -20
  64. package/packages/algod_client/src/models/application-local-reference.js +0 -23
  65. package/packages/algod_client/src/models/application-local-reference.js.map +0 -1
  66. package/packages/algod_client/src/models/application-local-reference.mjs +0 -23
  67. package/packages/algod_client/src/models/application-local-reference.mjs.map +0 -1
  68. package/packages/algod_client/src/models/asset-holding-reference.d.ts +0 -20
  69. package/packages/algod_client/src/models/asset-holding-reference.js +0 -23
  70. package/packages/algod_client/src/models/asset-holding-reference.js.map +0 -1
  71. package/packages/algod_client/src/models/asset-holding-reference.mjs +0 -23
  72. package/packages/algod_client/src/models/asset-holding-reference.mjs.map +0 -1
  73. package/packages/algod_client/src/models/box-reference.d.ts +0 -17
  74. package/packages/algod_client/src/models/box-reference.js +0 -23
  75. package/packages/algod_client/src/models/box-reference.js.map +0 -1
  76. package/packages/algod_client/src/models/box-reference.mjs +0 -23
  77. package/packages/algod_client/src/models/box-reference.mjs.map +0 -1
@@ -2,7 +2,7 @@ import { Address, ReadableAddress } from "../packages/common/src/address.js";
2
2
  import { ABIValue } from "../packages/abi/src/abi-value.js";
3
3
  import { Arc56Contract } from "../packages/abi/src/arc56-contract.js";
4
4
  import { ABIMethod, ABIReturn } from "../packages/abi/src/abi-method.js";
5
- import { AccessReference, OnApplicationComplete } from "../packages/transact/src/transactions/app-call.js";
5
+ import { OnApplicationComplete, ResourceReference } from "../packages/transact/src/transactions/app-call.js";
6
6
  import { Transaction } from "../packages/transact/src/transactions/transaction.js";
7
7
  import { AddressWithTransactionSigner, SendingAddress, TransactionSigner } from "../packages/transact/src/signer.js";
8
8
  import { PendingTransactionResponse } from "../packages/algod_client/src/models/pending-transaction-response.js";
@@ -186,7 +186,7 @@ declare class AppFactory {
186
186
  appReferences?: bigint[] | undefined;
187
187
  assetReferences?: bigint[] | undefined;
188
188
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
189
- accessReferences?: AccessReference[] | undefined;
189
+ accessReferences?: ResourceReference[] | undefined;
190
190
  rejectVersion?: number | undefined;
191
191
  sender?: ReadableAddress | undefined;
192
192
  method: string;
@@ -234,7 +234,7 @@ declare class AppFactory {
234
234
  appReferences?: bigint[] | undefined;
235
235
  assetReferences?: bigint[] | undefined;
236
236
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
237
- accessReferences?: AccessReference[] | undefined;
237
+ accessReferences?: ResourceReference[] | undefined;
238
238
  rejectVersion?: number | undefined;
239
239
  sender?: ReadableAddress | undefined;
240
240
  method: string;
@@ -247,7 +247,6 @@ declare class AppFactory {
247
247
  signer: AddressWithTransactionSigner | TransactionSigner | undefined;
248
248
  method: ABIMethod;
249
249
  args: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
250
- args?: Uint8Array[] | undefined;
251
250
  sender: SendingAddress;
252
251
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
253
252
  rekeyTo?: ReadableAddress | undefined;
@@ -259,25 +258,20 @@ declare class AppFactory {
259
258
  validityWindow?: number | bigint | undefined;
260
259
  firstValidRound?: bigint | undefined;
261
260
  lastValidRound?: bigint | undefined;
262
- onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
261
+ appId: bigint;
262
+ onComplete?: OnApplicationComplete.UpdateApplication | undefined;
263
+ args?: Uint8Array[] | undefined;
263
264
  accountReferences?: ReadableAddress[] | undefined;
264
265
  appReferences?: bigint[] | undefined;
265
266
  assetReferences?: bigint[] | undefined;
266
267
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
267
- accessReferences?: AccessReference[] | undefined;
268
+ accessReferences?: ResourceReference[] | undefined;
268
269
  rejectVersion?: number | undefined;
269
270
  approvalProgram: string | Uint8Array;
270
271
  clearStateProgram: string | Uint8Array;
271
- schema?: {
272
- globalInts: number;
273
- globalByteSlices: number;
274
- localInts: number;
275
- localByteSlices: number;
276
- } | undefined;
277
- extraProgramPages?: number | undefined;
278
272
  }> | AppMethodCall<{
279
- sender: SendingAddress;
280
273
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
274
+ sender: SendingAddress;
281
275
  rekeyTo?: ReadableAddress | undefined;
282
276
  note?: string | Uint8Array | undefined;
283
277
  lease?: string | Uint8Array | undefined;
@@ -287,18 +281,24 @@ declare class AppFactory {
287
281
  validityWindow?: number | bigint | undefined;
288
282
  firstValidRound?: bigint | undefined;
289
283
  lastValidRound?: bigint | undefined;
290
- appId: bigint;
291
- onComplete?: OnApplicationComplete.UpdateApplication | undefined;
292
284
  args?: Uint8Array[] | undefined;
285
+ onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
293
286
  accountReferences?: ReadableAddress[] | undefined;
294
287
  appReferences?: bigint[] | undefined;
295
288
  assetReferences?: bigint[] | undefined;
296
289
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
297
- accessReferences?: AccessReference[] | undefined;
290
+ accessReferences?: ResourceReference[] | undefined;
298
291
  rejectVersion?: number | undefined;
299
292
  approvalProgram: string | Uint8Array;
300
293
  clearStateProgram: string | Uint8Array;
301
- }> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
294
+ schema?: {
295
+ globalInts: number;
296
+ globalByteSlices: number;
297
+ localInts: number;
298
+ localByteSlices: number;
299
+ } | undefined;
300
+ extraProgramPages?: number | undefined;
301
+ }> | Promise<Transaction> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
302
302
  onComplete: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication;
303
303
  }>;
304
304
  /** Return params for a deployment update ABI call */
@@ -318,7 +318,7 @@ declare class AppFactory {
318
318
  appReferences?: bigint[] | undefined;
319
319
  assetReferences?: bigint[] | undefined;
320
320
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
321
- accessReferences?: AccessReference[] | undefined;
321
+ accessReferences?: ResourceReference[] | undefined;
322
322
  rejectVersion?: number | undefined;
323
323
  sender?: ReadableAddress | undefined;
324
324
  method: string;
@@ -339,7 +339,7 @@ declare class AppFactory {
339
339
  appReferences?: bigint[] | undefined;
340
340
  assetReferences?: bigint[] | undefined;
341
341
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
342
- accessReferences?: AccessReference[] | undefined;
342
+ accessReferences?: ResourceReference[] | undefined;
343
343
  rejectVersion?: number | undefined;
344
344
  sender?: ReadableAddress | undefined;
345
345
  method: string;
@@ -349,7 +349,6 @@ declare class AppFactory {
349
349
  signer: AddressWithTransactionSigner | TransactionSigner | undefined;
350
350
  method: ABIMethod;
351
351
  args: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
352
- args?: Uint8Array[] | undefined;
353
352
  sender: SendingAddress;
354
353
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
355
354
  rekeyTo?: ReadableAddress | undefined;
@@ -361,25 +360,20 @@ declare class AppFactory {
361
360
  validityWindow?: number | bigint | undefined;
362
361
  firstValidRound?: bigint | undefined;
363
362
  lastValidRound?: bigint | undefined;
364
- onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
363
+ appId: bigint;
364
+ onComplete?: OnApplicationComplete.UpdateApplication | undefined;
365
+ args?: Uint8Array[] | undefined;
365
366
  accountReferences?: ReadableAddress[] | undefined;
366
367
  appReferences?: bigint[] | undefined;
367
368
  assetReferences?: bigint[] | undefined;
368
369
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
369
- accessReferences?: AccessReference[] | undefined;
370
+ accessReferences?: ResourceReference[] | undefined;
370
371
  rejectVersion?: number | undefined;
371
372
  approvalProgram: string | Uint8Array;
372
373
  clearStateProgram: string | Uint8Array;
373
- schema?: {
374
- globalInts: number;
375
- globalByteSlices: number;
376
- localInts: number;
377
- localByteSlices: number;
378
- } | undefined;
379
- extraProgramPages?: number | undefined;
380
374
  }> | AppMethodCall<{
381
- sender: SendingAddress;
382
375
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
376
+ sender: SendingAddress;
383
377
  rekeyTo?: ReadableAddress | undefined;
384
378
  note?: string | Uint8Array | undefined;
385
379
  lease?: string | Uint8Array | undefined;
@@ -389,18 +383,24 @@ declare class AppFactory {
389
383
  validityWindow?: number | bigint | undefined;
390
384
  firstValidRound?: bigint | undefined;
391
385
  lastValidRound?: bigint | undefined;
392
- appId: bigint;
393
- onComplete?: OnApplicationComplete.UpdateApplication | undefined;
394
386
  args?: Uint8Array[] | undefined;
387
+ onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
395
388
  accountReferences?: ReadableAddress[] | undefined;
396
389
  appReferences?: bigint[] | undefined;
397
390
  assetReferences?: bigint[] | undefined;
398
391
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
399
- accessReferences?: AccessReference[] | undefined;
392
+ accessReferences?: ResourceReference[] | undefined;
400
393
  rejectVersion?: number | undefined;
401
394
  approvalProgram: string | Uint8Array;
402
395
  clearStateProgram: string | Uint8Array;
403
- }> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
396
+ schema?: {
397
+ globalInts: number;
398
+ globalByteSlices: number;
399
+ localInts: number;
400
+ localByteSlices: number;
401
+ } | undefined;
402
+ extraProgramPages?: number | undefined;
403
+ }> | Promise<Transaction> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
404
404
  onComplete: OnApplicationComplete.UpdateApplication;
405
405
  };
406
406
  /** Return params for a deployment delete ABI call */
@@ -420,7 +420,7 @@ declare class AppFactory {
420
420
  appReferences?: bigint[] | undefined;
421
421
  assetReferences?: bigint[] | undefined;
422
422
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
423
- accessReferences?: AccessReference[] | undefined;
423
+ accessReferences?: ResourceReference[] | undefined;
424
424
  rejectVersion?: number | undefined;
425
425
  sender?: ReadableAddress | undefined;
426
426
  method: string;
@@ -441,7 +441,7 @@ declare class AppFactory {
441
441
  appReferences?: bigint[] | undefined;
442
442
  assetReferences?: bigint[] | undefined;
443
443
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
444
- accessReferences?: AccessReference[] | undefined;
444
+ accessReferences?: ResourceReference[] | undefined;
445
445
  rejectVersion?: number | undefined;
446
446
  sender?: ReadableAddress | undefined;
447
447
  method: string;
@@ -451,7 +451,6 @@ declare class AppFactory {
451
451
  signer: AddressWithTransactionSigner | TransactionSigner | undefined;
452
452
  method: ABIMethod;
453
453
  args: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
454
- args?: Uint8Array[] | undefined;
455
454
  sender: SendingAddress;
456
455
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
457
456
  rekeyTo?: ReadableAddress | undefined;
@@ -463,25 +462,20 @@ declare class AppFactory {
463
462
  validityWindow?: number | bigint | undefined;
464
463
  firstValidRound?: bigint | undefined;
465
464
  lastValidRound?: bigint | undefined;
466
- onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
465
+ appId: bigint;
466
+ onComplete?: OnApplicationComplete.UpdateApplication | undefined;
467
+ args?: Uint8Array[] | undefined;
467
468
  accountReferences?: ReadableAddress[] | undefined;
468
469
  appReferences?: bigint[] | undefined;
469
470
  assetReferences?: bigint[] | undefined;
470
471
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
471
- accessReferences?: AccessReference[] | undefined;
472
+ accessReferences?: ResourceReference[] | undefined;
472
473
  rejectVersion?: number | undefined;
473
474
  approvalProgram: string | Uint8Array;
474
475
  clearStateProgram: string | Uint8Array;
475
- schema?: {
476
- globalInts: number;
477
- globalByteSlices: number;
478
- localInts: number;
479
- localByteSlices: number;
480
- } | undefined;
481
- extraProgramPages?: number | undefined;
482
476
  }> | AppMethodCall<{
483
- sender: SendingAddress;
484
477
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
478
+ sender: SendingAddress;
485
479
  rekeyTo?: ReadableAddress | undefined;
486
480
  note?: string | Uint8Array | undefined;
487
481
  lease?: string | Uint8Array | undefined;
@@ -491,24 +485,29 @@ declare class AppFactory {
491
485
  validityWindow?: number | bigint | undefined;
492
486
  firstValidRound?: bigint | undefined;
493
487
  lastValidRound?: bigint | undefined;
494
- appId: bigint;
495
- onComplete?: OnApplicationComplete.UpdateApplication | undefined;
496
488
  args?: Uint8Array[] | undefined;
489
+ onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
497
490
  accountReferences?: ReadableAddress[] | undefined;
498
491
  appReferences?: bigint[] | undefined;
499
492
  assetReferences?: bigint[] | undefined;
500
493
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
501
- accessReferences?: AccessReference[] | undefined;
494
+ accessReferences?: ResourceReference[] | undefined;
502
495
  rejectVersion?: number | undefined;
503
496
  approvalProgram: string | Uint8Array;
504
497
  clearStateProgram: string | Uint8Array;
505
- }> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
498
+ schema?: {
499
+ globalInts: number;
500
+ globalByteSlices: number;
501
+ localInts: number;
502
+ localByteSlices: number;
503
+ } | undefined;
504
+ extraProgramPages?: number | undefined;
505
+ }> | Promise<Transaction> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
506
506
  onComplete: OnApplicationComplete.DeleteApplication;
507
507
  };
508
508
  bare: {
509
509
  /** Return params for a create bare call, including deploy-time TEAL template replacements and compilation if provided */
510
510
  create: (params?: {
511
- args?: Uint8Array[] | undefined;
512
511
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
513
512
  rekeyTo?: ReadableAddress | undefined;
514
513
  note?: string | Uint8Array | undefined;
@@ -519,11 +518,12 @@ declare class AppFactory {
519
518
  validityWindow?: number | bigint | undefined;
520
519
  firstValidRound?: bigint | undefined;
521
520
  lastValidRound?: bigint | undefined;
521
+ args?: Uint8Array[] | undefined;
522
522
  accountReferences?: ReadableAddress[] | undefined;
523
523
  appReferences?: bigint[] | undefined;
524
524
  assetReferences?: bigint[] | undefined;
525
525
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
526
- accessReferences?: AccessReference[] | undefined;
526
+ accessReferences?: ResourceReference[] | undefined;
527
527
  rejectVersion?: number | undefined;
528
528
  sender?: ReadableAddress | undefined;
529
529
  deployTimeParams?: TealTemplateParams | undefined;
@@ -557,7 +557,6 @@ declare class AppFactory {
557
557
  /** The number of byte slices saved in local state. */
558
558
  localByteSlices: number;
559
559
  };
560
- args?: Uint8Array[] | undefined;
561
560
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
562
561
  rekeyTo?: ReadableAddress | undefined;
563
562
  note?: string | Uint8Array | undefined;
@@ -568,11 +567,12 @@ declare class AppFactory {
568
567
  validityWindow?: number | bigint | undefined;
569
568
  firstValidRound?: bigint | undefined;
570
569
  lastValidRound?: bigint | undefined;
570
+ args?: Uint8Array[] | undefined;
571
571
  accountReferences?: ReadableAddress[] | undefined;
572
572
  appReferences?: bigint[] | undefined;
573
573
  assetReferences?: bigint[] | undefined;
574
574
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
575
- accessReferences?: AccessReference[] | undefined;
575
+ accessReferences?: ResourceReference[] | undefined;
576
576
  rejectVersion?: number | undefined;
577
577
  sender?: ReadableAddress | undefined;
578
578
  updatable?: boolean | undefined;
@@ -586,7 +586,6 @@ declare class AppFactory {
586
586
  }>;
587
587
  /** Return params for a deployment update bare call */
588
588
  deployUpdate: (params?: {
589
- args?: Uint8Array[] | undefined;
590
589
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
591
590
  rekeyTo?: ReadableAddress | undefined;
592
591
  note?: string | Uint8Array | undefined;
@@ -597,15 +596,15 @@ declare class AppFactory {
597
596
  validityWindow?: number | bigint | undefined;
598
597
  firstValidRound?: bigint | undefined;
599
598
  lastValidRound?: bigint | undefined;
599
+ args?: Uint8Array[] | undefined;
600
600
  accountReferences?: ReadableAddress[] | undefined;
601
601
  appReferences?: bigint[] | undefined;
602
602
  assetReferences?: bigint[] | undefined;
603
603
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
604
- accessReferences?: AccessReference[] | undefined;
604
+ accessReferences?: ResourceReference[] | undefined;
605
605
  rejectVersion?: number | undefined;
606
606
  sender?: ReadableAddress | undefined;
607
607
  } | undefined) => {
608
- args?: Uint8Array[] | undefined;
609
608
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
610
609
  rekeyTo?: ReadableAddress | undefined;
611
610
  note?: string | Uint8Array | undefined;
@@ -616,11 +615,12 @@ declare class AppFactory {
616
615
  validityWindow?: number | bigint | undefined;
617
616
  firstValidRound?: bigint | undefined;
618
617
  lastValidRound?: bigint | undefined;
618
+ args?: Uint8Array[] | undefined;
619
619
  accountReferences?: ReadableAddress[] | undefined;
620
620
  appReferences?: bigint[] | undefined;
621
621
  assetReferences?: bigint[] | undefined;
622
622
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
623
- accessReferences?: AccessReference[] | undefined;
623
+ accessReferences?: ResourceReference[] | undefined;
624
624
  rejectVersion?: number | undefined;
625
625
  sender?: ReadableAddress | undefined;
626
626
  } & {
@@ -630,7 +630,6 @@ declare class AppFactory {
630
630
  };
631
631
  /** Return params for a deployment delete bare call */
632
632
  deployDelete: (params?: {
633
- args?: Uint8Array[] | undefined;
634
633
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
635
634
  rekeyTo?: ReadableAddress | undefined;
636
635
  note?: string | Uint8Array | undefined;
@@ -641,15 +640,15 @@ declare class AppFactory {
641
640
  validityWindow?: number | bigint | undefined;
642
641
  firstValidRound?: bigint | undefined;
643
642
  lastValidRound?: bigint | undefined;
643
+ args?: Uint8Array[] | undefined;
644
644
  accountReferences?: ReadableAddress[] | undefined;
645
645
  appReferences?: bigint[] | undefined;
646
646
  assetReferences?: bigint[] | undefined;
647
647
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
648
- accessReferences?: AccessReference[] | undefined;
648
+ accessReferences?: ResourceReference[] | undefined;
649
649
  rejectVersion?: number | undefined;
650
650
  sender?: ReadableAddress | undefined;
651
651
  } | undefined) => {
652
- args?: Uint8Array[] | undefined;
653
652
  signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
654
653
  rekeyTo?: ReadableAddress | undefined;
655
654
  note?: string | Uint8Array | undefined;
@@ -660,11 +659,12 @@ declare class AppFactory {
660
659
  validityWindow?: number | bigint | undefined;
661
660
  firstValidRound?: bigint | undefined;
662
661
  lastValidRound?: bigint | undefined;
662
+ args?: Uint8Array[] | undefined;
663
663
  accountReferences?: ReadableAddress[] | undefined;
664
664
  appReferences?: bigint[] | undefined;
665
665
  assetReferences?: bigint[] | undefined;
666
666
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
667
- accessReferences?: AccessReference[] | undefined;
667
+ accessReferences?: ResourceReference[] | undefined;
668
668
  rejectVersion?: number | undefined;
669
669
  sender?: ReadableAddress | undefined;
670
670
  } & {
@@ -799,14 +799,14 @@ declare class AppFactory {
799
799
  compiledApproval?: CompiledTeal | undefined;
800
800
  compiledClear?: CompiledTeal | undefined;
801
801
  operationPerformed: "create";
802
- version: string;
803
- updatable?: boolean | undefined;
804
- deletable?: boolean | undefined;
805
802
  createdRound: bigint;
806
803
  updatedRound: bigint;
807
804
  createdMetadata: AppDeployMetadata;
808
805
  deleted: boolean;
809
806
  name: string;
807
+ version: string;
808
+ deletable?: boolean | undefined;
809
+ updatable?: boolean | undefined;
810
810
  groupId: string | undefined;
811
811
  txIds: string[];
812
812
  returns?: ABIReturn[] | undefined;
@@ -845,14 +845,14 @@ declare class AppFactory {
845
845
  compiledApproval?: CompiledTeal | undefined;
846
846
  compiledClear?: CompiledTeal | undefined;
847
847
  operationPerformed: "replace";
848
- version: string;
849
- updatable?: boolean | undefined;
850
- deletable?: boolean | undefined;
851
848
  createdRound: bigint;
852
849
  updatedRound: bigint;
853
850
  createdMetadata: AppDeployMetadata;
854
851
  deleted: boolean;
855
852
  name: string;
853
+ version: string;
854
+ deletable?: boolean | undefined;
855
+ updatable?: boolean | undefined;
856
856
  groupId: string | undefined;
857
857
  txIds: string[];
858
858
  returns?: ABIReturn[] | undefined;
@@ -102,11 +102,11 @@ var AppManager = class AppManager {
102
102
  approvalProgram: app.params.approvalProgram,
103
103
  clearStateProgram: app.params.clearStateProgram,
104
104
  creator: app.params.creator,
105
- localInts: Number(app.params.localStateSchema?.numUints ?? 0),
106
- localByteSlices: Number(app.params.localStateSchema?.numByteSlices ?? 0),
107
- globalInts: Number(app.params.globalStateSchema?.numUints ?? 0),
108
- globalByteSlices: Number(app.params.globalStateSchema?.numByteSlices ?? 0),
109
- extraProgramPages: Number(app.params.extraProgramPages ?? 0),
105
+ localInts: app.params.localStateSchema?.numUints ?? 0,
106
+ localByteSlices: app.params.localStateSchema?.numByteSlices ?? 0,
107
+ globalInts: app.params.globalStateSchema?.numUints ?? 0,
108
+ globalByteSlices: app.params.globalStateSchema?.numByteSlices ?? 0,
109
+ extraProgramPages: app.params.extraProgramPages ?? 0,
110
110
  globalState: AppManager.decodeAppState(convertedGlobalState)
111
111
  };
112
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"app-manager.js","names":["ProgramSourceMap","getApplicationAddress","getAddress","valueBase64: string","valueRaw: Buffer","ABI_RETURN_PREFIX","UPDATABLE_TEMPLATE_NAME","DELETABLE_TEMPLATE_NAME","result: string[]"],"sources":["../../src/types/app-manager.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { AlgodClient, EvalDelta, PendingTransactionResponse, TealValue } from '@algorandfoundation/algokit-algod-client'\nimport { Address, ReadableAddress, getAddress, getApplicationAddress } from '@algorandfoundation/algokit-common'\nimport { AddressWithTransactionSigner, BoxReference as TransactionBoxReference } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport {\n ABI_RETURN_PREFIX,\n BoxName,\n DELETABLE_TEMPLATE_NAME,\n UPDATABLE_TEMPLATE_NAME,\n type AppState,\n type CompiledTeal,\n type TealTemplateParams,\n} from './app'\n\n/** Information about an app. */\nexport interface AppInformation {\n /** The ID of the app. */\n appId: bigint\n /** The escrow address that the app operates with. */\n appAddress: Address\n /**\n * Approval program.\n */\n approvalProgram: Uint8Array\n /**\n * Clear state program.\n */\n clearStateProgram: Uint8Array\n /**\n * The address that created this application. This is the address where the\n * parameters and global state for this application can be found.\n */\n creator: Address\n /**\n * Current global state values.\n */\n globalState: AppState\n /** The number of allocated ints in per-user local state. */\n localInts: number\n /** The number of allocated byte slices in per-user local state. */\n localByteSlices: number\n /** The number of allocated ints in global state. */\n globalInts: number\n /** The number of allocated byte slices in global state. */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract. */\n extraProgramPages?: number\n}\n\n/**\n * Something that identifies an app box name - either a:\n * * `Uint8Array` (the actual binary of the box name)\n * * `string` (that will be encoded to a `Uint8Array`)\n * * `AddressWithSigner` (that will be encoded into the\n * public key address of the corresponding account)\n */\nexport type BoxIdentifier = string | Uint8Array | AddressWithTransactionSigner\n\n/**\n * A grouping of the app ID and name identifier to reference an app box.\n */\nexport interface BoxReference {\n /**\n * A unique application id\n */\n appId: bigint\n /**\n * Identifier for a box name\n */\n name: BoxIdentifier\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: BoxIdentifier\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: BoxIdentifier[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/** Allows management of application information. */\nexport class AppManager {\n private _algod: AlgodClient\n private _compilationResults: Record<string, CompiledTeal> = {}\n\n /**\n * Creates an `AppManager`\n * @param algod An algod instance\n */\n constructor(algod: AlgodClient) {\n this._algod = algod\n }\n\n /**\n * Compiles the given TEAL using algod and returns the result, including source map.\n *\n * The result of this compilation is also cached keyed by the TEAL\n * code so it can be retrieved via `getCompilationResult`.\n *\n * This function is re-entrant; it will only compile the same code once.\n *\n * @param tealCode The TEAL code\n * @returns The information about the compiled file\n * @example\n * ```typescript\n * const compiled = await appManager.compileTeal(tealProgram)\n * ```\n */\n async compileTeal(tealCode: string): Promise<CompiledTeal> {\n if (this._compilationResults[tealCode]) {\n return this._compilationResults[tealCode]\n }\n\n const compiled = await this._algod.tealCompile(tealCode, { sourcemap: true })\n const result = {\n teal: tealCode,\n compiled: compiled.result,\n compiledHash: compiled.hash,\n compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),\n sourceMap: new ProgramSourceMap(compiled.sourcemap as { version: number; sources: string[]; names: string[]; mappings: string }),\n }\n this._compilationResults[tealCode] = result\n\n return result\n }\n\n /**\n * Performs template substitution of a teal template and compiles it, returning the compiled result.\n *\n * Looks for `TMPL_{parameter}` for template replacements and replaces AlgoKit deploy-time control parameters\n * if deployment metadata is specified.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * @param tealTemplateCode The TEAL logic to compile\n * @param templateParams Any parameters to replace in the .teal file before compiling\n * @param deploymentMetadata The deployment metadata the app will be deployed with\n * @returns The information about the compiled code\n * @example\n * ```typescript\n * const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })\n * ```\n */\n async compileTealTemplate(\n tealTemplateCode: string,\n templateParams?: TealTemplateParams,\n deploymentMetadata?: { updatable?: boolean; deletable?: boolean },\n ): Promise<CompiledTeal> {\n let tealCode = AppManager.stripTealComments(tealTemplateCode)\n\n tealCode = AppManager.replaceTealTemplateParams(tealCode, templateParams)\n\n if (deploymentMetadata) {\n tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, deploymentMetadata)\n }\n\n return await this.compileTeal(tealCode)\n }\n\n /**\n * Returns a previous compilation result.\n * @param tealCode The TEAL code\n * @returns The information about the previously compiled file\n * or `undefined` if that TEAL code wasn't previously compiled\n * @example\n * ```typescript\n * const compiled = appManager.getCompilationResult(tealProgram)\n * ```\n */\n getCompilationResult(tealCode: string): CompiledTeal | undefined {\n return this._compilationResults[tealCode]\n }\n\n /**\n * Returns the current app information for the app with the given ID.\n *\n * @example\n * ```typescript\n * const appInfo = await appManager.getById(12353n);\n * ```\n *\n * @param appId The ID of the app\n * @returns The app information\n */\n public async getById(appId: bigint): Promise<AppInformation> {\n const app = await this._algod.getApplicationById(appId)\n const convertedGlobalState = (app.params.globalState ?? []).map((kv) => ({\n key: kv.key,\n value: kv.value,\n }))\n\n return {\n appId: BigInt(app.id),\n appAddress: getApplicationAddress(app.id),\n approvalProgram: app.params.approvalProgram,\n clearStateProgram: app.params.clearStateProgram,\n creator: app.params.creator,\n localInts: Number(app.params.localStateSchema?.numUints ?? 0),\n localByteSlices: Number(app.params.localStateSchema?.numByteSlices ?? 0),\n globalInts: Number(app.params.globalStateSchema?.numUints ?? 0),\n globalByteSlices: Number(app.params.globalStateSchema?.numByteSlices ?? 0),\n extraProgramPages: Number(app.params.extraProgramPages ?? 0),\n globalState: AppManager.decodeAppState(convertedGlobalState),\n }\n }\n\n /**\n * Returns the current global state values for the given app ID and account address\n *\n * @param appId The ID of the app to return global state for\n * @returns The current global state for the given app\n * @example\n * ```typescript\n * const globalState = await appManager.getGlobalState(12353n);\n * ```\n */\n public async getGlobalState(appId: bigint) {\n return (await this.getById(appId)).globalState\n }\n\n /**\n * Returns the current local state values for the given app ID and account address\n *\n * @param appId The ID of the app to return local state for\n * @param address The string address of the account to get local state for the given app\n * @returns The current local state for the given (app, account) combination\n * @example\n * ```typescript\n * const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');\n * ```\n */\n public async getLocalState(appId: bigint, address: ReadableAddress) {\n const appInfo = await this._algod.accountApplicationInformation(getAddress(address).toString(), Number(appId))\n\n if (!appInfo.appLocalState) {\n throw new Error(\"Couldn't find local state\")\n }\n\n // If keyValue is undefined or empty, return empty state\n if (!appInfo.appLocalState.keyValue || appInfo.appLocalState.keyValue.length === 0) {\n return {}\n }\n\n const convertedState = appInfo.appLocalState.keyValue.map((kv) => ({\n key: kv.key,\n value: kv.value,\n }))\n\n return AppManager.decodeAppState(convertedState)\n }\n\n /**\n * Returns the names of the current boxes for the given app.\n * @param appId The ID of the app return box names for\n * @returns The current box names\n * @example\n * ```typescript\n * const boxNames = await appManager.getBoxNames(12353n);\n * ```\n */\n public async getBoxNames(appId: bigint): Promise<BoxName[]> {\n const boxResult = await this._algod.getApplicationBoxes(appId)\n return boxResult.boxes.map((b: { name: Uint8Array }) => {\n return {\n nameRaw: b.name,\n nameBase64: Buffer.from(b.name).toString('base64'),\n name: Buffer.from(b.name).toString('utf-8'),\n }\n })\n }\n\n /**\n * Returns the value of the given box name for the given app.\n * @param appId The ID of the app return box names for\n * @param boxName The name of the box to return either as a string, binary array or `BoxName`\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValue(12353n, 'boxName');\n * ```\n */\n public async getBoxValue(appId: bigint, boxName: BoxIdentifier | BoxName): Promise<Uint8Array> {\n const boxId = typeof boxName === 'object' && 'nameRaw' in boxName ? boxName.nameRaw : boxName\n const name = AppManager.getBoxReference(boxId).name\n const boxResult = await this._algod.getApplicationBoxByName(Number(appId), name)\n return boxResult.value\n }\n\n /**\n * Returns the value of the given box names for the given app.\n * @param appId The ID of the app return box names for\n * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`\n * @returns The current box values as a byte array in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);\n * ```\n */\n public async getBoxValues(appId: bigint, boxNames: (BoxIdentifier | BoxName)[]): Promise<Uint8Array[]> {\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValue(appId, boxName)))\n }\n\n /**\n * Returns the value of the given box name for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box value as an ABI value\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValueFromABIType(request: BoxValueRequestParams): Promise<ABIValue> {\n const { appId, boxName, type } = request\n const value = await this.getBoxValue(appId, boxName)\n return type.decode(value)\n }\n\n /**\n * Returns the value of the given box names for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box values as an ABI value in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValuesFromABIType(request: BoxValuesRequestParams): Promise<ABIValue[]> {\n const { appId, boxNames, type } = request\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValueFromABIType({ appId, boxName, type })))\n }\n\n /**\n * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.\n * @param boxId The box to return a reference for\n * @returns The box reference ready to pass into a `algosdk.Transaction`\n * @example\n * ```typescript\n * const boxRef = AppManager.getBoxReference('boxName');\n * ```\n */\n public static getBoxReference(boxId: BoxIdentifier | BoxReference): TransactionBoxReference {\n const ref = typeof boxId === 'object' && 'appId' in boxId ? boxId : { appId: 0n, name: boxId }\n return {\n appId: ref.appId,\n name: typeof ref.name === 'string' ? new TextEncoder().encode(ref.name) : 'length' in ref.name ? ref.name : ref.name.addr.publicKey,\n } as TransactionBoxReference\n }\n\n /**\n * Converts an array of global/local state values from the algod api to a more friendly\n * generic object keyed by the UTF-8 value of the key.\n * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`\n * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values\n * @example\n * ```typescript\n * const stateValues = AppManager.decodeAppState(state);\n * ```\n */\n public static decodeAppState(state: { key: Uint8Array; value: TealValue | EvalDelta }[]): AppState {\n const stateValues = {} as AppState\n\n // Start with empty set\n for (const stateVal of state) {\n const keyBase64 = Buffer.from(stateVal.key).toString('base64')\n const keyRaw = stateVal.key\n const key = Buffer.from(stateVal.key).toString('utf-8')\n const tealValue = stateVal.value\n\n const dataTypeFlag = Number('action' in tealValue ? tealValue.action : tealValue.type)\n let valueBase64: string\n let valueRaw: Buffer\n switch (dataTypeFlag) {\n case 1:\n valueBase64 =\n typeof tealValue.bytes === 'string' ? tealValue.bytes : tealValue.bytes ? Buffer.from(tealValue.bytes).toString('base64') : ''\n valueRaw = Buffer.from(valueBase64, 'base64')\n stateValues[key] = {\n keyRaw,\n keyBase64,\n valueRaw: new Uint8Array(valueRaw),\n valueBase64: valueBase64,\n value: valueRaw.toString('utf-8'),\n }\n break\n case 2: {\n const value = tealValue.uint ?? 0\n stateValues[key] = {\n keyRaw,\n keyBase64,\n value: BigInt(value),\n }\n break\n }\n default:\n throw new Error(`Received unknown state data type of ${dataTypeFlag}`)\n }\n }\n\n return stateValues\n }\n\n /**\n * Returns any ABI return values for the given app call arguments and transaction confirmation.\n * @param confirmation The transaction confirmation from algod\n * @param method The ABI method\n * @returns The return value for the method call\n * @example\n * ```typescript\n * const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));\n * ```\n */\n public static getABIReturn(confirmation: PendingTransactionResponse | undefined, method: ABIMethod | undefined): ABIReturn | undefined {\n if (!method || !confirmation) {\n return undefined\n }\n\n if (method.returns.type === 'void') {\n return { method, rawReturnValue: undefined, returnValue: undefined }\n }\n\n try {\n const logs = confirmation.logs || []\n if (logs.length === 0) {\n throw new Error(`App call transaction did not log a return value`)\n }\n const lastLog = logs[logs.length - 1]\n if (!AppManager.hasAbiReturnPrefix(lastLog)) {\n throw new Error(`App call transaction did not log an ABI return value`)\n }\n\n const rawReturnValue = new Uint8Array(lastLog.slice(4))\n return {\n method: method,\n rawReturnValue,\n decodeError: undefined,\n returnValue: method.returns.type.decode(rawReturnValue),\n }\n } catch (err) {\n return {\n method: method,\n rawReturnValue: undefined,\n decodeError: err as Error,\n returnValue: undefined,\n }\n }\n }\n\n private static hasAbiReturnPrefix(log: Uint8Array): boolean {\n if (log.length < ABI_RETURN_PREFIX.length) {\n return false\n }\n for (let i = 0; i < ABI_RETURN_PREFIX.length; i++) {\n if (log[i] !== ABI_RETURN_PREFIX[i]) {\n return false\n }\n }\n return true\n }\n\n /**\n * Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * Note: If these values are defined, but the corresponding `TMPL_*` value\n * isn't in the teal code it will throw an exception.\n *\n * @param tealTemplateCode The TEAL template code to substitute\n * @param params The deploy-time deployment control parameter value to replace\n * @returns The replaced TEAL code\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });\n * ```\n */\n static replaceTealTemplateDeployTimeControlParams(tealTemplateCode: string, params: { updatable?: boolean; deletable?: boolean }) {\n if (params.updatable !== undefined) {\n if (!tealTemplateCode.includes(UPDATABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time updatability control requested for app deployment, but ${UPDATABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, UPDATABLE_TEMPLATE_NAME, (params.updatable ? 1 : 0).toString())\n }\n\n if (params.deletable !== undefined) {\n if (!tealTemplateCode.includes(DELETABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time deletability control requested for app deployment, but ${DELETABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, DELETABLE_TEMPLATE_NAME, (params.deletable ? 1 : 0).toString())\n }\n\n return tealTemplateCode\n }\n\n /**\n * Performs template substitution of a teal file.\n *\n * Looks for `TMPL_{parameter}` for template replacements.\n *\n * @param tealTemplateCode The TEAL template code to make parameter replacements in\n * @param templateParams Any parameters to replace in the teal code\n * @returns The TEAL code with replacements\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });\n * ```\n */\n static replaceTealTemplateParams(tealTemplateCode: string, templateParams?: TealTemplateParams) {\n if (templateParams !== undefined) {\n for (const key in templateParams) {\n const value = templateParams[key]\n const token = `TMPL_${key.replace(/^TMPL_/, '')}`\n\n // If this is a number, first replace any byte representations of the number\n // These may appear in the TEAL in order to circumvent int compression and preserve PC values\n if (typeof value === 'number' || typeof value === 'bigint') {\n tealTemplateCode = tealTemplateCode.replace(new RegExp(`(?<=bytes )${token}`, 'g'), `0x${value.toString(16).padStart(16, '0')}`)\n\n // We could probably return here since mixing pushint and pushbytes is likely not going to happen, but might as well do both\n }\n\n tealTemplateCode = replaceTemplateVariable(\n tealTemplateCode,\n token,\n typeof value === 'string'\n ? `0x${Buffer.from(value, 'utf-8').toString('hex')}`\n : ArrayBuffer.isView(value)\n ? `0x${Buffer.from(value).toString('hex')}`\n : value.toString(),\n )\n }\n }\n\n return tealTemplateCode\n }\n\n /**\n * Remove comments from TEAL code (useful to reduce code size before compilation).\n *\n * @param tealCode The TEAL logic to strip\n * @returns The TEAL without comments\n * @example\n * ```typescript\n * const stripped = AppManager.stripTealComments(tealProgram);\n * ```\n */\n static stripTealComments(tealCode: string) {\n const stripCommentFromLine = (line: string) => {\n const commentIndex = findUnquotedString(line, '//')\n if (commentIndex === undefined) {\n return line\n }\n return line.slice(0, commentIndex).trimEnd()\n }\n\n return tealCode\n .split('\\n')\n .map((line) => stripCommentFromLine(line))\n .join('\\n')\n }\n}\n\n/**\n * Find the first string within a line of TEAL. Only matches outside of quotes and base64 are returned.\n * Returns undefined if not found\n */\nconst findUnquotedString = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n let index = startIndex\n let inQuotes = false\n let inBase64 = false\n\n while (index < endIndex) {\n const currentChar = line[index]\n if ((currentChar === ' ' || currentChar === '(') && !inQuotes && lastTokenBase64(line, index)) {\n // enter base64\n inBase64 = true\n } else if ((currentChar === ' ' || currentChar === ')') && !inQuotes && inBase64) {\n // exit base64\n inBase64 = false\n } else if (currentChar === '\\\\' && inQuotes) {\n // escaped char, skip next character\n index += 1\n } else if (currentChar === '\"') {\n // quote boundary\n inQuotes = !inQuotes\n } else if (!inQuotes && !inBase64 && line.startsWith(token, index)) {\n // can test for match\n return index\n }\n index += 1\n }\n return undefined\n}\n\nconst lastTokenBase64 = (line: string, index: number): boolean => {\n try {\n const tokens = line.slice(0, index).split(/\\s+/)\n const last = tokens[tokens.length - 1]\n return ['base64', 'b64'].includes(last)\n } catch {\n return false\n }\n}\n\nfunction replaceTemplateVariable(program: string, token: string, replacement: string): string {\n const result: string[] = []\n const tokenIndexOffset = replacement.length - token.length\n\n const programLines = program.split('\\n')\n\n for (const line of programLines) {\n const _commentIndex = findUnquotedString(line, '//')\n const commentIndex = _commentIndex === undefined ? line.length : _commentIndex\n let code = line.substring(0, commentIndex)\n const comment = line.substring(commentIndex)\n let trailingIndex = 0\n\n while (true) {\n const tokenIndex = findTemplateToken(code, token, trailingIndex)\n if (tokenIndex === undefined) {\n break\n }\n trailingIndex = tokenIndex + token.length\n const prefix = code.substring(0, tokenIndex)\n const suffix = code.substring(trailingIndex)\n code = `${prefix}${replacement}${suffix}`\n trailingIndex += tokenIndexOffset\n }\n result.push(code + comment)\n }\n\n return result.join('\\n')\n}\n\nconst findTemplateToken = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n\n let index = startIndex\n while (index < endIndex) {\n const tokenIndex = findUnquotedString(line, token, index, endIndex)\n if (tokenIndex === undefined) {\n break\n }\n const trailingIndex = tokenIndex + token.length\n if (\n (tokenIndex === 0 || !isValidTokenCharacter(line[tokenIndex - 1])) &&\n (trailingIndex >= line.length || !isValidTokenCharacter(line[trailingIndex]))\n ) {\n return tokenIndex\n }\n index = trailingIndex\n }\n return undefined\n}\n\nfunction isValidTokenCharacter(char: string): boolean {\n return char.length === 1 && (/\\w/.test(char) || char === '_')\n}\n"],"mappings":";;;;;;AAkGA,IAAa,aAAb,MAAa,WAAW;CACtB,AAAQ;CACR,AAAQ,sBAAoD,EAAE;;;;;CAM9D,YAAY,OAAoB;AAC9B,OAAK,SAAS;;;;;;;;;;;;;;;;;CAkBhB,MAAM,YAAY,UAAyC;AACzD,MAAI,KAAK,oBAAoB,UAC3B,QAAO,KAAK,oBAAoB;EAGlC,MAAM,WAAW,MAAM,KAAK,OAAO,YAAY,UAAU,EAAE,WAAW,MAAM,CAAC;EAC7E,MAAM,SAAS;GACb,MAAM;GACN,UAAU,SAAS;GACnB,cAAc,SAAS;GACvB,uBAAuB,IAAI,WAAW,OAAO,KAAK,SAAS,QAAQ,SAAS,CAAC;GAC7E,WAAW,IAAIA,mCAAiB,SAAS,UAAuF;GACjI;AACD,OAAK,oBAAoB,YAAY;AAErC,SAAO;;;;;;;;;;;;;;;;;;;;CAqBT,MAAM,oBACJ,kBACA,gBACA,oBACuB;EACvB,IAAI,WAAW,WAAW,kBAAkB,iBAAiB;AAE7D,aAAW,WAAW,0BAA0B,UAAU,eAAe;AAEzE,MAAI,mBACF,YAAW,WAAW,2CAA2C,UAAU,mBAAmB;AAGhG,SAAO,MAAM,KAAK,YAAY,SAAS;;;;;;;;;;;;CAazC,qBAAqB,UAA4C;AAC/D,SAAO,KAAK,oBAAoB;;;;;;;;;;;;;CAclC,MAAa,QAAQ,OAAwC;EAC3D,MAAM,MAAM,MAAM,KAAK,OAAO,mBAAmB,MAAM;EACvD,MAAM,wBAAwB,IAAI,OAAO,eAAe,EAAE,EAAE,KAAK,QAAQ;GACvE,KAAK,GAAG;GACR,OAAO,GAAG;GACX,EAAE;AAEH,SAAO;GACL,OAAO,OAAO,IAAI,GAAG;GACrB,Y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AM;GACX,MAAM,aAAa,kBAAkB,MAAM,OAAO,cAAc;AAChE,OAAI,eAAe,OACjB;AAEF,mBAAgB,aAAa,MAAM;AAGnC,UAAO,GAFQ,KAAK,UAAU,GAAG,WAAW,GAEzB,cADJ,KAAK,UAAU,cAAc;AAE5C,oBAAiB;;AAEnB,SAAO,KAAK,OAAO,QAAQ;;AAG7B,QAAO,OAAO,KAAK,KAAK;;AAG1B,MAAM,qBAAqB,MAAc,OAAe,aAAqB,GAAG,cAA2C;CACzH,MAAM,WAAW,cAAc,SAAY,KAAK,SAAS;CAEzD,IAAI,QAAQ;AACZ,QAAO,QAAQ,UAAU;EACvB,MAAM,aAAa,mBAAmB,MAAM,OAAO,OAAO,SAAS;AACnE,MAAI,eAAe,OACjB;EAEF,MAAM,gBAAgB,aAAa,MAAM;AACzC,OACG,eAAe,KAAK,CAAC,sBAAsB,KAAK,aAAa,GAAG,MAChE,iBAAiB,KAAK,UAAU,CAAC,sBAAsB,KAAK,eAAe,EAE5E,QAAO;AAET,UAAQ;;;AAKZ,SAAS,sBAAsB,MAAuB;AACpD,QAAO,KAAK,WAAW,MAAM,KAAK,KAAK,KAAK,IAAI,SAAS"}
1
+ {"version":3,"file":"app-manager.js","names":["ProgramSourceMap","getApplicationAddress","getAddress","valueBase64: string","valueRaw: Buffer","ABI_RETURN_PREFIX","UPDATABLE_TEMPLATE_NAME","DELETABLE_TEMPLATE_NAME","result: string[]"],"sources":["../../src/types/app-manager.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { AlgodClient, EvalDelta, PendingTransactionResponse, TealValue } from '@algorandfoundation/algokit-algod-client'\nimport { Address, ReadableAddress, getAddress, getApplicationAddress } from '@algorandfoundation/algokit-common'\nimport { AddressWithTransactionSigner, BoxReference as TransactionBoxReference } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport {\n ABI_RETURN_PREFIX,\n BoxName,\n DELETABLE_TEMPLATE_NAME,\n UPDATABLE_TEMPLATE_NAME,\n type AppState,\n type CompiledTeal,\n type TealTemplateParams,\n} from './app'\n\n/** Information about an app. */\nexport interface AppInformation {\n /** The ID of the app. */\n appId: bigint\n /** The escrow address that the app operates with. */\n appAddress: Address\n /**\n * Approval program.\n */\n approvalProgram: Uint8Array\n /**\n * Clear state program.\n */\n clearStateProgram: Uint8Array\n /**\n * The address that created this application. This is the address where the\n * parameters and global state for this application can be found.\n */\n creator: Address\n /**\n * Current global state values.\n */\n globalState: AppState\n /** The number of allocated ints in per-user local state. */\n localInts: number\n /** The number of allocated byte slices in per-user local state. */\n localByteSlices: number\n /** The number of allocated ints in global state. */\n globalInts: number\n /** The number of allocated byte slices in global state. */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract. */\n extraProgramPages?: number\n}\n\n/**\n * Something that identifies an app box name - either a:\n * * `Uint8Array` (the actual binary of the box name)\n * * `string` (that will be encoded to a `Uint8Array`)\n * * `AddressWithSigner` (that will be encoded into the\n * public key address of the corresponding account)\n */\nexport type BoxIdentifier = string | Uint8Array | AddressWithTransactionSigner\n\n/**\n * A grouping of the app ID and name identifier to reference an app box.\n */\nexport interface BoxReference {\n /**\n * A unique application id\n */\n appId: bigint\n /**\n * Identifier for a box name\n */\n name: BoxIdentifier\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: BoxIdentifier\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: BoxIdentifier[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/** Allows management of application information. */\nexport class AppManager {\n private _algod: AlgodClient\n private _compilationResults: Record<string, CompiledTeal> = {}\n\n /**\n * Creates an `AppManager`\n * @param algod An algod instance\n */\n constructor(algod: AlgodClient) {\n this._algod = algod\n }\n\n /**\n * Compiles the given TEAL using algod and returns the result, including source map.\n *\n * The result of this compilation is also cached keyed by the TEAL\n * code so it can be retrieved via `getCompilationResult`.\n *\n * This function is re-entrant; it will only compile the same code once.\n *\n * @param tealCode The TEAL code\n * @returns The information about the compiled file\n * @example\n * ```typescript\n * const compiled = await appManager.compileTeal(tealProgram)\n * ```\n */\n async compileTeal(tealCode: string): Promise<CompiledTeal> {\n if (this._compilationResults[tealCode]) {\n return this._compilationResults[tealCode]\n }\n\n const compiled = await this._algod.tealCompile(tealCode, { sourcemap: true })\n const result = {\n teal: tealCode,\n compiled: compiled.result,\n compiledHash: compiled.hash,\n compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),\n sourceMap: new ProgramSourceMap(compiled.sourcemap as { version: number; sources: string[]; names: string[]; mappings: string }),\n }\n this._compilationResults[tealCode] = result\n\n return result\n }\n\n /**\n * Performs template substitution of a teal template and compiles it, returning the compiled result.\n *\n * Looks for `TMPL_{parameter}` for template replacements and replaces AlgoKit deploy-time control parameters\n * if deployment metadata is specified.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * @param tealTemplateCode The TEAL logic to compile\n * @param templateParams Any parameters to replace in the .teal file before compiling\n * @param deploymentMetadata The deployment metadata the app will be deployed with\n * @returns The information about the compiled code\n * @example\n * ```typescript\n * const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })\n * ```\n */\n async compileTealTemplate(\n tealTemplateCode: string,\n templateParams?: TealTemplateParams,\n deploymentMetadata?: { updatable?: boolean; deletable?: boolean },\n ): Promise<CompiledTeal> {\n let tealCode = AppManager.stripTealComments(tealTemplateCode)\n\n tealCode = AppManager.replaceTealTemplateParams(tealCode, templateParams)\n\n if (deploymentMetadata) {\n tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, deploymentMetadata)\n }\n\n return await this.compileTeal(tealCode)\n }\n\n /**\n * Returns a previous compilation result.\n * @param tealCode The TEAL code\n * @returns The information about the previously compiled file\n * or `undefined` if that TEAL code wasn't previously compiled\n * @example\n * ```typescript\n * const compiled = appManager.getCompilationResult(tealProgram)\n * ```\n */\n getCompilationResult(tealCode: string): CompiledTeal | undefined {\n return this._compilationResults[tealCode]\n }\n\n /**\n * Returns the current app information for the app with the given ID.\n *\n * @example\n * ```typescript\n * const appInfo = await appManager.getById(12353n);\n * ```\n *\n * @param appId The ID of the app\n * @returns The app information\n */\n public async getById(appId: bigint): Promise<AppInformation> {\n const app = await this._algod.getApplicationById(appId)\n const convertedGlobalState = (app.params.globalState ?? []).map((kv) => ({\n key: kv.key,\n value: kv.value,\n }))\n\n return {\n appId: BigInt(app.id),\n appAddress: getApplicationAddress(app.id),\n approvalProgram: app.params.approvalProgram,\n clearStateProgram: app.params.clearStateProgram,\n creator: app.params.creator,\n localInts: app.params.localStateSchema?.numUints ?? 0,\n localByteSlices: app.params.localStateSchema?.numByteSlices ?? 0,\n globalInts: app.params.globalStateSchema?.numUints ?? 0,\n globalByteSlices: app.params.globalStateSchema?.numByteSlices ?? 0,\n extraProgramPages: app.params.extraProgramPages ?? 0,\n globalState: AppManager.decodeAppState(convertedGlobalState),\n }\n }\n\n /**\n * Returns the current global state values for the given app ID and account address\n *\n * @param appId The ID of the app to return global state for\n * @returns The current global state for the given app\n * @example\n * ```typescript\n * const globalState = await appManager.getGlobalState(12353n);\n * ```\n */\n public async getGlobalState(appId: bigint) {\n return (await this.getById(appId)).globalState\n }\n\n /**\n * Returns the current local state values for the given app ID and account address\n *\n * @param appId The ID of the app to return local state for\n * @param address The string address of the account to get local state for the given app\n * @returns The current local state for the given (app, account) combination\n * @example\n * ```typescript\n * const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');\n * ```\n */\n public async getLocalState(appId: bigint, address: ReadableAddress) {\n const appInfo = await this._algod.accountApplicationInformation(getAddress(address).toString(), Number(appId))\n\n if (!appInfo.appLocalState) {\n throw new Error(\"Couldn't find local state\")\n }\n\n // If keyValue is undefined or empty, return empty state\n if (!appInfo.appLocalState.keyValue || appInfo.appLocalState.keyValue.length === 0) {\n return {}\n }\n\n const convertedState = appInfo.appLocalState.keyValue.map((kv) => ({\n key: kv.key,\n value: kv.value,\n }))\n\n return AppManager.decodeAppState(convertedState)\n }\n\n /**\n * Returns the names of the current boxes for the given app.\n * @param appId The ID of the app return box names for\n * @returns The current box names\n * @example\n * ```typescript\n * const boxNames = await appManager.getBoxNames(12353n);\n * ```\n */\n public async getBoxNames(appId: bigint): Promise<BoxName[]> {\n const boxResult = await this._algod.getApplicationBoxes(appId)\n return boxResult.boxes.map((b: { name: Uint8Array }) => {\n return {\n nameRaw: b.name,\n nameBase64: Buffer.from(b.name).toString('base64'),\n name: Buffer.from(b.name).toString('utf-8'),\n }\n })\n }\n\n /**\n * Returns the value of the given box name for the given app.\n * @param appId The ID of the app return box names for\n * @param boxName The name of the box to return either as a string, binary array or `BoxName`\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValue(12353n, 'boxName');\n * ```\n */\n public async getBoxValue(appId: bigint, boxName: BoxIdentifier | BoxName): Promise<Uint8Array> {\n const boxId = typeof boxName === 'object' && 'nameRaw' in boxName ? boxName.nameRaw : boxName\n const name = AppManager.getBoxReference(boxId).name\n const boxResult = await this._algod.getApplicationBoxByName(Number(appId), name)\n return boxResult.value\n }\n\n /**\n * Returns the value of the given box names for the given app.\n * @param appId The ID of the app return box names for\n * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`\n * @returns The current box values as a byte array in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);\n * ```\n */\n public async getBoxValues(appId: bigint, boxNames: (BoxIdentifier | BoxName)[]): Promise<Uint8Array[]> {\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValue(appId, boxName)))\n }\n\n /**\n * Returns the value of the given box name for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box value as an ABI value\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValueFromABIType(request: BoxValueRequestParams): Promise<ABIValue> {\n const { appId, boxName, type } = request\n const value = await this.getBoxValue(appId, boxName)\n return type.decode(value)\n }\n\n /**\n * Returns the value of the given box names for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box values as an ABI value in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValuesFromABIType(request: BoxValuesRequestParams): Promise<ABIValue[]> {\n const { appId, boxNames, type } = request\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValueFromABIType({ appId, boxName, type })))\n }\n\n /**\n * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.\n * @param boxId The box to return a reference for\n * @returns The box reference ready to pass into a `algosdk.Transaction`\n * @example\n * ```typescript\n * const boxRef = AppManager.getBoxReference('boxName');\n * ```\n */\n public static getBoxReference(boxId: BoxIdentifier | BoxReference): TransactionBoxReference {\n const ref = typeof boxId === 'object' && 'appId' in boxId ? boxId : { appId: 0n, name: boxId }\n return {\n appId: ref.appId,\n name: typeof ref.name === 'string' ? new TextEncoder().encode(ref.name) : 'length' in ref.name ? ref.name : ref.name.addr.publicKey,\n } as TransactionBoxReference\n }\n\n /**\n * Converts an array of global/local state values from the algod api to a more friendly\n * generic object keyed by the UTF-8 value of the key.\n * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`\n * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values\n * @example\n * ```typescript\n * const stateValues = AppManager.decodeAppState(state);\n * ```\n */\n public static decodeAppState(state: { key: Uint8Array; value: TealValue | EvalDelta }[]): AppState {\n const stateValues = {} as AppState\n\n // Start with empty set\n for (const stateVal of state) {\n const keyBase64 = Buffer.from(stateVal.key).toString('base64')\n const keyRaw = stateVal.key\n const key = Buffer.from(stateVal.key).toString('utf-8')\n const tealValue = stateVal.value\n\n const dataTypeFlag = Number('action' in tealValue ? tealValue.action : tealValue.type)\n let valueBase64: string\n let valueRaw: Buffer\n switch (dataTypeFlag) {\n case 1:\n valueBase64 =\n typeof tealValue.bytes === 'string' ? tealValue.bytes : tealValue.bytes ? Buffer.from(tealValue.bytes).toString('base64') : ''\n valueRaw = Buffer.from(valueBase64, 'base64')\n stateValues[key] = {\n keyRaw,\n keyBase64,\n valueRaw: new Uint8Array(valueRaw),\n valueBase64: valueBase64,\n value: valueRaw.toString('utf-8'),\n }\n break\n case 2: {\n const value = tealValue.uint ?? 0\n stateValues[key] = {\n keyRaw,\n keyBase64,\n value: BigInt(value),\n }\n break\n }\n default:\n throw new Error(`Received unknown state data type of ${dataTypeFlag}`)\n }\n }\n\n return stateValues\n }\n\n /**\n * Returns any ABI return values for the given app call arguments and transaction confirmation.\n * @param confirmation The transaction confirmation from algod\n * @param method The ABI method\n * @returns The return value for the method call\n * @example\n * ```typescript\n * const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));\n * ```\n */\n public static getABIReturn(confirmation: PendingTransactionResponse | undefined, method: ABIMethod | undefined): ABIReturn | undefined {\n if (!method || !confirmation) {\n return undefined\n }\n\n if (method.returns.type === 'void') {\n return { method, rawReturnValue: undefined, returnValue: undefined }\n }\n\n try {\n const logs = confirmation.logs || []\n if (logs.length === 0) {\n throw new Error(`App call transaction did not log a return value`)\n }\n const lastLog = logs[logs.length - 1]\n if (!AppManager.hasAbiReturnPrefix(lastLog)) {\n throw new Error(`App call transaction did not log an ABI return value`)\n }\n\n const rawReturnValue = new Uint8Array(lastLog.slice(4))\n return {\n method: method,\n rawReturnValue,\n decodeError: undefined,\n returnValue: method.returns.type.decode(rawReturnValue),\n }\n } catch (err) {\n return {\n method: method,\n rawReturnValue: undefined,\n decodeError: err as Error,\n returnValue: undefined,\n }\n }\n }\n\n private static hasAbiReturnPrefix(log: Uint8Array): boolean {\n if (log.length < ABI_RETURN_PREFIX.length) {\n return false\n }\n for (let i = 0; i < ABI_RETURN_PREFIX.length; i++) {\n if (log[i] !== ABI_RETURN_PREFIX[i]) {\n return false\n }\n }\n return true\n }\n\n /**\n * Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * Note: If these values are defined, but the corresponding `TMPL_*` value\n * isn't in the teal code it will throw an exception.\n *\n * @param tealTemplateCode The TEAL template code to substitute\n * @param params The deploy-time deployment control parameter value to replace\n * @returns The replaced TEAL code\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });\n * ```\n */\n static replaceTealTemplateDeployTimeControlParams(tealTemplateCode: string, params: { updatable?: boolean; deletable?: boolean }) {\n if (params.updatable !== undefined) {\n if (!tealTemplateCode.includes(UPDATABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time updatability control requested for app deployment, but ${UPDATABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, UPDATABLE_TEMPLATE_NAME, (params.updatable ? 1 : 0).toString())\n }\n\n if (params.deletable !== undefined) {\n if (!tealTemplateCode.includes(DELETABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time deletability control requested for app deployment, but ${DELETABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, DELETABLE_TEMPLATE_NAME, (params.deletable ? 1 : 0).toString())\n }\n\n return tealTemplateCode\n }\n\n /**\n * Performs template substitution of a teal file.\n *\n * Looks for `TMPL_{parameter}` for template replacements.\n *\n * @param tealTemplateCode The TEAL template code to make parameter replacements in\n * @param templateParams Any parameters to replace in the teal code\n * @returns The TEAL code with replacements\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });\n * ```\n */\n static replaceTealTemplateParams(tealTemplateCode: string, templateParams?: TealTemplateParams) {\n if (templateParams !== undefined) {\n for (const key in templateParams) {\n const value = templateParams[key]\n const token = `TMPL_${key.replace(/^TMPL_/, '')}`\n\n // If this is a number, first replace any byte representations of the number\n // These may appear in the TEAL in order to circumvent int compression and preserve PC values\n if (typeof value === 'number' || typeof value === 'bigint') {\n tealTemplateCode = tealTemplateCode.replace(new RegExp(`(?<=bytes )${token}`, 'g'), `0x${value.toString(16).padStart(16, '0')}`)\n\n // We could probably return here since mixing pushint and pushbytes is likely not going to happen, but might as well do both\n }\n\n tealTemplateCode = replaceTemplateVariable(\n tealTemplateCode,\n token,\n typeof value === 'string'\n ? `0x${Buffer.from(value, 'utf-8').toString('hex')}`\n : ArrayBuffer.isView(value)\n ? `0x${Buffer.from(value).toString('hex')}`\n : value.toString(),\n )\n }\n }\n\n return tealTemplateCode\n }\n\n /**\n * Remove comments from TEAL code (useful to reduce code size before compilation).\n *\n * @param tealCode The TEAL logic to strip\n * @returns The TEAL without comments\n * @example\n * ```typescript\n * const stripped = AppManager.stripTealComments(tealProgram);\n * ```\n */\n static stripTealComments(tealCode: string) {\n const stripCommentFromLine = (line: string) => {\n const commentIndex = findUnquotedString(line, '//')\n if (commentIndex === undefined) {\n return line\n }\n return line.slice(0, commentIndex).trimEnd()\n }\n\n return tealCode\n .split('\\n')\n .map((line) => stripCommentFromLine(line))\n .join('\\n')\n }\n}\n\n/**\n * Find the first string within a line of TEAL. Only matches outside of quotes and base64 are returned.\n * Returns undefined if not found\n */\nconst findUnquotedString = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n let index = startIndex\n let inQuotes = false\n let inBase64 = false\n\n while (index < endIndex) {\n const currentChar = line[index]\n if ((currentChar === ' ' || currentChar === '(') && !inQuotes && lastTokenBase64(line, index)) {\n // enter base64\n inBase64 = true\n } else if ((currentChar === ' ' || currentChar === ')') && !inQuotes && inBase64) {\n // exit base64\n inBase64 = false\n } else if (currentChar === '\\\\' && inQuotes) {\n // escaped char, skip next character\n index += 1\n } else if (currentChar === '\"') {\n // quote boundary\n inQuotes = !inQuotes\n } else if (!inQuotes && !inBase64 && line.startsWith(token, index)) {\n // can test for match\n return index\n }\n index += 1\n }\n return undefined\n}\n\nconst lastTokenBase64 = (line: string, index: number): boolean => {\n try {\n const tokens = line.slice(0, index).split(/\\s+/)\n const last = tokens[tokens.length - 1]\n return ['base64', 'b64'].includes(last)\n } catch {\n return false\n }\n}\n\nfunction replaceTemplateVariable(program: string, token: string, replacement: string): string {\n const result: string[] = []\n const tokenIndexOffset = replacement.length - token.length\n\n const programLines = program.split('\\n')\n\n for (const line of programLines) {\n const _commentIndex = findUnquotedString(line, '//')\n const commentIndex = _commentIndex === undefined ? line.length : _commentIndex\n let code = line.substring(0, commentIndex)\n const comment = line.substring(commentIndex)\n let trailingIndex = 0\n\n while (true) {\n const tokenIndex = findTemplateToken(code, token, trailingIndex)\n if (tokenIndex === undefined) {\n break\n }\n trailingIndex = tokenIndex + token.length\n const prefix = code.substring(0, tokenIndex)\n const suffix = code.substring(trailingIndex)\n code = `${prefix}${replacement}${suffix}`\n trailingIndex += tokenIndexOffset\n }\n result.push(code + comment)\n }\n\n return result.join('\\n')\n}\n\nconst findTemplateToken = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n\n let index = startIndex\n while (index < endIndex) {\n const tokenIndex = findUnquotedString(line, token, index, endIndex)\n if (tokenIndex === undefined) {\n break\n }\n const trailingIndex = tokenIndex + token.length\n if (\n (tokenIndex === 0 || !isValidTokenCharacter(line[tokenIndex - 1])) &&\n (trailingIndex >= line.length || !isValidTokenCharacter(line[trailingIndex]))\n ) {\n return tokenIndex\n }\n index = trailingIndex\n }\n return undefined\n}\n\nfunction isValidTokenCharacter(char: string): boolean {\n return char.length === 1 && (/\\w/.test(char) || char === '_')\n}\n"],"mappings":";;;;;;AAkGA,IAAa,aAAb,MAAa,WAAW;CACtB,AAAQ;CACR,AAAQ,sBAAoD,EAAE;;;;;CAM9D,YAAY,OAAoB;AAC9B,OAAK,SAAS;;;;;;;;;;;;;;;;;CAkBhB,MAAM,YAAY,UAAyC;AACzD,MAAI,KAAK,oBAAoB,UAC3B,QAAO,KAAK,oBAAoB;EAGlC,MAAM,WAAW,MAAM,KAAK,OAAO,YAAY,UAAU,EAAE,WAAW,MAAM,CAAC;EAC7E,MAAM,SAAS;GACb,MAAM;GACN,UAAU,SAAS;GACnB,cAAc,SAAS;GACvB,uBAAuB,IAAI,WAAW,OAAO,KAAK,SAAS,QAAQ,SAAS,CAAC;GAC7E,WAAW,IAAIA,mCAAiB,SAAS,UAAuF;GACjI;AACD,OAAK,oBAAoB,YAAY;AAErC,SAAO;;;;;;;;;;;;;;;;;;;;CAqBT,MAAM,oBACJ,kBACA,gBACA,oBACuB;EACvB,IAAI,WAAW,WAAW,kBAAkB,iBAAiB;AAE7D,aAAW,WAAW,0BAA0B,UAAU,eAAe;AAEzE,MAAI,mBACF,YAAW,WAAW,2CAA2C,UAAU,mBAAmB;AAGhG,SAAO,MAAM,KAAK,YAAY,SAAS;;;;;;;;;;;;CAazC,qBAAqB,UAA4C;AAC/D,SAAO,KAAK,oBAAoB;;;;;;;;;;;;;CAclC,MAAa,QAAQ,OAAwC;EAC3D,MAAM,MAAM,MAAM,KAAK,OAAO,mBAAmB,MAAM;EACvD,MAAM,wBAAwB,IAAI,OAAO,eAAe,EAAE,EAAE,KAAK,QAAQ;GACvE,KAAK,GAAG;GACR,OAAO,GAAG;GACX,EAAE;AAEH,SAAO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B,MAAM,OAAO,cAAc;AAChE,OAAI,eAAe,OACjB;AAEF,mBAAgB,aAAa,MAAM;AAGnC,UAAO,GAFQ,KAAK,UAAU,GAAG,WAAW,GAEzB,cADJ,KAAK,UAAU,cAAc;AAE5C,oBAAiB;;AAEnB,SAAO,KAAK,OAAO,QAAQ;;AAG7B,QAAO,OAAO,KAAK,KAAK;;AAG1B,MAAM,qBAAqB,MAAc,OAAe,aAAqB,GAAG,cAA2C;CACzH,MAAM,WAAW,cAAc,SAAY,KAAK,SAAS;CAEzD,IAAI,QAAQ;AACZ,QAAO,QAAQ,UAAU;EACvB,MAAM,aAAa,mBAAmB,MAAM,OAAO,OAAO,SAAS;AACnE,MAAI,eAAe,OACjB;EAEF,MAAM,gBAAgB,aAAa,MAAM;AACzC,OACG,eAAe,KAAK,CAAC,sBAAsB,KAAK,aAAa,GAAG,MAChE,iBAAiB,KAAK,UAAU,CAAC,sBAAsB,KAAK,eAAe,EAE5E,QAAO;AAET,UAAQ;;;AAKZ,SAAS,sBAAsB,MAAuB;AACpD,QAAO,KAAK,WAAW,MAAM,KAAK,KAAK,KAAK,IAAI,SAAS"}
@@ -102,11 +102,11 @@ var AppManager = class AppManager {
102
102
  approvalProgram: app.params.approvalProgram,
103
103
  clearStateProgram: app.params.clearStateProgram,
104
104
  creator: app.params.creator,
105
- localInts: Number(app.params.localStateSchema?.numUints ?? 0),
106
- localByteSlices: Number(app.params.localStateSchema?.numByteSlices ?? 0),
107
- globalInts: Number(app.params.globalStateSchema?.numUints ?? 0),
108
- globalByteSlices: Number(app.params.globalStateSchema?.numByteSlices ?? 0),
109
- extraProgramPages: Number(app.params.extraProgramPages ?? 0),
105
+ localInts: app.params.localStateSchema?.numUints ?? 0,
106
+ localByteSlices: app.params.localStateSchema?.numByteSlices ?? 0,
107
+ globalInts: app.params.globalStateSchema?.numUints ?? 0,
108
+ globalByteSlices: app.params.globalStateSchema?.numByteSlices ?? 0,
109
+ extraProgramPages: app.params.extraProgramPages ?? 0,
110
110
  globalState: AppManager.decodeAppState(convertedGlobalState)
111
111
  };
112
112
  }