@keetanetwork/keetanet-client 0.14.0 → 0.14.3
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.
- package/README.md +4 -0
- package/api/node.d.ts +1 -0
- package/client/builder.d.ts +8 -3
- package/client/index-browser.d.ts +6 -1
- package/client/index-browser.js +1852 -1723
- package/client/index.d.ts +6 -1
- package/client/index.js +248 -148
- package/docs/GETTING-STARTED.md +361 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/KeetaNetSDK.Client.html +4 -4
- package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +3 -2
- package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +2 -1
- package/docs/classes/KeetaNetSDK.Referenced.LedgerStorageTransactionBase.html +8 -0
- package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Stats.html +10 -4
- package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +10 -0
- package/docs/classes/KeetaNetSDK.Referenced.UserClientBuilder.html +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.Vote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.UserClient.html +2 -2
- package/docs/documents/GETTING-STARTED.html +3 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +2 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATESerializable.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BuilderBlockOptions.html +3 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +6 -3
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageTransactionBaseOptions.html +6 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
- package/docs/interfaces/{KeetaNetSDK.PublishOptions.html → KeetaNetSDK.Referenced.PublishOptions.html} +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_asn1.html +1 -1
- package/docs/modules/KeetaNetSDK.html +2 -2
- package/docs/types/KeetaNetSDK.Referenced.GetAccountStateAPIResponseFormatted.html +5 -2
- package/docs/types/KeetaNetSDK.Referenced.GetAccountStateAPIResponseSuccess.html +3 -2
- package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.SchemaMap.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes-1.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.LedgerErrorCodes.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1CheckUtilities.html +1 -0
- package/lib/error/certificate.d.ts +1 -1
- package/lib/error/ledger.d.ts +1 -1
- package/lib/ledger/common.d.ts +9 -0
- package/lib/ledger/db_dynamodb.d.ts +5 -9
- package/lib/ledger/db_postgres.d.ts +11 -3
- package/lib/ledger/db_spanner.d.ts +5 -12
- package/lib/ledger/db_spanner_helper.d.ts +1 -1
- package/lib/ledger/db_sqlite.d.ts +11 -3
- package/lib/ledger/index.d.ts +34 -2
- package/lib/p2p.d.ts +1 -1
- package/lib/stats.d.ts +22 -3
- package/lib/utils/asn1.d.ts +18 -1
- package/lib/utils/static-types.d.ts +11 -0
- package/package.json +1 -1
- package/version.d.ts +1 -1
- package/benchmarking/test.d.ts +0 -4
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageTransactionBase.html +0 -6
package/client/index.js
CHANGED
|
@@ -59579,6 +59579,7 @@ async function _Client_apiRaw(rep, api, method, options = {}) {
|
|
|
59579
59579
|
return ({
|
|
59580
59580
|
account: lib_1.default.Account.fromPublicKeyString(accountInfo.account),
|
|
59581
59581
|
currentHeadBlock: currentHeadBlock,
|
|
59582
|
+
currentHeadBlockHeight: accountInfo.currentHeadBlockHeight,
|
|
59582
59583
|
representative: currentRepresentative,
|
|
59583
59584
|
info: __classPrivateFieldGet(this, _Client_instances, "m", _Client_formatAccountInfo).call(this, accountInfo.info),
|
|
59584
59585
|
balances: __classPrivateFieldGet(this, _Client_instances, "m", _Client_formatAllBalances).call(this, accountInfo.balances)
|
|
@@ -64809,37 +64810,18 @@ function ExportBlockOperations(operations) {
|
|
|
64809
64810
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
64810
64811
|
return container;
|
|
64811
64812
|
}
|
|
64812
|
-
function assertExplicitContextValueLike(input) {
|
|
64813
|
-
if (typeof input !== 'object' || input === null) {
|
|
64814
|
-
throw (new Error(`Found entry which is not a context ${String(input)}`));
|
|
64815
|
-
}
|
|
64816
|
-
if (!('type' in input) || input.type !== 'context') {
|
|
64817
|
-
throw (new Error(`Found entry which is not a context ${String(input)}`));
|
|
64818
|
-
}
|
|
64819
|
-
if (!('kind' in input) || input.kind !== 'explicit') {
|
|
64820
|
-
throw (new Error(`Found entry which is not an explicit context ${String(input)}`));
|
|
64821
|
-
}
|
|
64822
|
-
if (!('value' in input)) {
|
|
64823
|
-
throw (new Error(`Found entry which is not a numeric explicit context ${String(input)}`));
|
|
64824
|
-
}
|
|
64825
|
-
const typeInput = input.value;
|
|
64826
|
-
if (typeof typeInput !== 'number') {
|
|
64827
|
-
throw (new Error(`Found entry which is not a numeric explicit context ${String(input)}`));
|
|
64828
|
-
}
|
|
64829
|
-
if (!('contains' in input)) {
|
|
64830
|
-
throw (new Error(`Found entry which which lacks contains ${JSON.stringify(input)}`));
|
|
64831
|
-
}
|
|
64832
|
-
if (!Array.isArray(input.contains)) {
|
|
64833
|
-
throw (new Error(`Found entry which is not a Sequence ${input.contains}`));
|
|
64834
|
-
}
|
|
64835
|
-
}
|
|
64836
64813
|
function ImportOperationsASN1(input, network) {
|
|
64837
64814
|
const retval = [];
|
|
64838
64815
|
for (const entryWrapper of input) {
|
|
64839
64816
|
const operation = {};
|
|
64840
|
-
|
|
64817
|
+
if (!asn1_1.ASN1CheckUtilities.isASN1ContextTag(entryWrapper, 'explicit')) {
|
|
64818
|
+
throw (new Error('Invalid createArgs type for CREATE_IDENTIFIER operation'));
|
|
64819
|
+
}
|
|
64841
64820
|
const type = assertOperationType(entryWrapper.value);
|
|
64842
64821
|
const entry = entryWrapper.contains;
|
|
64822
|
+
if (!Array.isArray(entry)) {
|
|
64823
|
+
throw (new Error(`Found entry which is not a Sequence ${typeof entry}`));
|
|
64824
|
+
}
|
|
64843
64825
|
const typeStr = operationTypeToString(type);
|
|
64844
64826
|
const operationSchema = BlockOperationASN1SchemaBase[typeStr];
|
|
64845
64827
|
if (!operationSchema) {
|
|
@@ -64871,16 +64853,24 @@ function ImportOperationsASN1(input, network) {
|
|
|
64871
64853
|
keyValueOut = newKeyValue;
|
|
64872
64854
|
}
|
|
64873
64855
|
else if (key === 'createArguments' && typeStr === 'CREATE_IDENTIFIER') {
|
|
64874
|
-
|
|
64856
|
+
if (!asn1_1.ASN1CheckUtilities.isASN1ContextTag(keyValueIn, 'explicit')) {
|
|
64857
|
+
throw (new Error('Invalid createArgs type for CREATE_IDENTIFIER operation'));
|
|
64858
|
+
}
|
|
64875
64859
|
if (keyValueIn.value !== account_1.AccountKeyAlgorithm.MULTISIG) {
|
|
64876
64860
|
throw (new Error('unrecognized type for multisig create arguments'));
|
|
64877
64861
|
}
|
|
64878
|
-
if (keyValueIn.contains.length !== 2
|
|
64862
|
+
if (!Array.isArray(keyValueIn.contains) || keyValueIn.contains.length !== 2) {
|
|
64863
|
+
throw (new Error('Invalid createArgs container'));
|
|
64864
|
+
}
|
|
64865
|
+
if (!Array.isArray(keyValueIn.contains[0])) {
|
|
64879
64866
|
throw (new Error('Invalid createArgs container'));
|
|
64880
64867
|
}
|
|
64881
64868
|
keyValueOut = {
|
|
64882
64869
|
type: keyValueIn.value,
|
|
64883
64870
|
signers: keyValueIn.contains[0].map(function (value) {
|
|
64871
|
+
if (!Buffer.isBuffer(value)) {
|
|
64872
|
+
throw (new Error(`Invalid signer value, expected Buffer, got ${typeof value}`));
|
|
64873
|
+
}
|
|
64884
64874
|
return (account_1.default.fromPublicKeyAndType(value));
|
|
64885
64875
|
}),
|
|
64886
64876
|
quorum: keyValueIn.contains[1]
|
|
@@ -65039,7 +65029,17 @@ const BlockErrorCodes = [
|
|
|
65039
65029
|
'DUPLICATE_INCLUDED',
|
|
65040
65030
|
'ORPHAN_FOUND',
|
|
65041
65031
|
'CYCLE_FOUND',
|
|
65042
|
-
'SECONDARY_GRAPH'
|
|
65032
|
+
'SECONDARY_GRAPH',
|
|
65033
|
+
'MISSING_FIELD',
|
|
65034
|
+
'SIGNATURE_ALGORITHM_MISMATCH',
|
|
65035
|
+
'SELF_SIGNED_VALIDATION_FAILED',
|
|
65036
|
+
'CHAIN_VERIFICATION_FAILED',
|
|
65037
|
+
'DUPLICATE_EXTENSION',
|
|
65038
|
+
'EXTENSION_NOT_PROCESSED',
|
|
65039
|
+
'INVALID_SIGNATURE_ALGORITHM',
|
|
65040
|
+
'INVALID_GRAPH_COUNT',
|
|
65041
|
+
'MOMENT_INVALID',
|
|
65042
|
+
'INVALID_VERSION'
|
|
65043
65043
|
];
|
|
65044
65044
|
class KeetaNetCertificateError extends _1.KeetaNetError {
|
|
65045
65045
|
constructor(code, message) {
|
|
@@ -65131,6 +65131,7 @@ const _1 = __webpack_require__(5390);
|
|
|
65131
65131
|
const helper_1 = __webpack_require__(3208);
|
|
65132
65132
|
const LedgerErrorType = 'LEDGER';
|
|
65133
65133
|
const LedgerErrorCodes = [
|
|
65134
|
+
'BLOCK_ALREADY_EXISTS',
|
|
65134
65135
|
'TRANSACTION_ABORTED',
|
|
65135
65136
|
'INVALID_CHAIN',
|
|
65136
65137
|
'INVALID_NETWORK',
|
|
@@ -66097,6 +66098,26 @@ class LedgerStorageBase {
|
|
|
66097
66098
|
}));
|
|
66098
66099
|
return (Object.fromEntries(response));
|
|
66099
66100
|
}
|
|
66101
|
+
async getAccountsBlockHeightInfo(transaction, toFetch) {
|
|
66102
|
+
const response = await Promise.all(toFetch.map(async ({ blockHash, account }) => {
|
|
66103
|
+
if (blockHash === undefined) {
|
|
66104
|
+
const block = await this.getHeadBlock(transaction, account, 'main');
|
|
66105
|
+
if (block !== null) {
|
|
66106
|
+
blockHash = block.hash;
|
|
66107
|
+
}
|
|
66108
|
+
}
|
|
66109
|
+
const retval = [];
|
|
66110
|
+
if (blockHash === undefined) {
|
|
66111
|
+
retval.push(...[account.publicKeyString.get(), null]);
|
|
66112
|
+
}
|
|
66113
|
+
else {
|
|
66114
|
+
const height = await this.getBlockHeight(transaction, blockHash, account);
|
|
66115
|
+
retval.push(...[account.publicKeyString.get(), { blockHash, height }]);
|
|
66116
|
+
}
|
|
66117
|
+
return (retval);
|
|
66118
|
+
}));
|
|
66119
|
+
return (Object.fromEntries(response));
|
|
66120
|
+
}
|
|
66100
66121
|
async getHeadBlockHashes(transaction, accounts) {
|
|
66101
66122
|
const received = await this.getHeadBlocks(transaction, accounts.toArray(), 'both');
|
|
66102
66123
|
return (Object.fromEntries(Object.entries(received).map(function ([account, value]) {
|
|
@@ -66109,6 +66130,16 @@ class LedgerStorageBase {
|
|
|
66109
66130
|
})));
|
|
66110
66131
|
}
|
|
66111
66132
|
async preAdjust(input, mayDefer = true, transaction) {
|
|
66133
|
+
const allBlockHeightsToFetch = input.blocks.map(block => {
|
|
66134
|
+
return ({ blockHash: block.hash, account: block.account });
|
|
66135
|
+
});
|
|
66136
|
+
const allBlockHeights = await this.getBlockHeights(transaction, allBlockHeightsToFetch);
|
|
66137
|
+
// Check if any blocks already exist on the ledger that would cause this staple to fail and exit early
|
|
66138
|
+
for (const [blockHash, blockHeight] of Object.entries(allBlockHeights)) {
|
|
66139
|
+
if (blockHeight !== null) {
|
|
66140
|
+
throw (new ledger_1.default('LEDGER_BLOCK_ALREADY_EXISTS', `Block Already Exists: ${blockHash.toString()}`));
|
|
66141
|
+
}
|
|
66142
|
+
}
|
|
66112
66143
|
const seenBlockHashes = new block_1.BlockHash.Set();
|
|
66113
66144
|
const blockHeights = {};
|
|
66114
66145
|
const toFetch = [];
|
|
@@ -67180,7 +67211,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
67180
67211
|
};
|
|
67181
67212
|
var _LedgerAtomicInterface_instances, _LedgerAtomicInterface_network, _LedgerAtomicInterface_subnet, _LedgerAtomicInterface_kind, _LedgerAtomicInterface_privateKey, _LedgerAtomicInterface_computeFeeFromBlocks, _LedgerAtomicInterface_storage, _LedgerAtomicInterface_ledger, _LedgerAtomicInterface_cache, _LedgerAtomicInterface_transaction, _LedgerAtomicInterface_assertTransaction, _LedgerAtomicInterface_validateVotingWeight, _LedgerAtomicInterface_listAccountInfo, _LedgerAtomicInterface_checkSingleAccountPermissions, _LedgerAtomicInterface_checkPermissionRequirements, _LedgerAtomicInterface_validateLedgerOutcome, _LedgerAtomicInterface_validateBlocksForVote, _LedgerAtomicInterface_voteOrQuoteWithFees, _Ledger_storage, _Ledger_config;
|
|
67182
67213
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
67183
|
-
exports.Ledger = exports.LedgerKind = void 0;
|
|
67214
|
+
exports.Ledger = exports.LedgerStorageTransactionBase = exports.LedgerKind = void 0;
|
|
67184
67215
|
const vote_1 = __webpack_require__(1130);
|
|
67185
67216
|
const block_1 = __webpack_require__(6158);
|
|
67186
67217
|
const account_1 = __importDefault(__webpack_require__(9415));
|
|
@@ -67193,6 +67224,7 @@ const conversion_1 = __webpack_require__(2360);
|
|
|
67193
67224
|
const cache_1 = __importDefault(__webpack_require__(5834));
|
|
67194
67225
|
const timing_1 = __webpack_require__(2895);
|
|
67195
67226
|
const operations_1 = __webpack_require__(2778);
|
|
67227
|
+
const stats_1 = __webpack_require__(2127);
|
|
67196
67228
|
/**
|
|
67197
67229
|
* Kind of ledger
|
|
67198
67230
|
*/
|
|
@@ -67201,6 +67233,16 @@ var LedgerKind;
|
|
|
67201
67233
|
LedgerKind[LedgerKind["REPRESENTATIVE"] = 0] = "REPRESENTATIVE";
|
|
67202
67234
|
LedgerKind[LedgerKind["ACCOUNT"] = 1] = "ACCOUNT";
|
|
67203
67235
|
})(LedgerKind || (exports.LedgerKind = LedgerKind = {}));
|
|
67236
|
+
class LedgerStorageTransactionBase {
|
|
67237
|
+
constructor(options) {
|
|
67238
|
+
this.node = options.node;
|
|
67239
|
+
this.moment = options.moment ?? new Date();
|
|
67240
|
+
this.identifier = options.identifier;
|
|
67241
|
+
this.readOnly = options.readOnly ?? true;
|
|
67242
|
+
this.statsPending = new stats_1.StatsPending();
|
|
67243
|
+
}
|
|
67244
|
+
}
|
|
67245
|
+
exports.LedgerStorageTransactionBase = LedgerStorageTransactionBase;
|
|
67204
67246
|
/**
|
|
67205
67247
|
* Atomic transactional interface to a storage backend
|
|
67206
67248
|
*/
|
|
@@ -67242,6 +67284,7 @@ class LedgerAtomicInterface {
|
|
|
67242
67284
|
const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
67243
67285
|
__classPrivateFieldSet(this, _LedgerAtomicInterface_transaction, null, "f");
|
|
67244
67286
|
await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").commitTransaction(transaction);
|
|
67287
|
+
__classPrivateFieldGet(this, _LedgerAtomicInterface_ledger, "f").node?.stats.merge(transaction.statsPending);
|
|
67245
67288
|
}
|
|
67246
67289
|
async abort() {
|
|
67247
67290
|
const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
@@ -67484,12 +67527,9 @@ class LedgerAtomicInterface {
|
|
|
67484
67527
|
/**
|
|
67485
67528
|
* Add all the block hashes to the node checksum
|
|
67486
67529
|
*/
|
|
67487
|
-
const
|
|
67488
|
-
|
|
67489
|
-
|
|
67490
|
-
for (const block of staple.blocks) {
|
|
67491
|
-
ourNode.stats.xor('ledgerChecksum', block.hash);
|
|
67492
|
-
}
|
|
67530
|
+
for (const staple of voteStaples) {
|
|
67531
|
+
for (const block of staple.blocks) {
|
|
67532
|
+
transaction.statsPending.xor('ledgerChecksum', block.hash);
|
|
67493
67533
|
}
|
|
67494
67534
|
}
|
|
67495
67535
|
postambleTiming?.end();
|
|
@@ -67577,6 +67617,11 @@ class LedgerAtomicInterface {
|
|
|
67577
67617
|
const retval = await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").getBlock(transaction, blockhash, from);
|
|
67578
67618
|
return (retval);
|
|
67579
67619
|
}
|
|
67620
|
+
async getAccountsBlockHeightInfo(toFetch) {
|
|
67621
|
+
const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
67622
|
+
const retval = await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").getAccountsBlockHeightInfo(transaction, toFetch);
|
|
67623
|
+
return (retval);
|
|
67624
|
+
}
|
|
67580
67625
|
async getVoteStaple(stapleBlockHash, from = 'main') {
|
|
67581
67626
|
__classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
67582
67627
|
const results = await this.getVoteStaples([stapleBlockHash], from);
|
|
@@ -68253,13 +68298,7 @@ class Ledger {
|
|
|
68253
68298
|
return (await this.run(identifier, code, true));
|
|
68254
68299
|
}
|
|
68255
68300
|
async beginTransaction(identifier, readOnly = false) {
|
|
68256
|
-
const
|
|
68257
|
-
node: this.node,
|
|
68258
|
-
moment: new Date(),
|
|
68259
|
-
identifier,
|
|
68260
|
-
readOnly
|
|
68261
|
-
};
|
|
68262
|
-
const transaction = await __classPrivateFieldGet(this, _Ledger_storage, "f").beginTransaction(transactionBase);
|
|
68301
|
+
const transaction = await __classPrivateFieldGet(this, _Ledger_storage, "f").beginTransaction({ node: this.node, moment: new Date(), identifier, readOnly });
|
|
68263
68302
|
return (new LedgerAtomicInterface(transaction, __classPrivateFieldGet(this, _Ledger_storage, "f"), __classPrivateFieldGet(this, _Ledger_config, "f"), this));
|
|
68264
68303
|
}
|
|
68265
68304
|
async vote(...args) {
|
|
@@ -68352,6 +68391,11 @@ class Ledger {
|
|
|
68352
68391
|
return (await transaction.getBlock(...args));
|
|
68353
68392
|
}));
|
|
68354
68393
|
}
|
|
68394
|
+
async getAccountsBlockHeightInfo(...args) {
|
|
68395
|
+
return (await this.runReadOnly('db-getAccountsBlockHeightInfo', async function (transaction) {
|
|
68396
|
+
return (await transaction.getAccountsBlockHeightInfo(...args));
|
|
68397
|
+
}));
|
|
68398
|
+
}
|
|
68355
68399
|
async getVoteStaple(...args) {
|
|
68356
68400
|
return (await this.runReadOnly('db-getVoteStaple', async function (transaction) {
|
|
68357
68401
|
return (await transaction.getVoteStaple(...args));
|
|
@@ -68383,7 +68427,7 @@ class Ledger {
|
|
|
68383
68427
|
}));
|
|
68384
68428
|
}
|
|
68385
68429
|
async getFee(...args) {
|
|
68386
|
-
return (await this.
|
|
68430
|
+
return (await this.runReadOnly('db-getFee', async function (transaction) {
|
|
68387
68431
|
return (await transaction.getFee(...args));
|
|
68388
68432
|
}));
|
|
68389
68433
|
}
|
|
@@ -68934,7 +68978,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
68934
68978
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
68935
68979
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
68936
68980
|
};
|
|
68937
|
-
var _P2PHttpConnection_switch, _P2PWebSocket_underlyingSocket, _P2PWebSocket_socket, _P2PWebSocket_switch, _P2PSwitch_instances, _P2PSwitch_connectedPeersCleanup, _P2PSwitch_connectedPeersRemote, _P2PSwitch_connectedPeersLocal, _P2PSwitch_localNode, _P2PSwitch_manualPeersCheckIntervals, _P2PSwitch_asyncSends, _P2PSwitch_messageFilterCache, _P2PSwitch_connectedPeerConnection, _P2PSwitch_connectedPeers, _P2PSwitch_updateLastSeenPeer, _P2PSwitch_peersCacheSet, _P2PSwitch_peersCached, _P2PSwitch_relayActiveState, _P2PSwitch_performPeerCleanup, _P2PSwitch_getLocalPeerInfo, _P2PSwitch_emitOutgoingGreeting, _P2PSwitch_localNodeKeyOrNull, _P2PSwitch_handleIncomingGreeting, _P2PSwitch_updateConnTimeout, _P2PSwitch_connectToPeer, _P2PSwitch_passesFilter;
|
|
68981
|
+
var _P2PHttpConnection_switch, _P2PWebSocket_underlyingSocket, _P2PWebSocket_socket, _P2PWebSocket_switch, _P2PSwitch_instances, _P2PSwitch_connectedPeersCleanup, _P2PSwitch_connectedPeersRemote, _P2PSwitch_connectedPeersLocal, _P2PSwitch_localNode, _P2PSwitch_manualPeersCheckIntervals, _P2PSwitch_asyncSends, _P2PSwitch_messageFilterCache, _P2PSwitch_cachedLocalPeerInfo, _P2PSwitch_cachedLocalPeerSerialized, _P2PSwitch_connectedPeerConnection, _P2PSwitch_connectedPeers, _P2PSwitch_updateLastSeenPeer, _P2PSwitch_peersCacheSet, _P2PSwitch_peersCached, _P2PSwitch_relayActiveState, _P2PSwitch_performPeerCleanup, _P2PSwitch_getLocalPeerInfo, _P2PSwitch_emitOutgoingGreeting, _P2PSwitch_localNodeKeyOrNull, _P2PSwitch_handleIncomingGreeting, _P2PSwitch_updateConnTimeout, _P2PSwitch_connectToPeer, _P2PSwitch_passesFilter;
|
|
68938
68982
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
68939
68983
|
exports.Testing = exports.P2PSwitch = exports.P2PWebSocket = exports.P2PHttpConnection = void 0;
|
|
68940
68984
|
exports.generateP2PPeerSigned = generateP2PPeerSigned;
|
|
@@ -69628,6 +69672,8 @@ class P2PSwitch {
|
|
|
69628
69672
|
_P2PSwitch_manualPeersCheckIntervals.set(this, void 0);
|
|
69629
69673
|
_P2PSwitch_asyncSends.set(this, []);
|
|
69630
69674
|
_P2PSwitch_messageFilterCache.set(this, {});
|
|
69675
|
+
_P2PSwitch_cachedLocalPeerInfo.set(this, undefined);
|
|
69676
|
+
_P2PSwitch_cachedLocalPeerSerialized.set(this, undefined);
|
|
69631
69677
|
/**
|
|
69632
69678
|
* Write a debug or error message to the connected node.
|
|
69633
69679
|
*
|
|
@@ -69935,11 +69981,14 @@ class P2PSwitch {
|
|
|
69935
69981
|
return (await __classPrivateFieldGet(this, _P2PSwitch_instances, "m", _P2PSwitch_getLocalPeerInfo).call(this));
|
|
69936
69982
|
}
|
|
69937
69983
|
async getOutgoingGreetingInfo() {
|
|
69938
|
-
|
|
69939
|
-
|
|
69940
|
-
|
|
69984
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_cachedLocalPeerSerialized, "f") === undefined) {
|
|
69985
|
+
const greetingInfo = await __classPrivateFieldGet(this, _P2PSwitch_instances, "m", _P2PSwitch_getLocalPeerInfo).call(this);
|
|
69986
|
+
if (greetingInfo === null) {
|
|
69987
|
+
throw (new Error('Invalid NodeKind for emitting outgoing greeting'));
|
|
69988
|
+
}
|
|
69989
|
+
__classPrivateFieldSet(this, _P2PSwitch_cachedLocalPeerSerialized, P2PPeerToJSO(greetingInfo), "f");
|
|
69941
69990
|
}
|
|
69942
|
-
return (
|
|
69991
|
+
return (__classPrivateFieldGet(this, _P2PSwitch_cachedLocalPeerSerialized, "f"));
|
|
69943
69992
|
}
|
|
69944
69993
|
/**
|
|
69945
69994
|
* Receive a message from a connection
|
|
@@ -70467,7 +70516,7 @@ class P2PSwitch {
|
|
|
70467
70516
|
}
|
|
70468
70517
|
}
|
|
70469
70518
|
exports.P2PSwitch = P2PSwitch;
|
|
70470
|
-
_P2PSwitch_connectedPeersCleanup = new WeakMap(), _P2PSwitch_connectedPeersRemote = new WeakMap(), _P2PSwitch_connectedPeersLocal = new WeakMap(), _P2PSwitch_localNode = new WeakMap(), _P2PSwitch_manualPeersCheckIntervals = new WeakMap(), _P2PSwitch_asyncSends = new WeakMap(), _P2PSwitch_messageFilterCache = new WeakMap(), _P2PSwitch_peersCacheSet = new WeakMap(), _P2PSwitch_instances = new WeakSet(), _P2PSwitch_connectedPeerConnection =
|
|
70519
|
+
_P2PSwitch_connectedPeersCleanup = new WeakMap(), _P2PSwitch_connectedPeersRemote = new WeakMap(), _P2PSwitch_connectedPeersLocal = new WeakMap(), _P2PSwitch_localNode = new WeakMap(), _P2PSwitch_manualPeersCheckIntervals = new WeakMap(), _P2PSwitch_asyncSends = new WeakMap(), _P2PSwitch_messageFilterCache = new WeakMap(), _P2PSwitch_cachedLocalPeerInfo = new WeakMap(), _P2PSwitch_cachedLocalPeerSerialized = new WeakMap(), _P2PSwitch_peersCacheSet = new WeakMap(), _P2PSwitch_instances = new WeakSet(), _P2PSwitch_connectedPeerConnection =
|
|
70471
70520
|
/**
|
|
70472
70521
|
* Get the connection for a given peer or PeerID
|
|
70473
70522
|
*/
|
|
@@ -70608,47 +70657,50 @@ async function _P2PSwitch_relayActiveState(conn) {
|
|
|
70608
70657
|
*/
|
|
70609
70658
|
/** XXX:TODO */
|
|
70610
70659
|
}, _P2PSwitch_getLocalPeerInfo = async function _P2PSwitch_getLocalPeerInfo() {
|
|
70611
|
-
|
|
70612
|
-
|
|
70613
|
-
|
|
70614
|
-
|
|
70615
|
-
|
|
70616
|
-
id: 'unused'
|
|
70617
|
-
};
|
|
70618
|
-
break;
|
|
70619
|
-
case node_1.NodeKind.REPRESENTATIVE:
|
|
70620
|
-
{
|
|
70621
|
-
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints === undefined) {
|
|
70622
|
-
throw (new Error('internal error: Our endpoints are not defined'));
|
|
70623
|
-
}
|
|
70624
|
-
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.p2p === undefined) {
|
|
70625
|
-
throw (new Error('internal error: Our endpoint (p2p) is not defined'));
|
|
70626
|
-
}
|
|
70627
|
-
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.api === undefined) {
|
|
70628
|
-
throw (new Error('internal error: Our endpoint (api) is not defined'));
|
|
70629
|
-
}
|
|
70630
|
-
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.ledgerPrivateKey === undefined) {
|
|
70631
|
-
throw (new Error('internal error: Our ledger key is not defined'));
|
|
70632
|
-
}
|
|
70633
|
-
const greetingInfoSigned = await generateP2PPeerSigned({
|
|
70660
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_cachedLocalPeerInfo, "f") === undefined) {
|
|
70661
|
+
let greetingInfo;
|
|
70662
|
+
switch (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.kind) {
|
|
70663
|
+
case node_1.NodeKind.PARTICIPANT:
|
|
70664
|
+
greetingInfo = {
|
|
70634
70665
|
kind: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.kind,
|
|
70635
|
-
|
|
70636
|
-
|
|
70637
|
-
p2p: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.p2p,
|
|
70638
|
-
api: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.api
|
|
70639
|
-
},
|
|
70640
|
-
preferUpdates: this.config.useHTTPRepublish ? 'http' : 'websocket'
|
|
70641
|
-
});
|
|
70642
|
-
if (greetingInfoSigned === null) {
|
|
70643
|
-
throw (new Error('internal error: Could not generate signature'));
|
|
70644
|
-
}
|
|
70645
|
-
greetingInfo = greetingInfoSigned;
|
|
70666
|
+
id: 'unused'
|
|
70667
|
+
};
|
|
70646
70668
|
break;
|
|
70647
|
-
|
|
70648
|
-
|
|
70649
|
-
|
|
70669
|
+
case node_1.NodeKind.REPRESENTATIVE:
|
|
70670
|
+
{
|
|
70671
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints === undefined) {
|
|
70672
|
+
throw (new Error('internal error: Our endpoints are not defined'));
|
|
70673
|
+
}
|
|
70674
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.p2p === undefined) {
|
|
70675
|
+
throw (new Error('internal error: Our endpoint (p2p) is not defined'));
|
|
70676
|
+
}
|
|
70677
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.api === undefined) {
|
|
70678
|
+
throw (new Error('internal error: Our endpoint (api) is not defined'));
|
|
70679
|
+
}
|
|
70680
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.ledgerPrivateKey === undefined) {
|
|
70681
|
+
throw (new Error('internal error: Our ledger key is not defined'));
|
|
70682
|
+
}
|
|
70683
|
+
const greetingInfoSigned = await generateP2PPeerSigned({
|
|
70684
|
+
kind: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.kind,
|
|
70685
|
+
key: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.ledgerPrivateKey,
|
|
70686
|
+
endpoints: {
|
|
70687
|
+
p2p: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.p2p,
|
|
70688
|
+
api: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.api
|
|
70689
|
+
},
|
|
70690
|
+
preferUpdates: this.config.useHTTPRepublish ? 'http' : 'websocket'
|
|
70691
|
+
});
|
|
70692
|
+
if (greetingInfoSigned === null) {
|
|
70693
|
+
throw (new Error('internal error: Could not generate signature'));
|
|
70694
|
+
}
|
|
70695
|
+
greetingInfo = greetingInfoSigned;
|
|
70696
|
+
break;
|
|
70697
|
+
}
|
|
70698
|
+
default:
|
|
70699
|
+
return (null);
|
|
70700
|
+
}
|
|
70701
|
+
__classPrivateFieldSet(this, _P2PSwitch_cachedLocalPeerInfo, greetingInfo, "f");
|
|
70650
70702
|
}
|
|
70651
|
-
return (
|
|
70703
|
+
return (__classPrivateFieldGet(this, _P2PSwitch_cachedLocalPeerInfo, "f"));
|
|
70652
70704
|
}, _P2PSwitch_emitOutgoingGreeting = async function _P2PSwitch_emitOutgoingGreeting(to) {
|
|
70653
70705
|
const messageID = uuid.v4();
|
|
70654
70706
|
const greeting = await this.getOutgoingGreetingInfo();
|
|
@@ -71372,9 +71424,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
71372
71424
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
71373
71425
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
71374
71426
|
};
|
|
71375
|
-
var
|
|
71427
|
+
var _a, _Stats_syncPromise, _Stats_kv, _Stats_assertDurationBreakdowns, _Stats_getDurationRange;
|
|
71376
71428
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
71377
|
-
exports.Stats = void 0;
|
|
71429
|
+
exports.Stats = exports.StatsPending = void 0;
|
|
71378
71430
|
const kv_memory_1 = __importDefault(__webpack_require__(1557));
|
|
71379
71431
|
const buffer_1 = __webpack_require__(3310);
|
|
71380
71432
|
const hash_1 = __webpack_require__(7908);
|
|
@@ -71404,11 +71456,57 @@ const durationRanges = {
|
|
|
71404
71456
|
'100000ms': [10001, 100000],
|
|
71405
71457
|
'ExtraLong': [100000, Number.MAX_SAFE_INTEGER]
|
|
71406
71458
|
};
|
|
71407
|
-
class
|
|
71459
|
+
class StatsPending {
|
|
71460
|
+
constructor() {
|
|
71461
|
+
this.localDBIncr = {};
|
|
71462
|
+
this.localDBXOR = {};
|
|
71463
|
+
}
|
|
71464
|
+
consume() {
|
|
71465
|
+
const incrChanges = this.localDBIncr;
|
|
71466
|
+
this.localDBIncr = {};
|
|
71467
|
+
const xorChanges = this.localDBXOR;
|
|
71468
|
+
this.localDBXOR = {};
|
|
71469
|
+
return ({ incrChanges, xorChanges });
|
|
71470
|
+
}
|
|
71471
|
+
compoundKey(arena, key) {
|
|
71472
|
+
const compoundKey = [arena, key].join('|');
|
|
71473
|
+
return (compoundKey);
|
|
71474
|
+
}
|
|
71475
|
+
incrCompoundKey(compoundKey, change) {
|
|
71476
|
+
if (this.localDBIncr[compoundKey] === undefined) {
|
|
71477
|
+
this.localDBIncr[compoundKey] = 0;
|
|
71478
|
+
}
|
|
71479
|
+
this.localDBIncr[compoundKey] += change;
|
|
71480
|
+
}
|
|
71481
|
+
incr(arena, key, change = 1) {
|
|
71482
|
+
const compoundKey = this.compoundKey(arena, key);
|
|
71483
|
+
this.incrCompoundKey(compoundKey, change);
|
|
71484
|
+
}
|
|
71485
|
+
xor(key, change) {
|
|
71486
|
+
const changeValue = typeof change === 'bigint' ? change : change.toBigInt();
|
|
71487
|
+
const existingValue = this.localDBXOR[key];
|
|
71488
|
+
if (existingValue === undefined) {
|
|
71489
|
+
this.localDBXOR[key] = changeValue;
|
|
71490
|
+
return;
|
|
71491
|
+
}
|
|
71492
|
+
this.localDBXOR[key] ^= changeValue;
|
|
71493
|
+
}
|
|
71494
|
+
merge(pending) {
|
|
71495
|
+
const { incrChanges, xorChanges } = pending.consume();
|
|
71496
|
+
// Merge incr changes
|
|
71497
|
+
for (const [key, value] of Object.entries(incrChanges)) {
|
|
71498
|
+
this.incrCompoundKey(key, value);
|
|
71499
|
+
}
|
|
71500
|
+
// Merge xor changes
|
|
71501
|
+
for (const [key, value] of Object.entries(xorChanges)) {
|
|
71502
|
+
this.xor(key, value);
|
|
71503
|
+
}
|
|
71504
|
+
}
|
|
71505
|
+
}
|
|
71506
|
+
exports.StatsPending = StatsPending;
|
|
71507
|
+
class Stats extends StatsPending {
|
|
71408
71508
|
constructor(config) {
|
|
71409
|
-
|
|
71410
|
-
_Stats_localDBIncr.set(this, {});
|
|
71411
|
-
_Stats_localDBXOR.set(this, {});
|
|
71509
|
+
super();
|
|
71412
71510
|
_Stats_syncPromise.set(this, void 0);
|
|
71413
71511
|
_Stats_kv.set(this, void 0);
|
|
71414
71512
|
let kv = config.kv;
|
|
@@ -71451,22 +71549,6 @@ class Stats {
|
|
|
71451
71549
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
71452
71550
|
return ret;
|
|
71453
71551
|
}
|
|
71454
|
-
incr(arena, key, change = 1) {
|
|
71455
|
-
const compoundKey = __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_compoundKey).call(this, arena, key);
|
|
71456
|
-
if (__classPrivateFieldGet(this, _Stats_localDBIncr, "f")[compoundKey] === undefined) {
|
|
71457
|
-
__classPrivateFieldGet(this, _Stats_localDBIncr, "f")[compoundKey] = 0;
|
|
71458
|
-
}
|
|
71459
|
-
__classPrivateFieldGet(this, _Stats_localDBIncr, "f")[compoundKey] += change;
|
|
71460
|
-
}
|
|
71461
|
-
xor(key, change) {
|
|
71462
|
-
const changeValue = change.toBigInt();
|
|
71463
|
-
const existingValue = __classPrivateFieldGet(this, _Stats_localDBXOR, "f")[key];
|
|
71464
|
-
if (existingValue === undefined) {
|
|
71465
|
-
__classPrivateFieldGet(this, _Stats_localDBXOR, "f")[key] = changeValue;
|
|
71466
|
-
return;
|
|
71467
|
-
}
|
|
71468
|
-
__classPrivateFieldGet(this, _Stats_localDBXOR, "f")[key] ^= changeValue;
|
|
71469
|
-
}
|
|
71470
71552
|
async getXor(key) {
|
|
71471
71553
|
await __classPrivateFieldGet(this, _Stats_syncPromise, "f");
|
|
71472
71554
|
const bufferKey = `@buffer:${key}`;
|
|
@@ -71476,8 +71558,8 @@ class Stats {
|
|
|
71476
71558
|
base = BigInt(`0x${baseString}`);
|
|
71477
71559
|
}
|
|
71478
71560
|
let local = 0n;
|
|
71479
|
-
if (
|
|
71480
|
-
local =
|
|
71561
|
+
if (this.localDBXOR[key] !== undefined) {
|
|
71562
|
+
local = this.localDBXOR[key];
|
|
71481
71563
|
}
|
|
71482
71564
|
const computed = base ^ local;
|
|
71483
71565
|
const retval = new buffer_1.BufferStorage(computed, XOR_BUFFER_SIZE);
|
|
@@ -71503,7 +71585,7 @@ class Stats {
|
|
|
71503
71585
|
}
|
|
71504
71586
|
async get(arena, key) {
|
|
71505
71587
|
await __classPrivateFieldGet(this, _Stats_syncPromise, "f");
|
|
71506
|
-
const compoundKey =
|
|
71588
|
+
const compoundKey = this.compoundKey(arena, key);
|
|
71507
71589
|
let base = await __classPrivateFieldGet(this, _Stats_kv, "f").get('stats', compoundKey);
|
|
71508
71590
|
if (base === undefined) {
|
|
71509
71591
|
base = 0;
|
|
@@ -71515,8 +71597,8 @@ class Stats {
|
|
|
71515
71597
|
throw (new Error('internal error: corrupt data in stats table'));
|
|
71516
71598
|
}
|
|
71517
71599
|
let local = 0;
|
|
71518
|
-
if (
|
|
71519
|
-
local =
|
|
71600
|
+
if (this.localDBIncr[compoundKey] !== undefined) {
|
|
71601
|
+
local = this.localDBIncr[compoundKey];
|
|
71520
71602
|
}
|
|
71521
71603
|
return (base + local);
|
|
71522
71604
|
}
|
|
@@ -71544,20 +71626,17 @@ class Stats {
|
|
|
71544
71626
|
return (retval);
|
|
71545
71627
|
}
|
|
71546
71628
|
async sync() {
|
|
71547
|
-
const
|
|
71548
|
-
const localDBXOR = Object.entries(__classPrivateFieldGet(this, _Stats_localDBXOR, "f"));
|
|
71549
|
-
__classPrivateFieldSet(this, _Stats_localDBIncr, {}, "f");
|
|
71550
|
-
__classPrivateFieldSet(this, _Stats_localDBXOR, {}, "f");
|
|
71629
|
+
const { incrChanges, xorChanges } = this.consume();
|
|
71551
71630
|
await __classPrivateFieldGet(this, _Stats_syncPromise, "f");
|
|
71552
71631
|
__classPrivateFieldSet(this, _Stats_syncPromise, (async () => {
|
|
71553
71632
|
const updatePromises = [];
|
|
71554
|
-
for (const [key, value] of
|
|
71633
|
+
for (const [key, value] of Object.entries(incrChanges)) {
|
|
71555
71634
|
if (value === undefined) {
|
|
71556
71635
|
continue;
|
|
71557
71636
|
}
|
|
71558
71637
|
updatePromises.push(__classPrivateFieldGet(this, _Stats_kv, "f").incr('stats', key, value));
|
|
71559
71638
|
}
|
|
71560
|
-
for (const [key, value] of
|
|
71639
|
+
for (const [key, value] of Object.entries(xorChanges)) {
|
|
71561
71640
|
if (value === undefined) {
|
|
71562
71641
|
continue;
|
|
71563
71642
|
}
|
|
@@ -71572,10 +71651,7 @@ class Stats {
|
|
|
71572
71651
|
}
|
|
71573
71652
|
}
|
|
71574
71653
|
exports.Stats = Stats;
|
|
71575
|
-
_a = Stats,
|
|
71576
|
-
const compoundKey = [arena, key].join('|');
|
|
71577
|
-
return (compoundKey);
|
|
71578
|
-
}, _Stats_assertDurationBreakdowns = function _Stats_assertDurationBreakdowns(durations) {
|
|
71654
|
+
_a = Stats, _Stats_syncPromise = new WeakMap(), _Stats_kv = new WeakMap(), _Stats_assertDurationBreakdowns = function _Stats_assertDurationBreakdowns(durations) {
|
|
71579
71655
|
for (const duration of durations) {
|
|
71580
71656
|
this.assertDurationBreakdown(duration);
|
|
71581
71657
|
}
|
|
@@ -71637,7 +71713,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
71637
71713
|
};
|
|
71638
71714
|
var _ValidateASN1_schema, _BufferStorageASN1_data;
|
|
71639
71715
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
71640
|
-
exports._Testing = exports.ASN1BigIntToBuffer = exports.ASN1IntegerToBigInt = exports.JStoASN1 = exports.ASN1toJS = exports.BufferStorageASN1 = exports.ValidateASN1 = exports.asn1 = void 0;
|
|
71716
|
+
exports._Testing = exports.ASN1BigIntToBuffer = exports.ASN1IntegerToBigInt = exports.JStoASN1 = exports.ASN1toJS = exports.BufferStorageASN1 = exports.ValidateASN1 = exports.ASN1CheckUtilities = exports.asn1 = void 0;
|
|
71641
71717
|
exports.isASN1Object = isASN1Object;
|
|
71642
71718
|
exports.isValidSequenceSchema = isValidSequenceSchema;
|
|
71643
71719
|
const asn1js = __importStar(__webpack_require__(7813));
|
|
@@ -71768,7 +71844,16 @@ function isASN1Set(input) {
|
|
|
71768
71844
|
}
|
|
71769
71845
|
return (true);
|
|
71770
71846
|
}
|
|
71771
|
-
function
|
|
71847
|
+
function isASN1ContextTagKind(input) {
|
|
71848
|
+
if (typeof input !== 'string') {
|
|
71849
|
+
return (false);
|
|
71850
|
+
}
|
|
71851
|
+
if (!(['explicit', 'implicit'].includes(input))) {
|
|
71852
|
+
return (false);
|
|
71853
|
+
}
|
|
71854
|
+
return (true);
|
|
71855
|
+
}
|
|
71856
|
+
function isASN1ContextTag(input, tagKind) {
|
|
71772
71857
|
if (!isASN1Object(input)) {
|
|
71773
71858
|
return (false);
|
|
71774
71859
|
}
|
|
@@ -71781,6 +71866,12 @@ function isASN1ContextTag(input) {
|
|
|
71781
71866
|
if (!('contains' in input) || input.contains === undefined) {
|
|
71782
71867
|
return (false);
|
|
71783
71868
|
}
|
|
71869
|
+
if (!('kind' in input) || !isASN1ContextTagKind(input.kind)) {
|
|
71870
|
+
return (false);
|
|
71871
|
+
}
|
|
71872
|
+
if (tagKind !== undefined && input.kind !== tagKind) {
|
|
71873
|
+
return (false);
|
|
71874
|
+
}
|
|
71784
71875
|
return (true);
|
|
71785
71876
|
}
|
|
71786
71877
|
function isASN1BitString(input) {
|
|
@@ -71837,6 +71928,15 @@ function isStringValidForKind(input, kind) {
|
|
|
71837
71928
|
}
|
|
71838
71929
|
return (false);
|
|
71839
71930
|
}
|
|
71931
|
+
exports.ASN1CheckUtilities = {
|
|
71932
|
+
isASN1Object,
|
|
71933
|
+
isASN1OID,
|
|
71934
|
+
isASN1String,
|
|
71935
|
+
isASN1Set,
|
|
71936
|
+
isASN1ContextTag,
|
|
71937
|
+
isASN1BitString,
|
|
71938
|
+
isASN1Date
|
|
71939
|
+
};
|
|
71840
71940
|
/**
|
|
71841
71941
|
* Checks if an ASN.1 sequence is valid based on a provided validation schema.
|
|
71842
71942
|
*/
|
|
@@ -73318,7 +73418,7 @@ class CertificateBuilder {
|
|
|
73318
73418
|
case 'sha3-256':
|
|
73319
73419
|
return (hashLib.name);
|
|
73320
73420
|
default:
|
|
73321
|
-
throw (new Error(`Unsupported hash algorithm "${hashLib.name}"`));
|
|
73421
|
+
throw (new Error(`internal error: Unsupported hash algorithm "${hashLib.name}"`));
|
|
73322
73422
|
}
|
|
73323
73423
|
}
|
|
73324
73424
|
const hashName = params.hashParams?.defaults?.[purpose] ?? defaultHashName;
|
|
@@ -73337,7 +73437,7 @@ class CertificateBuilder {
|
|
|
73337
73437
|
const hashName = this.hashName(params, purpose);
|
|
73338
73438
|
const hashFunction = params.hashParams.functions?.[hashName];
|
|
73339
73439
|
if (hashFunction === undefined) {
|
|
73340
|
-
throw (new Error(`Hash function "${hashName}" not found for purpose "${purpose}"`));
|
|
73440
|
+
throw (new Error(`internal error: Hash function "${hashName}" not found for purpose "${purpose}"`));
|
|
73341
73441
|
}
|
|
73342
73442
|
return (hashFunction(...data));
|
|
73343
73443
|
}
|
|
@@ -73461,28 +73561,28 @@ class CertificateBuilder {
|
|
|
73461
73561
|
/* Validate that required parameters are set */
|
|
73462
73562
|
const issuer = finalParams.issuer;
|
|
73463
73563
|
if (issuer === undefined) {
|
|
73464
|
-
throw (new
|
|
73564
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"issuer" not set'));
|
|
73465
73565
|
}
|
|
73466
73566
|
const subjectPublicKey = finalParams.subjectPublicKey;
|
|
73467
73567
|
if (subjectPublicKey === undefined) {
|
|
73468
|
-
throw (new
|
|
73568
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"subject" not set'));
|
|
73469
73569
|
}
|
|
73470
73570
|
const validFrom = finalParams.validFrom;
|
|
73471
73571
|
if (validFrom === undefined) {
|
|
73472
|
-
throw (new
|
|
73572
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"validFrom" not set'));
|
|
73473
73573
|
}
|
|
73474
73574
|
const validTo = finalParams.validTo;
|
|
73475
73575
|
if (validTo === undefined) {
|
|
73476
|
-
throw (new
|
|
73576
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"validTo" not set'));
|
|
73477
73577
|
}
|
|
73478
73578
|
const serial = finalParams.serial;
|
|
73479
73579
|
if (serial === undefined) {
|
|
73480
|
-
throw (new
|
|
73580
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"serialNumber" not set'));
|
|
73481
73581
|
}
|
|
73482
73582
|
const hashLib = finalParams.hashLib;
|
|
73483
73583
|
const hashParams = finalParams.hashParams;
|
|
73484
73584
|
if (hashParams === undefined) {
|
|
73485
|
-
throw (new
|
|
73585
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"hashParams" not set'));
|
|
73486
73586
|
}
|
|
73487
73587
|
return ({
|
|
73488
73588
|
...finalParams,
|
|
@@ -73796,7 +73896,7 @@ class Certificate {
|
|
|
73796
73896
|
const tbsCertificate = parts[0];
|
|
73797
73897
|
const [version, serialNumber, signatureAlgorithmSigned, issuer, [notBefore, notAfter], subject, subjectPublicKey, extensions] = tbsCertificate;
|
|
73798
73898
|
if (version.contains !== 2n) {
|
|
73799
|
-
throw (new
|
|
73899
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_VERSION', 'Only X509v3 certificates are supported'));
|
|
73800
73900
|
}
|
|
73801
73901
|
const signatureAlgorithm = parts[1];
|
|
73802
73902
|
/**
|
|
@@ -73836,7 +73936,7 @@ class Certificate {
|
|
|
73836
73936
|
const signatureAlgorithmSignedBuffer = new ASN1.BufferStorageASN1(signatureAlgorithmSigned).getDERBuffer();
|
|
73837
73937
|
const signatureAlgorithmBuffer = new ASN1.BufferStorageASN1(signatureAlgorithm).getDERBuffer();
|
|
73838
73938
|
if (!signatureAlgorithmSignedBuffer.equals(signatureAlgorithmBuffer)) {
|
|
73839
|
-
throw (new
|
|
73939
|
+
throw (new certificate_1.default('CERTIFICATE_SIGNATURE_ALGORITHM_MISMATCH', 'Signature algorithm mismatch between signature and certificate'));
|
|
73840
73940
|
}
|
|
73841
73941
|
/*
|
|
73842
73942
|
* Process the extensions base extensions, which can be critical for
|
|
@@ -73866,7 +73966,7 @@ class Certificate {
|
|
|
73866
73966
|
}
|
|
73867
73967
|
});
|
|
73868
73968
|
if (!found) {
|
|
73869
|
-
throw (new
|
|
73969
|
+
throw (new certificate_1.default('CERTIFICATE_SELF_SIGNED_VALIDATION_FAILED', 'Self-signed certificate is not a root CA in the Root CA store'));
|
|
73870
73970
|
}
|
|
73871
73971
|
this.chain = [this];
|
|
73872
73972
|
}
|
|
@@ -73875,7 +73975,7 @@ class Certificate {
|
|
|
73875
73975
|
this.chain = [this];
|
|
73876
73976
|
}
|
|
73877
73977
|
if (!this.verify(this)) {
|
|
73878
|
-
throw (new
|
|
73978
|
+
throw (new certificate_1.default('CERTIFICATE_SELF_SIGNED_VALIDATION_FAILED', 'Self-signed certificate signature verification failed'));
|
|
73879
73979
|
}
|
|
73880
73980
|
}
|
|
73881
73981
|
else {
|
|
@@ -73885,7 +73985,7 @@ class Certificate {
|
|
|
73885
73985
|
if (options?.store !== undefined) {
|
|
73886
73986
|
const chain = this.verifyChain(options.store);
|
|
73887
73987
|
if (chain === null || chain.length === 0) {
|
|
73888
|
-
throw (new
|
|
73988
|
+
throw (new certificate_1.default('CERTIFICATE_CHAIN_VERIFICATION_FAILED', 'Certificate chain verification failed'));
|
|
73889
73989
|
}
|
|
73890
73990
|
this.chain = chain;
|
|
73891
73991
|
}
|
|
@@ -73950,7 +74050,7 @@ class Certificate {
|
|
|
73950
74050
|
compatibleKeyTypes = [account_1.default.AccountKeyAlgorithm.ED25519];
|
|
73951
74051
|
break;
|
|
73952
74052
|
default:
|
|
73953
|
-
throw (new
|
|
74053
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_SIGNATURE_ALGORITHM', `Unsupported signature algorithm ${signatureAlgorithm}`));
|
|
73954
74054
|
}
|
|
73955
74055
|
let hashAlgorithm;
|
|
73956
74056
|
switch (signatureAlgorithm) {
|
|
@@ -73964,7 +74064,7 @@ class Certificate {
|
|
|
73964
74064
|
hashAlgorithm = null;
|
|
73965
74065
|
break;
|
|
73966
74066
|
default:
|
|
73967
|
-
throw (new
|
|
74067
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_SIGNATURE_ALGORITHM', `Unsupported signature algorithm ${signatureAlgorithm}`));
|
|
73968
74068
|
}
|
|
73969
74069
|
let accountIsCompatible = false;
|
|
73970
74070
|
for (const checkCompatibleKeyType of compatibleKeyTypes) {
|
|
@@ -73974,7 +74074,7 @@ class Certificate {
|
|
|
73974
74074
|
}
|
|
73975
74075
|
}
|
|
73976
74076
|
if (!accountIsCompatible) {
|
|
73977
|
-
throw (new
|
|
74077
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_SIGNATURE_ALGORITHM', `Account does not have a compatible key type for signature algorithm ${signatureAlgorithm}`));
|
|
73978
74078
|
}
|
|
73979
74079
|
let dataToVerify;
|
|
73980
74080
|
if (hashAlgorithm !== null) {
|
|
@@ -74001,7 +74101,7 @@ class Certificate {
|
|
|
74001
74101
|
return (true);
|
|
74002
74102
|
}
|
|
74003
74103
|
if (certificates.size > 10) {
|
|
74004
|
-
throw (new
|
|
74104
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_GRAPH_COUNT', 'Cannot currently handle more than 10 certificates in a graph'));
|
|
74005
74105
|
}
|
|
74006
74106
|
const issuersFrom = [];
|
|
74007
74107
|
const issuersTo = [];
|
|
@@ -74114,7 +74214,7 @@ class Certificate {
|
|
|
74114
74214
|
assertValid(moment) {
|
|
74115
74215
|
const valid = this.checkValid(moment, true);
|
|
74116
74216
|
if (!valid.valid) {
|
|
74117
|
-
throw (new
|
|
74217
|
+
throw (new certificate_1.default('CERTIFICATE_MOMENT_INVALID', `Certificate is not valid: ${valid.reason}`));
|
|
74118
74218
|
}
|
|
74119
74219
|
}
|
|
74120
74220
|
checkIssued(issuer, reason) {
|
|
@@ -74179,7 +74279,7 @@ class Certificate {
|
|
|
74179
74279
|
}
|
|
74180
74280
|
assertConstructed() {
|
|
74181
74281
|
if (!__classPrivateFieldGet(this, _Certificate_finalizeConstructionCalled, "f")) {
|
|
74182
|
-
throw (new Error('finalizeConstruction not called'));
|
|
74282
|
+
throw (new Error('internal error: finalizeConstruction not called'));
|
|
74183
74283
|
}
|
|
74184
74284
|
}
|
|
74185
74285
|
/**
|
|
@@ -74310,7 +74410,7 @@ _Certificate_raw = new WeakMap(), _Certificate_hash = new WeakMap(), _Certificat
|
|
|
74310
74410
|
for (const extension of extensions) {
|
|
74311
74411
|
const id = extension[0].oid;
|
|
74312
74412
|
if (seenExtensions.has(id)) {
|
|
74313
|
-
throw (new
|
|
74413
|
+
throw (new certificate_1.default('CERTIFICATE_DUPLICATE_EXTENSION', `Duplicate extension ${id}`));
|
|
74314
74414
|
}
|
|
74315
74415
|
seenExtensions.add(id);
|
|
74316
74416
|
}
|
|
@@ -74365,7 +74465,7 @@ _Certificate_raw = new WeakMap(), _Certificate_hash = new WeakMap(), _Certificat
|
|
|
74365
74465
|
[id] = extension;
|
|
74366
74466
|
}
|
|
74367
74467
|
if (critical && !__classPrivateFieldGet(this, _Certificate_extensionsProcessed, "f").has(id.oid)) {
|
|
74368
|
-
throw (new
|
|
74468
|
+
throw (new certificate_1.default('CERTIFICATE_EXTENSION_NOT_PROCESSED', `Critical extension ${id.oid} not processed`));
|
|
74369
74469
|
}
|
|
74370
74470
|
}
|
|
74371
74471
|
}, _Certificate_checkValid = function _Certificate_checkValid(moment) {
|
|
@@ -77346,7 +77446,7 @@ exports.Testing = { findRDN, blockHashesFromVote, feeFromVote };
|
|
|
77346
77446
|
|
|
77347
77447
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
77348
77448
|
exports.version = void 0;
|
|
77349
|
-
exports.version = '0.14.
|
|
77449
|
+
exports.version = '0.14.3+gc0f4c96265aa999e6f32e3b21443d294bbf33806';
|
|
77350
77450
|
exports["default"] = exports.version;
|
|
77351
77451
|
|
|
77352
77452
|
|