@keetanetwork/keetanet-client 0.14.13 → 0.14.14

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 (123) hide show
  1. package/client/index-browser.d.ts +3 -1
  2. package/client/index-browser.js +167 -49
  3. package/client/index.d.ts +3 -1
  4. package/client/index.js +166 -50
  5. package/config/index.d.ts +3 -0
  6. package/docs/assets/hierarchy.js +1 -1
  7. package/docs/assets/search.js +1 -1
  8. package/docs/classes/KeetaNetSDK.Client.html +4 -3
  9. package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
  10. package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
  11. package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +2 -2
  12. package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
  13. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
  14. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
  15. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +1 -1
  16. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
  17. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
  18. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
  19. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
  20. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  21. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  22. package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +2 -2
  23. package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
  24. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
  25. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +3 -2
  26. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +3 -2
  27. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +3 -2
  28. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
  29. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +3 -2
  30. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +3 -2
  31. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +3 -2
  32. package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
  33. package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +3 -2
  34. package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +3 -2
  35. package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +3 -2
  36. package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
  37. package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
  38. package/docs/classes/KeetaNetSDK.Referenced.IdempotentKey.html +2 -2
  39. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +3 -2
  40. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
  41. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +1 -1
  42. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +1 -1
  43. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +1 -1
  44. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerIdempotentKeyError.html +1 -1
  45. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.html +1 -1
  46. package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
  47. package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +3 -2
  48. package/docs/classes/KeetaNetSDK.Referenced.Log.html +15 -3
  49. package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
  50. package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
  51. package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +3 -2
  52. package/docs/classes/KeetaNetSDK.Referenced.Stats.html +1 -1
  53. package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +1 -1
  54. package/docs/classes/KeetaNetSDK.Referenced.Vote.html +1 -1
  55. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +1 -1
  56. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +3 -2
  57. package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
  58. package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +3 -2
  59. package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +1 -1
  60. package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +1 -1
  61. package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
  62. package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +1 -1
  63. package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +3 -2
  64. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +3 -2
  65. package/docs/classes/KeetaNetSDK.UserClient.html +2 -2
  66. package/docs/hierarchy.html +1 -1
  67. package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
  68. package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
  69. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
  70. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
  71. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
  72. package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
  73. package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
  74. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
  75. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
  76. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +1 -1
  77. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
  78. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATESerializable.html +1 -1
  79. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
  80. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
  81. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
  82. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
  83. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
  84. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  85. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  86. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
  87. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
  88. package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
  89. package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
  90. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
  91. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
  92. package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
  93. package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
  94. package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
  95. package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
  96. package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
  97. package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
  98. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
  99. package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
  100. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
  101. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
  102. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
  103. package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +3 -2
  104. package/docs/interfaces/KeetaNetSDK.Referenced.PublishOptions.html +1 -1
  105. package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
  106. package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
  107. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +1 -1
  108. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +1 -1
  109. package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
  110. package/docs/interfaces/KeetaNetSDK.Referenced.src_config.ValidationConfig.html +2 -2
  111. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
  112. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
  113. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
  114. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
  115. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
  116. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Struct.html +1 -1
  117. package/docs/types/KeetaNetSDK.Referenced.src_config.NetworkConfig.html +1 -1
  118. package/lib/ledger/common.d.ts +3 -0
  119. package/lib/log/index.d.ts +20 -0
  120. package/lib/utils/buffer.d.ts +1 -0
  121. package/npm-shrinkwrap.json +2 -2
  122. package/package.json +1 -1
  123. package/version.d.ts +1 -1
@@ -615,12 +615,14 @@ export declare class Client {
615
615
  * @param account The account to get the history for -- if null then the history for all accounts will be returned
616
616
  * @param options The options to use for the request
617
617
  * @param options.startBlocksHash The block hash to start from -- this is used to paginate the request
618
- * @param options.depth The maximum number of vote staples to return -- this is used to limit the number of vote staples returned
618
+ * @param options.depth The maximum number of vote staples to return -- this is used to limit the number of vote staples returned, default is everything)
619
+ * @param options.pageSize How large of a page size to request at a given time (default is 200)
619
620
  * @return The history of vote staples for the given account, in reverse order starting with the most recent vote staple
