@keetanetwork/keetanet-client 0.14.2 → 0.14.4

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 (173) hide show
  1. package/README.md +4 -0
  2. package/api/node.d.ts +1 -0
  3. package/benchmarking/test.d.ts +4 -0
  4. package/client/index-browser.d.ts +23 -1
  5. package/client/index-browser.js +440 -148
  6. package/client/index.d.ts +23 -1
  7. package/client/index.js +434 -111
  8. package/docs/GETTING-STARTED.md +361 -0
  9. package/docs/assets/hierarchy.js +1 -1
  10. package/docs/assets/navigation.js +1 -1
  11. package/docs/assets/search.js +1 -1
  12. package/docs/classes/KeetaNetSDK.Client.html +8 -4
  13. package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
  14. package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
  15. package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +1 -1
  16. package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
  17. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
  18. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
  19. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +1 -1
  20. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
  21. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
  22. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
  23. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
  24. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  25. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  26. package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +1 -1
  27. package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
  28. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
  29. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
  30. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
  31. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
  32. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
  33. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
  34. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
  35. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
  36. package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
  37. package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
  38. package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
  39. package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
  40. package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
  41. package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
  42. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
  43. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
  44. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +8 -5
  45. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +6 -0
  46. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +9 -0
  47. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.html +9 -0
  48. package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
  49. package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
  50. package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +3 -2
  51. package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +2 -1
  52. package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
  53. package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
  54. package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
  55. package/docs/classes/KeetaNetSDK.Referenced.Stats.html +1 -1
  56. package/docs/classes/KeetaNetSDK.Referenced.StatsPending.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/classes/KeetaNetSDK.UserClient.html +11 -6
  69. package/docs/documents/GETTING-STARTED.html +3 -2
  70. package/docs/hierarchy.html +1 -1
  71. package/docs/index.html +2 -1
  72. package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
  73. package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
  74. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
  75. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
  76. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
  77. package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
  78. package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +3 -2
  79. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
  80. package/docs/interfaces/KeetaNetSDK.Referenced.BaseTokenInfo.html +4 -0
  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.BlockJSONOperationMANAGE_CERTIFICATESerializable.html +1 -1
  85. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
  86. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
  87. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
  88. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
  89. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
  90. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  91. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  92. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
  93. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
  94. package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
  95. package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
  96. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
  97. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
  98. package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +3 -2
  99. package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
  100. package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
  101. package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
  102. package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +5 -2
  103. package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
  104. package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
  105. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
  106. package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
  107. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
  108. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
  109. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
  110. package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
  111. package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
  112. package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
  113. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +1 -1
  114. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +1 -1
  115. package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
  116. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
  117. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
  118. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
  119. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
  120. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
  121. package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
  122. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_initial.html +1 -1
  123. package/docs/types/KeetaNetSDK.Referenced.ErrorCode.html +1 -1
  124. package/docs/types/KeetaNetSDK.Referenced.GetAccountStateAPIResponseFormatted.html +5 -2
  125. package/docs/types/KeetaNetSDK.Referenced.GetAccountStateAPIResponseSuccess.html +3 -2
  126. package/docs/types/KeetaNetSDK.Referenced.LedgerBaseErrorCode.html +1 -0
  127. package/docs/types/KeetaNetSDK.Referenced.LedgerVoteErrorCode.html +1 -0
  128. package/docs/variables/KeetaNetSDK.Referenced.FullLedgerBaseErrorCode.html +1 -0
  129. package/docs/variables/KeetaNetSDK.Referenced.FullLedgerVoteErrorCodes.html +1 -0
  130. package/docs/variables/KeetaNetSDK.Referenced.allFullErrorCodes.html +1 -0
  131. package/lib/error/account.d.ts +6 -7
  132. package/lib/error/api.d.ts +8 -0
  133. package/lib/error/base.d.ts +16 -0
  134. package/lib/error/block.d.ts +6 -7
  135. package/lib/error/certificate.d.ts +6 -7
  136. package/lib/error/client.d.ts +6 -7
  137. package/lib/error/index.d.ts +7 -18
  138. package/lib/error/kv.d.ts +6 -7
  139. package/lib/error/ledger.d.ts +28 -8
  140. package/lib/error/permissions.d.ts +6 -7
  141. package/lib/error/vote.d.ts +6 -7
  142. package/lib/ledger/common.d.ts +9 -0
  143. package/lib/ledger/index.d.ts +23 -0
  144. package/lib/node/local.d.ts +1 -2
  145. package/lib/p2p.d.ts +1 -1
  146. package/lib/utils/initial.d.ts +6 -0
  147. package/npm-shrinkwrap.json +598 -0
  148. package/package.json +3 -2
  149. package/version.d.ts +1 -1
  150. package/docs/types/KeetaNetSDK.Referenced.AccountErrorCode.html +0 -1
  151. package/docs/types/KeetaNetSDK.Referenced.BlockErrorCode.html +0 -1
  152. package/docs/types/KeetaNetSDK.Referenced.CertificateErrorCode.html +0 -1
  153. package/docs/types/KeetaNetSDK.Referenced.ClientErrorCode.html +0 -1
  154. package/docs/types/KeetaNetSDK.Referenced.KVErrorCode.html +0 -1
  155. package/docs/types/KeetaNetSDK.Referenced.LedgerErrorCode.html +0 -1
  156. package/docs/types/KeetaNetSDK.Referenced.PermissionsErrorCode.html +0 -1
  157. package/docs/types/KeetaNetSDK.Referenced.VoteErrorCode.html +0 -1
  158. package/docs/variables/KeetaNetSDK.Referenced.AccountErrorCodes.html +0 -1
  159. package/docs/variables/KeetaNetSDK.Referenced.AccountErrorType.html +0 -1
  160. package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes-1.html +0 -1
  161. package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes.html +0 -1
  162. package/docs/variables/KeetaNetSDK.Referenced.BlockErrorType.html +0 -1
  163. package/docs/variables/KeetaNetSDK.Referenced.CertificateErrorType.html +0 -1
  164. package/docs/variables/KeetaNetSDK.Referenced.ClientErrorCodes.html +0 -1
  165. package/docs/variables/KeetaNetSDK.Referenced.ClientErrorType.html +0 -1
  166. package/docs/variables/KeetaNetSDK.Referenced.KVErrorCodes.html +0 -1
  167. package/docs/variables/KeetaNetSDK.Referenced.KVErrorType.html +0 -1
  168. package/docs/variables/KeetaNetSDK.Referenced.LedgerErrorCodes.html +0 -1
  169. package/docs/variables/KeetaNetSDK.Referenced.LedgerErrorType.html +0 -1
  170. package/docs/variables/KeetaNetSDK.Referenced.PermissionsErrorCodes.html +0 -1
  171. package/docs/variables/KeetaNetSDK.Referenced.PermissionsErrorType.html +0 -1
  172. package/docs/variables/KeetaNetSDK.Referenced.VoteErrorCodes.html +0 -1
  173. package/docs/variables/KeetaNetSDK.Referenced.VoteErrorType.html +0 -1
@@ -114577,24 +114577,16 @@ function client_fromOffsetArray(setOffsets) {
114577
114577
  return val;
114578
114578
  }
114579
114579
  client_bitfield_defineProperty(src_client_BitField, "isInstance", client_checkableGenerator(client_BitField));
114580
- ;// ./src/lib/error/index.ts
114581
- var client_KeetaNetError;
114582
- function client_error_defineProperty(e, r, t) { return (r = client_error_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
114583
- function client_error_toPropertyKey(t) { var i = client_error_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
114584
- function client_error_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); }
114580
+ ;// ./src/lib/error/base.ts
114581
+ var client_KeetaNetErrorBase;
114582
+ 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; }
114583
+ function client_base_toPropertyKey(t) { var i = client_base_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
114584
+ 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); }
114585
114585
 
