@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
package/client/index.js CHANGED
@@ -58059,6 +58059,7 @@ const client_1 = __importDefault(__webpack_require__(3642));
58059
58059
  const certificate_1 = __webpack_require__(5661);
58060
58060
  const certificate_2 = __webpack_require__(5661);
58061
58061
  const vote_1 = __webpack_require__(1130);
58062
+ const ledger_1 = __webpack_require__(452);
58062
58063
  function isGetAccountStateAPIResponseFailure(object) {
58063
58064
  if (typeof object !== 'object' || object === null) {
58064
58065
  return (false);
@@ -58369,10 +58370,10 @@ class Client {
58369
58370
  * @param account The account to fetch the information for
58370
58371
  * @return The account information
58371
58372
  */
58372
- async getAccountInfo(account) {
58373
+ async getAccountInfo(account, rep = 'ANY') {
58373
58374
  account = account_1.default.toAccount(account);
58374
58375
  const accountPubKey = account.publicKeyString.get();
58375
- const result = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_api).call(this, 'ANY', 'GET /node/ledger/account/:account', {
58376
+ const result = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_api).call(this, rep, 'GET /node/ledger/account/:account', {
58376
58377
  args: {
58377
58378
  account: accountPubKey
58378
58379
  }
@@ -59185,6 +59186,59 @@ class Client {
59185
59186
  }
59186
59187
  return (voteStaple);
59187
59188
  }
59189
+ /**
59190
+ * Sync any partially-published account artifacts
59191
+ *
59192
+ * @param account Account to sync
59193
+ * @param publish Publish the synced staple to the network (default is true)
59194
+ */
59195
+ async syncAccount(account, publish = true, reps) {
59196
+ await __classPrivateFieldGet(this, _Client_updateRepsPromise, "f");
59197
+ if (reps === undefined) {
59198
+ reps = this.representatives;
59199
+ }
59200
+ const repAccountInfoPromises = [];
59201
+ for (const rep of reps) {
59202
+ repAccountInfoPromises.push((async () => {
59203
+ const info = await this.getAccountInfo(account, rep);
59204
+ return ({
59205
+ rep,
59206
+ info
59207
+ });
59208
+ })());
59209
+ }
59210
+ const accountInfoSettled = await Promise.allSettled(repAccountInfoPromises);
59211
+ const accountInfo = [];
59212
+ for (const info of accountInfoSettled) {
59213
+ if (info.status === 'fulfilled') {
59214
+ accountInfo.push(info.value);
59215
+ }
59216
+ }
59217
+ const accountInfoSorted = accountInfo.sort(function (a, b) {
59218
+ return (Number(BigInt(a.info.currentHeadBlockHeight ?? -1) - BigInt(b.info.currentHeadBlockHeight ?? -1)));
59219
+ });
59220
+ if (accountInfoSorted[0].info.currentHeadBlockHeight === accountInfoSorted[accountInfoSorted.length - 1].info.currentHeadBlockHeight) {
59221
+ // Block Heights match so return
59222
+ return (null);
59223
+ }
59224
+ let lowestHead = accountInfoSorted[0].info.currentHeadBlock;
59225
+ if (lowestHead === null) {
59226
+ lowestHead = block_1.default.getAccountOpeningHash(account).toString();
59227
+ }
59228
+ // Get the missing successor block and vote staple from the rep with the highest block height
59229
+ const successorBlock = await this.getSuccessorBlock(lowestHead, accountInfoSorted[accountInfoSorted.length - 1].rep);
59230
+ if (successorBlock === null) {
59231
+ return (null);
59232
+ }
59233
+ const successorStaple = await this.getVoteStaple(successorBlock.hash, 'main', accountInfoSorted[accountInfoSorted.length - 1].rep);
59234
+ if (successorStaple === null) {
59235
+ return (null);
59236
+ }
59237
+ if (publish === true) {
59238
+ await this.transmitStaple(successorStaple, [accountInfoSorted[0].rep]);
59239
+ }
59240
+ return (successorStaple);
59241
+ }
59188
59242
  async getVoteQuotes(blocks) {
59189
59243
  return (await __classPrivateFieldGet(this, _Client_instances, "m", _Client_requestQuotes).call(this, blocks));
59190
59244
  }
@@ -59215,7 +59269,8 @@ async function _Client_apiRaw(rep, api, method, options = {}) {
59215
59269
  ...options
59216
59270
  };
59217
59271
  let delay = 1;
59218
- let result, resultThrow;
59272
+ let result;
59273
+ let resultThrow;
59219
59274
  for (let retry = 0; retry < Number.MAX_SAFE_INTEGER; retry++) {
59220
59275
  if (rep === 'ANY') {
59221
59276
  if (__classPrivateFieldGet(this, _Client_weightOrderedReps, "f").length === 0) {
@@ -59272,7 +59327,19 @@ async function _Client_apiRaw(rep, api, method, options = {}) {
59272
59327
  try {
59273
59328
  const errorInfo = await response.json();
59274
59329
  if (errorInfo.error === true) {
59275
- resultThrow = errorInfo;
59330
+ const keetaNetError = error_1.KeetaNetError.fromJSON(errorInfo);
59331
+ try {
59332
+ if (ledger_1.KeetaNetLedgerVoteError.isInstance(keetaNetError)) {
59333
+ for (const account of keetaNetError.accounts) {
59334
+ await this.syncAccount(account);
59335
+ }
59336
+ continue;
59337
+ }
59338
+ }
59339
+ catch {
59340
+ // ignored error parsing KeetaNet Error just return original
59341
+ }
59342
+ resultThrow = keetaNetError;
59276
59343
  break;
59277
59344
  }
59278
59345
  }
@@ -59335,14 +59402,8 @@ async function _Client_apiRaw(rep, api, method, options = {}) {
59335
59402
  break;
59336
59403
  }
59337
59404
  if (resultThrow) {
59338
- if (resultThrow.code && resultThrow.type) {
59339
- const error = new error_1.KeetaNetError(resultThrow.code, resultThrow.message);
59340
- error.type = resultThrow.type;
59341
- throw (error);
59342
- }
59343
- else {
59344
- throw (new Error(resultThrow.message));
59345
- }
59405
+ const toThrow = error_1.KeetaNetError.fromJSON(resultThrow);
59406
+ throw (toThrow);
59346
59407
  }
59347
59408
  return (result);
59348
59409
  }, _Client_api = async function _Client_api(rep, api, options = {}) {
@@ -59579,6 +59640,7 @@ async function _Client_apiRaw(rep, api, method, options = {}) {
59579
59640
  return ({
59580
59641
  account: lib_1.default.Account.fromPublicKeyString(accountInfo.account),
59581
59642
  currentHeadBlock: currentHeadBlock,
59643
+ currentHeadBlockHeight: accountInfo.currentHeadBlockHeight,
59582
59644
  representative: currentRepresentative,
59583
59645
  info: __classPrivateFieldGet(this, _Client_instances, "m", _Client_formatAccountInfo).call(this, accountInfo.info),
59584
59646
  balances: __classPrivateFieldGet(this, _Client_instances, "m", _Client_formatAllBalances).call(this, accountInfo.balances)
@@ -59872,7 +59934,7 @@ class UserClient {
59872
59934
  * @returns The vote staple that was generated and whether it was able to be published
59873
59935
  */
59874
59936
  async initializeNetwork(initOpts, options = {}) {
59875
- const { delegateTo = this.client.representatives[0].key, addSupplyAmount, voteSerial = 0n } = initOpts;
59937
+ const { delegateTo = this.client.representatives[0].key, addSupplyAmount, voteSerial = 0n, baseTokenInfo } = initOpts;
59876
59938
  if (this.signer === null) {
59877
59939
  throw (new Error('May not initialize chain with a read-only UserClient (signer is null)'));
59878
59940
  }
@@ -59885,7 +59947,8 @@ class UserClient {
59885
59947
  delegateTo: delegateTo,
59886
59948
  recipient: __classPrivateFieldGet(this, _UserClient_instances, "m", _UserClient_getAccount).call(this, options).assertAccount(),
59887
59949
  amount: addSupplyAmount
59888
- }
59950
+ },
59951
+ baseTokenInfo
59889
59952
  });
59890
59953
  return (await this.client.transmitStaple(voteStaple));
59891
59954
  }
@@ -59975,7 +60038,10 @@ class UserClient {
59975
60038
  * @param options options for publishing {@link PublishOptions }
59976
60039
  * @return The vote staple that was generated and whether it was able to be published
59977
60040
  */
59978
- async publishBuilder(builder, options = { generateFeeBlock: __classPrivateFieldGet(this, _UserClient_config, "f").generateFeeBlock }) {
60041
+ async publishBuilder(builder, options = {}) {
60042
+ if (options.generateFeeBlock === undefined) {
60043
+ options.generateFeeBlock = __classPrivateFieldGet(this, _UserClient_config, "f").generateFeeBlock;
60044
+ }
59979
60045
  if (!__classPrivateFieldGet(this, _UserClient_config, "f").usePublishAid) {
59980
60046
  return (await __classPrivateFieldGet(this, _UserClient_client, "f").transmitBuilder(builder, this.network, options));
59981
60047
  }
@@ -60031,16 +60097,19 @@ class UserClient {
60031
60097
  try {
60032
60098
  const builder = this.initBuilder(options);
60033
60099
  builder.send(account_1.default.toAccount(to), BigInt(amount), account_1.default.toAccount(token), external);
60034
- return (await this.publishBuilder(builder));
60100
+ const publish = await this.publishBuilder(builder);
60101
+ return (publish);
60035
60102
  }
60036
60103
  catch (transmitError) {
60037
60104
  let error = true;
60038
60105
  if (retries < 2) {
60039
- if (error_1.KeetaNetError.isInstance(transmitError) && transmitError.code === 'LEDGER_SUCCESSOR_VOTE_EXISTS') {
60040
- const staple = await this.recover(true, options);
60041
- if (staple) {
60042
- error = false;
60043
- return (await this.send(to, amount, token, external, options, retries + 1));
60106
+ if (error_1.KeetaNetError.isInstance(transmitError)) {
60107
+ if (transmitError.code === 'LEDGER_SUCCESSOR_VOTE_EXISTS') {
60108
+ const staple = await this.recover(true, options);
60109
+ if (staple) {
60110
+ error = false;
60111
+ return (await this.send(to, amount, token, external, options, retries + 1));
60112
+ }
60044
60113
  }
60045
60114
  }
60046
60115
  }
@@ -60246,6 +60315,16 @@ class UserClient {
60246
60315
  async recover(publish, options = {}) {
60247
60316
  return (await __classPrivateFieldGet(this, _UserClient_client, "f").recoverAccount(__classPrivateFieldGet(this, _UserClient_instances, "m", _UserClient_getAccount).call(this, options), publish));
60248
60317
  }
60318
+ /**
60319
+ * Sync any partially-published account artifacts
60320
+ *
60321
+ * @param publish Publish the recovered staple to the network
60322
+ * (default: true)
60323
+ * @param options User client options (common options)
60324
+ */
60325
+ async sync(publish, options = {}) {
60326
+ return (await __classPrivateFieldGet(this, _UserClient_client, "f").syncAccount(__classPrivateFieldGet(this, _UserClient_instances, "m", _UserClient_getAccount).call(this, options), publish));
60327
+ }
60249
60328
  /**
60250
60329
  * Register a callback for change messages and set up a websocket filtered to our account only.
60251
60330
  * Also set up long timeout polling for changes in case the websocket misses a change update
@@ -64925,10 +65004,11 @@ function ImportOperationsASN1(input, network) {
64925
65004
  "use strict";
64926
65005
 
64927
65006
  Object.defineProperty(exports, "__esModule", ({ value: true }));
64928
- const _1 = __webpack_require__(5390);
65007
+ exports.FullAccountErrorCodes = exports.AccountErrorCodes = void 0;
65008
+ const base_1 = __webpack_require__(1096);
64929
65009
  const helper_1 = __webpack_require__(3208);
64930
65010
  const AccountErrorType = 'ACCOUNT';
64931
- const AccountErrorCodes = [
65011
+ exports.AccountErrorCodes = [
64932
65012
  'INVALID_PREFIX',
64933
65013
  'INVALID_KEYTYPE',
64934
65014
  'INVALID_KEYTYPE_EXTERNAL',
@@ -64943,15 +65023,85 @@ const AccountErrorCodes = [
64943
65023
  'SEED_INDEX_TOO_LARGE',
64944
65024
  'ENCRYPTION_NOT_SUPPORTED'
64945
65025
  ];
64946
- class KeetaNetAccountError extends _1.KeetaNetError {
65026
+ exports.FullAccountErrorCodes = exports.AccountErrorCodes.map(code => `${AccountErrorType}_${code}`);
65027
+ class KeetaNetAccountError extends base_1.KeetaNetErrorBase {
64947
65028
  constructor(code, message) {
64948
- super(code, message, { type: AccountErrorType, codes: AccountErrorCodes });
65029
+ super(code, message, { type: AccountErrorType, codes: exports.AccountErrorCodes });
64949
65030
  }
64950
65031
  }
64951
65032
  KeetaNetAccountError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetAccountError);
64952
65033
  exports["default"] = KeetaNetAccountError;
64953
65034
 
64954
65035
 
65036
+ /***/ }),
65037
+
65038
+ /***/ 7533:
65039
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
65040
+
65041
+ "use strict";
65042
+
65043
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
65044
+ exports.FullAPIErrorCodes = exports.APIErrorCodes = void 0;
65045
+ const base_1 = __webpack_require__(1096);
65046
+ const helper_1 = __webpack_require__(3208);
65047
+ const APIErrorType = 'API';
65048
+ exports.APIErrorCodes = [
65049
+ 'INVALID_LIMIT',
65050
+ 'INVALID_SIDE',
65051
+ 'INVALID_START',
65052
+ 'LIMIT_NOT_NUMBER',
65053
+ 'LIMIT_NOT_GREATER_THAN_ZERO',
65054
+ 'REP_MISSING',
65055
+ 'START_MISSING'
65056
+ ];
65057
+ exports.FullAPIErrorCodes = exports.APIErrorCodes.map(code => `${APIErrorType}_${code}`);
65058
+ class KeetaNetAPIError extends base_1.KeetaNetErrorBase {
65059
+ constructor(code, message) {
65060
+ super(code, message, { type: APIErrorType, codes: exports.APIErrorCodes });
65061
+ }
65062
+ }
65063
+ KeetaNetAPIError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetAPIError);
65064
+ exports["default"] = KeetaNetAPIError;
65065
+
65066
+
65067
+ /***/ }),
65068
+
65069
+ /***/ 1096:
65070
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
65071
+
65072
+ "use strict";
65073
+
65074
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
65075
+ exports.KeetaNetErrorBase = void 0;
65076
+ const helper_1 = __webpack_require__(3208);
65077
+ class KeetaNetErrorBase extends Error {
65078
+ constructor(code, message, validation) {
65079
+ super(message);
65080
+ const type = validation?.type || 'GENERIC';
65081
+ if (validation !== undefined) {
65082
+ const prefix = `${validation.type}_`;
65083
+ const validPrefix = code.startsWith(prefix);
65084
+ const withoutPrefix = code.substring(prefix.length);
65085
+ const validCode = validation.codes.includes(withoutPrefix);
65086
+ if (!validPrefix || !validCode) {
65087
+ throw (new Error(`Invalid construction of KeetaNetError Type: ${validation.type} Code: ${code}, prefix ${prefix} valid ${validPrefix} valid code: ${validCode}`));
65088
+ }
65089
+ }
65090
+ this.code = code;
65091
+ this.type = type;
65092
+ }
65093
+ toJSON() {
65094
+ return ({
65095
+ type: this.type,
65096
+ code: this.code,
65097
+ message: this.message
65098
+ });
65099
+ }
65100
+ }
65101
+ exports.KeetaNetErrorBase = KeetaNetErrorBase;
65102
+ KeetaNetErrorBase.isInstance = (0, helper_1.checkableGenerator)(KeetaNetErrorBase, false);
65103
+
65104
+
64955
65105
  /***/ }),
64956
65106
 
64957
65107
  /***/ 7412:
@@ -64960,10 +65110,11 @@ exports["default"] = KeetaNetAccountError;
64960
65110
  "use strict";
64961
65111
 
64962
65112
  Object.defineProperty(exports, "__esModule", ({ value: true }));
64963
- const _1 = __webpack_require__(5390);
65113
+ exports.FullBlockErrorCodes = exports.BlockErrorCodes = void 0;
65114
+ const base_1 = __webpack_require__(1096);
64964
65115
  const helper_1 = __webpack_require__(3208);
64965
65116
  const BlockErrorType = 'BLOCK';
64966
- const BlockErrorCodes = [
65117
+ exports.BlockErrorCodes = [
64967
65118
  'INVALID_TYPE',
64968
65119
  'INVALID_VERSION',
64969
65120
  'NO_MULTIPLE_SET_REP',
@@ -65004,9 +65155,10 @@ const BlockErrorCodes = [
65004
65155
  'EXTERNAL_MISSING',
65005
65156
  'SUPPLY_INVALID'
65006
65157
  ];
65007
- class KeetaNetBlockError extends _1.KeetaNetError {
65158
+ exports.FullBlockErrorCodes = exports.BlockErrorCodes.map(code => `${BlockErrorType}_${code}`);
65159
+ class KeetaNetBlockError extends base_1.KeetaNetErrorBase {
65008
65160
  constructor(code, message) {
65009
- super(code, message, { type: BlockErrorType, codes: BlockErrorCodes });
65161
+ super(code, message, { type: BlockErrorType, codes: exports.BlockErrorCodes });
65010
65162
  }
65011
65163
  }
65012
65164
  KeetaNetBlockError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetBlockError);
@@ -65021,10 +65173,11 @@ exports["default"] = KeetaNetBlockError;
65021
65173
  "use strict";
65022
65174
 
65023
65175
  Object.defineProperty(exports, "__esModule", ({ value: true }));
65024
- const _1 = __webpack_require__(5390);
65176
+ exports.FullCertificateErrorCodes = exports.CertificateErrorCodes = void 0;
65177
+ const base_1 = __webpack_require__(1096);
65025
65178
  const helper_1 = __webpack_require__(3208);
65026
65179
  const CertificateErrorType = 'CERTIFICATE';
65027
- const BlockErrorCodes = [
65180
+ exports.CertificateErrorCodes = [
65028
65181
  'DUPLICATE_INCLUDED',
65029
65182
  'ORPHAN_FOUND',
65030
65183
  'CYCLE_FOUND',
@@ -65040,9 +65193,10 @@ const BlockErrorCodes = [
65040
65193
  'MOMENT_INVALID',
65041
65194
  'INVALID_VERSION'
65042
65195
  ];
65043
- class KeetaNetCertificateError extends _1.KeetaNetError {
65196
+ exports.FullCertificateErrorCodes = exports.CertificateErrorCodes.map(code => `${CertificateErrorType}_${code}`);
65197
+ class KeetaNetCertificateError extends base_1.KeetaNetErrorBase {
65044
65198
  constructor(code, message) {
65045
- super(code, message, { type: CertificateErrorType, codes: BlockErrorCodes });
65199
+ super(code, message, { type: CertificateErrorType, codes: exports.CertificateErrorCodes });
65046
65200
  }
65047
65201
  }
65048
65202
  KeetaNetCertificateError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetCertificateError);
@@ -65057,10 +65211,11 @@ exports["default"] = KeetaNetCertificateError;
65057
65211
  "use strict";
65058
65212
 
65059
65213
  Object.defineProperty(exports, "__esModule", ({ value: true }));
65060
- const _1 = __webpack_require__(5390);
65214
+ exports.FullClientErrorCodes = exports.ClientErrorCodes = void 0;
65215
+ const base_1 = __webpack_require__(1096);
65061
65216
  const helper_1 = __webpack_require__(3208);
65062
65217
  const ClientErrorType = 'CLIENT';
65063
- const ClientErrorCodes = [
65218
+ exports.ClientErrorCodes = [
65064
65219
  'BUILDER_AMOUNT_IS_ZERO',
65065
65220
  'BUILDER_CANNOT_READ_BEFORE_RENDER',
65066
65221
  'BUILDER_REQUIRES_PRIVATE_KEY',
@@ -65068,9 +65223,10 @@ const ClientErrorCodes = [
65068
65223
  'PUBLISH_AID_NOT_AVAILABLE',
65069
65224
  'SIGNER_REQUIRES_PRIVATE_KEY'
65070
65225
  ];
65071
- class KeetaNetClientError extends _1.KeetaNetError {
65226
+ exports.FullClientErrorCodes = exports.ClientErrorCodes.map(code => `${ClientErrorType}_${code}`);
65227
+ class KeetaNetClientError extends base_1.KeetaNetErrorBase {
65072
65228
  constructor(code, message) {
65073
- super(code, message, { type: ClientErrorType, codes: ClientErrorCodes });
65229
+ super(code, message, { type: ClientErrorType, codes: exports.ClientErrorCodes });
65074
65230
  }
65075
65231
  }
65076
65232
  KeetaNetClientError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetClientError);
@@ -65080,41 +65236,135 @@ exports["default"] = KeetaNetClientError;
65080
65236
  /***/ }),
65081
65237
 
65082
65238
  /***/ 5390:
65083
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
65239
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
65084
65240
 
65085
65241
  "use strict";
65086
65242
 
65243
+ var __importDefault = (this && this.__importDefault) || function (mod) {
65244
+ return (mod && mod.__esModule) ? mod : { "default": mod };
65245
+ };
65087
65246
  Object.defineProperty(exports, "__esModule", ({ value: true }));
65088
65247
  exports.KeetaNetError = void 0;
65089
65248
  exports.ExpectErrorCode = ExpectErrorCode;
65090
- const helper_1 = __webpack_require__(3208);
65249
+ const account_1 = __importDefault(__webpack_require__(9415));
65250
+ const account_2 = __webpack_require__(4642);
65251
+ const api_1 = __webpack_require__(7533);
65252
+ const base_1 = __webpack_require__(1096);
65253
+ const block_1 = __webpack_require__(7412);
65254
+ const certificate_1 = __webpack_require__(9890);
65255
+ const client_1 = __webpack_require__(3642);
65256
+ const kv_1 = __webpack_require__(9272);
65257
+ const ledger_1 = __webpack_require__(452);
65258
+ const permissions_1 = __webpack_require__(2105);
65259
+ const vote_1 = __webpack_require__(3689);
65260
+ const allErrorCodesWithoutPrefix = [
65261
+ ...account_2.AccountErrorCodes,
65262
+ ...api_1.APIErrorCodes,
65263
+ ...block_1.BlockErrorCodes,
65264
+ ...certificate_1.CertificateErrorCodes,
65265
+ ...client_1.ClientErrorCodes,
65266
+ ...kv_1.KVErrorCodes,
65267
+ ...ledger_1.LedgerBaseErrorCodes,
65268
+ ...ledger_1.LedgerVoteErrorCodes,
65269
+ ...permissions_1.PermissionsErrorCodes,
65270
+ ...vote_1.VoteErrorCodes
65271
+ ];
65272
+ const allFullErrorCodes = [
65273
+ ...account_2.FullAccountErrorCodes,
65274
+ ...api_1.FullAPIErrorCodes,
65275
+ ...block_1.FullBlockErrorCodes,
65276
+ ...certificate_1.FullCertificateErrorCodes,
65277
+ ...client_1.FullClientErrorCodes,
65278
+ ...kv_1.FullKVErrorCodes,
65279
+ ...ledger_1.FullLedgerErrorCodes,
65280
+ ...permissions_1.FullPermissionsErrorCodes,
65281
+ ...vote_1.FullVoteErrorCodes
65282
+ ];
65283
+ const errorCodeSet = new Set(allFullErrorCodes);
65091
65284
  async function ExpectErrorCode(code, test) {
65092
65285
  await expect(test).rejects.toThrow(expect.objectContaining({
65093
65286
  code: code
65094
65287
  }));
65095
65288
  }
65096
- class KeetaNetError extends Error {
65097
- constructor(code, message, validation) {
65098
- super(message);
65099
- let type = validation?.type;
65100
- if (!type) {
65101
- type = 'GENERIC';
65289
+ class KeetaNetError extends base_1.KeetaNetErrorBase {
65290
+ static assertValidErrorCode(code) {
65291
+ return (errorCodeSet.has(code));
65292
+ }
65293
+ static fromJSON(json) {
65294
+ if (typeof json === 'object' && json !== null && 'type' in json && 'code' in json && 'message' in json) {
65295
+ const { type, code, message } = json;
65296
+ if (typeof type !== 'string' || typeof code !== 'string' || typeof message !== 'string') {
65297
+ return (new Error('Invalid JSON for KeetaNetError (bad type or code or message)'));
65298
+ }
65299
+ if (type === 'LEDGER') {
65300
+ let shouldRetry;
65301
+ let retryDelay;
65302
+ if ('shouldRetry' in json) {
65303
+ if (typeof json.shouldRetry !== 'boolean') {
65304
+ return (new Error('Invalid JSON for KeetaNetLedgerError (bad shouldRetry)'));
65305
+ }
65306
+ shouldRetry = json.shouldRetry;
65307
+ }
65308
+ if ('retryDelay' in json) {
65309
+ if (typeof json.retryDelay !== 'number') {
65310
+ return (new Error('Invalid JSON for KeetaNetLedgerError (bad retryDelay)'));
65311
+ }
65312
+ retryDelay = json.retryDelay;
65313
+ }
65314
+ if (ledger_1.KeetaNetLedgerVoteError.assertValidLedgerErrorCode(code)) {
65315
+ if (!('accounts' in json) || !Array.isArray(json.accounts)) {
65316
+ return (new Error('Invalid JSON for KeetaNetLedgerVoteError (bad accounts)'));
65317
+ }
65318
+ const accountsArray = json.accounts.map((account) => {
65319
+ return (account_1.default.fromPublicKeyString(account));
65320
+ });
65321
+ const accounts = new account_1.default.Set(accountsArray);
65322
+ return (new ledger_1.KeetaNetLedgerVoteError(code, message, accounts));
65323
+ }
65324
+ else if (ledger_1.KeetaNetLedgerError.assertValidLedgerErrorCode(code)) {
65325
+ return (new ledger_1.KeetaNetLedgerError(code, message, shouldRetry, retryDelay));
65326
+ }
65327
+ }
65328
+ if (this.assertValidErrorCode(code)) {
65329
+ return (new KeetaNetError(code, message, { type, codes: allErrorCodesWithoutPrefix }));
65330
+ }
65102
65331
  }
65103
- if (validation !== undefined) {
65104
- const prefix = `${validation.type}_`;
65105
- const validPrefix = code.startsWith(prefix);
65106
- const withoutPrefix = code.substring(prefix.length);
65107
- const validCode = validation.codes.includes(withoutPrefix);
65108
- if (!validPrefix || !validCode) {
65109
- throw (new Error(`Invalid construction of KeetaNetError Type: ${validation.type} Code: ${code}, prefix ${prefix} valid ${validPrefix} valid code: ${validCode}`));
65332
+ if (typeof json === 'object' && json !== null && 'message' in json) {
65333
+ if (typeof json.message !== 'string') {
65334
+ return (new Error('Invalid JSON for KeetaNetError (bad message)'));
65110
65335
  }
65336
+ return (new Error(json.message));
65111
65337
  }
65112
- this.code = code;
65113
- this.type = type;
65338
+ return (new Error('Unknown error'));
65114
65339
  }
65115
65340
  }
65116
65341
  exports.KeetaNetError = KeetaNetError;
65117
- KeetaNetError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetError, false);
65342
+
65343
+
65344
+ /***/ }),
65345
+
65346
+ /***/ 9272:
65347
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
65348
+
65349
+ "use strict";
65350
+
65351
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
65352
+ exports.FullKVErrorCodes = exports.KVErrorCodes = void 0;
65353
+ const base_1 = __webpack_require__(1096);
65354
+ const helper_1 = __webpack_require__(3208);
65355
+ const KVErrorType = 'KV';
65356
+ exports.KVErrorCodes = [
65357
+ 'TTL_NOT_SUPPORTED',
65358
+ 'KEY_ALREADY_EXISTS'
65359
+ ];
65360
+ exports.FullKVErrorCodes = exports.KVErrorCodes.map(code => `${KVErrorType}_${code}`);
65361
+ class KeetaNetKVError extends base_1.KeetaNetErrorBase {
65362
+ constructor(code, message) {
65363
+ super(code, message, { type: KVErrorType, codes: exports.KVErrorCodes });
65364
+ }
65365
+ }
65366
+ KeetaNetKVError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetKVError);
65367
+ exports["default"] = KeetaNetKVError;
65118
65368
 
65119
65369
 
65120
65370
  /***/ }),
@@ -65125,22 +65375,20 @@ KeetaNetError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetError, false
65125
65375
  "use strict";
65126
65376
 
65127
65377
  Object.defineProperty(exports, "__esModule", ({ value: true }));
65128
- exports.KeetaNetLedgerError = void 0;
65129
- const _1 = __webpack_require__(5390);
65378
+ exports.KeetaNetLedgerVoteError = exports.KeetaNetLedgerError = exports.FullLedgerVoteErrorCodes = exports.FullLedgerBaseErrorCode = exports.FullLedgerErrorCodes = exports.LedgerVoteErrorCodes = exports.LedgerBaseErrorCodes = void 0;
65379
+ const base_1 = __webpack_require__(1096);
65130
65380
  const helper_1 = __webpack_require__(3208);
65131
65381
  const LedgerErrorType = 'LEDGER';
65132
- const LedgerErrorCodes = [
65382
+ exports.LedgerBaseErrorCodes = [
65133
65383
  'BLOCK_ALREADY_EXISTS',
65134
65384
  'TRANSACTION_ABORTED',
65135
65385
  'INVALID_CHAIN',
65136
65386
  'INVALID_NETWORK',
65137
65387
  'INVALID_SUBNET',
65138
- 'NOT_EMPTY',
65139
- 'NOT_OPENING',
65140
- 'NOT_SUCCESSOR',
65141
65388
  'INVALID_PERMISSIONS',
65142
65389
  'INVALID_OWNER_COUNT',
65143
65390
  'INVALID_BALANCE',
65391
+ 'NOT_EMPTY',
65144
65392
  'PREVIOUS_ALREADY_USED',
65145
65393
  'PREVIOUS_NOT_SEEN',
65146
65394
  'SUCCESSOR_VOTE_EXISTS',
@@ -65163,9 +65411,22 @@ const LedgerErrorCodes = [
65163
65411
  'QUOTE_MISMATCH',
65164
65412
  'REQUIRED_FEE_MISMATCH'
65165
65413
  ];
65166
- class KeetaNetLedgerError extends _1.KeetaNetError {
65414
+ // Errors that can trigger rep sync
65415
+ exports.LedgerVoteErrorCodes = [
65416
+ 'NOT_SUCCESSOR',
65417
+ 'NOT_OPENING'
65418
+ ];
65419
+ exports.FullLedgerErrorCodes = [...exports.LedgerBaseErrorCodes, ...exports.LedgerVoteErrorCodes].map(code => `${LedgerErrorType}_${code}`);
65420
+ exports.FullLedgerBaseErrorCode = exports.LedgerBaseErrorCodes.map(code => `${LedgerErrorType}_${code}`);
65421
+ exports.FullLedgerVoteErrorCodes = exports.LedgerVoteErrorCodes.map(code => `${LedgerErrorType}_${code}`);
65422
+ const ledgerBaseErrorCodeSet = new Set(exports.FullLedgerBaseErrorCode);
65423
+ const ledgerVoteErrorCodeSet = new Set(exports.FullLedgerVoteErrorCodes);
65424
+ class KeetaNetLedgerError extends base_1.KeetaNetErrorBase {
65425
+ static assertValidLedgerErrorCode(code) {
65426
+ return (ledgerBaseErrorCodeSet.has(code));
65427
+ }
65167
65428
  constructor(code, message, shouldRetry = false, retryDelay) {
65168
- super(code, message, { type: LedgerErrorType, codes: LedgerErrorCodes });
65429
+ super(code, message, { type: LedgerErrorType, codes: exports.LedgerBaseErrorCodes });
65169
65430
  this.type = LedgerErrorType;
65170
65431
  this.shouldRetry = shouldRetry;
65171
65432
  if (shouldRetry && retryDelay !== undefined) {
@@ -65175,7 +65436,27 @@ class KeetaNetLedgerError extends _1.KeetaNetError {
65175
65436
  }
65176
65437
  exports.KeetaNetLedgerError = KeetaNetLedgerError;
65177
65438
  KeetaNetLedgerError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetLedgerError);
65178
- exports["default"] = KeetaNetLedgerError;
65439
+ class KeetaNetLedgerVoteError extends base_1.KeetaNetErrorBase {
65440
+ static assertValidLedgerErrorCode(code) {
65441
+ return (ledgerVoteErrorCodeSet.has(code));
65442
+ }
65443
+ constructor(code, message, accounts) {
65444
+ super(code, message, { type: LedgerErrorType, codes: exports.LedgerVoteErrorCodes });
65445
+ this.type = LedgerErrorType;
65446
+ this.shouldRetry = false;
65447
+ this.accounts = accounts;
65448
+ }
65449
+ toJSON() {
65450
+ return ({
65451
+ ...super.toJSON(),
65452
+ accounts: [...this.accounts.values()].map(function (account) {
65453
+ return (account.publicKeyString.get());
65454
+ })
65455
+ });
65456
+ }
65457
+ }
65458
+ exports.KeetaNetLedgerVoteError = KeetaNetLedgerVoteError;
65459
+ KeetaNetLedgerVoteError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetLedgerVoteError);
65179
65460
 
65180
65461
 
65181
65462
  /***/ }),
@@ -65186,19 +65467,21 @@ exports["default"] = KeetaNetLedgerError;
65186
65467
  "use strict";
65187
65468
 
65188
65469
  Object.defineProperty(exports, "__esModule", ({ value: true }));
65189
- const _1 = __webpack_require__(5390);
65470
+ exports.FullPermissionsErrorCodes = exports.PermissionsErrorCodes = void 0;
65471
+ const base_1 = __webpack_require__(1096);
65190
65472
  const helper_1 = __webpack_require__(3208);
65191
65473
  const PermissionsErrorType = 'PERMISSIONS';
65192
- const PermissionsErrorCodes = [
65474
+ exports.PermissionsErrorCodes = [
65193
65475
  'CANNOT_MIX_FLAGS_AND_TYPES',
65194
65476
  'EXTERNAL_OFFSET_TOO_LARGE',
65195
65477
  'INVALID_EXTERNAL_FLAG',
65196
65478
  'INVALID_FLAG',
65197
65479
  'INVALID_FLAG_ASSERTION'
65198
65480
  ];
65199
- class KeetaNetPermissionsError extends _1.KeetaNetError {
65481
+ exports.FullPermissionsErrorCodes = exports.PermissionsErrorCodes.map(code => `${PermissionsErrorType}_${code}`);
65482
+ class KeetaNetPermissionsError extends base_1.KeetaNetErrorBase {
65200
65483
  constructor(code, message) {
65201
- super(code, message, { type: PermissionsErrorType, codes: PermissionsErrorCodes });
65484
+ super(code, message, { type: PermissionsErrorType, codes: exports.PermissionsErrorCodes });
65202
65485
  }
65203
65486
  }
65204
65487
  KeetaNetPermissionsError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetPermissionsError);
@@ -65213,10 +65496,11 @@ exports["default"] = KeetaNetPermissionsError;
65213
65496
  "use strict";
65214
65497
 
65215
65498
  Object.defineProperty(exports, "__esModule", ({ value: true }));
65216
- const _1 = __webpack_require__(5390);
65499
+ exports.FullVoteErrorCodes = exports.VoteErrorCodes = void 0;
65500
+ const base_1 = __webpack_require__(1096);
65217
65501
  const helper_1 = __webpack_require__(3208);
65218
65502
  const VoteErrorType = 'VOTE';
65219
- const VoteErrorCodes = [
65503
+ exports.VoteErrorCodes = [
65220
65504
  // Errors related to Vote
65221
65505
  'SERIAL_MISMATCH',
65222
65506
  'INVALID_VERSION',
@@ -65301,9 +65585,10 @@ const VoteErrorCodes = [
65301
65585
  'MALFORMED_FEES_KIND_MISSING',
65302
65586
  'MALFORMED_FEES_QUOTE_INVALID'
65303
65587
  ];
65304
- class KeetaNetVoteError extends _1.KeetaNetError {
65588
+ exports.FullVoteErrorCodes = exports.VoteErrorCodes.map(code => `${VoteErrorType}_${code}`);
65589
+ class KeetaNetVoteError extends base_1.KeetaNetErrorBase {
65305
65590
  constructor(code, message) {
65306
- super(code, message, { type: VoteErrorType, codes: VoteErrorCodes });
65591
+ super(code, message, { type: VoteErrorType, codes: exports.VoteErrorCodes });
65307
65592
  }
65308
65593
  }
65309
65594
  KeetaNetVoteError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetVoteError);
@@ -65663,7 +65948,7 @@ exports.assertLedgerStorage = assertLedgerStorage;
65663
65948
  const account_1 = __importStar(__webpack_require__(9415));
65664
65949
  const block_1 = __webpack_require__(6158);
65665
65950
  const permissions_1 = __webpack_require__(5860);
65666
- const ledger_1 = __importDefault(__webpack_require__(452));
65951
+ const ledger_1 = __webpack_require__(452);
65667
65952
  const helper_1 = __webpack_require__(3208);
65668
65953
  const config_1 = __webpack_require__(1491);
65669
65954
  const block_2 = __importDefault(__webpack_require__(7412));
@@ -66097,6 +66382,26 @@ class LedgerStorageBase {
66097
66382
  }));
66098
66383
  return (Object.fromEntries(response));
66099
66384
  }
66385
+ async getAccountsBlockHeightInfo(transaction, toFetch) {
66386
+ const response = await Promise.all(toFetch.map(async ({ blockHash, account }) => {
66387
+ if (blockHash === undefined) {
66388
+ const block = await this.getHeadBlock(transaction, account, 'main');
66389
+ if (block !== null) {
66390
+ blockHash = block.hash;
66391
+ }
66392
+ }
66393
+ const retval = [];
66394
+ if (blockHash === undefined) {
66395
+ retval.push(...[account.publicKeyString.get(), null]);
66396
+ }
66397
+ else {
66398
+ const height = await this.getBlockHeight(transaction, blockHash, account);
66399
+ retval.push(...[account.publicKeyString.get(), { blockHash, height }]);
66400
+ }
66401
+ return (retval);
66402
+ }));
66403
+ return (Object.fromEntries(response));
66404
+ }
66100
66405
  async getHeadBlockHashes(transaction, accounts) {
66101
66406
  const received = await this.getHeadBlocks(transaction, accounts.toArray(), 'both');
66102
66407
  return (Object.fromEntries(Object.entries(received).map(function ([account, value]) {
@@ -66116,7 +66421,7 @@ class LedgerStorageBase {
66116
66421
  // Check if any blocks already exist on the ledger that would cause this staple to fail and exit early
66117
66422
  for (const [blockHash, blockHeight] of Object.entries(allBlockHeights)) {
66118
66423
  if (blockHeight !== null) {
66119
- throw (new ledger_1.default('LEDGER_BLOCK_ALREADY_EXISTS', `Block Already Exists: ${blockHash.toString()}`));
66424
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_BLOCK_ALREADY_EXISTS', `Block Already Exists: ${blockHash.toString()}`));
66120
66425
  }
66121
66426
  }
66122
66427
  const seenBlockHashes = new block_1.BlockHash.Set();
@@ -66204,7 +66509,7 @@ class LedgerStorageBase {
66204
66509
  return (validKeys.includes(key) === false);
66205
66510
  });
66206
66511
  if (foundBannedKey !== undefined) {
66207
- throw (new ledger_1.default('LEDGER_INVALID_ACCOUNT_INFO_KEY', `Invalid AccountInfo field ${foundBannedKey}`));
66512
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_ACCOUNT_INFO_KEY', `Invalid AccountInfo field ${foundBannedKey}`));
66208
66513
  }
66209
66514
  }
66210
66515
  /**
@@ -67196,7 +67501,7 @@ const block_1 = __webpack_require__(6158);
67196
67501
  const account_1 = __importDefault(__webpack_require__(9415));
67197
67502
  const common_1 = __webpack_require__(5663);
67198
67503
  const helper_1 = __webpack_require__(3208);
67199
- const ledger_1 = __importDefault(__webpack_require__(452));
67504
+ const ledger_1 = __webpack_require__(452);
67200
67505
  const permissions_1 = __webpack_require__(5860);
67201
67506
  const effects_1 = __webpack_require__(7346);
67202
67507
  const conversion_1 = __webpack_require__(2360);
@@ -67272,7 +67577,7 @@ class LedgerAtomicInterface {
67272
67577
  }
67273
67578
  async vote(blocks, otherVotes, quote) {
67274
67579
  if (blocks.length === 0) {
67275
- throw (new ledger_1.default('LEDGER_MISSING_BLOCKS', 'At least one block is required to issue a vote'));
67580
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_MISSING_BLOCKS', 'At least one block is required to issue a vote'));
67276
67581
  }
67277
67582
  if (!__classPrivateFieldGet(this, _LedgerAtomicInterface_privateKey, "f")) {
67278
67583
  throw (new Error('Cannot vote on block, no private key loaded'));
@@ -67284,10 +67589,10 @@ class LedgerAtomicInterface {
67284
67589
  const ledgerPubKey = privateKey.publicKeyString.get();
67285
67590
  if (quote !== undefined) {
67286
67591
  if (otherVotes !== undefined) {
67287
- throw (new ledger_1.default('LEDGER_PERM_VOTE_WITH_QUOTE', 'Quote should not be included when requesting permanent votes'));
67592
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_PERM_VOTE_WITH_QUOTE', 'Quote should not be included when requesting permanent votes'));
67288
67593
  }
67289
67594
  if (!quote.issuer.comparePublicKey(ledgerPubKey)) {
67290
- throw (new ledger_1.default('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match issuer public key'));
67595
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match issuer public key'));
67291
67596
  }
67292
67597
  }
67293
67598
  const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
@@ -67296,13 +67601,13 @@ class LedgerAtomicInterface {
67296
67601
  * us and the blocks are in the same order as the set of
67297
67602
  * blocks we are voting on now
67298
67603
  */
67604
+ let hasFeeBlock = false;
67299
67605
  if (otherVotes !== undefined) {
67300
67606
  let foundOurVote = false;
67301
67607
  const seenVoteUIDs = new Set();
67302
67608
  const seenVoteIssuers = new account_1.default.Set();
67303
- const possibleFeeBlock = blocks.at(-1);
67304
- let hasFeeBlock = false;
67305
67609
  let blockCount = blocks.length;
67610
+ const possibleFeeBlock = blocks.at(-1);
67306
67611
  if (possibleFeeBlock?.purpose === block_1.BlockPurpose.FEE) {
67307
67612
  hasFeeBlock = true;
67308
67613
  blockCount--;
@@ -67310,13 +67615,13 @@ class LedgerAtomicInterface {
67310
67615
  const requiredFees = new Map();
67311
67616
  for (const checkVote of otherVotes) {
67312
67617
  if (checkVote.quote === true) {
67313
- throw (new ledger_1.default('LEDGER_PERM_VOTE_WITH_QUOTE', 'Cannot request permanent votes with quotes'));
67618
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_PERM_VOTE_WITH_QUOTE', 'Cannot request permanent votes with quotes'));
67314
67619
  }
67315
67620
  if (seenVoteUIDs.has(checkVote.$id)) {
67316
- throw (new ledger_1.default('LEDGER_DUPLICATE_VOTE_FOUND', 'Duplicate vote UID found'));
67621
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_DUPLICATE_VOTE_FOUND', 'Duplicate vote UID found'));
67317
67622
  }
67318
67623
  if (seenVoteIssuers.has(checkVote.issuer)) {
67319
- throw (new ledger_1.default('LEDGER_DUPLICATE_VOTE_ISSUER_FOUND', 'Multiple votes found from same issuer'));
67624
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_DUPLICATE_VOTE_ISSUER_FOUND', 'Multiple votes found from same issuer'));
67320
67625
  }
67321
67626
  seenVoteIssuers.add(checkVote.issuer);
67322
67627
  seenVoteUIDs.add(checkVote.$id);
@@ -67324,7 +67629,7 @@ class LedgerAtomicInterface {
67324
67629
  requiredFees.set(checkVote.issuer, checkVote.fee);
67325
67630
  }
67326
67631
  if (checkVote.$permanent) {
67327
- throw (new ledger_1.default('LEDGER_CANNOT_EXCHANGE_PERM_VOTE', 'Asked to exchange a permanent vote for a permanent vote'));
67632
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_CANNOT_EXCHANGE_PERM_VOTE', 'Asked to exchange a permanent vote for a permanent vote'));
67328
67633
  }
67329
67634
  let blocksDifferFromVoteBlocks = checkVote.blocks.length !== blockCount;
67330
67635
  /* If they do not differ from length alone, compare block hashes */
@@ -67337,7 +67642,7 @@ class LedgerAtomicInterface {
67337
67642
  }
67338
67643
  }
67339
67644
  if (blocksDifferFromVoteBlocks) {
67340
- throw (new ledger_1.default('LEDGER_BLOCKS_DIFFER_FROM_VOTED_ON', 'Asked to exchange different number of blocks for a permanent vote'));
67645
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_BLOCKS_DIFFER_FROM_VOTED_ON', 'Asked to exchange different number of blocks for a permanent vote'));
67341
67646
  }
67342
67647
  if (checkVote.issuer.comparePublicKey(ledgerPubKey)) {
67343
67648
  foundOurVote = true;
@@ -67345,10 +67650,10 @@ class LedgerAtomicInterface {
67345
67650
  }
67346
67651
  if (requiredFees.size > 0) {
67347
67652
  if (!hasFeeBlock) {
67348
- throw (new ledger_1.default('LEDGER_MISSING_REQUIRED_FEE_BLOCK', 'Missing fee block but votes require it'));
67653
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_MISSING_REQUIRED_FEE_BLOCK', 'Missing fee block but votes require it'));
67349
67654
  }
67350
67655
  if (requiredFees.size !== possibleFeeBlock?.operations.length) {
67351
- throw (new ledger_1.default('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees'));
67656
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees'));
67352
67657
  }
67353
67658
  }
67354
67659
  // Verify that all required fees have been included in the fee block
@@ -67358,21 +67663,21 @@ class LedgerAtomicInterface {
67358
67663
  const expectedToken = fee.token ?? __classPrivateFieldGet(this, _LedgerAtomicInterface_ledger, "f").baseToken;
67359
67664
  if (operation.type === operations_1.OperationType.SEND && operation.to.comparePublicKey(expectedPayTo)) {
67360
67665
  if (operation.amount !== fee.amount) {
67361
- throw (new ledger_1.default('LEDGER_FEE_AMOUNT_MISMATCH', `Fee Amount Mismatch, found: ${operation.amount} expected: ${fee.amount}`));
67666
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_FEE_AMOUNT_MISMATCH', `Fee Amount Mismatch, found: ${operation.amount} expected: ${fee.amount}`));
67362
67667
  }
67363
67668
  if (!operation.token.comparePublicKey(expectedToken)) {
67364
- throw (new ledger_1.default('LEDGER_FEE_TOKEN_MISMATCH', `Fee Token Mismatch, found: ${operation.token.publicKeyString.get()} expected: ${expectedToken.publicKeyString.get()}`));
67669
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_FEE_TOKEN_MISMATCH', `Fee Token Mismatch, found: ${operation.token.publicKeyString.get()} expected: ${expectedToken.publicKeyString.get()}`));
67365
67670
  }
67366
67671
  return (true);
67367
67672
  }
67368
67673
  return (false);
67369
67674
  });
67370
67675
  if (foundFee === undefined) {
67371
- throw (new ledger_1.default('LEDGER_FEE_MISSING', `Missing Required Fee for ${fee.payTo?.publicKeyString.get() ?? issuer.publicKeyString.get()}`));
67676
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_FEE_MISSING', `Missing Required Fee for ${fee.payTo?.publicKeyString.get() ?? issuer.publicKeyString.get()}`));
67372
67677
  }
67373
67678
  }
67374
67679
  if (!foundOurVote) {
67375
- throw (new ledger_1.default('LEDGER_NO_PERM_WITHOUT_SELF_TEMP', 'Asked to give a permanent vote without a temporary vote from us'));
67680
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_NO_PERM_WITHOUT_SELF_TEMP', 'Asked to give a permanent vote without a temporary vote from us'));
67376
67681
  }
67377
67682
  }
67378
67683
  const allLedgerHeads = await __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_validateBlocksForVote).call(this, blocks);
@@ -67382,15 +67687,15 @@ class LedgerAtomicInterface {
67382
67687
  const accountHead = allHeads[account.publicKeyString.get()];
67383
67688
  if (accountHead === null) {
67384
67689
  if (!expectedBlock.$opening) {
67385
- throw (new ledger_1.default('LEDGER_NOT_OPENING', 'Cannot vote on non-opening block for an empty account'));
67690
+ throw (new ledger_1.KeetaNetLedgerVoteError('LEDGER_NOT_OPENING', 'Cannot vote on non-opening block for an empty account', needToGetHeadFor));
67386
67691
  }
67387
67692
  continue;
67388
67693
  }
67389
67694
  if (expectedBlock.$opening) {
67390
- throw (new ledger_1.default('LEDGER_NOT_EMPTY', 'Cannot vote on opening block for a non-empty account'));
67695
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_NOT_EMPTY', 'Cannot vote on opening block for a non-empty account'));
67391
67696
  }
67392
67697
  if (expectedBlock.previous.toString() !== accountHead.toString()) {
67393
- throw (new ledger_1.default('LEDGER_NOT_SUCCESSOR', 'The block is not the successor to the account head block'));
67698
+ throw (new ledger_1.KeetaNetLedgerVoteError('LEDGER_NOT_SUCCESSOR', 'The block is not the successor to the account head block', needToGetHeadFor));
67394
67699
  }
67395
67700
  }
67396
67701
  /**
@@ -67414,7 +67719,7 @@ class LedgerAtomicInterface {
67414
67719
  mayReplace = !ourVote.$permanent && ourVote.issuer.comparePublicKey(ledgerPubKey);
67415
67720
  }
67416
67721
  if (!mayReplace) {
67417
- throw (new ledger_1.default('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((0, conversion_1.toJSONSerializable)(previousVotes))})`));
67722
+ throw (new ledger_1.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((0, conversion_1.toJSONSerializable)(previousVotes))})`));
67418
67723
  }
67419
67724
  }
67420
67725
  }
@@ -67427,13 +67732,19 @@ class LedgerAtomicInterface {
67427
67732
  await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").addPendingVote(transaction, blocksAndVote);
67428
67733
  return (vote);
67429
67734
  }
67735
+ /**
67736
+ * Validate ledger outcome again before permanent votes if blocks includes a fee block
67737
+ */
67738
+ if (hasFeeBlock) {
67739
+ await __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_validateLedgerOutcome).call(this, blocks);
67740
+ }
67430
67741
  /**
67431
67742
  * Validate the votes are sufficient weight and grant
67432
67743
  * our permanent vote
67433
67744
  */
67434
67745
  const votesSufficient = await __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_validateVotingWeight).call(this, otherVotes);
67435
67746
  if (votesSufficient !== true) {
67436
- throw (new ledger_1.default('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Unable to create a vote from these votes, they do not represent enough voting power'));
67747
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Unable to create a vote from these votes, they do not represent enough voting power'));
67437
67748
  }
67438
67749
  /**
67439
67750
  * Serial number
@@ -67493,7 +67804,7 @@ class LedgerAtomicInterface {
67493
67804
  const weightTiming = __classPrivateFieldGet(this, _LedgerAtomicInterface_ledger, "f").node?.timing.startTime('db-add/getWeight');
67494
67805
  const votesSufficient = await __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_validateVotingWeight).call(this, votesAndBlocks.votes);
67495
67806
  if (votesSufficient !== true) {
67496
- throw (new ledger_1.default('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Votes attached do not represent enough voting power'));
67807
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Votes attached do not represent enough voting power'));
67497
67808
  }
67498
67809
  weightTiming?.end();
67499
67810
  const changesTiming = __classPrivateFieldGet(this, _LedgerAtomicInterface_ledger, "f").node?.timing.startTime('db-add/computeEffectOfBlocks');
@@ -67596,6 +67907,11 @@ class LedgerAtomicInterface {
67596
67907
  const retval = await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").getBlock(transaction, blockhash, from);
67597
67908
  return (retval);
67598
67909
  }
67910
+ async getAccountsBlockHeightInfo(toFetch) {
67911
+ const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
67912
+ const retval = await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").getAccountsBlockHeightInfo(transaction, toFetch);
67913
+ return (retval);
67914
+ }
67599
67915
  async getVoteStaple(stapleBlockHash, from = 'main') {
67600
67916
  __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
67601
67917
  const results = await this.getVoteStaples([stapleBlockHash], from);
@@ -67851,7 +68167,7 @@ _LedgerAtomicInterface_network = new WeakMap(), _LedgerAtomicInterface_subnet =
67851
68167
  const baseFlagsStr = requirement.permissions.base.flags.join(', ');
67852
68168
  const externalOffsetsStr = requirement.permissions.external.trueOffsets.join(', ');
67853
68169
  const reqTargetKey = requirement.target?.publicKeyString.get();
67854
- throw (new ledger_1.default('LEDGER_INVALID_PERMISSIONS', `${accountPubKey} does not have required permissions to perform action on ${reqEntityKey}/${reqTargetKey} -- needs [${baseFlagsStr}]/[${externalOffsetsStr}]`));
68170
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_PERMISSIONS', `${accountPubKey} does not have required permissions to perform action on ${reqEntityKey}/${reqTargetKey} -- needs [${baseFlagsStr}]/[${externalOffsetsStr}]`));
67855
68171
  }
67856
68172
  }
67857
68173
  }, _LedgerAtomicInterface_checkPermissionRequirements = async function _LedgerAtomicInterface_checkPermissionRequirements(effects) {
@@ -67901,7 +68217,7 @@ _LedgerAtomicInterface_network = new WeakMap(), _LedgerAtomicInterface_subnet =
67901
68217
  throw (new Error(`Multisig quorum not found for ${multisigPubKey}`));
67902
68218
  }
67903
68219
  if (foundInfo.multisigQuorum > foundSingerLength) {
67904
- throw (new ledger_1.default('LEDGER_INVALID_PERMISSIONS', `Quorum of ${foundInfo.multisigQuorum} not reached for ${multisigPubKey} -- got ${foundSingerLength}`));
68220
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_PERMISSIONS', `Quorum of ${foundInfo.multisigQuorum} not reached for ${multisigPubKey} -- got ${foundSingerLength}`));
67905
68221
  }
67906
68222
  }
67907
68223
  const checkPromises = [];
@@ -67999,7 +68315,7 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
67999
68315
  if (ownerLength === 1) {
68000
68316
  continue;
68001
68317
  }
68002
- throw (new ledger_1.default('LEDGER_INVALID_OWNER_COUNT', `Invalid number of owners for ${identifierPubKey} - Got ${ownerLength}/1`));
68318
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_OWNER_COUNT', `Invalid number of owners for ${identifierPubKey} - Got ${ownerLength}/1`));
68003
68319
  }
68004
68320
  const { balances } = await (0, common_1.computeLedgerEffect)({
68005
68321
  checkRangeConstraints: true,
@@ -68010,10 +68326,10 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
68010
68326
  for (const tokenPubKey in acctBalanceChanges) {
68011
68327
  const { change, fellNegative, receiveValidated } = acctBalanceChanges[tokenPubKey];
68012
68328
  if (fellNegative) {
68013
- throw (new ledger_1.default('LEDGER_INVALID_BALANCE', `Resulting balance becomes negative at one+ point(s) during this transaction for account/token ${accountPubKey}/${tokenPubKey}: change ${change}`));
68329
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_BALANCE', `Resulting balance becomes negative at one+ point(s) during this transaction for account/token ${accountPubKey}/${tokenPubKey}: change ${change}`));
68014
68330
  }
68015
68331
  if (receiveValidated === false) {
68016
- throw (new ledger_1.default('LEDGER_RECEIVE_NOT_MET', `${accountPubKey}/${tokenPubKey} did not receive enough of requested token. change: ${change}`));
68332
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_RECEIVE_NOT_MET', `${accountPubKey}/${tokenPubKey} did not receive enough of requested token. change: ${change}`));
68017
68333
  }
68018
68334
  }
68019
68335
  }
@@ -68033,13 +68349,13 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
68033
68349
  const prevBlockHash = block.previous;
68034
68350
  seenBlockHashes.add(block.hash);
68035
68351
  if (block.network !== __classPrivateFieldGet(this, _LedgerAtomicInterface_network, "f")) {
68036
- throw (new ledger_1.default('LEDGER_INVALID_NETWORK', 'Cannot vote on block for a different network'));
68352
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_NETWORK', 'Cannot vote on block for a different network'));
68037
68353
  }
68038
68354
  if (block.subnet !== __classPrivateFieldGet(this, _LedgerAtomicInterface_subnet, "f")) {
68039
- throw (new ledger_1.default('LEDGER_INVALID_SUBNET', 'Cannot vote on block for a different subnet'));
68355
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_SUBNET', 'Cannot vote on block for a different subnet'));
68040
68356
  }
68041
68357
  if (usedPreviousBlockHashes.has(prevBlockHash)) {
68042
- throw (new ledger_1.default('LEDGER_PREVIOUS_ALREADY_USED', `Invalid reference to block, previous: ${prevBlockHash} has already been used`));
68358
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_PREVIOUS_ALREADY_USED', `Invalid reference to block, previous: ${prevBlockHash} has already been used`));
68043
68359
  }
68044
68360
  usedPreviousBlockHashes.add(prevBlockHash);
68045
68361
  /**
@@ -68054,10 +68370,10 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
68054
68370
  if (prevBlock !== undefined) {
68055
68371
  predecessorBeingVotedOn = true;
68056
68372
  if (!(prevBlock.account.comparePublicKey(block.account))) {
68057
- throw (new ledger_1.default('LEDGER_INVALID_CHAIN', 'Invalid chain, changes accounts'));
68373
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_CHAIN', 'Invalid chain, changes accounts'));
68058
68374
  }
68059
68375
  if (!seenBlockHashes.has(prevBlockHash)) {
68060
- throw (new ledger_1.default('LEDGER_PREVIOUS_NOT_SEEN', `Invalid reference to block, out-of-order: ${prevBlockHash} has not already been seen`));
68376
+ throw (new ledger_1.KeetaNetLedgerError('LEDGER_PREVIOUS_NOT_SEEN', `Invalid reference to block, out-of-order: ${prevBlockHash} has not already been seen`));
68061
68377
  }
68062
68378
  }
68063
68379
  }
@@ -68239,7 +68555,7 @@ class Ledger {
68239
68555
  shouldTryToRetry = (now - startTime) < retryConfig.timeout;
68240
68556
  }
68241
68557
  if (shouldTryToRetry) {
68242
- if (ledger_1.default.isInstance(txnError)) {
68558
+ if (ledger_1.KeetaNetLedgerError.isInstance(txnError)) {
68243
68559
  if (txnError.shouldRetry) {
68244
68560
  let retryDelay = 20;
68245
68561
  if (txnError.retryDelay) {
@@ -68365,6 +68681,11 @@ class Ledger {
68365
68681
  return (await transaction.getBlock(...args));
68366
68682
  }));
68367
68683
  }
68684
+ async getAccountsBlockHeightInfo(...args) {
68685
+ return (await this.runReadOnly('db-getAccountsBlockHeightInfo', async function (transaction) {
68686
+ return (await transaction.getAccountsBlockHeightInfo(...args));
68687
+ }));
68688
+ }
68368
68689
  async getVoteStaple(...args) {
68369
68690
  return (await this.runReadOnly('db-getVoteStaple', async function (transaction) {
68370
68691
  return (await transaction.getVoteStaple(...args));
@@ -75707,7 +76028,9 @@ async function generateInitialVoteStaple(options) {
75707
76028
  },
75708
76029
  {
75709
76030
  type: block_1.default.Builder.OperationType.SET_INFO,
75710
- name: '', description: '', metadata: '',
76031
+ name: options.baseTokenInfo?.currencyCode ?? '',
76032
+ description: options.baseTokenInfo?.name ?? '',
76033
+ metadata: options.baseTokenInfo ? btoa(JSON.stringify({ decimalPlaces: options.baseTokenInfo.decimalPlaces })) : '',
75711
76034
  defaultPermission: new permissions_1.Permissions(['ACCESS'])
75712
76035
  },
75713
76036
  ...additionalBaseTokenOperations
@@ -77415,7 +77738,7 @@ exports.Testing = { findRDN, blockHashesFromVote, feeFromVote };
77415
77738
 
77416
77739
  Object.defineProperty(exports, "__esModule", ({ value: true }));
77417
77740
  exports.version = void 0;
77418
- exports.version = '0.14.2+g68f40cc8d6fed6135fa06451bd1fb0691868e25f';
77741
+ exports.version = '0.14.4+g6020a42a3e7fdf7cae2d3783e939f895ae1be911';
77419
77742
  exports["default"] = exports.version;
77420
77743
 
77421
77744