620
621
  */
621
622
  getHistory(account: GenericAccount | string | null, options?: {
622
623
  startBlocksHash?: VoteBlocksHash | string;
623
624
  depth?: number;
625
+ pageSize?: number;
624
626
  }): Promise<{
625
627
  voteStaple: VoteStaple;
626
628
  }[]>;
@@ -106251,6 +106251,9 @@ class src_client_BufferStorage {
106251
106251
  throw new Error(`Unsupported conversion: ${encoding}`);
106252
106252
  }
106253
106253
  }
106254
+ toJSON() {
106255
+ return this.toString('hex');
106256
+ }
106254
106257
  toBigInt() {
106255
106258
  const hex_value = `0x${this.toString('hex')}`;
106256
106259
  const value = BigInt(hex_value);
@@ -113092,6 +113095,7 @@ const client_asn1 = client_asn1_namespaceObject;
113092
113095
  * native bindings.
113093
113096
  */
113094
113097
  const client_ASN1_ENCODE_DECODE_PARANOID = client_asn1_process.env['KEETANET_NODE_ASN1_ENCODE_DECODE_PARANOID'] === '1';
113098
+ const client_MAXIMUM_BIGINT_BYTE_LENGTH = 1024;
113095
113099
  function client_jsBigIntToBuffer(value) {
113096
113100
  /**
113097
113101
  * Convert value to Hex
@@ -113113,21 +113117,39 @@ function client_jsBigIntToBuffer(value) {
113113
113117
  if (valueStr.length % 2 !== 0) {
113114
113118
  valueStr = '0' + valueStr;
113115
113119
  }
113116
-
113117
- /*
113118
- * Pad with a leading 0 byte if the MSB is 1 to avoid writing a
113119
- * negative number
113120
- */
113121
- const leader = valueStr.slice(0, 2);
113122
- const leaderValue = Number(`0x${leader}`);
113123
- if (!isNegative) {
113120
+ if (isNegative) {
113121
+ // Convert to minimal two's complement
113122
+ let n = BigInt('0x' + valueStr);
113123
+ n = -n;
113124
+ // Find minimal byte length
113125
+ const leader = Number('0x' + valueStr.slice(0, 2));
113126
+ let extraByteLength = 0;
113127
+ if (leader > 0x80) {
113128
+ extraByteLength = 1;
113129
+ }
113130
+ const byteLength = valueStr.length / 2 + extraByteLength;
113131
+
113132
+ // Compute two's complement
113133
+ const mod = 1n << BigInt(8 * byteLength);
113134
+ const twos = mod + n;
113135
+ let hex = twos.toString(16);
113136
+ if (hex.length % 2 !== 0) {
113137
+ hex = '0' + hex;
113138
+ }
113139
+ // Remove redundant leading ff bytes
113140
+ while (hex.length > 2 && hex.startsWith('ff') && Number.parseInt(hex.slice(2, 4), 16) >= 0x80) {
113141
+ hex = hex.slice(2);
113142
+ }
113143
+ valueStr = hex;
113144
+ } else {
113145
+ const leader = valueStr.slice(0, 2);
113146
+ const leaderValue = Number(`0x${leader}`);
113124
113147
  if (leaderValue > 127) {
113125
113148
  valueStr = '00' + valueStr;
113126
113149
  }
113127
- } else {
113128
- if (leaderValue <= 127) {
113129
- valueStr = 'FF' + valueStr;
113130
- }
113150
+ }
113151
+ if (valueStr.length / 2 >= client_MAXIMUM_BIGINT_BYTE_LENGTH) {
113152
+ throw new Error(`jsBigIntToBuffer: Unable to encode bigint, too large, goes over maximum byte length of ${client_MAXIMUM_BIGINT_BYTE_LENGTH}`);
113131
113153
  }
113132
113154
 
113133
113155
  /*
@@ -113136,16 +113158,42 @@ function client_jsBigIntToBuffer(value) {
113136
113158
  const valueBuffer = client_asn1_Buffer.from(valueStr, 'hex');
113137
113159
  return valueBuffer;
113138
113160
  }
113161
+ function client_assertDERInteger(data) {
113162
+ const buf = client_asn1_Buffer.from(data.valueBlock.valueHex);
113163
+
113164
+ // Check for zero-length integer
113165
+ if (buf.length === 0) {
113166
+ throw new Error('Invalid DER: Integer has zero length');
113167
+ }
113168
+
113169
+ // Check for unnecessary leading zeros (positive numbers)
113170
+ // Only check multi-byte integers
113171
+ if (buf.length > 1 && buf[0] === 0x00 && (buf[1] & 0x80) === 0) {
113172
+ throw new Error('Invalid DER: Integer has unnecessary leading zero byte');
113173
+ }
113139
113174
 
113140
- /* XXX:TODO: This does not correctly deal with negative values */
113175
+ // Check for unnecessary leading 0xFF (negative numbers)
113176
+ // Only check multi-byte integers
113177
+ if (buf.length > 1 && buf[0] === 0xFF && (buf[1] & 0x80) !== 0) {
113178
+ throw new Error('Invalid DER: Integer has unnecessary leading 0xFF byte');
113179
+ }
113180
+ }
113141
113181
  function client_jsIntegerToBigInt(value) {
113142
- let valueStr;
113143
- if (value instanceof client_Integer) {
113144
- valueStr = value.toString().split(':')[1].trim();
113182
+ if (typeof value === 'number') {
113183
+ return BigInt(value);
113184
+ }
113185
+ client_assertDERInteger(value);
113186
+ const buf = client_asn1_Buffer.from(value.valueBlock.valueHex);
113187
+ const isNegative = (buf[0] & 0x80) !== 0;
113188
+ if (!isNegative) {
113189
+ return BigInt('0x' + buf.toString('hex'));
113145
113190
  } else {
113146
- valueStr = value;
113191
+ // Two's complement: value = unsigned - 2^(8*len)
113192
+ const unsigned = BigInt('0x' + buf.toString('hex'));
113193
+ const bits = BigInt(buf.length * 8);
113194
+ const twosComp = unsigned - (1n << bits);
113195
+ return twosComp;
113147
113196
  }
113148
- return BigInt(valueStr);
113149
113197
  }
113150
113198
  function client_isASN1Object(input) {
113151
113199
  if (input === null || input === undefined || typeof input !== 'object') {
@@ -115163,6 +115211,9 @@ const client_baseValidationConfig = {
115163
115211
  maxLength: 256,
115164
115212
  regex: /^[-_A-Za-z0-9+/= ]+$/,
115165
115213
  canBeEmpty: true
115214
+ },
115215
+ validateNumericValues: {
115216
+ cutoffEpoch: 1763683200000n // 2025-11-21T00:00:00.000Z
115166
115217
  }
115167
115218
  },
115168
115219
  idempotentKey: {
@@ -117694,6 +117745,16 @@ function client_validateSupply(amount, network) {
117694
117745
  throw new src_client_KeetaNetBlockError('BLOCK_SUPPLY_INVALID', `supply does not fit proper format -- GOT: '${amount}' MaxValue: ${maxValue}`);
117695
117746
  }
117696
117747
  }
117748
+ function client_validateNumericValue(value, block, fieldName, context) {
117749
+ if (value >= 0n) {
117750
+ return;
117751
+ }
117752
+ const config = client_getValidation(block.network).blockOperations.validateNumericValues;
117753
+ if (BigInt(block.date.valueOf()) < config.cutoffEpoch) {
117754
+ return;
117755
+ }
117756
+ throw new src_client_KeetaNetBlockError('BLOCK_AMOUNT_BELOW_ZERO', `${fieldName !== null && fieldName !== void 0 ? fieldName : 'value'} cannot be negative`);
117757
+ }
117697
117758
  function client_validateBlockSignerCount(amount, network) {
117698
117759
  const {
117699
117760
  maxValue
@@ -118623,11 +118684,7 @@ class src_client_BlockOperation {
118623
118684
  if (amount === undefined || amount === null) {
118624
118685
  throw new Error('internal error: "amount" is invalid');
118625
118686
  }
118626
- const bigintAmount = BigInt(amount);
118627
- if (bigintAmount < 0n) {
118628
- throw new src_client_KeetaNetBlockError('BLOCK_AMOUNT_BELOW_ZERO', 'value cannot be negative');
118629
- }
118630
- return bigintAmount;
118687
+ return BigInt(amount);
118631
118688
  }
118632
118689
  }
118633
118690
  client_BlockOperation = src_client_BlockOperation;
@@ -118675,6 +118732,7 @@ class src_client_BlockOperationSEND extends src_client_BlockOperation {
118675
118732
  block
118676
118733
  } = context;
118677
118734
  const account = block.account;
118735
+ client_validateNumericValue(this.amount, block, 'amount');
118678
118736
 
118679
118737
  // Only allow tokens to use send if they are the token being sent
118680
118738
  if (account.keyType === client_AccountKeyAlgorithm.TOKEN && this.token.comparePublicKey(account) === false) {
@@ -118782,6 +118840,7 @@ class src_client_BlockOperationRECEIVE extends src_client_BlockOperation {
118782
118840
  block
118783
118841
  } = context;
118784
118842
  const account = block.account;
118843
+ client_validateNumericValue(this.amount, block, 'amount');
118785
118844
  if (account.isToken()) {
118786
118845
  throw new src_client_KeetaNetBlockError('BLOCK_NO_TOKEN_OP', 'Token addresses cannot use RECEIVE');
118787
118846
  }
@@ -118870,6 +118929,7 @@ class src_client_BlockOperationTOKEN_ADMIN_MODIFY_BALANCE extends src_client_Blo
118870
118929
  const {
118871
118930
  block
118872
118931
  } = context;
118932
+ client_validateNumericValue(client_operations_classPrivateFieldGet(client_amount3, this), block, 'amount');
118873
118933
  if (block.account.keyType === client_AccountKeyAlgorithm.TOKEN) {
118874
118934
  throw new src_client_KeetaNetBlockError('BLOCK_NO_TOKEN_OP', 'You cannot use TOKEN_ADMIN_MODIFY_BALANCE on a token account');
118875
118935
  }
@@ -119337,6 +119397,7 @@ class src_client_BlockOperationTOKEN_ADMIN_SUPPLY extends src_client_BlockOperat
119337
119397
  const {
119338
119398
  block
119339
119399
  } = context;
119400
+ client_validateNumericValue(client_operations_classPrivateFieldGet(client_amount4, this), block, 'amount');
119340
119401
  if (block.account.keyType !== client_AccountKeyAlgorithm.TOKEN) {
119341
119402
  throw new src_client_KeetaNetBlockError('BLOCK_ONLY_TOKEN_OP', 'Only token accounts can use TOKEN_ADMIN_SUPPLY');
119342
119403
  }
@@ -120802,10 +120863,12 @@ class src_client_BlockBuilder {
120802
120863
  client_block_classPrivateFieldSet(client_block, this, new src_client_Block(block));
120803
120864
  } else {
120804
120865
  const incompleteBlockJSON = {
120805
- date: new Date().toISOString(),
120806
120866
  version: 1,
120807
120867
  ...block
120808
120868
  };
120869
+ if (incompleteBlockJSON.date === undefined) {
120870
+ incompleteBlockJSON.date = new Date().toISOString();
120871
+ }
120809
120872
 
120810
120873
  /*
120811
120874
  * Map input to our values
@@ -125229,10 +125292,6 @@ function client_updateAccountInfoInState(state, account, info) {
125229
125292
  * Compute the effect of a SEND operation
125230
125293
  */
125231
125294
  function client_computeEffectOfOperationSEND(state, block, operation) {
125232
- if (operation.amount < 0n) {
125233
- throw new Error('Internal error: SEND operation with negative amount');
125234
- }
125235
-
125236
125295
  // Decrement sender balance
125237
125296
  const senderChange = {
125238
125297
  state,
@@ -125262,10 +125321,6 @@ function client_computeEffectOfOperationSEND(state, block, operation) {
125262
125321
  * Compute the effect of a RECEIVE operation
125263
125322
  */
125264
125323
  function client_computeEffectOfOperationRECEIVE(state, block, operation) {
125265
- if (operation.amount < 0n) {
125266
- throw new Error('Internal error: RECEIVE operation with negative amount');
125267
- }
125268
-
125269
125324
  // Increment recipient balance
125270
125325
  const recipientChange = {
125271
125326
  state,
@@ -125301,9 +125356,6 @@ function client_computeEffectOfOperationRECEIVE(state, block, operation) {
125301
125356
  }
125302
125357
  }
125303
125358
  function client_computeEffectOfOperationTOKEN_ADMIN_MODIFY_BALANCE(state, block, operation) {
125304
- if (operation.amount < 0n) {
125305
- throw new Error('Internal error: TOKEN_ADMIN_MODIFY_BALANCE operation with negative amount');
125306
- }
125307
125359
  if (operation.method === src_client_Block.AdjustMethod.SET) {
125308
125360
  const setChange = {
125309
125361
  state,
@@ -125424,9 +125476,6 @@ function client_computeEffectOfOperationMODIFY_PERMISSIONS(state, block, operati
125424
125476
  }
125425
125477
  function client_computeEffectOfOperationTOKEN_ADMIN_SUPPLY(state, block, operation) {
125426
125478
  var _state$accounts$token;
125427
- if (operation.amount < 0n) {
125428
- throw new Error('Internal error: TOKEN_ADMIN_SUPPLY operation with negative amount');
125429
- }
125430
125479
  const tokenPubKey = block.account.publicKeyString.get();
125431
125480
  let value = 0n;
125432
125481
  switch (operation.method) {
@@ -126199,6 +126248,10 @@ class client_Log {
126199
126248
  * The maximum number of log entries to send to each target at a time
126200
126249
  */
126201
126250
  client_log_defineProperty(this, "batchSize", 10);
126251
+ /**
126252
+ * Parent logger, if any -- used for creating hierarchical loggers
126253
+ */
126254
+ client_log_defineProperty(this, "parent", null);
126202
126255
  if ((_options === null || _options === void 0 ? void 0 : _options.logDebugTracing) !== undefined) {
126203
126256
  client_log_classPrivateFieldSet(client_logDebugTracing, this, _options.logDebugTracing);
126204
126257
  }
@@ -126263,10 +126316,14 @@ class client_Log {
126263
126316
  if (client_log_classPrivateFieldGet(client_destroyed, this)) {
126264
126317
  throw new Error('Cannot register target on destroyed Log instance');
126265
126318
  }
126266
-
126267
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
126268
- const id = Symbol('LogTargetID');
126269
- client_log_classPrivateFieldGet(client_targets, this).set(id, target);
126319
+ let id;
126320
+ if (this.parent) {
126321
+ id = this.parent.registerTarget(target);
126322
+ } else {
126323
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
126324
+ id = Symbol('LogTargetID');
126325
+ client_log_classPrivateFieldGet(client_targets, this).set(id, target);
126326
+ }
126270
126327
  return id;
126271
126328
  }
126272
126329
 
@@ -126288,7 +126345,48 @@ class client_Log {
126288
126345
  if (client_log_classPrivateFieldGet(client_destroyed, this)) {
126289
126346
  return;
126290
126347
  }
126291
- client_log_classPrivateFieldGet(client_targets, this).delete(id);
126348
+ if (this.parent) {
126349
+ this.parent.unregisterTarget(id);
126350
+ } else {
126351
+ client_log_classPrivateFieldGet(client_targets, this).delete(id);
126352
+ }
126353
+ }
126354
+
126355
+ /**
126356
+ * Get the currently registered log targets.
126357
+ *
126358
+ * If this is a child logger, this will return the parent's targets
126359
+ * because child loggers share the same targets as their parent.
126360
+ */
126361
+ get targets() {
126362
+ if (client_log_classPrivateFieldGet(client_destroyed, this)) {
126363
+ return [];
126364
+ }
126365
+ if (this.parent) {
126366
+ return this.parent.targets;
126367
+ }
126368
+ return Array.from(client_log_classPrivateFieldGet(client_targets, this).values());
126369
+ }
126370
+ /**
126371
+ * Create a child logger instance that shares the same targets as this instance
126372
+ * but has its own log queue, this is useful for creating hierarchical loggers
126373
+ * which can call sync independently.
126374
+ *
126375
+ * Since the child shares the same targets, registering or unregistering targets
126376
+ * from either the parent or child will affect both.
126377
+ */
126378
+ createChild() {
126379
+ var _this$parent;
126380
+ const child = new client_Log({
126381
+ logDebugTracing: client_log_classPrivateFieldGet(client_logDebugTracing, this)
126382
+ });
126383
+
126384
+ /**
126385
+ * Attach child nodes to our own parent to collapse
126386
+ * chains of loggers
126387
+ */
126388
+ child.parent = (_this$parent = this.parent) !== null && _this$parent !== void 0 ? _this$parent : this;
126389
+ return child;
126292
126390
  }
126293
126391
 
126294
126392
  /**
@@ -126338,7 +126436,7 @@ class client_Log {
126338
126436
  * in case a target is added later; However, if there are
126339
126437
  * too many logs, drop the oldest ones
126340
126438
  */
126341
- if (client_log_classPrivateFieldGet(client_targets, this).size === 0) {
126439
+ if (this.targets.length === 0) {
126342
126440
  if (client_log_classPrivateFieldGet(client_logs, this).length > client_MAX_LOGS_TO_ENQUEUE_WITH_NO_TARGETS) {
126343
126441
  client_log_classPrivateFieldGet(client_logs, this).splice(0, client_log_classPrivateFieldGet(client_logs, this).length - client_MAX_LOGS_TO_ENQUEUE_WITH_NO_TARGETS);
126344
126442
  }
@@ -126363,7 +126461,7 @@ class client_Log {
126363
126461
  * while a sync is in progress -- they will continue to be sent
126364
126462
  * to the registered targets at the time of the sync
126365
126463
  */
126366
- const targets = Array.from(client_log_classPrivateFieldGet(client_targets, this).values());
126464
+ const targets = [...this.targets];
126367
126465
  do {
126368
126466
  try {
126369
126467
  client_log_classPrivateFieldSet(client_shouldSyncAgain, this, false);
@@ -128118,6 +128216,13 @@ async function client_validateBlockOperations(blocks) {
128118
128216
  for (const block of blocks) {
128119
128217
  for (const operation of block.operations) {
128120
128218
  switch (operation.type) {
128219
+ case src_client_Block.OperationType.RECEIVE:
128220
+ case src_client_Block.OperationType.SEND:
128221
+ case src_client_Block.OperationType.TOKEN_ADMIN_SUPPLY:
128222
+ if (operation.amount < 0n) {
128223
+ throw new Error(`Operation amount cannot be negative: ${operation.amount}`);
128224
+ }
128225
+ break;
128121
128226
  case src_client_Block.OperationType.SET_REP:
128122
128227
  if (client_ledger_classPrivateFieldGet(client_operations, this).setRep !== undefined) {
128123
128228
  const validRep = await client_ledger_classPrivateFieldGet(client_operations, this).setRep(block.account, operation.to);
@@ -128130,6 +128235,9 @@ async function client_validateBlockOperations(blocks) {
128130
128235
  if (!client_ledger_classPrivateFieldGet(client_operations, this).enableTokenAdminModifyBalance) {
128131
128236
  throw new client_ledger_KeetaNetLedgerError('LEDGER_OPERATION_NOT_SUPPORTED', 'TOKEN_ADMIN_MODIFY_BALANCE operation not supported');
128132
128237
  }
128238
+ if (operation.amount < 0n) {
128239
+ throw new Error(`Operation amount cannot be negative: ${operation.amount}`);
128240
+ }
128133
128241
  break;
128134
128242
  default:
128135
128243
  break;
@@ -128835,7 +128943,7 @@ client_lib_ledger_defineProperty(src_client_Ledger, "isInstance", client_checkab
128835
128943
  // EXTERNAL MODULE: ws (ignored)
128836
128944
  var client_ws_ignored_ = __webpack_require__(4708);
128837
128945
  ;// ./src/version.ts
128838
- const client_version = '0.14.13+g566b8de2c01660608e6eb5257113db271d7fc075';
128946
+ const client_version = '0.14.14+gdd8e58acb0e1edfb9050da584aaa65b7e5f722a2';
128839
128947
  /* harmony default export */ const client_src_version = ((/* unused pure expression or super */ null && (client_version)));
128840
128948
  ;// ./src/lib/p2p.ts
128841
128949
  /* provided dependency */ var client_p2p_Buffer = __webpack_require__(8287)["Buffer"];
@@ -133279,13 +133387,15 @@ class src_client_Client {
133279
133387
  * @param account The account to get the history for -- if null then the history for all accounts will be returned
133280
133388
  * @param options The options to use for the request
133281
133389
  * @param options.startBlocksHash The block hash to start from -- this is used to paginate the request
133282
- * @param options.depth The maximum number of vote staples to return -- this is used to limit the number of vote staples returned
133390
+ * @param options.depth The maximum number of vote staples to return -- this is used to limit the number of vote staples returned, default is everything)
133391
+ * @param options.pageSize How large of a page size to request at a given time (default is 200)
133283
133392
  * @return The history of vote staples for the given account, in reverse order starting with the most recent vote staple
133284
133393
  */
133285
133394
  async getHistory(account) {
133286
133395
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
133287
133396
  const {
133288
133397
  depth = Infinity,
133398
+ pageSize = 200,
133289
133399
  startBlocksHash
133290
133400
  } = options;
133291
133401
  account = client_lib_account.toPublicKeyString(account);
@@ -133299,7 +133409,7 @@ class src_client_Client {
133299
133409
  }
133300
133410
  const retval = [];
133301
133411
  while (retval.length < depth) {
133302
- const limit = Math.min(depth - retval.length, 200);
133412
+ const limit = Math.min(depth - retval.length, pageSize);
133303
133413
  const query = {
133304
133414
  limit: String(limit)
133305
133415
  };
@@ -133336,7 +133446,15 @@ class src_client_Client {
133336
133446
  break;
133337
133447
  }
133338
133448
  }
133339
- startVoteStapleID = history.history.slice(-1)[0]['$id'];
133449
+ if (typeof history.nextKey === 'string' || history.nextKey === null) {
133450
+ if (history.nextKey === null) {
133451
+ break;
133452
+ }
133453
+ startVoteStapleID = history.nextKey;
133454
+ } else {
133455
+ /* @deprecated -- workaround broken API */
133456
+ startVoteStapleID = history.history.slice(-1)[0]['$id'];
133457
+ }
133340
133458
  }
133341
133459
  return retval;
133342
133460
  }
package/client/index.d.ts CHANGED
@@ -615,12 +615,14 @@ export declare class Client {
615
615
  * @param account The account to get the history for -- if null then the history for all accounts will be returned
616
616
  * @param options The options to use for the request
617
617
  * @param options.startBlocksHash The block hash to start from -- this is used to paginate the request
618
- * @param options.depth The maximum number of vote staples to return -- this is used to limit the number of vote staples returned
618
+ * @param options.depth The maximum number of vote staples to return -- this is used to limit the number of vote staples returned, default is everything)
619
+ * @param options.pageSize How large of a page size to request at a given time (default is 200)
619
620
  * @return The history of vote staples for the given account, in reverse order starting with the most recent vote staple
620
621
  */
621
622
  getHistory(account: GenericAccount | string | null, options?: {
622
623
  startBlocksHash?: VoteBlocksHash | string;
623
624
  depth?: number;
625
+ pageSize?: number;
624
626
  }): Promise<{
625
627
  voteStaple: VoteStaple;
626
628
  }[]>;