@keetanetwork/keetanet-client 0.16.1 → 0.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/client/index-browser.d.ts +3 -2
  2. package/client/index-browser.js +296 -98
  3. package/client/index.d.ts +3 -2
  4. package/client/index.js +232 -43
  5. package/docs/assets/hierarchy.js +1 -1
  6. package/docs/assets/search.js +1 -1
  7. package/docs/classes/KeetaNetSDK.Referenced.Account.html +6 -3
  8. package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
  9. package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
  10. package/docs/classes/KeetaNetSDK.Referenced.Block.html +1 -1
  11. package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +1 -1
  12. package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
  13. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
  14. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
  15. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +1 -1
  16. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
  17. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
  18. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
  19. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
  20. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  21. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  22. package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +1 -1
  23. package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
  24. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
  25. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
  26. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
  27. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
  28. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
  29. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
  30. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
  31. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
  32. package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
  33. package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
  34. package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
  35. package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
  36. package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
  37. package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
  38. package/docs/classes/KeetaNetSDK.Referenced.IdempotentKey.html +1 -1
  39. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
  40. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
  41. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +2 -2
  42. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +1 -1
  43. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +1 -1
  44. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerIdempotentKeyError.html +1 -1
  45. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.html +1 -1
  46. package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
  47. package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
  48. package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +1 -1
  49. package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +1 -1
  50. package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
  51. package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
  52. package/docs/classes/KeetaNetSDK.Referenced.PossiblyUnsignedBlock.html +1 -1
  53. package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
  54. package/docs/classes/KeetaNetSDK.Referenced.Stats.html +1 -1
  55. package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +1 -1
  56. package/docs/classes/KeetaNetSDK.Referenced.UnsignedBlock.html +1 -1
  57. package/docs/classes/KeetaNetSDK.Referenced.Vote.html +1 -1
  58. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +1 -1
  59. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +1 -1
  60. package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
  61. package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +1 -1
  62. package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +1 -1
  63. package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +1 -1
  64. package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
  65. package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +1 -1
  66. package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +1 -1
  67. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
  68. package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.applyNamespace.html +5 -0
  69. package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_helper.getTypedObjectEntries.html +1 -0
  70. package/docs/hierarchy.html +1 -1
  71. package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
  72. package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
  73. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
  74. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
  75. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
  76. package/docs/interfaces/KeetaNetSDK.Referenced.BaseAccountInfo.html +1 -1
  77. package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
  78. package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
  79. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierAccountInfo.html +1 -1
  80. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
  81. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
  82. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +1 -1
  83. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
  84. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
  85. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
  86. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
  87. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
  88. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
  89. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  90. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  91. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
  92. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
  93. package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
  94. package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
  95. package/docs/interfaces/KeetaNetSDK.Referenced.ECDSA_SECP256K1AccountInfo.html +1 -1
  96. package/docs/interfaces/KeetaNetSDK.Referenced.ECDSA_SECP256R1AccountInfo.html +1 -1
  97. package/docs/interfaces/KeetaNetSDK.Referenced.ED25519AccountInfo.html +1 -1
  98. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
  99. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
  100. package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
  101. package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
  102. package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
  103. package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
  104. package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +2 -2
  105. package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
  106. package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
  107. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigAccountInfo.html +1 -1
  108. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
  109. package/docs/interfaces/KeetaNetSDK.Referenced.NetworkAccountInfo.html +1 -1
  110. package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
  111. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
  112. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
  113. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
  114. package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
  115. package/docs/interfaces/KeetaNetSDK.Referenced.PublishOptions.html +1 -1
  116. package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
  117. package/docs/interfaces/KeetaNetSDK.Referenced.StorageAccountInfo.html +1 -1
  118. package/docs/interfaces/KeetaNetSDK.Referenced.TokenAccountInfo.html +1 -1
  119. package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
  120. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +1 -1
  121. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +1 -1
  122. package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
  123. package/docs/interfaces/KeetaNetSDK.Referenced.signOptionsType.html +16 -3
  124. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
  125. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
  126. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
  127. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
  128. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
  129. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Struct.html +1 -1
  130. package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
  131. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.html +1 -0
  132. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_helper.html +1 -1
  133. package/docs/variables/KeetaNetSDK.Referenced.allFullErrorCodes.html +1 -1
  134. package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.KeetaNamespaceVersion.html +3 -0
  135. package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.MaxNamespaceLength.html +3 -0
  136. package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.namespacePrefixSchema.html +9 -0
  137. package/docs/variables/KeetaNetSDK.lib.html +2 -2
  138. package/lib/account.d.ts +37 -0
  139. package/lib/error/account.d.ts +2 -2
  140. package/lib/error/index.d.ts +1 -1
  141. package/lib/error/vote.d.ts +1 -1
  142. package/lib/index.d.ts +4 -2
  143. package/lib/ledger/common.d.ts +12 -0
  144. package/lib/ledger/db_dynamodb.d.ts +2 -2
  145. package/lib/ledger/db_postgres.d.ts +1 -1
  146. package/lib/ledger/db_spanner.d.ts +1 -1
  147. package/lib/ledger/db_spanner_helper.d.ts +1 -1
  148. package/lib/ledger/db_sqlite.d.ts +1 -1
  149. package/lib/ledger/index.d.ts +2 -2
  150. package/lib/utils/domain-separation.d.ts +31 -0
  151. package/lib/utils/external-keys/gcp-kms.d.ts +53 -0
  152. package/lib/utils/external-keys/gcp-kms.js +328 -0
  153. package/lib/utils/external-keys/passkey-prf.d.ts +1 -3
  154. package/lib/utils/external-keys/passkey-prf.js +6 -0
  155. package/lib/utils/helper.d.ts +1 -0
  156. package/npm-shrinkwrap.json +27 -9
  157. package/package.json +1 -1
  158. package/version.d.ts +1 -1
