algosdk 3.7.0-beta.1 → 3.8.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.
Files changed (116) hide show
  1. package/README.md +4 -4
  2. package/dist/browser/algosdk.min.js +1 -1
  3. package/dist/browser/algosdk.min.js.map +1 -1
  4. package/dist/cjs/appAccess.js +4 -0
  5. package/dist/cjs/appAccess.js.map +1 -1
  6. package/dist/cjs/client/v2/algod/getPeers.js +20 -0
  7. package/dist/cjs/client/v2/algod/getPeers.js.map +1 -0
  8. package/dist/cjs/client/v2/algod/models/types.js +153 -5
  9. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  10. package/dist/cjs/client/v2/indexer/models/types.js +163 -12
  11. package/dist/cjs/client/v2/indexer/models/types.js.map +1 -1
  12. package/dist/cjs/composer.js +4 -6
  13. package/dist/cjs/composer.js.map +1 -1
  14. package/dist/cjs/ed25519-signer.js +18 -0
  15. package/dist/cjs/ed25519-signer.js.map +1 -1
  16. package/dist/cjs/encoding/address.js +9 -0
  17. package/dist/cjs/encoding/address.js.map +1 -1
  18. package/dist/cjs/falcon-signer.js +16 -0
  19. package/dist/cjs/falcon-signer.js.map +1 -1
  20. package/dist/cjs/heartbeat.js +7 -0
  21. package/dist/cjs/heartbeat.js.map +1 -1
  22. package/dist/cjs/logicsig.js +86 -6
  23. package/dist/cjs/logicsig.js.map +1 -1
  24. package/dist/cjs/makeTxn.js +11 -2
  25. package/dist/cjs/makeTxn.js.map +1 -1
  26. package/dist/cjs/mnemonic/mnemonic.js +2 -0
  27. package/dist/cjs/mnemonic/mnemonic.js.map +1 -1
  28. package/dist/cjs/pq-signer.js +51 -0
  29. package/dist/cjs/pq-signer.js.map +1 -1
  30. package/dist/cjs/signer.js.map +1 -1
  31. package/dist/cjs/signing.js +22 -0
  32. package/dist/cjs/signing.js.map +1 -1
  33. package/dist/cjs/transaction.js +8 -0
  34. package/dist/cjs/transaction.js.map +1 -1
  35. package/dist/cjs/types/block.js +28 -0
  36. package/dist/cjs/types/block.js.map +1 -1
  37. package/dist/cjs/types/statedelta.js +17 -0
  38. package/dist/cjs/types/statedelta.js.map +1 -1
  39. package/dist/cjs/utils/utils.js +14 -1
  40. package/dist/cjs/utils/utils.js.map +1 -1
  41. package/dist/esm/appAccess.js +4 -0
  42. package/dist/esm/appAccess.js.map +1 -1
  43. package/dist/esm/client/v2/algod/getPeers.js +14 -0
  44. package/dist/esm/client/v2/algod/getPeers.js.map +1 -0
  45. package/dist/esm/client/v2/algod/models/types.js +149 -3
  46. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  47. package/dist/esm/client/v2/indexer/models/types.js +161 -11
  48. package/dist/esm/client/v2/indexer/models/types.js.map +1 -1
  49. package/dist/esm/composer.js +4 -6
  50. package/dist/esm/composer.js.map +1 -1
  51. package/dist/esm/ed25519-signer.js +18 -0
  52. package/dist/esm/ed25519-signer.js.map +1 -1
  53. package/dist/esm/encoding/address.js +9 -0
  54. package/dist/esm/encoding/address.js.map +1 -1
  55. package/dist/esm/falcon-signer.js +16 -0
  56. package/dist/esm/falcon-signer.js.map +1 -1
  57. package/dist/esm/heartbeat.js +8 -1
  58. package/dist/esm/heartbeat.js.map +1 -1
  59. package/dist/esm/logicsig.js +86 -6
  60. package/dist/esm/logicsig.js.map +1 -1
  61. package/dist/esm/makeTxn.js +11 -2
  62. package/dist/esm/makeTxn.js.map +1 -1
  63. package/dist/esm/mnemonic/mnemonic.js +2 -0
  64. package/dist/esm/mnemonic/mnemonic.js.map +1 -1
  65. package/dist/esm/pq-signer.js +51 -0
  66. package/dist/esm/pq-signer.js.map +1 -1
  67. package/dist/esm/signer.js.map +1 -1
  68. package/dist/esm/signing.js +22 -0
  69. package/dist/esm/signing.js.map +1 -1
  70. package/dist/esm/transaction.js +8 -0
  71. package/dist/esm/transaction.js.map +1 -1
  72. package/dist/esm/types/block.js +28 -0
  73. package/dist/esm/types/block.js.map +1 -1
  74. package/dist/esm/types/statedelta.js +17 -0
  75. package/dist/esm/types/statedelta.js.map +1 -1
  76. package/dist/esm/utils/utils.js +12 -0
  77. package/dist/esm/utils/utils.js.map +1 -1
  78. package/dist/types/client/v2/algod/getPeers.d.ts +7 -0
  79. package/dist/types/client/v2/algod/models/types.d.ts +90 -3
  80. package/dist/types/client/v2/indexer/models/types.d.ts +114 -7
  81. package/dist/types/composer.d.ts +3 -3
  82. package/dist/types/ed25519-signer.d.ts +29 -0
  83. package/dist/types/encoding/address.d.ts +9 -0
  84. package/dist/types/falcon-signer.d.ts +29 -2
  85. package/dist/types/heartbeat.d.ts +2 -0
  86. package/dist/types/logicsig.d.ts +91 -6
  87. package/dist/types/makeTxn.d.ts +8 -2
  88. package/dist/types/mnemonic/mnemonic.d.ts +2 -0
  89. package/dist/types/pq-signer.d.ts +39 -2
  90. package/dist/types/signer.d.ts +76 -5
  91. package/dist/types/signing.d.ts +22 -0
  92. package/dist/types/transaction.d.ts +1 -0
  93. package/dist/types/types/block.d.ts +22 -0
  94. package/dist/types/types/statedelta.d.ts +18 -0
  95. package/dist/types/types/transactions/base.d.ts +10 -0
  96. package/dist/types/utils/utils.d.ts +1 -0
  97. package/package.json +2 -2
  98. package/src/appAccess.ts +5 -0
  99. package/src/client/v2/algod/models/types.ts +234 -0
  100. package/src/client/v2/indexer/models/types.ts +280 -8
  101. package/src/composer.ts +7 -11
  102. package/src/ed25519-signer.ts +29 -0
  103. package/src/encoding/address.ts +9 -0
  104. package/src/falcon-signer.ts +31 -1
  105. package/src/heartbeat.ts +11 -0
  106. package/src/logicsig.ts +93 -6
  107. package/src/makeTxn.ts +13 -4
  108. package/src/mnemonic/mnemonic.ts +2 -0
  109. package/src/pq-signer.ts +71 -1
  110. package/src/signer.ts +77 -5
  111. package/src/signing.ts +22 -0
  112. package/src/transaction.ts +10 -0
  113. package/src/types/block.ts +54 -0
  114. package/src/types/statedelta.ts +34 -0
  115. package/src/types/transactions/base.ts +11 -0
  116. package/src/utils/utils.ts +13 -0