114586
- async function client_ExpectErrorCode(code, test) {
114587
- await expect(test).rejects.toThrow(expect.objectContaining({
114588
- code: code
114589
- }));
114590
- }
114591
- class src_client_KeetaNetError extends Error {
114586
+ class src_client_KeetaNetErrorBase extends Error {
114592
114587
  constructor(code, message, validation) {
114593
114588
  super(message);
114594
- let type = validation === null || validation === void 0 ? void 0 : validation.type;
114595
- if (!type) {
114596
- type = 'GENERIC';
114597
- }
114589
+ const type = (validation === null || validation === void 0 ? void 0 : validation.type) || 'GENERIC';
114598
114590
  if (validation !== undefined) {
114599
114591
  const prefix = `${validation.type}_`;
114600
114592
  const validPrefix = code.startsWith(prefix);
@@ -114607,9 +114599,16 @@ class src_client_KeetaNetError extends Error {
114607
114599
  this.code = code;
114608
114600
  this.type = type;
114609
114601
  }
114602
+ toJSON() {
114603
+ return {
114604
+ type: this.type,
114605
+ code: this.code,
114606
+ message: this.message
114607
+ };
114608
+ }
114610
114609
  }
114611
- client_KeetaNetError = src_client_KeetaNetError;
114612
- client_error_defineProperty(src_client_KeetaNetError, "isInstance", client_checkableGenerator(client_KeetaNetError, false));
114610
+ client_KeetaNetErrorBase = src_client_KeetaNetErrorBase;
114611
+ client_base_defineProperty(src_client_KeetaNetErrorBase, "isInstance", client_checkableGenerator(client_KeetaNetErrorBase, false));
114613
114612
  ;// ./src/lib/error/permissions.ts
114614
114613
  var client_KeetaNetPermissionsError;
114615
114614
  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; }
@@ -114619,7 +114618,8 @@ function client_permissions_toPrimitive(t, r) { if ("object" != typeof t || !t)
114619
114618
 
114620
114619
  const client_PermissionsErrorType = 'PERMISSIONS';
114621
114620
  const client_PermissionsErrorCodes = ['CANNOT_MIX_FLAGS_AND_TYPES', 'EXTERNAL_OFFSET_TOO_LARGE', 'INVALID_EXTERNAL_FLAG', 'INVALID_FLAG', 'INVALID_FLAG_ASSERTION'];
114622
- class src_client_KeetaNetPermissionsError extends src_client_KeetaNetError {
114621
+ const client_FullPermissionsErrorCodes = client_PermissionsErrorCodes.map(code => `${client_PermissionsErrorType}_${code}`);
114622
+ class src_client_KeetaNetPermissionsError extends src_client_KeetaNetErrorBase {
114623
114623
  constructor(code, message) {
114624
114624
  super(code, message, {
114625
114625
  type: client_PermissionsErrorType,
@@ -115225,7 +115225,8 @@ function client_block_toPrimitive(t, r) { if ("object" != typeof t || !t) return
115225
115225
 
115226
115226
  const client_BlockErrorType = 'BLOCK';
115227
115227
  const client_BlockErrorCodes = ['INVALID_TYPE', 'INVALID_VERSION', 'NO_MULTIPLE_SET_REP', 'IDENTIFIER_NEED_DEFAULT_PERMISSIONS', 'CANNOT_SEND_NON_TOKEN', 'TOKEN_RECEIVE_DIFFERS', 'ONLY_TOKEN_OP', 'ONLY_IDENTIFIER_OP', 'NO_TOKEN_OP', 'NO_IDENTIFIER_OP', 'INVALID_SIGNER', 'INVALID_PURPOSE_VALIDATION', 'INVALID_MULTISIG_QUORUM', 'INVALID_MULTISIG_SIGNER_DEPTH', 'INVALID_MULTISIG_SIGNER_COUNT', 'INVALID_MULTISIG_SIGNER_DUPLICATE', 'INVALID_CREATE_IDENTIFIER_ARGS', 'NO_MULTISIG_OP', 'IDENTIFIER_INVALID', 'GENERAL_FIELD_INVALID', 'PERMISSIONS_INVALID_DEFAULT', 'PERMISSIONS_INVALID_ENTITY', 'PERMISSIONS_INVALID_PRINCIPAL', 'PERMISSIONS_INVALID_TARGET', 'INVALID_ACCOUNT_TYPE', 'NO_ADMIN_ON_TARGET', 'PREVIOUS_SELF', 'NO_DELEGATE_ADMIN', 'NO_MODIFY_PERMISSION_DUPE', 'CANNOT_FORWARD_TO_SELF', 'EXACT_TRUE_WHEN_FORWARDING', 'CERTIFICATE_SUBJECT_MISMATCH', 'NO_DUPLICATE_CERTIFICATE_OPERATION', 'INTERMEDIATE_CERTIFICATES_ONLY_ADD', 'INVALID_CERTIFICATE_VALUE', 'EXTERNAL_TOO_LONG', 'EXTERNAL_INVALID', 'EXTERNAL_MISSING', 'SUPPLY_INVALID'];
115228
- class src_client_KeetaNetBlockError extends src_client_KeetaNetError {
115228
+ const client_FullBlockErrorCodes = client_BlockErrorCodes.map(code => `${client_BlockErrorType}_${code}`);
115229
+ class src_client_KeetaNetBlockError extends src_client_KeetaNetErrorBase {
115229
115230
  constructor(code, message) {
115230
115231
  super(code, message, {
115231
115232
  type: client_BlockErrorType,
@@ -115325,12 +115326,13 @@ function client_certificate_toPrimitive(t, r) { if ("object" != typeof t || !t)
115325
115326
 
115326
115327
 
115327
115328
  const client_CertificateErrorType = 'CERTIFICATE';
115328
- const client_certificate_BlockErrorCodes = ['DUPLICATE_INCLUDED', 'ORPHAN_FOUND', 'CYCLE_FOUND', 'SECONDARY_GRAPH', 'MISSING_FIELD', 'SIGNATURE_ALGORITHM_MISMATCH', 'SELF_SIGNED_VALIDATION_FAILED', 'CHAIN_VERIFICATION_FAILED', 'DUPLICATE_EXTENSION', 'EXTENSION_NOT_PROCESSED', 'INVALID_SIGNATURE_ALGORITHM', 'INVALID_GRAPH_COUNT', 'MOMENT_INVALID', 'INVALID_VERSION'];
115329
- class src_client_KeetaNetCertificateError extends src_client_KeetaNetError {
115329
+ const client_CertificateErrorCodes = ['DUPLICATE_INCLUDED', 'ORPHAN_FOUND', 'CYCLE_FOUND', 'SECONDARY_GRAPH', 'MISSING_FIELD', 'SIGNATURE_ALGORITHM_MISMATCH', 'SELF_SIGNED_VALIDATION_FAILED', 'CHAIN_VERIFICATION_FAILED', 'DUPLICATE_EXTENSION', 'EXTENSION_NOT_PROCESSED', 'INVALID_SIGNATURE_ALGORITHM', 'INVALID_GRAPH_COUNT', 'MOMENT_INVALID', 'INVALID_VERSION'];
115330
+ const client_FullCertificateErrorCodes = client_CertificateErrorCodes.map(code => `${client_CertificateErrorType}_${code}`);
115331
+ class src_client_KeetaNetCertificateError extends src_client_KeetaNetErrorBase {
115330
115332
  constructor(code, message) {
115331
115333
  super(code, message, {
115332
115334
  type: client_CertificateErrorType,
115333
- codes: client_certificate_BlockErrorCodes
115335
+ codes: client_CertificateErrorCodes
115334
115336
  });
115335
115337
  }
115336
115338
  }
@@ -116736,23 +116738,34 @@ client_utils_certificate_defineProperty(src_client_Certificate, "Hash", src_clie
116736
116738
  */
116737
116739
  client_utils_certificate_defineProperty(src_client_Certificate, "certificateObjectTypeID", '8d05dca5-5f42-4dc9-8bf9-f534c6570994:CERTIFICATE');
116738
116740
  ;// ./src/lib/error/ledger.ts
116739
- var client_KeetaNetLedgerError;
116741
+ var client_KeetaNetLedgerError, client_KeetaNetLedgerVoteError;
116740
116742
  function client_ledger_defineProperty(e, r, t) { return (r = client_ledger_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
116741
116743
  function client_ledger_toPropertyKey(t) { var i = client_ledger_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
116742
116744
  function client_ledger_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); }
116743
116745
 
116744
116746
 
116745
116747
  const client_LedgerErrorType = 'LEDGER';
116746
- const client_LedgerErrorCodes = ['BLOCK_ALREADY_EXISTS', 'TRANSACTION_ABORTED', 'INVALID_CHAIN', 'INVALID_NETWORK', 'INVALID_SUBNET', 'NOT_EMPTY', 'NOT_OPENING', 'NOT_SUCCESSOR', 'INVALID_PERMISSIONS', 'INVALID_OWNER_COUNT', 'INVALID_BALANCE', 'PREVIOUS_ALREADY_USED', 'PREVIOUS_NOT_SEEN', 'SUCCESSOR_VOTE_EXISTS', 'INSUFFICIENT_VOTING_WEIGHT', 'INVALID_ACCOUNT_INFO_KEY', 'RECEIVE_NOT_MET', 'DUPLICATE_VOTE_FOUND', 'CANNOT_EXCHANGE_PERM_VOTE', 'BLOCKS_DIFFER_FROM_VOTED_ON', 'NO_PERM_WITHOUT_SELF_TEMP', 'DUPLICATE_VOTE_ISSUER_FOUND', 'OTHER', 'MISSING_BLOCKS',
116748
+ const client_LedgerBaseErrorCodes = ['BLOCK_ALREADY_EXISTS', 'TRANSACTION_ABORTED', 'INVALID_CHAIN', 'INVALID_NETWORK', 'INVALID_SUBNET', 'INVALID_PERMISSIONS', 'INVALID_OWNER_COUNT', 'INVALID_BALANCE', 'NOT_EMPTY', 'PREVIOUS_ALREADY_USED', 'PREVIOUS_NOT_SEEN', 'SUCCESSOR_VOTE_EXISTS', 'INSUFFICIENT_VOTING_WEIGHT', 'INVALID_ACCOUNT_INFO_KEY', 'RECEIVE_NOT_MET', 'DUPLICATE_VOTE_FOUND', 'CANNOT_EXCHANGE_PERM_VOTE', 'BLOCKS_DIFFER_FROM_VOTED_ON', 'NO_PERM_WITHOUT_SELF_TEMP', 'DUPLICATE_VOTE_ISSUER_FOUND', 'OTHER', 'MISSING_BLOCKS',
116747
116749
  // Fee Errors
116748
116750
  'FEE_AMOUNT_MISMATCH', 'FEE_TOKEN_MISMATCH', 'FEE_MISSING', 'MISSING_REQUIRED_FEE_BLOCK', 'PERM_VOTE_WITH_QUOTE', 'QUOTE_MISMATCH', 'REQUIRED_FEE_MISMATCH'];
116749
- class client_ledger_KeetaNetLedgerError extends src_client_KeetaNetError {
116751
+
116752
+ // Errors that can trigger rep sync
116753
+ const client_LedgerVoteErrorCodes = ['NOT_SUCCESSOR', 'NOT_OPENING'];
116754
+ const client_FullLedgerErrorCodes = [...client_LedgerBaseErrorCodes, ...client_LedgerVoteErrorCodes].map(code => `${client_LedgerErrorType}_${code}`);
116755
+ const client_FullLedgerBaseErrorCode = client_LedgerBaseErrorCodes.map(code => `${client_LedgerErrorType}_${code}`);
116756
+ const client_FullLedgerVoteErrorCodes = client_LedgerVoteErrorCodes.map(code => `${client_LedgerErrorType}_${code}`);
116757
+ const client_ledgerBaseErrorCodeSet = new Set(client_FullLedgerBaseErrorCode);
116758
+ const client_ledgerVoteErrorCodeSet = new Set(client_FullLedgerVoteErrorCodes);
116759
+ class client_ledger_KeetaNetLedgerError extends src_client_KeetaNetErrorBase {
116760
+ static assertValidLedgerErrorCode(code) {
116761
+ return client_ledgerBaseErrorCodeSet.has(code);
116762
+ }
116750
116763
  constructor(code, message) {
116751
116764
  let shouldRetry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
116752
116765
  let retryDelay = arguments.length > 3 ? arguments[3] : undefined;
116753
116766
  super(code, message, {
116754
116767
  type: client_LedgerErrorType,
116755
- codes: client_LedgerErrorCodes
116768
+ codes: client_LedgerBaseErrorCodes
116756
116769
  });
116757
116770
  client_ledger_defineProperty(this, "type", client_LedgerErrorType);
116758
116771
  this.shouldRetry = shouldRetry;
@@ -116763,7 +116776,30 @@ class client_ledger_KeetaNetLedgerError extends src_client_KeetaNetError {
116763
116776
  }
116764
116777
  client_KeetaNetLedgerError = client_ledger_KeetaNetLedgerError;
116765
116778
  client_ledger_defineProperty(client_ledger_KeetaNetLedgerError, "isInstance", client_checkableGenerator(client_KeetaNetLedgerError));
116766
- /* harmony default export */ const client_ledger = (client_ledger_KeetaNetLedgerError);
116779
+ class src_client_KeetaNetLedgerVoteError extends src_client_KeetaNetErrorBase {
116780
+ static assertValidLedgerErrorCode(code) {
116781
+ return client_ledgerVoteErrorCodeSet.has(code);
116782
+ }
116783
+ constructor(code, message, accounts) {
116784
+ super(code, message, {
116785
+ type: client_LedgerErrorType,
116786
+ codes: client_LedgerVoteErrorCodes
116787
+ });
116788
+ client_ledger_defineProperty(this, "type", client_LedgerErrorType);
116789
+ client_ledger_defineProperty(this, "shouldRetry", false);
116790
+ this.accounts = accounts;
116791
+ }
116792
+ toJSON() {
116793
+ return {
116794
+ ...super.toJSON(),
116795
+ accounts: [...this.accounts.values()].map(function (account) {
116796
+ return account.publicKeyString.get();
116797
+ })
116798
+ };
116799
+ }
116800
+ }
116801
+ client_KeetaNetLedgerVoteError = src_client_KeetaNetLedgerVoteError;
116802
+ client_ledger_defineProperty(src_client_KeetaNetLedgerVoteError, "isInstance", client_checkableGenerator(client_KeetaNetLedgerVoteError));
116767
116803
  ;// ./src/lib/ledger/common.ts
116768
116804
  function client_common_classPrivateMethodInitSpec(e, a) { client_common_checkPrivateRedeclaration(e, a), a.add(e); }
116769
116805
  function client_common_checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
@@ -117272,10 +117308,36 @@ class client_LedgerStorageBase {
117272
117308
  }));
117273
117309
  return Object.fromEntries(response);
117274
117310
  }
117311
+ async getAccountsBlockHeightInfo(transaction, toFetch) {
117312
+ const response = await Promise.all(toFetch.map(async _ref2 => {
117313
+ let {
117314
+ blockHash,
117315
+ account
117316
+ } = _ref2;
117317
+ if (blockHash === undefined) {
117318
+ const block = await this.getHeadBlock(transaction, account, 'main');
117319
+ if (block !== null) {
117320
+ blockHash = block.hash;
117321
+ }
117322
+ }
117323
+ const retval = [];
117324
+ if (blockHash === undefined) {
117325
+ retval.push(...[account.publicKeyString.get(), null]);
117326
+ } else {
117327
+ const height = await this.getBlockHeight(transaction, blockHash, account);
117328
+ retval.push(...[account.publicKeyString.get(), {
117329
+ blockHash,
117330
+ height
117331
+ }]);
117332
+ }
117333
+ return retval;
117334
+ }));
117335
+ return Object.fromEntries(response);
117336
+ }
117275
117337
  async getHeadBlockHashes(transaction, accounts) {
117276
117338
  const received = await this.getHeadBlocks(transaction, accounts.toArray(), 'both');
117277
- return Object.fromEntries(Object.entries(received).map(function (_ref2) {
117278
- let [account, value] = _ref2;
117339
+ return Object.fromEntries(Object.entries(received).map(function (_ref3) {
117340
+ let [account, value] = _ref3;
117279
117341
  if (value) {
117280
117342
  return [account, value.hash];
117281
117343
  } else {
@@ -120125,7 +120187,8 @@ function client_account_toPrimitive(t, r) { if ("object" != typeof t || !t) retu
120125
120187
 
120126
120188
  const client_AccountErrorType = 'ACCOUNT';
120127
120189
  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'];
120128
- class src_client_KeetaNetAccountError extends src_client_KeetaNetError {
120190
+ const client_FullAccountErrorCodes = client_AccountErrorCodes.map(code => `${client_AccountErrorType}_${code}`);
120191
+ class src_client_KeetaNetAccountError extends src_client_KeetaNetErrorBase {
120129
120192
  constructor(code, message) {
120130
120193
  super(code, message, {
120131
120194
  type: client_AccountErrorType,
@@ -122256,7 +122319,8 @@ const client_VoteErrorCodes = [
122256
122319
  'MALFORMED_FEES_AMOUNT', 'MALFORMED_FEES_FROM_VOTE_INVALID_INPUT', 'MALFORMED_FEES_IN_PERMANENT_VOTE', 'MALFORMED_FEES_PAY_TO_INVALID', 'MALFORMED_FEES_TOKEN_NOT_TOKEN',
122257
122320
  // Fee Quote Errors
122258
122321
  'FEE_IS_QUOTE', 'FEE_QUOTE_MISSING_FEES', 'FEE_NOT_QUOTE', 'MALFORMED_FEES_KIND_MISSING', 'MALFORMED_FEES_QUOTE_INVALID'];
122259
- class src_client_KeetaNetVoteError extends src_client_KeetaNetError {
122322
+ const client_FullVoteErrorCodes = client_VoteErrorCodes.map(code => `${client_VoteErrorType}_${code}`);
122323
+ class src_client_KeetaNetVoteError extends src_client_KeetaNetErrorBase {
122260
122324
  constructor(code, message) {
122261
122325
  super(code, message, {
122262
122326
  type: client_VoteErrorType,
@@ -125546,7 +125610,7 @@ var client_kind = /*#__PURE__*/new WeakMap();
125546
125610
  var client_ledger_privateKey = /*#__PURE__*/new WeakMap();
125547
125611
  var client_computeFeeFromBlocks = /*#__PURE__*/new WeakMap();
125548
125612
  var client_ledger_storage = /*#__PURE__*/new WeakMap();
125549
- var src_client_ledger = /*#__PURE__*/new WeakMap();
125613
+ var client_ledger = /*#__PURE__*/new WeakMap();
125550
125614
  var src_client_cache = /*#__PURE__*/new WeakMap();
125551
125615
  var client_transaction = /*#__PURE__*/new WeakMap();
125552
125616
  var client_LedgerAtomicInterface_brand = /*#__PURE__*/new WeakSet();
@@ -125562,7 +125626,7 @@ class client_LedgerAtomicInterface {
125562
125626
  client_ledger_classPrivateFieldInitSpec(this, client_ledger_privateKey, void 0);
125563
125627
  client_ledger_classPrivateFieldInitSpec(this, client_computeFeeFromBlocks, void 0);
125564
125628
  client_ledger_classPrivateFieldInitSpec(this, client_ledger_storage, void 0);
125565
- client_ledger_classPrivateFieldInitSpec(this, src_client_ledger, void 0);
125629
+ client_ledger_classPrivateFieldInitSpec(this, client_ledger, void 0);
125566
125630
  client_ledger_classPrivateFieldInitSpec(this, src_client_cache, void 0);
125567
125631
  client_ledger_classPrivateFieldInitSpec(this, client_transaction, void 0);
125568
125632
  client_ledger_classPrivateFieldSet(client_network, this, config.network);
@@ -125570,7 +125634,7 @@ class client_LedgerAtomicInterface {
125570
125634
  client_ledger_classPrivateFieldSet(client_kind, this, config.kind);
125571
125635
  client_ledger_classPrivateFieldSet(client_ledger_privateKey, this, config.privateKey);
125572
125636
  client_ledger_classPrivateFieldSet(client_computeFeeFromBlocks, this, config.computeFeeFromBlocks);
125573
- client_ledger_classPrivateFieldSet(src_client_ledger, this, ledger);
125637
+ client_ledger_classPrivateFieldSet(client_ledger, this, ledger);
125574
125638
  client_ledger_classPrivateFieldSet(client_ledger_storage, this, storage);
125575
125639
  client_ledger_classPrivateFieldSet(client_transaction, this, _transaction2);
125576
125640
 
@@ -125592,7 +125656,7 @@ class client_LedgerAtomicInterface {
125592
125656
  const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
125593
125657
  client_ledger_classPrivateFieldSet(client_transaction, this, null);
125594
125658
  await client_ledger_classPrivateFieldGet(client_ledger_storage, this).commitTransaction(transaction);
125595
- (_classPrivateFieldGet2 = client_ledger_classPrivateFieldGet(src_client_ledger, this).node) === null || _classPrivateFieldGet2 === void 0 || _classPrivateFieldGet2.stats.merge(transaction.statsPending);
125659
+ (_classPrivateFieldGet2 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet2 === void 0 || _classPrivateFieldGet2.stats.merge(transaction.statsPending);
125596
125660
  }
125597
125661
  async abort() {
125598
125662
  const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
@@ -125601,22 +125665,22 @@ class client_LedgerAtomicInterface {
125601
125665
  }
125602
125666
  async vote(blocks, otherVotes, quote) {
125603
125667
  if (blocks.length === 0) {
125604
- throw new client_ledger('LEDGER_MISSING_BLOCKS', 'At least one block is required to issue a vote');
125668
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_MISSING_BLOCKS', 'At least one block is required to issue a vote');
125605
125669
  }
125606
125670
  if (!client_ledger_classPrivateFieldGet(client_ledger_privateKey, this)) {
125607
125671
  throw new Error('Cannot vote on block, no private key loaded');
125608
125672
  }
125609
- if (client_ledger_classPrivateFieldGet(src_client_ledger, this).ledgerWriteMode !== 'read-write') {
125610
- throw new Error(`May not issue votes in read-only mode, in ${client_ledger_classPrivateFieldGet(src_client_ledger, this).ledgerWriteMode} mode`);
125673
+ if (client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode !== 'read-write') {
125674
+ throw new Error(`May not issue votes in read-only mode, in ${client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode} mode`);
125611
125675
  }
125612
125676
  const privateKey = client_ledger_classPrivateFieldGet(client_ledger_privateKey, this);
125613
125677
  const ledgerPubKey = privateKey.publicKeyString.get();
125614
125678
  if (quote !== undefined) {
125615
125679
  if (otherVotes !== undefined) {
125616
- throw new client_ledger('LEDGER_PERM_VOTE_WITH_QUOTE', 'Quote should not be included when requesting permanent votes');
125680
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_PERM_VOTE_WITH_QUOTE', 'Quote should not be included when requesting permanent votes');
125617
125681
  }
125618
125682
  if (!quote.issuer.comparePublicKey(ledgerPubKey)) {
125619
- throw new client_ledger('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match issuer public key');
125683
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match issuer public key');
125620
125684
  }
125621
125685
  }
125622
125686
  const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
@@ -125626,13 +125690,13 @@ class client_LedgerAtomicInterface {
125626
125690
  * us and the blocks are in the same order as the set of
125627
125691
  * blocks we are voting on now
125628
125692
  */
125693
+ let hasFeeBlock = false;
125629
125694
  if (otherVotes !== undefined) {
125630
125695
  let foundOurVote = false;
125631
125696
  const seenVoteUIDs = new Set();
125632
125697
  const seenVoteIssuers = new client_lib_account.Set();
125633
- const possibleFeeBlock = blocks.at(-1);
125634
- let hasFeeBlock = false;
125635
125698
  let blockCount = blocks.length;
125699
+ const possibleFeeBlock = blocks.at(-1);
125636
125700
  if ((possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.purpose) === client_BlockPurpose.FEE) {
125637
125701
  hasFeeBlock = true;
125638
125702
  blockCount--;
@@ -125640,13 +125704,13 @@ class client_LedgerAtomicInterface {
125640
125704
  const requiredFees = new Map();
125641
125705
  for (const checkVote of otherVotes) {
125642
125706
  if (checkVote.quote === true) {
125643
- throw new client_ledger('LEDGER_PERM_VOTE_WITH_QUOTE', 'Cannot request permanent votes with quotes');
125707
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_PERM_VOTE_WITH_QUOTE', 'Cannot request permanent votes with quotes');
125644
125708
  }
125645
125709
  if (seenVoteUIDs.has(checkVote.$id)) {
125646
- throw new client_ledger('LEDGER_DUPLICATE_VOTE_FOUND', 'Duplicate vote UID found');
125710
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_DUPLICATE_VOTE_FOUND', 'Duplicate vote UID found');
125647
125711
  }
125648
125712
  if (seenVoteIssuers.has(checkVote.issuer)) {
125649
- throw new client_ledger('LEDGER_DUPLICATE_VOTE_ISSUER_FOUND', 'Multiple votes found from same issuer');
125713
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_DUPLICATE_VOTE_ISSUER_FOUND', 'Multiple votes found from same issuer');
125650
125714
  }
125651
125715
  seenVoteIssuers.add(checkVote.issuer);
125652
125716
  seenVoteUIDs.add(checkVote.$id);
@@ -125654,7 +125718,7 @@ class client_LedgerAtomicInterface {
125654
125718
  requiredFees.set(checkVote.issuer, checkVote.fee);
125655
125719
  }
125656
125720
  if (checkVote.$permanent) {
125657
- throw new client_ledger('LEDGER_CANNOT_EXCHANGE_PERM_VOTE', 'Asked to exchange a permanent vote for a permanent vote');
125721
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_CANNOT_EXCHANGE_PERM_VOTE', 'Asked to exchange a permanent vote for a permanent vote');
125658
125722
  }
125659
125723
  let blocksDifferFromVoteBlocks = checkVote.blocks.length !== blockCount;
125660
125724
 
@@ -125668,7 +125732,7 @@ class client_LedgerAtomicInterface {
125668
125732
  }
125669
125733
  }
125670
125734
  if (blocksDifferFromVoteBlocks) {
125671
- throw new client_ledger('LEDGER_BLOCKS_DIFFER_FROM_VOTED_ON', 'Asked to exchange different number of blocks for a permanent vote');
125735
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_BLOCKS_DIFFER_FROM_VOTED_ON', 'Asked to exchange different number of blocks for a permanent vote');
125672
125736
  }
125673
125737
  if (checkVote.issuer.comparePublicKey(ledgerPubKey)) {
125674
125738
  foundOurVote = true;
@@ -125676,10 +125740,10 @@ class client_LedgerAtomicInterface {
125676
125740
  }
125677
125741
  if (requiredFees.size > 0) {
125678
125742
  if (!hasFeeBlock) {
125679
- throw new client_ledger('LEDGER_MISSING_REQUIRED_FEE_BLOCK', 'Missing fee block but votes require it');
125743
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_MISSING_REQUIRED_FEE_BLOCK', 'Missing fee block but votes require it');
125680
125744
  }
125681
125745
  if (requiredFees.size !== (possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length)) {
125682
- throw new client_ledger('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees');
125746
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees');
125683
125747
  }
125684
125748
  }
125685
125749
 
@@ -125688,13 +125752,13 @@ class client_LedgerAtomicInterface {
125688
125752
  const foundFee = possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.find(operation => {
125689
125753
  var _fee$payTo, _fee$token;
125690
125754
  const expectedPayTo = (_fee$payTo = fee.payTo) !== null && _fee$payTo !== void 0 ? _fee$payTo : issuer;
125691
- const expectedToken = (_fee$token = fee.token) !== null && _fee$token !== void 0 ? _fee$token : client_ledger_classPrivateFieldGet(src_client_ledger, this).baseToken;
125755
+ const expectedToken = (_fee$token = fee.token) !== null && _fee$token !== void 0 ? _fee$token : client_ledger_classPrivateFieldGet(client_ledger, this).baseToken;
125692
125756
  if (operation.type === client_OperationType.SEND && operation.to.comparePublicKey(expectedPayTo)) {
125693
125757
  if (operation.amount !== fee.amount) {
125694
- throw new client_ledger('LEDGER_FEE_AMOUNT_MISMATCH', `Fee Amount Mismatch, found: ${operation.amount} expected: ${fee.amount}`);
125758
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_FEE_AMOUNT_MISMATCH', `Fee Amount Mismatch, found: ${operation.amount} expected: ${fee.amount}`);
125695
125759
  }
125696
125760
  if (!operation.token.comparePublicKey(expectedToken)) {
125697
- throw new client_ledger('LEDGER_FEE_TOKEN_MISMATCH', `Fee Token Mismatch, found: ${operation.token.publicKeyString.get()} expected: ${expectedToken.publicKeyString.get()}`);
125761
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_FEE_TOKEN_MISMATCH', `Fee Token Mismatch, found: ${operation.token.publicKeyString.get()} expected: ${expectedToken.publicKeyString.get()}`);
125698
125762
  }
125699
125763
  return true;
125700
125764
  }
@@ -125702,11 +125766,11 @@ class client_LedgerAtomicInterface {
125702
125766
  });
125703
125767
  if (foundFee === undefined) {
125704
125768
  var _fee$payTo$publicKeyS, _fee$payTo2;
125705
- throw new client_ledger('LEDGER_FEE_MISSING', `Missing Required Fee for ${(_fee$payTo$publicKeyS = (_fee$payTo2 = fee.payTo) === null || _fee$payTo2 === void 0 ? void 0 : _fee$payTo2.publicKeyString.get()) !== null && _fee$payTo$publicKeyS !== void 0 ? _fee$payTo$publicKeyS : issuer.publicKeyString.get()}`);
125769
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_FEE_MISSING', `Missing Required Fee for ${(_fee$payTo$publicKeyS = (_fee$payTo2 = fee.payTo) === null || _fee$payTo2 === void 0 ? void 0 : _fee$payTo2.publicKeyString.get()) !== null && _fee$payTo$publicKeyS !== void 0 ? _fee$payTo$publicKeyS : issuer.publicKeyString.get()}`);
125706
125770
  }
125707
125771
  }
125708
125772
  if (!foundOurVote) {
125709
- throw new client_ledger('LEDGER_NO_PERM_WITHOUT_SELF_TEMP', 'Asked to give a permanent vote without a temporary vote from us');
125773
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_NO_PERM_WITHOUT_SELF_TEMP', 'Asked to give a permanent vote without a temporary vote from us');
125710
125774
  }
125711
125775
  }
125712
125776
  const allLedgerHeads = await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateBlocksForVote).call(this, blocks);
@@ -125716,15 +125780,15 @@ class client_LedgerAtomicInterface {
125716
125780
  const accountHead = allHeads[account.publicKeyString.get()];
125717
125781
  if (accountHead === null) {
125718
125782
  if (!expectedBlock.$opening) {
125719
- throw new client_ledger('LEDGER_NOT_OPENING', 'Cannot vote on non-opening block for an empty account');
125783
+ throw new src_client_KeetaNetLedgerVoteError('LEDGER_NOT_OPENING', 'Cannot vote on non-opening block for an empty account', needToGetHeadFor);
125720
125784
  }
125721
125785
  continue;
125722
125786
  }
125723
125787
  if (expectedBlock.$opening) {
125724
- throw new client_ledger('LEDGER_NOT_EMPTY', 'Cannot vote on opening block for a non-empty account');
125788
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_NOT_EMPTY', 'Cannot vote on opening block for a non-empty account');
125725
125789
  }
125726
125790
  if (expectedBlock.previous.toString() !== accountHead.toString()) {
125727
- throw new client_ledger('LEDGER_NOT_SUCCESSOR', 'The block is not the successor to the account head block');
125791
+ throw new src_client_KeetaNetLedgerVoteError('LEDGER_NOT_SUCCESSOR', 'The block is not the successor to the account head block', needToGetHeadFor);
125728
125792
  }
125729
125793
  }
125730
125794
 
@@ -125750,7 +125814,7 @@ class client_LedgerAtomicInterface {
125750
125814
  mayReplace = !ourVote.$permanent && ourVote.issuer.comparePublicKey(ledgerPubKey);
125751
125815
  }
125752
125816
  if (!mayReplace) {
125753
- throw new client_ledger('LEDGER_SUCCESSOR_VOTE_EXISTS', `We cannot vote for this block (hash=${block.hash.toString()}), we have an existing vote for a successor (previous votes = ${JSON.stringify(client_toJSONSerializable(previousVotes))})`);
125817
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_SUCCESSOR_VOTE_EXISTS', `We cannot vote for this block (hash=${block.hash.toString()}), we have an existing vote for a successor (previous votes = ${JSON.stringify(client_toJSONSerializable(previousVotes))})`);
125754
125818
  }
125755
125819
  }
125756
125820
  }
@@ -125765,13 +125829,20 @@ class client_LedgerAtomicInterface {
125765
125829
  return vote;
125766
125830
  }
125767
125831
 
125832
+ /**
125833
+ * Validate ledger outcome again before permanent votes if blocks includes a fee block
125834
+ */
125835
+ if (hasFeeBlock) {
125836
+ await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateLedgerOutcome).call(this, blocks);
125837
+ }
125838
+
125768
125839
  /**
125769
125840
  * Validate the votes are sufficient weight and grant
125770
125841
  * our permanent vote
125771
125842
  */
125772
125843
  const votesSufficient = await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateVotingWeight).call(this, otherVotes);
125773
125844
  if (votesSufficient !== true) {
125774
- throw new client_ledger('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Unable to create a vote from these votes, they do not represent enough voting power');
125845
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Unable to create a vote from these votes, they do not represent enough voting power');
125775
125846
  }
125776
125847
 
125777
125848
  /**
@@ -125800,7 +125871,7 @@ class client_LedgerAtomicInterface {
125800
125871
  async add(votesAndBlocks, from) {
125801
125872
  var _classPrivateFieldGet3, _classPrivateFieldGet4, _classPrivateFieldGet5, _classPrivateFieldGet6;
125802
125873
  const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
125803
- switch (client_ledger_classPrivateFieldGet(src_client_ledger, this).ledgerWriteMode) {
125874
+ switch (client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode) {
125804
125875
  case 'read-only':
125805
125876
  throw new Error('Cannot add blocks to a read-only ledger');
125806
125877
  case 'bootstrap-only':
@@ -125812,7 +125883,7 @@ class client_LedgerAtomicInterface {
125812
125883
  case 'no-voting':
125813
125884
  break;
125814
125885
  default:
125815
- throw new Error(`internal error: invalid ledger write mode: ${client_ledger_classPrivateFieldGet(src_client_ledger, this).ledgerWriteMode}`);
125886
+ throw new Error(`internal error: invalid ledger write mode: ${client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode}`);
125816
125887
  }
125817
125888
  const {
125818
125889
  votes,
@@ -125834,19 +125905,19 @@ class client_LedgerAtomicInterface {
125834
125905
  throw new Error('Can only insert permanent votes');
125835
125906
  }
125836
125907
  }
125837
- const weightTiming = (_classPrivateFieldGet3 = client_ledger_classPrivateFieldGet(src_client_ledger, this).node) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.timing.startTime('db-add/getWeight');
125908
+ const weightTiming = (_classPrivateFieldGet3 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.timing.startTime('db-add/getWeight');
125838
125909
  const votesSufficient = await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateVotingWeight).call(this, votesAndBlocks.votes);
125839
125910
  if (votesSufficient !== true) {
125840
- throw new client_ledger('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Votes attached do not represent enough voting power');
125911
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Votes attached do not represent enough voting power');
125841
125912
  }
125842
125913
  weightTiming === null || weightTiming === void 0 || weightTiming.end();
125843
- const changesTiming = (_classPrivateFieldGet4 = client_ledger_classPrivateFieldGet(src_client_ledger, this).node) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.timing.startTime('db-add/computeEffectOfBlocks');
125844
- const changes = client_computeEffectOfBlocks(votesAndBlocks.blocks, client_ledger_classPrivateFieldGet(src_client_ledger, this));
125914
+ const changesTiming = (_classPrivateFieldGet4 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.timing.startTime('db-add/computeEffectOfBlocks');
125915
+ const changes = client_computeEffectOfBlocks(votesAndBlocks.blocks, client_ledger_classPrivateFieldGet(client_ledger, this));
125845
125916
  changesTiming === null || changesTiming === void 0 || changesTiming.end();
125846
- const adjustTiming = (_classPrivateFieldGet5 = client_ledger_classPrivateFieldGet(src_client_ledger, this).node) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.timing.startTime('db-add/adjust');
125917
+ const adjustTiming = (_classPrivateFieldGet5 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.timing.startTime('db-add/adjust');
125847
125918
  const voteStaples = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).adjust(transaction, votesAndBlocks, changes);
125848
125919
  adjustTiming === null || adjustTiming === void 0 || adjustTiming.end();
125849
- const postambleTiming = (_classPrivateFieldGet6 = client_ledger_classPrivateFieldGet(src_client_ledger, this).node) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.timing.startTime('db-add/postamble');
125920
+ const postambleTiming = (_classPrivateFieldGet6 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.timing.startTime('db-add/postamble');
125850
125921
  /**
125851
125922
  * Add all the block hashes to the node checksum
125852
125923
  */
@@ -125948,6 +126019,11 @@ class client_LedgerAtomicInterface {
125948
126019
  const retval = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).getBlock(transaction, blockhash, from);
125949
126020
  return retval;
125950
126021
  }
126022
+ async getAccountsBlockHeightInfo(toFetch) {
126023
+ const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
126024
+ const retval = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).getAccountsBlockHeightInfo(transaction, toFetch);
126025
+ return retval;
126026
+ }
125951
126027
  async getVoteStaple(stapleBlockHash) {
125952
126028
  let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'main';
125953
126029
  client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
@@ -126149,8 +126225,8 @@ class client_LedgerAtomicInterface {
126149
126225
  return await client_ledger_classPrivateFieldGet(client_ledger_storage, this).gc(transaction, timeLimitMS);
126150
126226
  }
126151
126227
  async getFee(blocks, effectsInput) {
126152
- const effects = effectsInput !== null && effectsInput !== void 0 ? effectsInput : client_computeEffectOfBlocks(blocks, client_ledger_classPrivateFieldGet(src_client_ledger, this));
126153
- return client_ledger_classPrivateFieldGet(client_computeFeeFromBlocks, this).call(this, client_ledger_classPrivateFieldGet(src_client_ledger, this), blocks, effects);
126228
+ const effects = effectsInput !== null && effectsInput !== void 0 ? effectsInput : client_computeEffectOfBlocks(blocks, client_ledger_classPrivateFieldGet(client_ledger, this));
126229
+ return client_ledger_classPrivateFieldGet(client_computeFeeFromBlocks, this).call(this, client_ledger_classPrivateFieldGet(client_ledger, this), blocks, effects);
126154
126230
  }
126155
126231
  async _testingRunStorageFunction(code) {
126156
126232
  const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
@@ -126178,7 +126254,7 @@ async function client_validateVotingWeight(votes) {
126178
126254
  */
126179
126255
  if (totalVotingPower === 0n) {
126180
126256
  const foundTrustedVote = votes.find(vote => {
126181
- return vote.issuer.comparePublicKey(client_ledger_classPrivateFieldGet(src_client_ledger, this).initialTrustedAccount);
126257
+ return vote.issuer.comparePublicKey(client_ledger_classPrivateFieldGet(client_ledger, this).initialTrustedAccount);
126182
126258
  });
126183
126259
  return foundTrustedVote !== undefined;
126184
126260
  }
@@ -126231,7 +126307,7 @@ async function client_checkSingleAccountPermissions(account, requirements, accou
126231
126307
  const baseFlagsStr = requirement.permissions.base.flags.join(', ');
126232
126308
  const externalOffsetsStr = requirement.permissions.external.trueOffsets.join(', ');
126233
126309
  const reqTargetKey = (_requirement$target = requirement.target) === null || _requirement$target === void 0 ? void 0 : _requirement$target.publicKeyString.get();
126234
- throw new client_ledger('LEDGER_INVALID_PERMISSIONS', `${accountPubKey} does not have required permissions to perform action on ${reqEntityKey}/${reqTargetKey} -- needs [${baseFlagsStr}]/[${externalOffsetsStr}]`);
126310
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_PERMISSIONS', `${accountPubKey} does not have required permissions to perform action on ${reqEntityKey}/${reqTargetKey} -- needs [${baseFlagsStr}]/[${externalOffsetsStr}]`);
126235
126311
  }
126236
126312
  }
126237
126313
  }
@@ -126290,7 +126366,7 @@ async function client_checkPermissionRequirements(effects) {
126290
126366
  throw new Error(`Multisig quorum not found for ${multisigPubKey}`);
126291
126367
  }
126292
126368
  if (foundInfo.multisigQuorum > foundSingerLength) {
126293
- throw new client_ledger('LEDGER_INVALID_PERMISSIONS', `Quorum of ${foundInfo.multisigQuorum} not reached for ${multisigPubKey} -- got ${foundSingerLength}`);
126369
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_PERMISSIONS', `Quorum of ${foundInfo.multisigQuorum} not reached for ${multisigPubKey} -- got ${foundSingerLength}`);
126294
126370
  }
126295
126371
  }
126296
126372
  const checkPromises = [];
@@ -126339,7 +126415,7 @@ async function client_validateLedgerOutcome(blocks) {
126339
126415
  break;
126340
126416
  }
126341
126417
  };
126342
- const effects = client_computeEffectOfBlocks(blocks, client_ledger_classPrivateFieldGet(src_client_ledger, this));
126418
+ const effects = client_computeEffectOfBlocks(blocks, client_ledger_classPrivateFieldGet(client_ledger, this));
126343
126419
  const accountEffects = effects.accounts;
126344
126420
  const allAccountsChanges = Object.values(accountEffects);
126345
126421
 
@@ -126411,13 +126487,13 @@ async function client_validateLedgerOutcome(blocks) {
126411
126487
  if (ownerLength === 1) {
126412
126488
  continue;
126413
126489
  }
126414
- throw new client_ledger('LEDGER_INVALID_OWNER_COUNT', `Invalid number of owners for ${identifierPubKey} - Got ${ownerLength}/1`);
126490
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_OWNER_COUNT', `Invalid number of owners for ${identifierPubKey} - Got ${ownerLength}/1`);
126415
126491
  }
126416
126492
  const {
126417
126493
  balances
126418
126494
  } = await client_computeLedgerEffect({
126419
126495
  checkRangeConstraints: true,
126420
- baseToken: client_ledger_classPrivateFieldGet(src_client_ledger, this).baseToken
126496
+ baseToken: client_ledger_classPrivateFieldGet(client_ledger, this).baseToken
126421
126497
  }, accountEffects, client_ledger_classPrivateFieldGet(client_ledger_storage, this), client_ledger_classPrivateFieldGet(client_network, this), client_ledger_classPrivateFieldGet(client_transaction, this));
126422
126498
  for (const accountPubKey in balances) {
126423
126499
  const acctBalanceChanges = balances[accountPubKey];
@@ -126428,10 +126504,10 @@ async function client_validateLedgerOutcome(blocks) {
126428
126504
  receiveValidated
126429
126505
  } = acctBalanceChanges[tokenPubKey];
126430
126506
  if (fellNegative) {
126431
- throw new client_ledger('LEDGER_INVALID_BALANCE', `Resulting balance becomes negative at one+ point(s) during this transaction for account/token ${accountPubKey}/${tokenPubKey}: change ${change}`);
126507
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_BALANCE', `Resulting balance becomes negative at one+ point(s) during this transaction for account/token ${accountPubKey}/${tokenPubKey}: change ${change}`);
126432
126508
  }
126433
126509
  if (receiveValidated === false) {
126434
- throw new client_ledger('LEDGER_RECEIVE_NOT_MET', `${accountPubKey}/${tokenPubKey} did not receive enough of requested token. change: ${change}`);
126510
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_RECEIVE_NOT_MET', `${accountPubKey}/${tokenPubKey} did not receive enough of requested token. change: ${change}`);
126435
126511
  }
126436
126512
  }
126437
126513
  }
@@ -126452,13 +126528,13 @@ async function client_validateBlocksForVote(blocks) {
126452
126528
  const prevBlockHash = block.previous;
126453
126529
  seenBlockHashes.add(block.hash);
126454
126530
  if (block.network !== client_ledger_classPrivateFieldGet(client_network, this)) {
126455
- throw new client_ledger('LEDGER_INVALID_NETWORK', 'Cannot vote on block for a different network');
126531
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_NETWORK', 'Cannot vote on block for a different network');
126456
126532
  }
126457
126533
  if (block.subnet !== client_ledger_classPrivateFieldGet(client_subnet, this)) {
126458
- throw new client_ledger('LEDGER_INVALID_SUBNET', 'Cannot vote on block for a different subnet');
126534
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_SUBNET', 'Cannot vote on block for a different subnet');
126459
126535
  }
126460
126536
  if (usedPreviousBlockHashes.has(prevBlockHash)) {
126461
- throw new client_ledger('LEDGER_PREVIOUS_ALREADY_USED', `Invalid reference to block, previous: ${prevBlockHash} has already been used`);
126537
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_PREVIOUS_ALREADY_USED', `Invalid reference to block, previous: ${prevBlockHash} has already been used`);
126462
126538
  }
126463
126539
  usedPreviousBlockHashes.add(prevBlockHash);
126464
126540
 
@@ -126474,10 +126550,10 @@ async function client_validateBlocksForVote(blocks) {
126474
126550
  if (prevBlock !== undefined) {
126475
126551
  predecessorBeingVotedOn = true;
126476
126552
  if (!prevBlock.account.comparePublicKey(block.account)) {
126477
- throw new client_ledger('LEDGER_INVALID_CHAIN', 'Invalid chain, changes accounts');
126553
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_CHAIN', 'Invalid chain, changes accounts');
126478
126554
  }
126479
126555
  if (!seenBlockHashes.has(prevBlockHash)) {
126480
- throw new client_ledger('LEDGER_PREVIOUS_NOT_SEEN', `Invalid reference to block, out-of-order: ${prevBlockHash} has not already been seen`);
126556
+ throw new client_ledger_KeetaNetLedgerError('LEDGER_PREVIOUS_NOT_SEEN', `Invalid reference to block, out-of-order: ${prevBlockHash} has not already been seen`);
126481
126557
  }
126482
126558
  }
126483
126559
  }
@@ -126489,8 +126565,8 @@ async function client_validateBlocksForVote(blocks) {
126489
126565
  }
126490
126566
  async function client_voteOrQuoteWithFees(blocks, type, quote) {
126491
126567
  var _quote$fee;
126492
- if (client_ledger_classPrivateFieldGet(src_client_ledger, this).ledgerWriteMode !== 'read-write') {
126493
- throw new Error(`May not issue votes in read-only mode, in ${client_ledger_classPrivateFieldGet(src_client_ledger, this).ledgerWriteMode} mode`);
126568
+ if (client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode !== 'read-write') {
126569
+ throw new Error(`May not issue votes in read-only mode, in ${client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode} mode`);
126494
126570
  }
126495
126571
  if (!client_ledger_classPrivateFieldGet(client_ledger_privateKey, this)) {
126496
126572
  throw new Error('Cannot vote on block, no private key loaded');
@@ -126670,7 +126746,7 @@ class src_client_Ledger {
126670
126746
  shouldTryToRetry = now - startTime < retryConfig.timeout;
126671
126747
  }
126672
126748
  if (shouldTryToRetry) {
126673
- if (client_ledger.isInstance(txnError)) {
126749
+ if (client_ledger_KeetaNetLedgerError.isInstance(txnError)) {
126674
126750
  if (txnError.shouldRetry) {
126675
126751
  let retryDelay = 20;
126676
126752
  if (txnError.retryDelay) {
@@ -126853,57 +126929,65 @@ class src_client_Ledger {
126853
126929
  return await transaction.getBlock(...args);
126854
126930
  });
126855
126931
  }
126856
- async getVoteStaple() {
126932
+ async getAccountsBlockHeightInfo() {
126857
126933
  for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
126858
126934
  args[_key19] = arguments[_key19];
126859
126935
  }
126936
+ return await this.runReadOnly('db-getAccountsBlockHeightInfo', async function (transaction) {
126937
+ return await transaction.getAccountsBlockHeightInfo(...args);
126938
+ });
126939
+ }
126940
+ async getVoteStaple() {
126941
+ for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
126942
+ args[_key20] = arguments[_key20];
126943
+ }
126860
126944
  return await this.runReadOnly('db-getVoteStaple', async function (transaction) {
126861
126945
  return await transaction.getVoteStaple(...args);
126862
126946
  });
126863
126947
  }
126864
126948
  async getVoteStaples() {
126865
- for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
126866
- args[_key20] = arguments[_key20];
126949
+ for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
126950
+ args[_key21] = arguments[_key21];
126867
126951
  }
126868
126952
  return await this.runReadOnly('db-getVoteStaples', async function (transaction) {
126869
126953
  return await transaction.getVoteStaples(...args);
126870
126954
  });
126871
126955
  }
126872
126956
  async getHistory() {
126873
- for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
126874
- args[_key21] = arguments[_key21];
126957
+ for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
126958
+ args[_key22] = arguments[_key22];
126875
126959
  }
126876
126960
  return await this.runReadOnly('db-getHistory', async function (transaction) {
126877
126961
  return await transaction.getHistory(...args);
126878
126962
  });
126879
126963
  }
126880
126964
  async getStaplesFromBlockHashes() {
126881
- for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
126882
- args[_key22] = arguments[_key22];
126965
+ for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
126966
+ args[_key23] = arguments[_key23];
126883
126967
  }
126884
126968
  return await this.runReadOnly('db-getStaplesFromBlockHashes', async function (transaction) {
126885
126969
  return await transaction.getStaplesFromBlockHashes(...args);
126886
126970
  });
126887
126971
  }
126888
126972
  async getVoteStaplesAfter() {
126889
- for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
126890
- args[_key23] = arguments[_key23];
126973
+ for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
126974
+ args[_key24] = arguments[_key24];
126891
126975
  }
126892
126976
  return await this.runReadOnly('db-getVoteStaplesAfter', async function (transaction) {
126893
126977
  return await transaction.getVoteStaplesAfter(...args);
126894
126978
  });
126895
126979
  }
126896
126980
  async gc() {
126897
- for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
126898
- args[_key24] = arguments[_key24];
126981
+ for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
126982
+ args[_key25] = arguments[_key25];
126899
126983
  }
126900
126984
  return await this.run('db-gc', async function (transaction) {
126901
126985
  return await transaction.gc(...args);
126902
126986
  });
126903
126987
  }
126904
126988
  async getFee() {
126905
- for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
126906
- args[_key25] = arguments[_key25];
126989
+ for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
126990
+ args[_key26] = arguments[_key26];
126907
126991
  }
126908
126992
  return await this.runReadOnly('db-getFee', async function (transaction) {
126909
126993
  return await transaction.getFee(...args);
@@ -126931,11 +127015,11 @@ class src_client_Ledger {
126931
127015
  client_Ledger = src_client_Ledger;
126932
127016
  client_lib_ledger_defineProperty(src_client_Ledger, "Kind", client_LedgerKind);
126933
127017
  client_lib_ledger_defineProperty(src_client_Ledger, "isInstance", client_checkableGenerator(client_Ledger));
126934
- /* harmony default export */ const client_lib_ledger = (src_client_Ledger);
127018
+ /* harmony default export */ const src_client_ledger = (src_client_Ledger);
126935
127019
  // EXTERNAL MODULE: ws (ignored)
126936
127020
  var client_ws_ignored_ = __webpack_require__(4708);
126937
127021
  ;// ./src/version.ts
126938
- const client_version = '0.14.2+g68f40cc8d6fed6135fa06451bd1fb0691868e25f';
127022
+ const client_version = '0.14.4+g6020a42a3e7fdf7cae2d3783e939f895ae1be911';
126939
127023
  /* harmony default export */ const client_src_version = ((/* unused pure expression or super */ null && (client_version)));
126940
127024
  ;// ./src/lib/p2p.ts
126941
127025
  /* provided dependency */ var client_p2p_Buffer = __webpack_require__(8287)["Buffer"];
@@ -129000,13 +129084,13 @@ class src_client_Node {
129000
129084
  this.baseToken = baseToken;
129001
129085
 
129002
129086
  /* XXX:TODO: Compute ledger kind from node kind */
129003
- const ledgerKind = client_lib_ledger.Kind.REPRESENTATIVE;
129087
+ const ledgerKind = src_client_ledger.Kind.REPRESENTATIVE;
129004
129088
  this.config = config;
129005
129089
  const initialTrustedAccount = config.initialTrustedAccount;
129006
129090
  if (initialTrustedAccount.hasPrivateKey) {
129007
129091
  throw new Error('There is no reason for us to have the private key in setup of the initialTrustedAccount');
129008
129092
  }
129009
- this.ledger = new client_lib_ledger({
129093
+ this.ledger = new src_client_ledger({
129010
129094
  privateKey: config.ledgerPrivateKey,
129011
129095
  network: config.network,
129012
129096
  subnet: config.subnet,
@@ -129158,6 +129242,144 @@ client_Node = src_client_Node;
129158
129242
  client_node_defineProperty(src_client_Node, "Kind", client_node_NodeKind);
129159
129243
  client_node_defineProperty(src_client_Node, "isInstance", client_checkableGenerator(client_Node));
129160
129244
  /* harmony default export */ const client_node = (src_client_Node);
129245
+ ;// ./src/lib/error/api.ts
129246
+ var client_KeetaNetAPIError;
129247
+ function client_api_defineProperty(e, r, t) { return (r = client_api_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
129248
+ function client_api_toPropertyKey(t) { var i = client_api_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
129249
+ function client_api_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); }
129250
+
129251
+
129252
+ const client_APIErrorType = 'API';
129253
+ const client_APIErrorCodes = ['INVALID_LIMIT', 'INVALID_SIDE', 'INVALID_START', 'LIMIT_NOT_NUMBER', 'LIMIT_NOT_GREATER_THAN_ZERO', 'REP_MISSING', 'START_MISSING'];
129254
+ const client_FullAPIErrorCodes = client_APIErrorCodes.map(code => `${client_APIErrorType}_${code}`);
129255
+ class src_client_KeetaNetAPIError extends src_client_KeetaNetErrorBase {
129256
+ constructor(code, message) {
129257
+ super(code, message, {
129258
+ type: client_APIErrorType,
129259
+ codes: client_APIErrorCodes
129260
+ });
129261
+ }
129262
+ }
129263
+ client_KeetaNetAPIError = src_client_KeetaNetAPIError;
129264
+ client_api_defineProperty(src_client_KeetaNetAPIError, "isInstance", client_checkableGenerator(client_KeetaNetAPIError));
129265
+ ;// ./src/lib/error/client.ts
129266
+ var client_KeetaNetClientError;
129267
+ function client_client_defineProperty(e, r, t) { return (r = client_client_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
129268
+ function client_client_toPropertyKey(t) { var i = client_client_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
129269
+ function client_client_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); }
129270
+
129271
+
129272
+ const client_ClientErrorType = 'CLIENT';
129273
+ const client_ClientErrorCodes = ['BUILDER_AMOUNT_IS_ZERO', 'BUILDER_CANNOT_READ_BEFORE_RENDER', 'BUILDER_REQUIRES_PRIVATE_KEY', 'BUILDER_USER_CLIENT_REQUIRED', 'PUBLISH_AID_NOT_AVAILABLE', 'SIGNER_REQUIRES_PRIVATE_KEY'];
129274
+ const client_FullClientErrorCodes = client_ClientErrorCodes.map(code => `${client_ClientErrorType}_${code}`);
129275
+ class src_client_KeetaNetClientError extends src_client_KeetaNetErrorBase {
129276
+ constructor(code, message) {
129277
+ super(code, message, {
129278
+ type: client_ClientErrorType,
129279
+ codes: client_ClientErrorCodes
129280
+ });
129281
+ }
129282
+ }
129283
+ client_KeetaNetClientError = src_client_KeetaNetClientError;
129284
+ client_client_defineProperty(src_client_KeetaNetClientError, "isInstance", client_checkableGenerator(client_KeetaNetClientError));
129285
+ ;// ./src/lib/error/kv.ts
129286
+ var client_KeetaNetKVError;
129287
+ function client_error_kv_defineProperty(e, r, t) { return (r = client_error_kv_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
129288
+ function client_error_kv_toPropertyKey(t) { var i = client_error_kv_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
129289
+ function client_error_kv_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); }
129290
+
129291
+
129292
+ const client_KVErrorType = 'KV';
129293
+ const client_KVErrorCodes = ['TTL_NOT_SUPPORTED', 'KEY_ALREADY_EXISTS'];
129294
+ const client_FullKVErrorCodes = client_KVErrorCodes.map(code => `${client_KVErrorType}_${code}`);
129295
+ class src_client_KeetaNetKVError extends src_client_KeetaNetErrorBase {
129296
+ constructor(code, message) {
129297
+ super(code, message, {
129298
+ type: client_KVErrorType,
129299
+ codes: client_KVErrorCodes
129300
+ });
129301
+ }
129302
+ }
129303
+ client_KeetaNetKVError = src_client_KeetaNetKVError;
129304
+ client_error_kv_defineProperty(src_client_KeetaNetKVError, "isInstance", client_checkableGenerator(client_KeetaNetKVError));
129305
+ ;// ./src/lib/error/index.ts
129306
+
129307
+
129308
+
129309
+
129310
+
129311
+
129312
+
129313
+
129314
+
129315
+
129316
+
129317
+ const client_allErrorCodesWithoutPrefix = [...client_AccountErrorCodes, ...client_APIErrorCodes, ...client_BlockErrorCodes, ...client_CertificateErrorCodes, ...client_ClientErrorCodes, ...client_KVErrorCodes, ...client_LedgerBaseErrorCodes, ...client_LedgerVoteErrorCodes, ...client_PermissionsErrorCodes, ...client_VoteErrorCodes];
129318
+ const client_allFullErrorCodes = [...client_FullAccountErrorCodes, ...client_FullAPIErrorCodes, ...client_FullBlockErrorCodes, ...client_FullCertificateErrorCodes, ...client_FullClientErrorCodes, ...client_FullKVErrorCodes, ...client_FullLedgerErrorCodes, ...client_FullPermissionsErrorCodes, ...client_FullVoteErrorCodes];
129319
+ const client_errorCodeSet = new Set(client_allFullErrorCodes);
129320
+ async function client_ExpectErrorCode(code, test) {
129321
+ await expect(test).rejects.toThrow(expect.objectContaining({
129322
+ code: code
129323
+ }));
129324
+ }
129325
+ class client_KeetaNetError extends src_client_KeetaNetErrorBase {
129326
+ static assertValidErrorCode(code) {
129327
+ return client_errorCodeSet.has(code);
129328
+ }
129329
+ static fromJSON(json) {
129330
+ if (typeof json === 'object' && json !== null && 'type' in json && 'code' in json && 'message' in json) {
129331
+ const {
129332
+ type,
129333
+ code,
129334
+ message
129335
+ } = json;
129336
+ if (typeof type !== 'string' || typeof code !== 'string' || typeof message !== 'string') {
129337
+ return new Error('Invalid JSON for KeetaNetError (bad type or code or message)');
129338
+ }
129339
+ if (type === 'LEDGER') {
129340
+ let shouldRetry;
129341
+ let retryDelay;
129342
+ if ('shouldRetry' in json) {
129343
+ if (typeof json.shouldRetry !== 'boolean') {
129344
+ return new Error('Invalid JSON for KeetaNetLedgerError (bad shouldRetry)');
129345
+ }
129346
+ shouldRetry = json.shouldRetry;
129347
+ }
129348
+ if ('retryDelay' in json) {
129349
+ if (typeof json.retryDelay !== 'number') {
129350
+ return new Error('Invalid JSON for KeetaNetLedgerError (bad retryDelay)');
129351
+ }
129352
+ retryDelay = json.retryDelay;
129353
+ }
129354
+ if (src_client_KeetaNetLedgerVoteError.assertValidLedgerErrorCode(code)) {
129355
+ if (!('accounts' in json) || !Array.isArray(json.accounts)) {
129356
+ return new Error('Invalid JSON for KeetaNetLedgerVoteError (bad accounts)');
129357
+ }
129358
+ const accountsArray = json.accounts.map(account => {
129359
+ return client_lib_account.fromPublicKeyString(account);
129360
+ });
129361
+ const accounts = new client_lib_account.Set(accountsArray);
129362
+ return new src_client_KeetaNetLedgerVoteError(code, message, accounts);
129363
+ } else if (client_ledger_KeetaNetLedgerError.assertValidLedgerErrorCode(code)) {
129364
+ return new client_ledger_KeetaNetLedgerError(code, message, shouldRetry, retryDelay);
129365
+ }
129366
+ }
129367
+ if (this.assertValidErrorCode(code)) {
129368
+ return new client_KeetaNetError(code, message, {
129369
+ type,
129370
+ codes: client_allErrorCodesWithoutPrefix
129371
+ });
129372
+ }
129373
+ }
129374
+ if (typeof json === 'object' && json !== null && 'message' in json) {
129375
+ if (typeof json.message !== 'string') {
129376
+ return new Error('Invalid JSON for KeetaNetError (bad message)');
129377
+ }
129378
+ return new Error(json.message);
129379
+ }
129380
+ return new Error('Unknown error');
129381
+ }
129382
+ }
129161
129383
  // EXTERNAL MODULE: ./node_modules/bloom-filters/dist/api.js
129162
129384
  var client_api = __webpack_require__(5652);
129163
129385
  ;// ./src/lib/utils/bloom.ts
@@ -129231,6 +129453,7 @@ function client_deserializeBloomFilter(input) {
129231
129453
  // Blocks that will return from generateInitialVoteStaple if you are adding supply
129232
129454
 
129233
129455
  async function client_generateInitialVoteStaple(options) {
129456
+ var _options$baseTokenInf, _options$baseTokenInf2, _options$baseTokenInf3, _options$baseTokenInf4;
129234
129457
  const {
129235
129458
  network,
129236
129459
  initialTrustedAccount,
@@ -129291,9 +129514,11 @@ async function client_generateInitialVoteStaple(options) {
129291
129514
  permissions: new client_permissions_Permissions(['OWNER'])
129292
129515
  }, {
129293
129516
  type: client_lib_block.Builder.OperationType.SET_INFO,
129294
- name: '',
129295
- description: '',
129296
- metadata: '',
129517
+ name: (_options$baseTokenInf = (_options$baseTokenInf2 = options.baseTokenInfo) === null || _options$baseTokenInf2 === void 0 ? void 0 : _options$baseTokenInf2.currencyCode) !== null && _options$baseTokenInf !== void 0 ? _options$baseTokenInf : '',
129518
+ description: (_options$baseTokenInf3 = (_options$baseTokenInf4 = options.baseTokenInfo) === null || _options$baseTokenInf4 === void 0 ? void 0 : _options$baseTokenInf4.name) !== null && _options$baseTokenInf3 !== void 0 ? _options$baseTokenInf3 : '',
129519
+ metadata: options.baseTokenInfo ? btoa(JSON.stringify({
129520
+ decimalPlaces: options.baseTokenInfo.decimalPlaces
129521
+ })) : '',
129297
129522
  defaultPermission: new client_permissions_Permissions(['ACCESS'])
129298
129523
  }, ...additionalBaseTokenOperations]
129299
129524
  }).seal();
@@ -129373,8 +129598,8 @@ async function client_generateInitialVoteStaple(options) {
129373
129598
  */
129374
129599
  Account: client_lib_account,
129375
129600
  Block: client_lib_block,
129376
- Error: src_client_KeetaNetError,
129377
- Ledger: client_lib_ledger,
129601
+ Error: client_KeetaNetError,
129602
+ Ledger: src_client_ledger,
129378
129603
  Node: client_node,
129379
129604
  P2P: client_p2p,
129380
129605
  Permissions: client_permissions_Permissions,
@@ -129391,25 +129616,6 @@ async function client_generateInitialVoteStaple(options) {
129391
129616
  Certificate: client_utils_certificate_namespaceObject
129392
129617
  }
129393
129618
  });
129394
- ;// ./src/lib/error/client.ts
129395
- var client_KeetaNetClientError;
129396
- function client_client_defineProperty(e, r, t) { return (r = client_client_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
129397
- function client_client_toPropertyKey(t) { var i = client_client_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
129398
- function client_client_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); }
129399
-
129400
-
129401
- const client_ClientErrorType = 'CLIENT';
129402
- const client_ClientErrorCodes = ['BUILDER_AMOUNT_IS_ZERO', 'BUILDER_CANNOT_READ_BEFORE_RENDER', 'BUILDER_REQUIRES_PRIVATE_KEY', 'BUILDER_USER_CLIENT_REQUIRED', 'PUBLISH_AID_NOT_AVAILABLE', 'SIGNER_REQUIRES_PRIVATE_KEY'];
129403
- class src_client_KeetaNetClientError extends src_client_KeetaNetError {
129404
- constructor(code, message) {
129405
- super(code, message, {
129406
- type: client_ClientErrorType,
129407
- codes: client_ClientErrorCodes
129408
- });
129409
- }
129410
- }
129411
- client_KeetaNetClientError = src_client_KeetaNetClientError;
129412
- client_client_defineProperty(src_client_KeetaNetClientError, "isInstance", client_checkableGenerator(client_KeetaNetClientError));
129413
129619
  ;// ./src/client/builder.ts
129414
129620
  /* provided dependency */ var client_builder_Buffer = __webpack_require__(8287)["Buffer"];
129415
129621
  var client_PendingAccount, client_UserClientBuilder;
@@ -130390,6 +130596,7 @@ function client_client_assertClassBrand(e, t, n) { if ("function" == typeof e ?
130390
130596
 
130391
130597
 
130392
130598
 
130599
+
130393
130600
 
130394
130601
 
130395
130602
  /*
@@ -130768,9 +130975,10 @@ class src_client_Client {
130768
130975
  * @return The account information
130769
130976
  */
130770
130977
  async getAccountInfo(account) {
130978
+ let rep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'ANY';
130771
130979
  account = client_lib_account.toAccount(account);
130772
130980
  const accountPubKey = account.publicKeyString.get();
130773
- const result = await client_client_assertClassBrand(client_Client_brand, this, src_client_api).call(this, 'ANY', 'GET /node/ledger/account/:account', {
130981
+ const result = await client_client_assertClassBrand(client_Client_brand, this, src_client_api).call(this, rep, 'GET /node/ledger/account/:account', {
130774
130982
  args: {
130775
130983
  account: accountPubKey
130776
130984
  }
@@ -131660,6 +131868,64 @@ class src_client_Client {
131660
131868
  }
131661
131869
  return voteStaple;
131662
131870
  }
131871
+
131872
+ /**
131873
+ * Sync any partially-published account artifacts
131874
+ *
131875
+ * @param account Account to sync
131876
+ * @param publish Publish the synced staple to the network (default is true)
131877
+ */
131878
+ async syncAccount(account) {
131879
+ let publish = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
131880
+ let reps = arguments.length > 2 ? arguments[2] : undefined;
131881
+ await client_client_classPrivateFieldGet(client_updateRepsPromise, this);
131882
+ if (reps === undefined) {
131883
+ reps = this.representatives;
131884
+ }
131885
+ const repAccountInfoPromises = [];
131886
+ for (const rep of reps) {
131887
+ repAccountInfoPromises.push((async () => {
131888
+ const info = await this.getAccountInfo(account, rep);
131889
+ return {
131890
+ rep,
131891
+ info
131892
+ };
131893
+ })());
131894
+ }
131895
+ const accountInfoSettled = await Promise.allSettled(repAccountInfoPromises);
131896
+ const accountInfo = [];
131897
+ for (const info of accountInfoSettled) {
131898
+ if (info.status === 'fulfilled') {
131899
+ accountInfo.push(info.value);
131900
+ }
131901
+ }
131902
+ const accountInfoSorted = accountInfo.sort(function (a, b) {
131903
+ var _a$info$currentHeadBl, _b$info$currentHeadBl;
131904
+ return Number(BigInt((_a$info$currentHeadBl = a.info.currentHeadBlockHeight) !== null && _a$info$currentHeadBl !== void 0 ? _a$info$currentHeadBl : -1) - BigInt((_b$info$currentHeadBl = b.info.currentHeadBlockHeight) !== null && _b$info$currentHeadBl !== void 0 ? _b$info$currentHeadBl : -1));
131905
+ });
131906
+ if (accountInfoSorted[0].info.currentHeadBlockHeight === accountInfoSorted[accountInfoSorted.length - 1].info.currentHeadBlockHeight) {
131907
+ // Block Heights match so return
131908
+ return null;
131909
+ }
131910
+ let lowestHead = accountInfoSorted[0].info.currentHeadBlock;
131911
+ if (lowestHead === null) {
131912
+ lowestHead = client_lib_block.getAccountOpeningHash(account).toString();
131913
+ }
131914
+
131915
+ // Get the missing successor block and vote staple from the rep with the highest block height
131916
+ const successorBlock = await this.getSuccessorBlock(lowestHead, accountInfoSorted[accountInfoSorted.length - 1].rep);
131917
+ if (successorBlock === null) {
131918
+ return null;
131919
+ }
131920
+ const successorStaple = await this.getVoteStaple(successorBlock.hash, 'main', accountInfoSorted[accountInfoSorted.length - 1].rep);
131921
+ if (successorStaple === null) {
131922
+ return null;
131923
+ }
131924
+ if (publish === true) {
131925
+ await this.transmitStaple(successorStaple, [accountInfoSorted[0].rep]);
131926
+ }
131927
+ return successorStaple;
131928
+ }
131663
131929
  async getVoteQuotes(blocks) {
131664
131930
  return await client_client_assertClassBrand(client_Client_brand, this, client_requestQuotes).call(this, blocks);
131665
131931
  }
@@ -131691,7 +131957,8 @@ async function client_apiRaw(rep, api, method) {
131691
131957
  ...options
131692
131958
  };
131693
131959
  let delay = 1;
131694
- let result, resultThrow;
131960
+ let result;
131961
+ let resultThrow;
131695
131962
  for (let retry = 0; retry < Number.MAX_SAFE_INTEGER; retry++) {
131696
131963
  if (rep === 'ANY') {
131697
131964
  var _classPrivateFieldGet4;
@@ -131748,7 +132015,18 @@ async function client_apiRaw(rep, api, method) {
131748
132015
  try {
131749
132016
  const errorInfo = await response.json();
131750
132017
  if (errorInfo.error === true) {
131751
- resultThrow = errorInfo;
132018
+ const keetaNetError = client_KeetaNetError.fromJSON(errorInfo);
132019
+ try {
132020
+ if (src_client_KeetaNetLedgerVoteError.isInstance(keetaNetError)) {
132021
+ for (const account of keetaNetError.accounts) {
132022
+ await this.syncAccount(account);
132023
+ }
132024
+ continue;
132025
+ }
132026
+ } catch {
132027
+ // ignored error parsing KeetaNet Error just return original
132028
+ }
132029
+ resultThrow = keetaNetError;
131752
132030
  break;
131753
132031
  }
131754
132032
  } catch (errorResponse) {
@@ -131810,13 +132088,8 @@ async function client_apiRaw(rep, api, method) {
131810
132088
  break;
131811
132089
  }
131812
132090
  if (resultThrow) {
131813
- if (resultThrow.code && resultThrow.type) {
131814
- const error = new src_client_KeetaNetError(resultThrow.code, resultThrow.message);
131815
- error.type = resultThrow.type;
131816
- throw error;
131817
- } else {
131818
- throw new Error(resultThrow.message);
131819
- }
132091
+ const toThrow = client_KeetaNetError.fromJSON(resultThrow);
132092
+ throw toThrow;
131820
132093
  }
131821
132094
  return result;
131822
132095
  }
@@ -132076,6 +132349,7 @@ function client_parseAccountInfo(account, accountInfo) {
132076
132349
  return {
132077
132350
  account: client_src_lib.Account.fromPublicKeyString(accountInfo.account),
132078
132351
  currentHeadBlock: currentHeadBlock,
132352
+ currentHeadBlockHeight: accountInfo.currentHeadBlockHeight,
132079
132353
  representative: currentRepresentative,
132080
132354
  info: client_client_assertClassBrand(client_Client_brand, this, client_formatAccountInfo).call(this, accountInfo.info),
132081
132355
  balances: client_client_assertClassBrand(client_Client_brand, this, client_formatAllBalances).call(this, accountInfo.balances)
@@ -132396,7 +132670,8 @@ class src_client_UserClient {
132396
132670
  const {
132397
132671
  delegateTo = this.client.representatives[0].key,
132398
132672
  addSupplyAmount,
132399
- voteSerial = 0n
132673
+ voteSerial = 0n,
132674
+ baseTokenInfo
132400
132675
  } = initOpts;
132401
132676
  if (this.signer === null) {
132402
132677
  throw new Error('May not initialize chain with a read-only UserClient (signer is null)');
@@ -132412,7 +132687,8 @@ class src_client_UserClient {
132412
132687
  delegateTo: delegateTo,
132413
132688
  recipient: client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options).assertAccount(),
132414
132689
  amount: addSupplyAmount
132415
- }
132690
+ },
132691
+ baseTokenInfo
132416
132692
  });
132417
132693
  return await this.client.transmitStaple(voteStaple);
132418
132694
  }
@@ -132517,9 +132793,10 @@ class src_client_UserClient {
132517
132793
  * @return The vote staple that was generated and whether it was able to be published
132518
132794
  */
132519
132795
  async publishBuilder(builder) {
132520
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
132521
- generateFeeBlock: client_client_classPrivateFieldGet(client_client_config, this).generateFeeBlock
132522
- };
132796
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
132797
+ if (options.generateFeeBlock === undefined) {
132798
+ options.generateFeeBlock = client_client_classPrivateFieldGet(client_client_config, this).generateFeeBlock;
132799
+ }
132523
132800
  if (!client_client_classPrivateFieldGet(client_client_config, this).usePublishAid) {
132524
132801
  return await client_client_classPrivateFieldGet(client_client, this).transmitBuilder(builder, this.network, options);
132525
132802
  }
@@ -132638,15 +132915,18 @@ class src_client_UserClient {
132638
132915
  try {
132639
132916
  const builder = this.initBuilder(options);
132640
132917
  builder.send(client_lib_account.toAccount(to), BigInt(amount), client_lib_account.toAccount(token), external);
132641
- return await this.publishBuilder(builder);
132918
+ const publish = await this.publishBuilder(builder);
132919
+ return publish;
132642
132920
  } catch (transmitError) {
132643
132921
  let error = true;
132644
132922
  if (retries < 2) {
132645
- if (src_client_KeetaNetError.isInstance(transmitError) && transmitError.code === 'LEDGER_SUCCESSOR_VOTE_EXISTS') {
132646
- const staple = await this.recover(true, options);
132647
- if (staple) {
132648
- error = false;
132649
- return await this.send(to, amount, token, external, options, retries + 1);
132923
+ if (client_KeetaNetError.isInstance(transmitError)) {
132924
+ if (transmitError.code === 'LEDGER_SUCCESSOR_VOTE_EXISTS') {
132925
+ const staple = await this.recover(true, options);
132926
+ if (staple) {
132927
+ error = false;
132928
+ return await this.send(to, amount, token, external, options, retries + 1);
132929
+ }
132650
132930
  }
132651
132931
  }
132652
132932
  }
@@ -132886,6 +133166,18 @@ class src_client_UserClient {
132886
133166
  return await client_client_classPrivateFieldGet(client_client, this).recoverAccount(client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options), publish);
132887
133167
  }
132888
133168
 
133169
+ /**
133170
+ * Sync any partially-published account artifacts
133171
+ *
133172
+ * @param publish Publish the recovered staple to the network
133173
+ * (default: true)
133174
+ * @param options User client options (common options)
133175
+ */
133176
+ async sync(publish) {
133177
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
133178
+ return await client_client_classPrivateFieldGet(client_client, this).syncAccount(client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options), publish);
133179
+ }
133180
+
132889
133181
  /**
132890
133182
  * Register a callback for change messages and set up a websocket filtered to our account only.
132891
133183
  * Also set up long timeout polling for changes in case the websocket misses a change update
@@ -133107,7 +133399,7 @@ async function client_publishWithPublishAid(blocks) {
133107
133399
  publish: json.publish
133108
133400
  };
133109
133401
  } catch (publishError) {
133110
- if (src_client_KeetaNetError.isInstance(publishError)) {
133402
+ if (client_KeetaNetError.isInstance(publishError)) {
133111
133403
  throw publishError;
133112
133404
  } else if (publishError instanceof Error) {
133113
133405
  throw new src_client_KeetaNetClientError('CLIENT_PUBLISH_AID_NOT_AVAILABLE', `Publish Aid not available: ${publishError.message}`);