@@ -101235,6 +101235,7 @@ __webpack_require__.d(client_helper_namespaceObject, {
101235
101235
  crypto: () => (client_helper_crypto),
101236
101236
  debugPrintableObject: () => (client_debugPrintableObject),
101237
101237
  env: () => (client_env),
101238
+ getTypedObjectEntries: () => (client_getTypedObjectEntries),
101238
101239
  isBuffer: () => (client_isBuffer),
101239
101240
  isIntegerOrBigInt: () => (client_isIntegerOrBigInt),
101240
101241
  nonNullable: () => (client_nonNullable),
@@ -101332,6 +101333,16 @@ __webpack_require__.d(client_utils_asn1_namespaceObject, {
101332
101333
  isValidSequenceSchema: () => (client_isValidSequenceSchema)
101333
101334
  });
101334
101335
 
101336
+ // NAMESPACE OBJECT: ./src/lib/utils/domain-separation.ts
101337
+ var client_domain_separation_namespaceObject = {};
101338
+ __webpack_require__.r(client_domain_separation_namespaceObject);
101339
+ __webpack_require__.d(client_domain_separation_namespaceObject, {
101340
+ KeetaNamespaceVersion: () => (client_KeetaNamespaceVersion),
101341
+ MaxNamespaceLength: () => (client_MaxNamespaceLength),
101342
+ applyNamespace: () => (client_applyNamespace),
101343
+ namespacePrefixSchema: () => (client_namespacePrefixSchema)
101344
+ });
101345
+
101335
101346
  // NAMESPACE OBJECT: ./src/lib/utils/conversion.ts
101336
101347
  var client_conversion_namespaceObject = {};
101337
101348
  __webpack_require__.r(client_conversion_namespaceObject);
@@ -105460,6 +105471,12 @@ function src_client_assertClassBrand(e, t, n) { if ("function" == typeof e ? e =
105460
105471
 
105461
105472
 
105462
105473
 
105474
+
105475
+ // Helper to get properly typed entries from an object
105476
+ function client_getTypedObjectEntries(obj) {
105477
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
105478
+ return Object.entries(obj);
105479
+ }
105463
105480
  const client_helper_randomBytes = client_crypto_default().randomBytes.bind((client_crypto_default()));
105464
105481
  const client_helper_randomUUID = (client_crypto_default()).randomUUID ? client_crypto_default().randomUUID.bind((client_crypto_default())) : function () {
105465
105482
  return client_esm_browser_v4();
@@ -106337,6 +106354,58 @@ class src_client_BufferStorage {
106337
106354
  client_BufferStorage = src_client_BufferStorage;
106338
106355
  client_buffer_defineProperty(src_client_BufferStorage, "isInstance", client_checkableGenerator(client_BufferStorage));
106339
106356
 
106357
+ ;// ./src/lib/error/base.ts
106358
+ var client_KeetaNetErrorBase;
106359
+ function client_base_defineProperty(e, r, t) { return (r = client_base_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
106360
+ function client_base_toPropertyKey(t) { var i = client_base_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
106361
+ function client_base_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
106362
+
106363
+ class src_client_KeetaNetErrorBase extends Error {
106364
+ constructor(code, message, validation) {
106365
+ super(message);
106366
+ const type = (validation === null || validation === void 0 ? void 0 : validation.type) || 'GENERIC';
106367
+ if (validation !== undefined) {
106368
+ const prefix = `${validation.type}_`;
106369
+ const validPrefix = code.startsWith(prefix);
106370
+ const withoutPrefix = code.substring(prefix.length);
106371
+ const validCode = validation.codes.includes(withoutPrefix);
106372
+ if (!validPrefix || !validCode) {
106373
+ throw new Error(`Invalid construction of KeetaNetError Type: ${validation.type} Code: ${code}, prefix ${prefix} valid ${validPrefix} valid code: ${validCode}`);
106374
+ }
106375
+ }
106376
+ this.code = code;
106377
+ this.type = type;
106378
+ }
106379
+ toJSON() {
106380
+ return {
106381
+ type: this.type,
106382
+ code: this.code,
106383
+ message: this.message
106384
+ };
106385
+ }
106386
+ }
106387
+ client_KeetaNetErrorBase = src_client_KeetaNetErrorBase;
106388
+ client_base_defineProperty(src_client_KeetaNetErrorBase, "isInstance", client_checkableGenerator(client_KeetaNetErrorBase, false));
106389
+ ;// ./src/lib/error/account.ts
106390
+ var client_KeetaNetAccountError;
106391
+ function client_account_defineProperty(e, r, t) { return (r = client_account_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
106392
+ function client_account_toPropertyKey(t) { var i = client_account_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
106393
+ function client_account_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
106394
+
106395
+
106396
+ const client_AccountErrorType = 'ACCOUNT';
106397
+ const client_AccountErrorCodes = ['INVALID_PREFIX', 'INVALID_KEYTYPE', 'INVALID_KEYTYPE_EXTERNAL', 'PASSPHRASE_WEAK', 'INVALID_CONSTRUCTION', 'NO_IDENTIFIER_SIGN', 'NO_IDENTIFIER_VERIFY', 'NOT_ACCOUNT', 'NOT_IDENTIFIER', 'INVALID_IDENTIFIER_CONSTRUCTION', 'SEED_INDEX_UNDEFINED', 'SEED_INDEX_NEGATIVE', 'SEED_INDEX_NOT_INT', 'SEED_INDEX_TOO_LARGE', 'ENCRYPTION_NOT_SUPPORTED', 'NAMESPACE_EMPTY', 'NAMESPACE_TOO_LONG'];
106398
+ const client_FullAccountErrorCodes = client_AccountErrorCodes.map(code => `${client_AccountErrorType}_${code}`);
106399
+ class src_client_KeetaNetAccountError extends src_client_KeetaNetErrorBase {
106400
+ constructor(code, message) {
106401
+ super(code, message, {
106402
+ type: client_AccountErrorType,
106403
+ codes: client_AccountErrorCodes
106404
+ });
106405
+ }
106406
+ }
106407
+ client_KeetaNetAccountError = src_client_KeetaNetAccountError;
106408
+ client_account_defineProperty(src_client_KeetaNetAccountError, "isInstance", client_checkableGenerator(client_KeetaNetAccountError));
106340
106409
  ;// ./node_modules/pvutils/build/utils.es.js
106341
106410
  /*!
106342
106411
  Copyright (c) Peculiar Ventures, LLC
@@ -115204,6 +115273,58 @@ const client_Testing = {
115204
115273
  ASN1IntegerToBigInt: client_jsIntegerToBigInt
115205
115274
  }
115206
115275
  };
115276
+ ;// ./src/lib/utils/domain-separation.ts
115277
+ /* provided dependency */ var client_domain_separation_Buffer = __webpack_require__(8287)["Buffer"];
115278
+
115279
+
115280
+
115281
+ /**
115282
+ * Version for Keeta's domain separation namespace schema, encoded as the
115283
+ * `INTEGER` field of `namespacePrefixSchema`.
115284
+ */
115285
+ const client_KeetaNamespaceVersion = 0;
115286
+
115287
+ /**
115288
+ * Maximum domain separation namespace length in bytes (for strings,
115289
+ * this is the UTF-8 byte length, not the character count).
115290
+ */
115291
+ const client_MaxNamespaceLength = 255;
115292
+
115293
+ /**
115294
+ * Schema for the namespace prefix:
115295
+ *
115296
+ * ```asn1
115297
+ * NamespacePrefix ::= SEQUENCE {
115298
+ * version INTEGER,
115299
+ * namespace OCTET STRING,
115300
+ * data OCTET STRING
115301
+ * }
115302
+ * ```
115303
+ */
115304
+ const client_namespacePrefixSchema = [client_ValidateASN1.IsInteger, client_ValidateASN1.IsOctetString, client_ValidateASN1.IsOctetString];
115305
+
115306
+ /**
115307
+ * Apply the `NamespacePrefix` domain separator to `data`.
115308
+ *
115309
+ * String namespaces are UTF-8 encoded; ArrayBuffer namespaces are used
115310
+ * verbatim. Namespace length MUST be 1-`MaxNamespaceLength` bytes after
115311
+ * encoding.
115312
+ */
115313
+ function client_applyNamespace(namespace, data) {
115314
+ let namespaceBytes;
115315
+ if (typeof namespace === 'string') {
115316
+ namespaceBytes = new TextEncoder().encode(namespace);
115317
+ } else {
115318
+ namespaceBytes = new Uint8Array(namespace);
115319
+ }
115320
+ if (namespaceBytes.length === 0) {
115321
+ throw new src_client_KeetaNetAccountError('ACCOUNT_NAMESPACE_EMPTY', 'Domain separation namespace must not be empty');
115322
+ }
115323
+ if (namespaceBytes.length > client_MaxNamespaceLength) {
115324
+ throw new src_client_KeetaNetAccountError('ACCOUNT_NAMESPACE_TOO_LONG', `Domain separation namespace must be 1-${client_MaxNamespaceLength} bytes, got: ${namespaceBytes.length}`);
115325
+ }
115326
+ return client_JStoASN1([client_KeetaNamespaceVersion, client_domain_separation_Buffer.from(namespaceBytes), client_domain_separation_Buffer.from(data)]).toBER(false);
115327
+ }
115207
115328
  ;// ./src/lib/utils/conversion.ts
115208
115329
  /* provided dependency */ var client_conversion_Buffer = __webpack_require__(8287)["Buffer"];
115209
115330
 
@@ -115561,38 +115682,6 @@ function client_fromOffsetArray(setOffsets) {
115561
115682
  return val;
115562
115683
  }
115563
115684
  client_bitfield_defineProperty(src_client_BitField, "isInstance", client_checkableGenerator(client_BitField));
115564
- ;// ./src/lib/error/base.ts
115565
- var client_KeetaNetErrorBase;
115566
- function client_base_defineProperty(e, r, t) { return (r = client_base_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
115567
- function client_base_toPropertyKey(t) { var i = client_base_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
115568
- function client_base_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
115569
-
115570
- class src_client_KeetaNetErrorBase extends Error {
115571
- constructor(code, message, validation) {
115572
- super(message);
115573
- const type = (validation === null || validation === void 0 ? void 0 : validation.type) || 'GENERIC';
115574
- if (validation !== undefined) {
115575
- const prefix = `${validation.type}_`;
115576
- const validPrefix = code.startsWith(prefix);
115577
- const withoutPrefix = code.substring(prefix.length);
115578
- const validCode = validation.codes.includes(withoutPrefix);
115579
- if (!validPrefix || !validCode) {
115580
- throw new Error(`Invalid construction of KeetaNetError Type: ${validation.type} Code: ${code}, prefix ${prefix} valid ${validPrefix} valid code: ${validCode}`);
115581
- }
115582
- }
115583
- this.code = code;
115584
- this.type = type;
115585
- }
115586
- toJSON() {
115587
- return {
115588
- type: this.type,
115589
- code: this.code,
115590
- message: this.message
115591
- };
115592
- }
115593
- }
115594
- client_KeetaNetErrorBase = src_client_KeetaNetErrorBase;
115595
- client_base_defineProperty(src_client_KeetaNetErrorBase, "isInstance", client_checkableGenerator(client_KeetaNetErrorBase, false));
115596
115685
  ;// ./src/lib/error/permissions.ts
115597
115686
  var client_KeetaNetPermissionsError;
115598
115687
  function client_permissions_defineProperty(e, r, t) { return (r = client_permissions_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -118012,6 +118101,32 @@ function client_validateBlockSignerDepth(depth, network) {
118012
118101
  }
118013
118102
  }
118014
118103
 
118104
+ /**
118105
+ * Determines if an account type can delegate voting weight via SET_REP.
118106
+ *
118107
+ * Regular accounts (ECDSA_SECP256K1, ED25519, ECDSA_SECP256R1) can always delegate.
118108
+ * Among identifier accounts, only STORAGE accounts can delegate.
118109
+ * TOKEN, NETWORK, and MULTISIG identifier accounts cannot delegate.
118110
+ *
118111
+ * @param keyType - The account key algorithm type to check
118112
+ * @returns true if the account type can use SET_REP to delegate, false otherwise
118113
+ *
118114
+ */
118115
+ function client_canDelegate(keyType) {
118116
+ // Regular accounts (non-identifiers) can always delegate
118117
+ if (!client_lib_account.isIdentifierKeyType(keyType)) {
118118
+ return true;
118119
+ }
118120
+
118121
+ // Among identifiers, only STORAGE can delegate
118122
+ if (keyType === client_AccountKeyAlgorithm.STORAGE) {
118123
+ return true;
118124
+ }
118125
+
118126
+ // Other identifier accounts cannot delegate
118127
+ return false;
118128
+ }
118129
+
118015
118130
  /**
118016
118131
  * Compute effects on the ledger from block effects
118017
118132
  */
@@ -118105,7 +118220,7 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
118105
118220
  const delegationField = (_effects$accountPubKe = effects[accountPubKey]) === null || _effects$accountPubKe === void 0 ? void 0 : _effects$accountPubKe.fields.delegation;
118106
118221
  const isDelegating = delegationField !== undefined;
118107
118222
  let requestedRep = false;
118108
- if (isDelegating && computeWeights && getFinalNumericValues && account.isAccount()) {
118223
+ if (isDelegating && computeWeights && getFinalNumericValues && client_canDelegate(account.keyType)) {
118109
118224
  requestedRep = true;
118110
118225
  prefetchPromises.push(getRep(account, getFinalNumericValues));
118111
118226
  prefetchPromises.push(getWeight(delegationField.delegateTo));
@@ -118137,7 +118252,7 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
118137
118252
  if (possibleNegative && checkRangeConstraints || set || getFinalNumericValues || isDelegating && computeWeights) {
118138
118253
  prefetchPromises.push(getPreviousBalance(account, token));
118139
118254
  }
118140
- if (computeWeights && isBaseToken && account.isAccount() && !requestedRep) {
118255
+ if (computeWeights && isBaseToken && client_canDelegate(account.keyType) && !requestedRep) {
118141
118256
  requestedRep = true;
118142
118257
  prefetchPromises.push(getRep(account, getFinalNumericValues));
118143
118258
  }
@@ -118287,7 +118402,7 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
118287
118402
  }
118288
118403
  const delegationField = (_effects$accountPubKe2 = effects[accountPubKey]) === null || _effects$accountPubKe2 === void 0 ? void 0 : _effects$accountPubKe2.fields.delegation;
118289
118404
  const isDelegating = delegationField !== undefined;
118290
- if (isDelegating && account.isAccount() && computeWeights) {
118405
+ if (isDelegating && client_canDelegate(account.keyType) && computeWeights) {
118291
118406
  const currentDelegation = await getRep(account, getFinalNumericValues);
118292
118407
  const previousBalance = await getPreviousBalance(account, baseToken);
118293
118408
  await modifyWeight(delegationField.delegateTo, previousBalance);
@@ -118348,7 +118463,7 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
118348
118463
  receivable[otherAccountPubKey][tokenPubKey] += balanceChange;
118349
118464
  }
118350
118465
  const isBaseToken = baseToken.comparePublicKey(tokenAcct);
118351
- if (isBaseToken && account.isAccount() && computeWeights) {
118466
+ if (isBaseToken && client_canDelegate(account.keyType) && computeWeights) {
118352
118467
  if (isDelegating) {
118353
118468
  await modifyWeight(delegationField.delegateTo, balanceChange);
118354
118469
  } else {
@@ -119370,8 +119485,8 @@ class src_client_BlockOperationSET_REP extends src_client_BlockOperation {
119370
119485
  const {
119371
119486
  block
119372
119487
  } = context;
119373
- if (block.account.isIdentifier()) {
119374
- throw new src_client_KeetaNetBlockError('BLOCK_NO_IDENTIFIER_OP', 'Identifier accounts cannot use SET_REP');
119488
+ if (!client_canDelegate(block.account.keyType)) {
119489
+ throw new src_client_KeetaNetBlockError('BLOCK_NO_IDENTIFIER_OP', `${client_AccountKeyAlgorithm[block.account.keyType]} accounts cannot use SET_REP`);
119375
119490
  }
119376
119491
  if (this.to.isIdentifier()) {
119377
119492
  throw new src_client_KeetaNetBlockError('BLOCK_NO_IDENTIFIER_OP', 'Cannot delegate to an identifier');
@@ -121215,8 +121330,11 @@ class src_client_UnsignedBlock extends src_client_PossiblyUnsignedBlock {
121215
121330
  async seal() {
121216
121331
  const signers = src_client_UnsignedBlock.getSortedRequiredSigners(this.signer);
121217
121332
  const hash = this.hash;
121333
+ const ancillaryData = this.toBytes(false);
121218
121334
  const signatures = await Promise.all(signers.map(async function (signer) {
121219
- const signature = await signer.sign(hash.getBuffer());
121335
+ const signature = await signer.sign(hash.getBuffer(), {
121336
+ ancillaryData
121337
+ });
121220
121338
  return signature.getBuffer();
121221
121339
  }));
121222
121340
  const shared = {
@@ -121640,26 +121758,6 @@ client_lib_block_defineProperty(src_client_BlockBuilder, "Operation", src_client
121640
121758
  client_lib_block_defineProperty(src_client_BlockBuilder, "NO_PREVIOUS", src_client_Block.NO_PREVIOUS);
121641
121759
  src_client_Block.Builder = src_client_BlockBuilder;
121642
121760
  /* harmony default export */ const client_lib_block = (src_client_Block);
121643
- ;// ./src/lib/error/account.ts
121644
- var client_KeetaNetAccountError;
121645
- function client_account_defineProperty(e, r, t) { return (r = client_account_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
121646
- function client_account_toPropertyKey(t) { var i = client_account_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
121647
- function client_account_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
121648
-
121649
-
121650
- const client_AccountErrorType = 'ACCOUNT';
121651
- const client_AccountErrorCodes = ['INVALID_PREFIX', 'INVALID_KEYTYPE', 'INVALID_KEYTYPE_EXTERNAL', 'PASSPHRASE_WEAK', 'INVALID_CONSTRUCTION', 'NO_IDENTIFIER_SIGN', 'NO_IDENTIFIER_VERIFY', 'INVALID_IDENTIFIER_CONSTRUCTION', 'SEED_INDEX_UNDEFINED', 'SEED_INDEX_NEGATIVE', 'SEED_INDEX_NOT_INT', 'SEED_INDEX_TOO_LARGE', 'ENCRYPTION_NOT_SUPPORTED'];
121652
- const client_FullAccountErrorCodes = client_AccountErrorCodes.map(code => `${client_AccountErrorType}_${code}`);
121653
- class src_client_KeetaNetAccountError extends src_client_KeetaNetErrorBase {
121654
- constructor(code, message) {
121655
- super(code, message, {
121656
- type: client_AccountErrorType,
121657
- codes: client_AccountErrorCodes
121658
- });
121659
- }
121660
- }
121661
- client_KeetaNetAccountError = src_client_KeetaNetAccountError;
121662
- client_account_defineProperty(src_client_KeetaNetAccountError, "isInstance", client_checkableGenerator(client_KeetaNetAccountError));
121663
121761
  ;// ./src/lib/utils/ed2curve.ts
121664
121762
  // https://raw.githubusercontent.com/jjavery/ed25519-to-x25519/main/src/ed2curve.js
121665
121763
 
@@ -122430,7 +122528,7 @@ class src_client_ExternalKeyPair extends client_KeyInterface {
122430
122528
  return client_account_classPrivateFieldGet(client_functions, this).decrypt(...arguments);
122431
122529
  }
122432
122530
  get supportsEncryption() {
122433
- return true;
122531
+ return client_account_classPrivateFieldGet(client_functions, this).supportsEncryption;
122434
122532
  }
122435
122533
  get keyType() {
122436
122534
  return client_account_classPrivateFieldGet(client_keyType, this);
@@ -123121,10 +123219,8 @@ function client_derivePublicKeyStringFromPublicKey(key, keyType) {
123121
123219
  }
123122
123220
 
123123
123221
  /**
123124
- * Account class, which is used to represent a key pair or an identifier
123125
- * account (which have no private key) such as tokens.
123126
- *
123127
- * @template T - The type of the key algorithm used for this account.
123222
+ * Statically validate that the KeyPairClassesByAlgorithm type has
123223
+ * every AccountKeyAlgorithm as a key
123128
123224
  */
123129
123225
  var client_privateKeyPair = /*#__PURE__*/new WeakMap();
123130
123226
  var client_publicKeyPair2 = /*#__PURE__*/new WeakMap();
@@ -123132,6 +123228,12 @@ var client_keyType4 = /*#__PURE__*/new WeakMap();
123132
123228
  var client_keyPairHandlesHashing = /*#__PURE__*/new WeakMap();
123133
123229
  var client_publicKeyString2 = /*#__PURE__*/new WeakMap();
123134
123230
  var client_publicKeyAndTypeString = /*#__PURE__*/new WeakMap();
123231
+ /**
123232
+ * Account class, which is used to represent a key pair or an identifier
123233
+ * account (which have no private key) such as tokens.
123234
+ *
123235
+ * @template T - The type of the key algorithm used for this account.
123236
+ */
123135
123237
  class src_client_Account {
123136
123238
  /**
123137
123239
  * Construct an account from a public key string. The public key
@@ -123501,6 +123603,9 @@ class src_client_Account {
123501
123603
  if (client_account_classPrivateFieldGet(client_privateKeyPair, this) === null) {
123502
123604
  throw new Error('May not sign unless a private key is available');
123503
123605
  }
123606
+ if (options.namespace !== undefined) {
123607
+ data = client_applyNamespace(options.namespace, data);
123608
+ }
123504
123609
  if (!client_account_classPrivateFieldGet(client_keyPairHandlesHashing, this) && !options.raw) {
123505
123610
  data = client_hash_Hash(client_account_Buffer.from(data));
123506
123611
  }
@@ -123516,6 +123621,9 @@ class src_client_Account {
123516
123621
  forCert: false,
123517
123622
  ...options
123518
123623
  };
123624
+ if (options.namespace !== undefined) {
123625
+ data = client_applyNamespace(options.namespace, data);
123626
+ }
123519
123627
  if (!client_account_classPrivateFieldGet(client_keyPairHandlesHashing, this) && !options.raw) {
123520
123628
  data = client_hash_Hash(client_account_Buffer.from(data));
123521
123629
  }
@@ -123658,10 +123766,12 @@ class src_client_Account {
123658
123766
  * Determine if an account is an identifier
123659
123767
  */
123660
123768
  isIdentifier() {
123661
- // We are checking here, so it is safe to assert the type
123662
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
123663
- return client_identifierKeyTypes.includes(this.keyType);
123769
+ return src_client_Account.isIdentifierKeyType(client_account_classPrivateFieldGet(client_keyType4, this));
123664
123770
  }
123771
+
123772
+ /**
123773
+ * Determine if an account is a regular (non-identifier)
123774
+ */
123665
123775
  isAccount() {
123666
123776
  return !this.isIdentifier();
123667
123777
  }
@@ -123695,7 +123805,7 @@ class src_client_Account {
123695
123805
  }
123696
123806
  assertAccount() {
123697
123807
  if (this.isIdentifier() !== false) {
123698
- throw new Error('Required Account but got Identifier');
123808
+ throw new src_client_KeetaNetAccountError('ACCOUNT_NOT_ACCOUNT', 'Required Account but got Identifier');
123699
123809
  }
123700
123810
 
123701
123811
  // We need to assert this type because we are changing what the constructed type is
@@ -123704,7 +123814,7 @@ class src_client_Account {
123704
123814
  }
123705
123815
  assertIdentifier() {
123706
123816
  if (this.isIdentifier() !== true) {
123707
- throw new Error(`Required Identifier but got Account, ${this.keyType}`);
123817
+ throw new src_client_KeetaNetAccountError('ACCOUNT_NOT_IDENTIFIER', `Required Identifier but got Account, ${this.keyType}`);
123708
123818
  }
123709
123819
 
123710
123820
  // We need to assert this type because we are changing what the constructed type is
@@ -123721,6 +123831,18 @@ client_Account = src_client_Account;
123721
123831
  */
123722
123832
  client_lib_account_defineProperty(src_client_Account, "AccountKeyAlgorithm", client_AccountKeyAlgorithm);
123723
123833
  client_lib_account_defineProperty(src_client_Account, "ExternalKeyPair", src_client_ExternalKeyPair);
123834
+ /**
123835
+ * Access to the underlying Key Pair classes for advanced use cases.
123836
+ */
123837
+ client_lib_account_defineProperty(src_client_Account, "KeyPairs", {
123838
+ [client_AccountKeyAlgorithm.ECDSA_SECP256K1]: src_client_ECDSASECP256K1KeyPair,
123839
+ [client_AccountKeyAlgorithm.ECDSA_SECP256R1]: src_client_ECDSASECP256R1KeyPair,
123840
+ [client_AccountKeyAlgorithm.ED25519]: src_client_ED25519KeyPair,
123841
+ [client_AccountKeyAlgorithm.NETWORK]: src_client_IdentifierKeyPair,
123842
+ [client_AccountKeyAlgorithm.TOKEN]: src_client_IdentifierKeyPair,
123843
+ [client_AccountKeyAlgorithm.STORAGE]: src_client_IdentifierKeyPair,
123844
+ [client_AccountKeyAlgorithm.MULTISIG]: src_client_IdentifierKeyPair
123845
+ });
123724
123846
  client_lib_account_defineProperty(src_client_Account, "isInstance", client_checkableGenerator(client_Account));
123725
123847
  client_lib_account_defineProperty(src_client_Account, "Set", client_setGenerator(client_Account, function (account) {
123726
123848
  const retval = account.publicKeyAndTypeString;
@@ -126523,6 +126645,12 @@ class src_client_BaseVoteBuilder {
126523
126645
  }
126524
126646
  client_BaseVoteBuilder = src_client_BaseVoteBuilder;
126525
126647
  function client_formatSingleFeeEntry(feeInput) {
126648
+ if (feeInput.amount === undefined) {
126649
+ throw new src_client_KeetaNetVoteError('VOTE_BUILDER_INVALID_FEE', 'Fee amount is required');
126650
+ }
126651
+ if (BigInt(feeInput.amount) < 0n) {
126652
+ throw new src_client_KeetaNetVoteError('VOTE_BUILDER_INVALID_FEE', 'Fee amount cannot be negative');
126653
+ }
126526
126654
  const fee = {
126527
126655
  amount: BigInt(feeInput.amount)
126528
126656
  };
@@ -128174,6 +128302,14 @@ class client_LedgerAtomicInterface {
128174
128302
  if (!quote.issuer.comparePublicKey(ledgerPubKey)) {
128175
128303
  throw new client_ledger_KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match issuer public key');
128176
128304
  }
128305
+ if (quote.blocks.length !== blocks.length) {
128306
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match blocks length');
128307
+ }
128308
+ for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
128309
+ if (!blocks[blockIndex].hash.compareHexString(quote.blocks[blockIndex])) {
128310
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match blocks content');
128311
+ }
128312
+ }
128177
128313
  }
128178
128314
 
128179
128315
  /**
@@ -128201,6 +128337,7 @@ class client_LedgerAtomicInterface {
128201
128337
  }
128202
128338
  }
128203
128339
  const requiredFees = new Map();
128340
+ const optionalFees = new Map();
128204
128341
  for (const checkVote of otherVotes) {
128205
128342
  if (checkVote.quote === true) {
128206
128343
  throw new client_ledger_KeetaNetLedgerError('LEDGER_VOTE_WITH_QUOTE', 'Cannot request votes with quote as supporting votes');
@@ -128214,7 +128351,18 @@ class client_LedgerAtomicInterface {
128214
128351
  seenVoteIssuers.add(checkVote.issuer);
128215
128352
  seenVoteUIDs.add(checkVote.$id);
128216
128353
  if (checkVote.fee !== undefined) {
128217
- requiredFees.set(checkVote.issuer, checkVote.fee);
128354
+ const checkVoteFee = Array.isArray(checkVote.fee) ? checkVote.fee : [checkVote.fee];
128355
+
128356
+ // Check if user has the option to pay zero (any fee with amount === 0)
128357
+ // If a zero-amount option exists, fee block is optional; otherwise required
128358
+ const hasZeroFeeOption = checkVoteFee.some(fee => fee.amount === 0n);
128359
+ if (hasZeroFeeOption) {
128360
+ // At least one fee option is zero amount - fee block is optional, but if included should match one of the provided options
128361
+ optionalFees.set(checkVote.issuer, checkVote.fee);
128362
+ } else if (checkVoteFee.length > 0) {
128363
+ // All fee options require payment (no zero option) - fee block MUST be present and operation should match at least one fee option
128364
+ requiredFees.set(checkVote.issuer, checkVote.fee);
128365
+ }
128218
128366
  }
128219
128367
 
128220
128368
  /*
@@ -128242,25 +128390,43 @@ class client_LedgerAtomicInterface {
128242
128390
  foundOurVote = true;
128243
128391
  }
128244
128392
  }
128245
-
128393
+ let finalRequiredFees = requiredFees;
128246
128394
  /*
128247
128395
  * We only care about fees if we are issuing a permanent vote,
128248
128396
  * if we are issuing a temporary vote the fees will be checked
128249
128397
  * when the permanent vote is requested
128250
128398
  */
128251
128399
  if (outcome === 'permanent') {
128252
- if (requiredFees.size > 0) {
128253
- if (!hasFeeBlock) {
128254
- throw new client_ledger_KeetaNetLedgerError('LEDGER_MISSING_REQUIRED_FEE_BLOCK', 'Missing fee block but votes require it');
128400
+ if (requiredFees.size > 0 || optionalFees.size > 0) {
128401
+ // If fees are required then a fee block should have been provided
128402
+ if (requiredFees.size > 0) {
128403
+ if (!hasFeeBlock) {
128404
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_MISSING_REQUIRED_FEE_BLOCK', 'Missing fee block but votes require it');
128405
+ }
128255
128406
  }
128256
- // Each vote requires exactly one fee payment, regardless of array size
128257
- if (requiredFees.size !== (possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length)) {
128258
- throw new client_ledger_KeetaNetLedgerError('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees');
128407
+
128408
+ // We can only validate operations match if we have a fee block
128409
+ if (hasFeeBlock) {
128410
+ // Each vote requires exactly one fee payment, regardless of array size
128411
+ // Optional fees may or may not be included in the operations but if they are they should match
128412
+ if (optionalFees.size > 0) {
128413
+ if ((possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length) !== requiredFees.size && (possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length) !== requiredFees.size + optionalFees.size) {
128414
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees or required and optional fees');
128415
+ }
128416
+ // If user provided optional fees then we should validate they match
128417
+ if ((possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length) === requiredFees.size + optionalFees.size) {
128418
+ finalRequiredFees = new Map([...requiredFees, ...optionalFees]);
128419
+ }
128420
+ } else {
128421
+ if (requiredFees.size !== (possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length)) {
128422
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees');
128423
+ }
128424
+ }
128259
128425
  }
128260
128426
  }
128261
128427
 
128262
128428
  // Verify that at least one required fee option has been satisfied for each vote
128263
- for (const [issuer, feeOrFees] of requiredFees) {
128429
+ for (const [issuer, feeOrFees] of finalRequiredFees) {
128264
128430
  // Handle both single fee and array of fees
128265
128431
  const fees = Array.isArray(feeOrFees) ? feeOrFees : [feeOrFees];
128266
128432
 
@@ -128591,6 +128757,10 @@ class client_LedgerAtomicInterface {
128591
128757
  return retval;
128592
128758
  }
128593
128759
  async getAccountRep(account) {
128760
+ const acct = client_lib_account.toAccount(account);
128761
+ if (!client_canDelegate(acct.keyType)) {
128762
+ return null;
128763
+ }
128594
128764
  const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
128595
128765
  const retval = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).getAccountRep(transaction, account);
128596
128766
  return retval;
@@ -129301,7 +129471,13 @@ async function client_voteOrQuoteWithFees(blocks, type, quote, options) {
129301
129471
  if (requireBlockTimestampCheck) {
129302
129472
  var _quote$fee;
129303
129473
  const fee = (_quote$fee = quote === null || quote === void 0 ? void 0 : quote.fee) !== null && _quote$fee !== void 0 ? _quote$fee : await this.getFee(blocks, effects);
129304
- if (fee !== null) {
129474
+ // We add an explicit fee of 0 if one is not provided.
129475
+ // Since the quote identifier is in the fee data and needs to be parsed correctly.
129476
+ if (fee === null || Array.isArray(fee) && fee.length === 0) {
129477
+ builder.addFee({
129478
+ amount: 0n
129479
+ });
129480
+ } else {
129305
129481
  builder.addFee(fee);
129306
129482
  }
129307
129483
  }
@@ -129728,7 +129904,7 @@ client_lib_ledger_defineProperty(src_client_Ledger, "isInstance", client_checkab
129728
129904
  // EXTERNAL MODULE: ws (ignored)
129729
129905
  var client_ws_ignored_ = __webpack_require__(4708);
129730
129906
  ;// ./src/version.ts
129731
- const client_version = '0.16.1+g8d5abd1c27152ecca68f2594f9191c1c77a334a4';
129907
+ const client_version = '0.16.2+g2c1441eed2a1c71a895d0fb5166c431799b3d3ca';
129732
129908
  /* harmony default export */ const client_src_version = ((/* unused pure expression or super */ null && (client_version)));
129733
129909
  ;// ./src/lib/p2p.ts
129734
129910
  /* provided dependency */ var client_p2p_Buffer = __webpack_require__(8287)["Buffer"];
@@ -132362,6 +132538,7 @@ async function client_generateInitialVoteStaple(options) {
132362
132538
 
132363
132539
 
132364
132540
 
132541
+
132365
132542
  /* harmony default export */ const client_src_lib = ({
132366
132543
  /**
132367
132544
  * The `Account` module provides functionality for managing key pairs
@@ -132381,11 +132558,12 @@ async function client_generateInitialVoteStaple(options) {
132381
132558
  ASN1: client_utils_asn1_namespaceObject,
132382
132559
  Bloom: client_bloom_namespaceObject,
132383
132560
  Buffer: client_utils_buffer_namespaceObject,
132561
+ Certificate: client_utils_certificate_namespaceObject,
132562
+ Conversion: client_conversion_namespaceObject,
132563
+ DomainSeparation: client_domain_separation_namespaceObject,
132384
132564
  Hash: client_hash_namespaceObject,
132385
132565
  Helper: client_helper_namespaceObject,
132386
- Initial: client_initial_namespaceObject,
132387
- Conversion: client_conversion_namespaceObject,
132388
- Certificate: client_utils_certificate_namespaceObject
132566
+ Initial: client_initial_namespaceObject
132389
132567
  }
132390
132568
  });
132391
132569
  ;// ./src/client/builder.ts
@@ -132836,6 +133014,11 @@ class src_client_UserClientBuilder {
132836
133014
  continue;
132837
133015
  }
132838
133016
 
133017
+ // If fee options contains an amount of 0, skip this vote
133018
+ if (fees.some(fee => fee.amount === 0n)) {
133019
+ continue;
133020
+ }
133021
+
132839
133022
  // Find fee with undefined token or matching baseToken
132840
133023
  let selectedFee = fees.find(fee => {
132841
133024
  if (fee.token === undefined || fee.token.comparePublicKey(baseToken)) {
@@ -133711,6 +133894,15 @@ class src_client_Client {
133711
133894
  return await this.transmit(blocks.blocks, options);
133712
133895
  }
133713
133896
 
133897
+ /**
133898
+ * Check if the provided votes require a fee block. This is true if any vote has only non zero-amount options available.
133899
+ * If a vote has at least one zero-amount fee option, the user can satisfy the fee requirement without payment.
133900
+ * This is used to determine if we need to generate a fee block before transmitting the blocks.
133901
+ *
133902
+ * @param tempVotes
133903
+ * @returns boolean true if provided votes require a fee block
133904
+ */
133905
+
133714
133906
  /**
133715
133907
  * Transmit a set of blocks to the network. This will request short
133716
133908
  * votes and permanent votes for the blocks and then publish them to
@@ -133723,13 +133915,7 @@ class src_client_Client {
133723
133915
  */
133724
133916
  async transmit(blocks, options) {
133725
133917
  const tempVotes = await client_client_assertClassBrand(client_Client_brand, this, client_requestVotes).call(this, blocks, undefined, undefined, options === null || options === void 0 ? void 0 : options.quotes);
133726
- let requiresFee = false;
133727
- for (const vote of tempVotes) {
133728
- if (vote.fee !== undefined) {
133729
- requiresFee = true;
133730
- }
133731
- }
133732
- if (requiresFee) {
133918
+ if (client_client_assertClassBrand(client_Client_brand, this, client_votesRequireFees).call(this, tempVotes)) {
133733
133919
  if ((options === null || options === void 0 ? void 0 : options.generateFeeBlock) === undefined) {
133734
133920
  throw new Error('Votes require fees but generateFeeBlock was not defined');
133735
133921
  }
@@ -134758,16 +134944,9 @@ class src_client_Client {
134758
134944
  tempVotes = [...tempVotes, ...newTempVotes];
134759
134945
  }
134760
134946
  const missingPermReps = client_client_classPrivateFieldGet(client_reps, this).filter(rep => !permReps.includes(rep));
134761
- // If any of the temporary votes require a fee, we need to generate a fee block
134762
- let requiresFee = false;
134763
- for (const vote of tempVotes) {
134764
- if (vote.fee !== undefined) {
134765
- requiresFee = true;
134766
- }
134767
- }
134768
134947
 
134769
134948
  // If we need a fee block and don't have any permanent votes, we need to generate a fee block
134770
- if (requiresFee && permVotes.length === 0) {
134949
+ if (client_client_assertClassBrand(client_Client_brand, this, client_votesRequireFees).call(this, tempVotes) && permVotes.length === 0) {
134771
134950
  if ((options === null || options === void 0 ? void 0 : options.generateFeeBlock) === undefined) {
134772
134951
  throw new Error('Votes require fees but generateFeeBlock was not defined');
134773
134952
  }
@@ -135288,6 +135467,25 @@ function client_getBuilderRenderOptions(network) {
135288
135467
  }
135289
135468
  };
135290
135469
  }
135470
+ function client_votesRequireFees(tempVotes) {
135471
+ let requiresFees = false;
135472
+ for (const vote of tempVotes) {
135473
+ if (vote.fee !== undefined) {
135474
+ const voteFee = Array.isArray(vote.fee) ? vote.fee : [vote.fee];
135475
+
135476
+ // Check if user has the option to pay zero (any fee with amount === 0)
135477
+ // If a zero-amount option exists, fee block is optional for this vote
135478
+ const hasZeroFeeOption = voteFee.some(fee => fee.amount === 0n);
135479
+
135480
+ // If no zero option exists (requires payment), fee block is required
135481
+ if (!hasZeroFeeOption) {
135482
+ requiresFees = true;
135483
+ break;
135484
+ }
135485
+ }
135486
+ }
135487
+ return requiresFees;
135488
+ }
135291
135489
  function client_urlSeparatedAccounts(accounts) {
135292
135490
  const pubKeys = accounts.map(account => client_lib_account.toPublicKeyString(account));
135293
135491
  return pubKeys.join(',');