@@ -21,14 +21,52 @@ export interface Addressable {
21
21
  * corresponds to the signed transaction from txnGroup[indexesToSign[i]]
22
22
  */
23
23
  export type TransactionSigner = (txnGroup: Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
24
+ /**
25
+ * An address paired with a signer able to sign transactions on its behalf.
26
+ *
27
+ * @remarks
28
+ * `address` is the address transactions are sent from, which is not necessarily
29
+ * the address that authorizes them: for a rekeyed account the two differ, and
30
+ * `txnSigner` sets the transaction's `sgnr` field accordingly.
31
+ */
24
32
  export interface AddressWithTransactionSigner extends Addressable {
25
33
  txnSigner: TransactionSigner;
26
34
  }
27
- /** Function for signing logic signatures for delegation
28
- * @param lsig - The logic signature that is being signed for delegation
29
- * @param msig - Optional multisig account that should be set when a public key is signing as a subsigner of a multisig
30
- * @returns The address of the delegator
31
- * */
35
+ /**
36
+ * An address paired with a signer that produces placeholder signatures for it.
37
+ *
38
+ * @remarks
39
+ * Useful for post-quantum accounts, whose real signatures are large and slow to
40
+ * produce, when only a simulation of the group is needed.
41
+ */
42
+ export interface AddressWithEmptyTransactionSigner extends Addressable {
43
+ /**
44
+ * A TransactionSigner that produces unsigned (or placeholder-signed)
45
+ * transactions. This must only be used to simulate transactions with the
46
+ * `allowEmptySignatures` option enabled.
47
+ */
48
+ emptyTxnSigner: TransactionSigner;
49
+ }
50
+ /**
51
+ * This type represents a function which can sign a LogicSig for delegation.
52
+ *
53
+ * @remarks
54
+ * Exactly one of `sig`, `lmsig` and `pqsig` is returned, according to the kind
55
+ * of key the signer holds and whether `msig` was supplied:
56
+ *
57
+ * - `sig` - an ed25519 signature from a single delegating account
58
+ * - `lmsig` - a multisig containing this signer's subsignature, returned when
59
+ * `msig` is supplied
60
+ * - `pqsig` - a post-quantum signature from a single delegating account
61
+ *
62
+ * @param lsig - The logic signature that is being signed for delegation
63
+ * @param msig - Optional multisig account that should be set when a public key is signing as a subsigner of a multisig
64
+ * @returns A promise which resolves to the signature and the address that
65
+ * produced it. When `msig` is omitted this is the delegating account; when
66
+ * `msig` is supplied it is the individual subsigner rather than the multisig.
67
+ * Either way it is an authorizing address, which is not necessarily the
68
+ * address the signer sends transactions from.
69
+ */
32
70
  export type DelegatedLsigSigner = (lsig: LogicSig, msig?: MultisigMetadata) => Promise<{
33
71
  address: Address;
34
72
  } & ({
@@ -38,14 +76,47 @@ export type DelegatedLsigSigner = (lsig: LogicSig, msig?: MultisigMetadata) => P
38
76
  } | {
39
77
  pqsig: EncodedPQSig;
40
78
  })>;
79
+ /**
80
+ * An address paired with a signer able to delegate a LogicSig to it.
81
+ */
41
82
  export interface AddressWithDelegatedLsigSigner extends Addressable {
42
83
  delegatedLsigSigner: DelegatedLsigSigner;
43
84
  }
85
+ /**
86
+ * This type represents a function which can sign arbitrary bytes, for use with
87
+ * {@link verifyBytes}.
88
+ *
89
+ * @remarks
90
+ * The implementation is responsible for prepending the "MX" domain-separation
91
+ * prefix ({@link SIGN_BYTES_PREFIX}) before signing, so `bytesToSign` is the
92
+ * caller's bytes alone.
93
+ *
94
+ * @param bytesToSign - The bytes to sign, without any domain-separation prefix
95
+ * @returns A promise which resolves to the raw signature
96
+ */
44
97
  export type MxBytesSigner = (bytesToSign: Uint8Array) => Promise<Uint8Array>;
98
+ /**
99
+ * An address paired with a signer able to sign arbitrary bytes on its behalf.
100
+ */
45
101
  export interface AddressWithMxBytesSigner extends Addressable {
46
102
  mxBytesSigner: MxBytesSigner;
47
103
  }
104
+ /**
105
+ * This type represents a function which can sign data for use with the
106
+ * `ed25519verify` opcode from within a LogicSig's program.
107
+ *
108
+ * @remarks
109
+ * The implementation is responsible for prepending the "ProgData" prefix
110
+ * ({@link SIGN_PROGRAM_DATA_PREFIX}) and the LogicSig's address before signing.
111
+ *
112
+ * @param data - The data to sign, without any prefix
113
+ * @param lsig - The LogicSig whose program will verify the signature
114
+ * @returns A promise which resolves to the raw signature
115
+ */
48
116
  export type ProgramDataSigner = (data: Uint8Array, lsig: LogicSig) => Promise<Uint8Array>;
117
+ /**
118
+ * An address paired with a signer able to sign program data on its behalf.
119
+ */
49
120
  export interface AddressWithProgramDataSigner extends Addressable {
50
121
  programDataSigner: ProgramDataSigner;
51
122
  }
@@ -3,6 +3,11 @@ import { SignedTransaction } from './signedTransaction.js';
3
3
  import { Transaction } from './transaction.js';
4
4
  import { LogicSig, LogicSigAccount } from './logicsig.js';
5
5
  import type { TransactionSigner } from './signer.js';
6
+ /**
7
+ * The domain-separation prefix prepended to arbitrary bytes before signing them
8
+ * with {@link signBytes}, so that such a signature can never be mistaken for a
9
+ * signature over a transaction or a program.
10
+ */
6
11
  export declare const SIGN_BYTES_PREFIX: Uint8Array;
7
12
  /**
8
13
  * @deprecated Use signTransactionWithSigner
@@ -25,6 +30,23 @@ export declare function signTransaction(txn: Transaction, sk: Uint8Array): {
25
30
  txID: string;
26
31
  blob: Uint8Array;
27
32
  };
33
+ /**
34
+ * signTransactionWithSigner signs a single transaction with the given signer.
35
+ *
36
+ * @remarks
37
+ * This is the replacement for the deprecated {@link signTransaction}, which can
38
+ * only sign with a raw ed25519 secret key. Because a `TransactionSigner` signs
39
+ * a group, the transaction is passed as a one-element group and the single
40
+ * result is returned.
41
+ *
42
+ * The decoded `stxn` is returned alongside the blob so callers can read what
43
+ * the signer produced — its `sig`, `pqsig` or `msig` field, and the `sgnr` field
44
+ * naming the key that signed when it is not the transaction sender.
45
+ *
46
+ * @param txn - the transaction to sign
47
+ * @param signer - the signer to sign with
48
+ * @returns an object with blob, txID and stxn properties
49
+ */
28
50
  export declare function signTransactionWithSigner(txn: Transaction, signer: TransactionSigner): Promise<ReturnType<typeof signTransaction> & {
29
51
  stxn: SignedTransaction;
30
52
  }>;
@@ -93,6 +93,7 @@ export interface HeartbeatTransactionFields {
93
93
  readonly seed: Uint8Array;
94
94
  readonly voteID: Uint8Array;
95
95
  readonly keyDilution: bigint;
96
+ readonly challengeDiscount: boolean;
96
97
  }
97
98
  /**
98
99
  * Transaction enables construction of Algorand transactions
@@ -49,9 +49,14 @@ export declare class TxnCommitments implements Encodable {
49
49
  * Root of transaction vector commitment merkle tree using SHA256 hash function
50
50
  */
51
51
  sha256Commitment: Uint8Array;
52
+ /**
53
+ * Root of transaction vector commitment merkle tree using SHA512 hash function
54
+ */
55
+ sha512Commitment: Uint8Array;
52
56
  constructor(params: {
53
57
  nativeSha512_256Commitment: Uint8Array;
54
58
  sha256Commitment: Uint8Array;
59
+ sha512Commitment?: Uint8Array;
55
60
  });
56
61
  getEncodingSchema(): Schema;
57
62
  toEncodingData(): Map<string, unknown>;
@@ -196,6 +201,10 @@ export declare class BlockHeader implements Encodable {
196
201
  * Previous block hash
197
202
  */
198
203
  branch: Uint8Array;
204
+ /**
205
+ * Previous block hash, using SHA-512
206
+ */
207
+ branch512: Uint8Array;
199
208
  /**
200
209
  * Sortition seed
201
210
  */
@@ -249,9 +258,20 @@ export declare class BlockHeader implements Encodable {
249
258
  */
250
259
  stateproofTracking: Map<number, StateProofTrackingData>;
251
260
  participationUpdates: ParticipationUpdates;
261
+ /**
262
+ * Load is the degree to which a block is full. Currently, it is based on the number of bytes in
263
+ * the final block, compared to the maximum allowed. It is expressed as a fixed-point integer with
264
+ * 6 digits of precision. So, 1,000,000 is a completely full block.
265
+ */
266
+ load: bigint;
267
+ /**
268
+ * CongestionTax is the fee required, beyond the MinFee, for "normal" transactions in this block.
269
+ */
270
+ congestionTax: bigint;
252
271
  constructor(params: {
253
272
  round: bigint;
254
273
  branch: Uint8Array;
274
+ branch512?: Uint8Array;
255
275
  seed: Uint8Array;
256
276
  txnCommitments: TxnCommitments;
257
277
  timestamp: bigint;
@@ -267,6 +287,8 @@ export declare class BlockHeader implements Encodable {
267
287
  txnCounter: bigint;
268
288
  stateproofTracking: Map<number, StateProofTrackingData>;
269
289
  participationUpdates: ParticipationUpdates;
290
+ load?: bigint;
291
+ congestionTax?: bigint;
270
292
  });
271
293
  getEncodingSchema(): Schema;
272
294
  toEncodingData(): Map<string, unknown>;
@@ -48,6 +48,20 @@ export declare class AppParams implements Encodable {
48
48
  localStateSchema: StateSchema;
49
49
  globalStateSchema: StateSchema;
50
50
  extraProgramPages: number;
51
+ version: bigint;
52
+ /**
53
+ * If non-zero, the account that must hold MBR for extra program pages and the
54
+ * global schema.
55
+ */
56
+ sizeSponsor: Address;
57
+ /**
58
+ * When true, any app may read this app's boxes.
59
+ */
60
+ foreignBoxReads: boolean;
61
+ /**
62
+ * When true, apps with the same creator may read and write this app's boxes.
63
+ */
64
+ familyBoxAccess: boolean;
51
65
  constructor(params: {
52
66
  approvalProgram: Uint8Array;
53
67
  clearStateProgram: Uint8Array;
@@ -55,6 +69,10 @@ export declare class AppParams implements Encodable {
55
69
  localStateSchema: StateSchema;
56
70
  globalStateSchema: StateSchema;
57
71
  extraProgramPages: number;
72
+ version?: bigint;
73
+ sizeSponsor?: Address;
74
+ foreignBoxReads?: boolean;
75
+ familyBoxAccess?: boolean;
58
76
  });
59
77
  getEncodingSchema(): Schema;
60
78
  toEncodingData(): Map<string, unknown>;
@@ -473,6 +473,16 @@ export interface HeartbeatTransactionParams {
473
473
  * Must match hbAddress account's current KeyDilution.
474
474
  */
475
475
  keyDilution: bigint;
476
+ /**
477
+ * Requests the challenge fee discount: when set, the required fee is reduced
478
+ * by one min fee. The network verifies that hbAddress is actually under
479
+ * challenge before granting it, and a heartbeat claiming the discount may not
480
+ * carry any extra fields (note, lease, group, etc.).
481
+ *
482
+ * Only allowed once transaction size pricing is enabled. Before that, the
483
+ * discount was inferred from an underpaid singleton heartbeat instead.
484
+ */
485
+ challengeDiscount?: boolean;
476
486
  }
477
487
  /**
478
488
  * A full list of all available transaction parameters
@@ -55,3 +55,4 @@ export declare function ensureSafeInteger(value: unknown): number;
55
55
  export declare function ensureSafeUnsignedInteger(value: unknown): number;
56
56
  export declare function ensureBigInt(value: unknown): bigint;
57
57
  export declare function ensureUint64(value: unknown): bigint;
58
+ export declare function isEmptyObject(obj: any): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "algosdk",
3
- "version": "3.7.0-beta.1",
3
+ "version": "3.8.0",
4
4
  "description": "The official JavaScript SDK for Algorand",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -75,7 +75,7 @@
75
75
  "eslint-plugin-import": "^2.25.2",
76
76
  "eslint-plugin-tsdoc": "^0.2.11",
77
77
  "express": "^4.19.2",
78
- "falcon-1024": "1.0.0-beta.2",
78
+ "@algorandfoundation/falcon-wasm": "1.0.0",
79
79
  "geckodriver": "^4.3.0",
80
80
  "husky": "^4.3.8",
81
81
  "lint-staged": "^10.5.4",
package/src/appAccess.ts CHANGED
@@ -113,7 +113,12 @@ export function resourceReferencesToEncodingData(
113
113
  ],
114
114
  ])
115
115
  );
116
+ continue;
116
117
  }
118
+
119
+ // A reference that names no resource encodes as an empty ResourceRef, which
120
+ // the network reads as a request for a box I/O quota bump.
121
+ accessList.push(new Map<string, unknown>());
117
122
  }
118
123
  return accessList;
119
124
  }