@keetanetwork/keetanet-client 0.14.3 → 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.
- package/benchmarking/test.d.ts +4 -0
- package/client/index-browser.d.ts +18 -1
- package/client/index-browser.js +385 -133
- package/client/index.d.ts +18 -1
- package/client/index.js +403 -111
- 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 +8 -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 +8 -5
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +6 -0
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +9 -0
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.html +9 -0
- package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
- 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 +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +1 -1
- 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 +11 -6
- package/docs/hierarchy.html +1 -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 +3 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseTokenInfo.html +4 -0
- 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.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 +3 -2
- 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.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.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_initial.html +1 -1
- package/docs/types/KeetaNetSDK.Referenced.ErrorCode.html +1 -1
- package/docs/types/KeetaNetSDK.Referenced.LedgerBaseErrorCode.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.LedgerVoteErrorCode.html +1 -0
- package/docs/variables/KeetaNetSDK.Referenced.FullLedgerBaseErrorCode.html +1 -0
- package/docs/variables/KeetaNetSDK.Referenced.FullLedgerVoteErrorCodes.html +1 -0
- package/docs/variables/KeetaNetSDK.Referenced.allFullErrorCodes.html +1 -0
- package/lib/error/account.d.ts +6 -7
- package/lib/error/api.d.ts +8 -0
- package/lib/error/base.d.ts +16 -0
- package/lib/error/block.d.ts +6 -7
- package/lib/error/certificate.d.ts +6 -7
- package/lib/error/client.d.ts +6 -7
- package/lib/error/index.d.ts +7 -18
- package/lib/error/kv.d.ts +6 -7
- package/lib/error/ledger.d.ts +28 -8
- package/lib/error/permissions.d.ts +6 -7
- package/lib/error/vote.d.ts +6 -7
- package/lib/node/local.d.ts +1 -2
- package/lib/utils/initial.d.ts +6 -0
- package/npm-shrinkwrap.json +598 -0
- package/package.json +3 -2
- package/version.d.ts +1 -1
- package/docs/types/KeetaNetSDK.Referenced.AccountErrorCode.html +0 -1
- package/docs/types/KeetaNetSDK.Referenced.BlockErrorCode.html +0 -1
- package/docs/types/KeetaNetSDK.Referenced.CertificateErrorCode.html +0 -1
- package/docs/types/KeetaNetSDK.Referenced.ClientErrorCode.html +0 -1
- package/docs/types/KeetaNetSDK.Referenced.KVErrorCode.html +0 -1
- package/docs/types/KeetaNetSDK.Referenced.LedgerErrorCode.html +0 -1
- package/docs/types/KeetaNetSDK.Referenced.PermissionsErrorCode.html +0 -1
- package/docs/types/KeetaNetSDK.Referenced.VoteErrorCode.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.AccountErrorCodes.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.AccountErrorType.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes-1.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.BlockErrorType.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.CertificateErrorType.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.ClientErrorCodes.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.ClientErrorType.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.KVErrorCodes.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.KVErrorType.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.LedgerErrorCodes.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.LedgerErrorType.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.PermissionsErrorCodes.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.PermissionsErrorType.html +0 -1
- package/docs/variables/KeetaNetSDK.Referenced.VoteErrorCodes.html +0 -1
- 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,
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
59339
|
-
|
|
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 = {}) {
|
|
@@ -59873,7 +59934,7 @@ class UserClient {
|
|
|
59873
59934
|
* @returns The vote staple that was generated and whether it was able to be published
|
|
59874
59935
|
*/
|
|
59875
59936
|
async initializeNetwork(initOpts, options = {}) {
|
|
59876
|
-
const { delegateTo = this.client.representatives[0].key, addSupplyAmount, voteSerial = 0n } = initOpts;
|
|
59937
|
+
const { delegateTo = this.client.representatives[0].key, addSupplyAmount, voteSerial = 0n, baseTokenInfo } = initOpts;
|
|
59877
59938
|
if (this.signer === null) {
|
|
59878
59939
|
throw (new Error('May not initialize chain with a read-only UserClient (signer is null)'));
|
|
59879
59940
|
}
|
|
@@ -59886,7 +59947,8 @@ class UserClient {
|
|
|
59886
59947
|
delegateTo: delegateTo,
|
|
59887
59948
|
recipient: __classPrivateFieldGet(this, _UserClient_instances, "m", _UserClient_getAccount).call(this, options).assertAccount(),
|
|
59888
59949
|
amount: addSupplyAmount
|
|
59889
|
-
}
|
|
59950
|
+
},
|
|
59951
|
+
baseTokenInfo
|
|
59890
59952
|
});
|
|
59891
59953
|
return (await this.client.transmitStaple(voteStaple));
|
|
59892
59954
|
}
|
|
@@ -59976,7 +60038,10 @@ class UserClient {
|
|
|
59976
60038
|
* @param options options for publishing {@link PublishOptions }
|
|
59977
60039
|
* @return The vote staple that was generated and whether it was able to be published
|
|
59978
60040
|
*/
|
|
59979
|
-
async publishBuilder(builder, options = {
|
|
60041
|
+
async publishBuilder(builder, options = {}) {
|
|
60042
|
+
if (options.generateFeeBlock === undefined) {
|
|
60043
|
+
options.generateFeeBlock = __classPrivateFieldGet(this, _UserClient_config, "f").generateFeeBlock;
|
|
60044
|
+
}
|
|
59980
60045
|
if (!__classPrivateFieldGet(this, _UserClient_config, "f").usePublishAid) {
|
|
59981
60046
|
return (await __classPrivateFieldGet(this, _UserClient_client, "f").transmitBuilder(builder, this.network, options));
|
|
59982
60047
|
}
|
|
@@ -60032,16 +60097,19 @@ class UserClient {
|
|
|
60032
60097
|
try {
|
|
60033
60098
|
const builder = this.initBuilder(options);
|
|
60034
60099
|
builder.send(account_1.default.toAccount(to), BigInt(amount), account_1.default.toAccount(token), external);
|
|
60035
|
-
|
|
60100
|
+
const publish = await this.publishBuilder(builder);
|
|
60101
|
+
return (publish);
|
|
60036
60102
|
}
|
|
60037
60103
|
catch (transmitError) {
|
|
60038
60104
|
let error = true;
|
|
60039
60105
|
if (retries < 2) {
|
|
60040
|
-
if (error_1.KeetaNetError.isInstance(transmitError)
|
|
60041
|
-
|
|
60042
|
-
|
|
60043
|
-
|
|
60044
|
-
|
|
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
|
+
}
|
|
60045
60113
|
}
|
|
60046
60114
|
}
|
|
60047
60115
|
}
|
|
@@ -60247,6 +60315,16 @@ class UserClient {
|
|
|
60247
60315
|
async recover(publish, options = {}) {
|
|
60248
60316
|
return (await __classPrivateFieldGet(this, _UserClient_client, "f").recoverAccount(__classPrivateFieldGet(this, _UserClient_instances, "m", _UserClient_getAccount).call(this, options), publish));
|
|
60249
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
|
+
}
|
|
60250
60328
|
/**
|
|
60251
60329
|
* Register a callback for change messages and set up a websocket filtered to our account only.
|
|
60252
60330
|
* Also set up long timeout polling for changes in case the websocket misses a change update
|
|
@@ -64926,10 +65004,11 @@ function ImportOperationsASN1(input, network) {
|
|
|
64926
65004
|
"use strict";
|
|
64927
65005
|
|
|
64928
65006
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
64929
|
-
|
|
65007
|
+
exports.FullAccountErrorCodes = exports.AccountErrorCodes = void 0;
|
|
65008
|
+
const base_1 = __webpack_require__(1096);
|
|
64930
65009
|
const helper_1 = __webpack_require__(3208);
|
|
64931
65010
|
const AccountErrorType = 'ACCOUNT';
|
|
64932
|
-
|
|
65011
|
+
exports.AccountErrorCodes = [
|
|
64933
65012
|
'INVALID_PREFIX',
|
|
64934
65013
|
'INVALID_KEYTYPE',
|
|
64935
65014
|
'INVALID_KEYTYPE_EXTERNAL',
|
|
@@ -64944,15 +65023,85 @@ const AccountErrorCodes = [
|
|
|
64944
65023
|
'SEED_INDEX_TOO_LARGE',
|
|
64945
65024
|
'ENCRYPTION_NOT_SUPPORTED'
|
|
64946
65025
|
];
|
|
64947
|
-
|
|
65026
|
+
exports.FullAccountErrorCodes = exports.AccountErrorCodes.map(code => `${AccountErrorType}_${code}`);
|
|
65027
|
+
class KeetaNetAccountError extends base_1.KeetaNetErrorBase {
|
|
64948
65028
|
constructor(code, message) {
|
|
64949
|
-
super(code, message, { type: AccountErrorType, codes: AccountErrorCodes });
|
|
65029
|
+
super(code, message, { type: AccountErrorType, codes: exports.AccountErrorCodes });
|
|
64950
65030
|
}
|
|
64951
65031
|
}
|
|
64952
65032
|
KeetaNetAccountError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetAccountError);
|
|
64953
65033
|
exports["default"] = KeetaNetAccountError;
|
|
64954
65034
|
|
|
64955
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
|
+
|
|
64956
65105
|
/***/ }),
|
|
64957
65106
|
|
|
64958
65107
|
/***/ 7412:
|
|
@@ -64961,10 +65110,11 @@ exports["default"] = KeetaNetAccountError;
|
|
|
64961
65110
|
"use strict";
|
|
64962
65111
|
|
|
64963
65112
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
64964
|
-
|
|
65113
|
+
exports.FullBlockErrorCodes = exports.BlockErrorCodes = void 0;
|
|
65114
|
+
const base_1 = __webpack_require__(1096);
|
|
64965
65115
|
const helper_1 = __webpack_require__(3208);
|
|
64966
65116
|
const BlockErrorType = 'BLOCK';
|
|
64967
|
-
|
|
65117
|
+
exports.BlockErrorCodes = [
|
|
64968
65118
|
'INVALID_TYPE',
|
|
64969
65119
|
'INVALID_VERSION',
|
|
64970
65120
|
'NO_MULTIPLE_SET_REP',
|
|
@@ -65005,9 +65155,10 @@ const BlockErrorCodes = [
|
|
|
65005
65155
|
'EXTERNAL_MISSING',
|
|
65006
65156
|
'SUPPLY_INVALID'
|
|
65007
65157
|
];
|
|
65008
|
-
|
|
65158
|
+
exports.FullBlockErrorCodes = exports.BlockErrorCodes.map(code => `${BlockErrorType}_${code}`);
|
|
65159
|
+
class KeetaNetBlockError extends base_1.KeetaNetErrorBase {
|
|
65009
65160
|
constructor(code, message) {
|
|
65010
|
-
super(code, message, { type: BlockErrorType, codes: BlockErrorCodes });
|
|
65161
|
+
super(code, message, { type: BlockErrorType, codes: exports.BlockErrorCodes });
|
|
65011
65162
|
}
|
|
65012
65163
|
}
|
|
65013
65164
|
KeetaNetBlockError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetBlockError);
|
|
@@ -65022,10 +65173,11 @@ exports["default"] = KeetaNetBlockError;
|
|
|
65022
65173
|
"use strict";
|
|
65023
65174
|
|
|
65024
65175
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
65025
|
-
|
|
65176
|
+
exports.FullCertificateErrorCodes = exports.CertificateErrorCodes = void 0;
|
|
65177
|
+
const base_1 = __webpack_require__(1096);
|
|
65026
65178
|
const helper_1 = __webpack_require__(3208);
|
|
65027
65179
|
const CertificateErrorType = 'CERTIFICATE';
|
|
65028
|
-
|
|
65180
|
+
exports.CertificateErrorCodes = [
|
|
65029
65181
|
'DUPLICATE_INCLUDED',
|
|
65030
65182
|
'ORPHAN_FOUND',
|
|
65031
65183
|
'CYCLE_FOUND',
|
|
@@ -65041,9 +65193,10 @@ const BlockErrorCodes = [
|
|
|
65041
65193
|
'MOMENT_INVALID',
|
|
65042
65194
|
'INVALID_VERSION'
|
|
65043
65195
|
];
|
|
65044
|
-
|
|
65196
|
+
exports.FullCertificateErrorCodes = exports.CertificateErrorCodes.map(code => `${CertificateErrorType}_${code}`);
|
|
65197
|
+
class KeetaNetCertificateError extends base_1.KeetaNetErrorBase {
|
|
65045
65198
|
constructor(code, message) {
|
|
65046
|
-
super(code, message, { type: CertificateErrorType, codes:
|
|
65199
|
+
super(code, message, { type: CertificateErrorType, codes: exports.CertificateErrorCodes });
|
|
65047
65200
|
}
|
|
65048
65201
|
}
|
|
65049
65202
|
KeetaNetCertificateError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetCertificateError);
|
|
@@ -65058,10 +65211,11 @@ exports["default"] = KeetaNetCertificateError;
|
|
|
65058
65211
|
"use strict";
|
|
65059
65212
|
|
|
65060
65213
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
65061
|
-
|
|
65214
|
+
exports.FullClientErrorCodes = exports.ClientErrorCodes = void 0;
|
|
65215
|
+
const base_1 = __webpack_require__(1096);
|
|
65062
65216
|
const helper_1 = __webpack_require__(3208);
|
|
65063
65217
|
const ClientErrorType = 'CLIENT';
|
|
65064
|
-
|
|
65218
|
+
exports.ClientErrorCodes = [
|
|
65065
65219
|
'BUILDER_AMOUNT_IS_ZERO',
|
|
65066
65220
|
'BUILDER_CANNOT_READ_BEFORE_RENDER',
|
|
65067
65221
|
'BUILDER_REQUIRES_PRIVATE_KEY',
|
|
@@ -65069,9 +65223,10 @@ const ClientErrorCodes = [
|
|
|
65069
65223
|
'PUBLISH_AID_NOT_AVAILABLE',
|
|
65070
65224
|
'SIGNER_REQUIRES_PRIVATE_KEY'
|
|
65071
65225
|
];
|
|
65072
|
-
|
|
65226
|
+
exports.FullClientErrorCodes = exports.ClientErrorCodes.map(code => `${ClientErrorType}_${code}`);
|
|
65227
|
+
class KeetaNetClientError extends base_1.KeetaNetErrorBase {
|
|
65073
65228
|
constructor(code, message) {
|
|
65074
|
-
super(code, message, { type: ClientErrorType, codes: ClientErrorCodes });
|
|
65229
|
+
super(code, message, { type: ClientErrorType, codes: exports.ClientErrorCodes });
|
|
65075
65230
|
}
|
|
65076
65231
|
}
|
|
65077
65232
|
KeetaNetClientError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetClientError);
|
|
@@ -65081,41 +65236,135 @@ exports["default"] = KeetaNetClientError;
|
|
|
65081
65236
|
/***/ }),
|
|
65082
65237
|
|
|
65083
65238
|
/***/ 5390:
|
|
65084
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
65239
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
65085
65240
|
|
|
65086
65241
|
"use strict";
|
|
65087
65242
|
|
|
65243
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
65244
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65245
|
+
};
|
|
65088
65246
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
65089
65247
|
exports.KeetaNetError = void 0;
|
|
65090
65248
|
exports.ExpectErrorCode = ExpectErrorCode;
|
|
65091
|
-
const
|
|
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);
|
|
65092
65284
|
async function ExpectErrorCode(code, test) {
|
|
65093
65285
|
await expect(test).rejects.toThrow(expect.objectContaining({
|
|
65094
65286
|
code: code
|
|
65095
65287
|
}));
|
|
65096
65288
|
}
|
|
65097
|
-
class KeetaNetError extends
|
|
65098
|
-
|
|
65099
|
-
|
|
65100
|
-
|
|
65101
|
-
|
|
65102
|
-
|
|
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
|
+
}
|
|
65103
65331
|
}
|
|
65104
|
-
if (
|
|
65105
|
-
|
|
65106
|
-
|
|
65107
|
-
const withoutPrefix = code.substring(prefix.length);
|
|
65108
|
-
const validCode = validation.codes.includes(withoutPrefix);
|
|
65109
|
-
if (!validPrefix || !validCode) {
|
|
65110
|
-
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)'));
|
|
65111
65335
|
}
|
|
65336
|
+
return (new Error(json.message));
|
|
65112
65337
|
}
|
|
65113
|
-
|
|
65114
|
-
this.type = type;
|
|
65338
|
+
return (new Error('Unknown error'));
|
|
65115
65339
|
}
|
|
65116
65340
|
}
|
|
65117
65341
|
exports.KeetaNetError = KeetaNetError;
|
|
65118
|
-
|
|
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;
|
|
65119
65368
|
|
|
65120
65369
|
|
|
65121
65370
|
/***/ }),
|
|
@@ -65126,22 +65375,20 @@ KeetaNetError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetError, false
|
|
|
65126
65375
|
"use strict";
|
|
65127
65376
|
|
|
65128
65377
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
65129
|
-
exports.KeetaNetLedgerError = void 0;
|
|
65130
|
-
const
|
|
65378
|
+
exports.KeetaNetLedgerVoteError = exports.KeetaNetLedgerError = exports.FullLedgerVoteErrorCodes = exports.FullLedgerBaseErrorCode = exports.FullLedgerErrorCodes = exports.LedgerVoteErrorCodes = exports.LedgerBaseErrorCodes = void 0;
|
|
65379
|
+
const base_1 = __webpack_require__(1096);
|
|
65131
65380
|
const helper_1 = __webpack_require__(3208);
|
|
65132
65381
|
const LedgerErrorType = 'LEDGER';
|
|
65133
|
-
|
|
65382
|
+
exports.LedgerBaseErrorCodes = [
|
|
65134
65383
|
'BLOCK_ALREADY_EXISTS',
|
|
65135
65384
|
'TRANSACTION_ABORTED',
|
|
65136
65385
|
'INVALID_CHAIN',
|
|
65137
65386
|
'INVALID_NETWORK',
|
|
65138
65387
|
'INVALID_SUBNET',
|
|
65139
|
-
'NOT_EMPTY',
|
|
65140
|
-
'NOT_OPENING',
|
|
65141
|
-
'NOT_SUCCESSOR',
|
|
65142
65388
|
'INVALID_PERMISSIONS',
|
|
65143
65389
|
'INVALID_OWNER_COUNT',
|
|
65144
65390
|
'INVALID_BALANCE',
|
|
65391
|
+
'NOT_EMPTY',
|
|
65145
65392
|
'PREVIOUS_ALREADY_USED',
|
|
65146
65393
|
'PREVIOUS_NOT_SEEN',
|
|
65147
65394
|
'SUCCESSOR_VOTE_EXISTS',
|
|
@@ -65164,9 +65411,22 @@ const LedgerErrorCodes = [
|
|
|
65164
65411
|
'QUOTE_MISMATCH',
|
|
65165
65412
|
'REQUIRED_FEE_MISMATCH'
|
|
65166
65413
|
];
|
|
65167
|
-
|
|
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
|
+
}
|
|
65168
65428
|
constructor(code, message, shouldRetry = false, retryDelay) {
|
|
65169
|
-
super(code, message, { type: LedgerErrorType, codes:
|
|
65429
|
+
super(code, message, { type: LedgerErrorType, codes: exports.LedgerBaseErrorCodes });
|
|
65170
65430
|
this.type = LedgerErrorType;
|
|
65171
65431
|
this.shouldRetry = shouldRetry;
|
|
65172
65432
|
if (shouldRetry && retryDelay !== undefined) {
|
|
@@ -65176,7 +65436,27 @@ class KeetaNetLedgerError extends _1.KeetaNetError {
|
|
|
65176
65436
|
}
|
|
65177
65437
|
exports.KeetaNetLedgerError = KeetaNetLedgerError;
|
|
65178
65438
|
KeetaNetLedgerError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetLedgerError);
|
|
65179
|
-
|
|
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);
|
|
65180
65460
|
|
|
65181
65461
|
|
|
65182
65462
|
/***/ }),
|
|
@@ -65187,19 +65467,21 @@ exports["default"] = KeetaNetLedgerError;
|
|
|
65187
65467
|
"use strict";
|
|
65188
65468
|
|
|
65189
65469
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
65190
|
-
|
|
65470
|
+
exports.FullPermissionsErrorCodes = exports.PermissionsErrorCodes = void 0;
|
|
65471
|
+
const base_1 = __webpack_require__(1096);
|
|
65191
65472
|
const helper_1 = __webpack_require__(3208);
|
|
65192
65473
|
const PermissionsErrorType = 'PERMISSIONS';
|
|
65193
|
-
|
|
65474
|
+
exports.PermissionsErrorCodes = [
|
|
65194
65475
|
'CANNOT_MIX_FLAGS_AND_TYPES',
|
|
65195
65476
|
'EXTERNAL_OFFSET_TOO_LARGE',
|
|
65196
65477
|
'INVALID_EXTERNAL_FLAG',
|
|
65197
65478
|
'INVALID_FLAG',
|
|
65198
65479
|
'INVALID_FLAG_ASSERTION'
|
|
65199
65480
|
];
|
|
65200
|
-
|
|
65481
|
+
exports.FullPermissionsErrorCodes = exports.PermissionsErrorCodes.map(code => `${PermissionsErrorType}_${code}`);
|
|
65482
|
+
class KeetaNetPermissionsError extends base_1.KeetaNetErrorBase {
|
|
65201
65483
|
constructor(code, message) {
|
|
65202
|
-
super(code, message, { type: PermissionsErrorType, codes: PermissionsErrorCodes });
|
|
65484
|
+
super(code, message, { type: PermissionsErrorType, codes: exports.PermissionsErrorCodes });
|
|
65203
65485
|
}
|
|
65204
65486
|
}
|
|
65205
65487
|
KeetaNetPermissionsError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetPermissionsError);
|
|
@@ -65214,10 +65496,11 @@ exports["default"] = KeetaNetPermissionsError;
|
|
|
65214
65496
|
"use strict";
|
|
65215
65497
|
|
|
65216
65498
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
65217
|
-
|
|
65499
|
+
exports.FullVoteErrorCodes = exports.VoteErrorCodes = void 0;
|
|
65500
|
+
const base_1 = __webpack_require__(1096);
|
|
65218
65501
|
const helper_1 = __webpack_require__(3208);
|
|
65219
65502
|
const VoteErrorType = 'VOTE';
|
|
65220
|
-
|
|
65503
|
+
exports.VoteErrorCodes = [
|
|
65221
65504
|
// Errors related to Vote
|
|
65222
65505
|
'SERIAL_MISMATCH',
|
|
65223
65506
|
'INVALID_VERSION',
|
|
@@ -65302,9 +65585,10 @@ const VoteErrorCodes = [
|
|
|
65302
65585
|
'MALFORMED_FEES_KIND_MISSING',
|
|
65303
65586
|
'MALFORMED_FEES_QUOTE_INVALID'
|
|
65304
65587
|
];
|
|
65305
|
-
|
|
65588
|
+
exports.FullVoteErrorCodes = exports.VoteErrorCodes.map(code => `${VoteErrorType}_${code}`);
|
|
65589
|
+
class KeetaNetVoteError extends base_1.KeetaNetErrorBase {
|
|
65306
65590
|
constructor(code, message) {
|
|
65307
|
-
super(code, message, { type: VoteErrorType, codes: VoteErrorCodes });
|
|
65591
|
+
super(code, message, { type: VoteErrorType, codes: exports.VoteErrorCodes });
|
|
65308
65592
|
}
|
|
65309
65593
|
}
|
|
65310
65594
|
KeetaNetVoteError.isInstance = (0, helper_1.checkableGenerator)(KeetaNetVoteError);
|
|
@@ -65664,7 +65948,7 @@ exports.assertLedgerStorage = assertLedgerStorage;
|
|
|
65664
65948
|
const account_1 = __importStar(__webpack_require__(9415));
|
|
65665
65949
|
const block_1 = __webpack_require__(6158);
|
|
65666
65950
|
const permissions_1 = __webpack_require__(5860);
|
|
65667
|
-
const ledger_1 =
|
|
65951
|
+
const ledger_1 = __webpack_require__(452);
|
|
65668
65952
|
const helper_1 = __webpack_require__(3208);
|
|
65669
65953
|
const config_1 = __webpack_require__(1491);
|
|
65670
65954
|
const block_2 = __importDefault(__webpack_require__(7412));
|
|
@@ -66137,7 +66421,7 @@ class LedgerStorageBase {
|
|
|
66137
66421
|
// Check if any blocks already exist on the ledger that would cause this staple to fail and exit early
|
|
66138
66422
|
for (const [blockHash, blockHeight] of Object.entries(allBlockHeights)) {
|
|
66139
66423
|
if (blockHeight !== null) {
|
|
66140
|
-
throw (new ledger_1.
|
|
66424
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_BLOCK_ALREADY_EXISTS', `Block Already Exists: ${blockHash.toString()}`));
|
|
66141
66425
|
}
|
|
66142
66426
|
}
|
|
66143
66427
|
const seenBlockHashes = new block_1.BlockHash.Set();
|
|
@@ -66225,7 +66509,7 @@ class LedgerStorageBase {
|
|
|
66225
66509
|
return (validKeys.includes(key) === false);
|
|
66226
66510
|
});
|
|
66227
66511
|
if (foundBannedKey !== undefined) {
|
|
66228
|
-
throw (new ledger_1.
|
|
66512
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_ACCOUNT_INFO_KEY', `Invalid AccountInfo field ${foundBannedKey}`));
|
|
66229
66513
|
}
|
|
66230
66514
|
}
|
|
66231
66515
|
/**
|
|
@@ -67217,7 +67501,7 @@ const block_1 = __webpack_require__(6158);
|
|
|
67217
67501
|
const account_1 = __importDefault(__webpack_require__(9415));
|
|
67218
67502
|
const common_1 = __webpack_require__(5663);
|
|
67219
67503
|
const helper_1 = __webpack_require__(3208);
|
|
67220
|
-
const ledger_1 =
|
|
67504
|
+
const ledger_1 = __webpack_require__(452);
|
|
67221
67505
|
const permissions_1 = __webpack_require__(5860);
|
|
67222
67506
|
const effects_1 = __webpack_require__(7346);
|
|
67223
67507
|
const conversion_1 = __webpack_require__(2360);
|
|
@@ -67293,7 +67577,7 @@ class LedgerAtomicInterface {
|
|
|
67293
67577
|
}
|
|
67294
67578
|
async vote(blocks, otherVotes, quote) {
|
|
67295
67579
|
if (blocks.length === 0) {
|
|
67296
|
-
throw (new ledger_1.
|
|
67580
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_MISSING_BLOCKS', 'At least one block is required to issue a vote'));
|
|
67297
67581
|
}
|
|
67298
67582
|
if (!__classPrivateFieldGet(this, _LedgerAtomicInterface_privateKey, "f")) {
|
|
67299
67583
|
throw (new Error('Cannot vote on block, no private key loaded'));
|
|
@@ -67305,10 +67589,10 @@ class LedgerAtomicInterface {
|
|
|
67305
67589
|
const ledgerPubKey = privateKey.publicKeyString.get();
|
|
67306
67590
|
if (quote !== undefined) {
|
|
67307
67591
|
if (otherVotes !== undefined) {
|
|
67308
|
-
throw (new ledger_1.
|
|
67592
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_PERM_VOTE_WITH_QUOTE', 'Quote should not be included when requesting permanent votes'));
|
|
67309
67593
|
}
|
|
67310
67594
|
if (!quote.issuer.comparePublicKey(ledgerPubKey)) {
|
|
67311
|
-
throw (new ledger_1.
|
|
67595
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match issuer public key'));
|
|
67312
67596
|
}
|
|
67313
67597
|
}
|
|
67314
67598
|
const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
@@ -67317,13 +67601,13 @@ class LedgerAtomicInterface {
|
|
|
67317
67601
|
* us and the blocks are in the same order as the set of
|
|
67318
67602
|
* blocks we are voting on now
|
|
67319
67603
|
*/
|
|
67604
|
+
let hasFeeBlock = false;
|
|
67320
67605
|
if (otherVotes !== undefined) {
|
|
67321
67606
|
let foundOurVote = false;
|
|
67322
67607
|
const seenVoteUIDs = new Set();
|
|
67323
67608
|
const seenVoteIssuers = new account_1.default.Set();
|
|
67324
|
-
const possibleFeeBlock = blocks.at(-1);
|
|
67325
|
-
let hasFeeBlock = false;
|
|
67326
67609
|
let blockCount = blocks.length;
|
|
67610
|
+
const possibleFeeBlock = blocks.at(-1);
|
|
67327
67611
|
if (possibleFeeBlock?.purpose === block_1.BlockPurpose.FEE) {
|
|
67328
67612
|
hasFeeBlock = true;
|
|
67329
67613
|
blockCount--;
|
|
@@ -67331,13 +67615,13 @@ class LedgerAtomicInterface {
|
|
|
67331
67615
|
const requiredFees = new Map();
|
|
67332
67616
|
for (const checkVote of otherVotes) {
|
|
67333
67617
|
if (checkVote.quote === true) {
|
|
67334
|
-
throw (new ledger_1.
|
|
67618
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_PERM_VOTE_WITH_QUOTE', 'Cannot request permanent votes with quotes'));
|
|
67335
67619
|
}
|
|
67336
67620
|
if (seenVoteUIDs.has(checkVote.$id)) {
|
|
67337
|
-
throw (new ledger_1.
|
|
67621
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_DUPLICATE_VOTE_FOUND', 'Duplicate vote UID found'));
|
|
67338
67622
|
}
|
|
67339
67623
|
if (seenVoteIssuers.has(checkVote.issuer)) {
|
|
67340
|
-
throw (new ledger_1.
|
|
67624
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_DUPLICATE_VOTE_ISSUER_FOUND', 'Multiple votes found from same issuer'));
|
|
67341
67625
|
}
|
|
67342
67626
|
seenVoteIssuers.add(checkVote.issuer);
|
|
67343
67627
|
seenVoteUIDs.add(checkVote.$id);
|
|
@@ -67345,7 +67629,7 @@ class LedgerAtomicInterface {
|
|
|
67345
67629
|
requiredFees.set(checkVote.issuer, checkVote.fee);
|
|
67346
67630
|
}
|
|
67347
67631
|
if (checkVote.$permanent) {
|
|
67348
|
-
throw (new ledger_1.
|
|
67632
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_CANNOT_EXCHANGE_PERM_VOTE', 'Asked to exchange a permanent vote for a permanent vote'));
|
|
67349
67633
|
}
|
|
67350
67634
|
let blocksDifferFromVoteBlocks = checkVote.blocks.length !== blockCount;
|
|
67351
67635
|
/* If they do not differ from length alone, compare block hashes */
|
|
@@ -67358,7 +67642,7 @@ class LedgerAtomicInterface {
|
|
|
67358
67642
|
}
|
|
67359
67643
|
}
|
|
67360
67644
|
if (blocksDifferFromVoteBlocks) {
|
|
67361
|
-
throw (new ledger_1.
|
|
67645
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_BLOCKS_DIFFER_FROM_VOTED_ON', 'Asked to exchange different number of blocks for a permanent vote'));
|
|
67362
67646
|
}
|
|
67363
67647
|
if (checkVote.issuer.comparePublicKey(ledgerPubKey)) {
|
|
67364
67648
|
foundOurVote = true;
|
|
@@ -67366,10 +67650,10 @@ class LedgerAtomicInterface {
|
|
|
67366
67650
|
}
|
|
67367
67651
|
if (requiredFees.size > 0) {
|
|
67368
67652
|
if (!hasFeeBlock) {
|
|
67369
|
-
throw (new ledger_1.
|
|
67653
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_MISSING_REQUIRED_FEE_BLOCK', 'Missing fee block but votes require it'));
|
|
67370
67654
|
}
|
|
67371
67655
|
if (requiredFees.size !== possibleFeeBlock?.operations.length) {
|
|
67372
|
-
throw (new ledger_1.
|
|
67656
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees'));
|
|
67373
67657
|
}
|
|
67374
67658
|
}
|
|
67375
67659
|
// Verify that all required fees have been included in the fee block
|
|
@@ -67379,21 +67663,21 @@ class LedgerAtomicInterface {
|
|
|
67379
67663
|
const expectedToken = fee.token ?? __classPrivateFieldGet(this, _LedgerAtomicInterface_ledger, "f").baseToken;
|
|
67380
67664
|
if (operation.type === operations_1.OperationType.SEND && operation.to.comparePublicKey(expectedPayTo)) {
|
|
67381
67665
|
if (operation.amount !== fee.amount) {
|
|
67382
|
-
throw (new ledger_1.
|
|
67666
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_FEE_AMOUNT_MISMATCH', `Fee Amount Mismatch, found: ${operation.amount} expected: ${fee.amount}`));
|
|
67383
67667
|
}
|
|
67384
67668
|
if (!operation.token.comparePublicKey(expectedToken)) {
|
|
67385
|
-
throw (new ledger_1.
|
|
67669
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_FEE_TOKEN_MISMATCH', `Fee Token Mismatch, found: ${operation.token.publicKeyString.get()} expected: ${expectedToken.publicKeyString.get()}`));
|
|
67386
67670
|
}
|
|
67387
67671
|
return (true);
|
|
67388
67672
|
}
|
|
67389
67673
|
return (false);
|
|
67390
67674
|
});
|
|
67391
67675
|
if (foundFee === undefined) {
|
|
67392
|
-
throw (new ledger_1.
|
|
67676
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_FEE_MISSING', `Missing Required Fee for ${fee.payTo?.publicKeyString.get() ?? issuer.publicKeyString.get()}`));
|
|
67393
67677
|
}
|
|
67394
67678
|
}
|
|
67395
67679
|
if (!foundOurVote) {
|
|
67396
|
-
throw (new ledger_1.
|
|
67680
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_NO_PERM_WITHOUT_SELF_TEMP', 'Asked to give a permanent vote without a temporary vote from us'));
|
|
67397
67681
|
}
|
|
67398
67682
|
}
|
|
67399
67683
|
const allLedgerHeads = await __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_validateBlocksForVote).call(this, blocks);
|
|
@@ -67403,15 +67687,15 @@ class LedgerAtomicInterface {
|
|
|
67403
67687
|
const accountHead = allHeads[account.publicKeyString.get()];
|
|
67404
67688
|
if (accountHead === null) {
|
|
67405
67689
|
if (!expectedBlock.$opening) {
|
|
67406
|
-
throw (new ledger_1.
|
|
67690
|
+
throw (new ledger_1.KeetaNetLedgerVoteError('LEDGER_NOT_OPENING', 'Cannot vote on non-opening block for an empty account', needToGetHeadFor));
|
|
67407
67691
|
}
|
|
67408
67692
|
continue;
|
|
67409
67693
|
}
|
|
67410
67694
|
if (expectedBlock.$opening) {
|
|
67411
|
-
throw (new ledger_1.
|
|
67695
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_NOT_EMPTY', 'Cannot vote on opening block for a non-empty account'));
|
|
67412
67696
|
}
|
|
67413
67697
|
if (expectedBlock.previous.toString() !== accountHead.toString()) {
|
|
67414
|
-
throw (new ledger_1.
|
|
67698
|
+
throw (new ledger_1.KeetaNetLedgerVoteError('LEDGER_NOT_SUCCESSOR', 'The block is not the successor to the account head block', needToGetHeadFor));
|
|
67415
67699
|
}
|
|
67416
67700
|
}
|
|
67417
67701
|
/**
|
|
@@ -67435,7 +67719,7 @@ class LedgerAtomicInterface {
|
|
|
67435
67719
|
mayReplace = !ourVote.$permanent && ourVote.issuer.comparePublicKey(ledgerPubKey);
|
|
67436
67720
|
}
|
|
67437
67721
|
if (!mayReplace) {
|
|
67438
|
-
throw (new ledger_1.
|
|
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))})`));
|
|
67439
67723
|
}
|
|
67440
67724
|
}
|
|
67441
67725
|
}
|
|
@@ -67448,13 +67732,19 @@ class LedgerAtomicInterface {
|
|
|
67448
67732
|
await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").addPendingVote(transaction, blocksAndVote);
|
|
67449
67733
|
return (vote);
|
|
67450
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
|
+
}
|
|
67451
67741
|
/**
|
|
67452
67742
|
* Validate the votes are sufficient weight and grant
|
|
67453
67743
|
* our permanent vote
|
|
67454
67744
|
*/
|
|
67455
67745
|
const votesSufficient = await __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_validateVotingWeight).call(this, otherVotes);
|
|
67456
67746
|
if (votesSufficient !== true) {
|
|
67457
|
-
throw (new ledger_1.
|
|
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'));
|
|
67458
67748
|
}
|
|
67459
67749
|
/**
|
|
67460
67750
|
* Serial number
|
|
@@ -67514,7 +67804,7 @@ class LedgerAtomicInterface {
|
|
|
67514
67804
|
const weightTiming = __classPrivateFieldGet(this, _LedgerAtomicInterface_ledger, "f").node?.timing.startTime('db-add/getWeight');
|
|
67515
67805
|
const votesSufficient = await __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_validateVotingWeight).call(this, votesAndBlocks.votes);
|
|
67516
67806
|
if (votesSufficient !== true) {
|
|
67517
|
-
throw (new ledger_1.
|
|
67807
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Votes attached do not represent enough voting power'));
|
|
67518
67808
|
}
|
|
67519
67809
|
weightTiming?.end();
|
|
67520
67810
|
const changesTiming = __classPrivateFieldGet(this, _LedgerAtomicInterface_ledger, "f").node?.timing.startTime('db-add/computeEffectOfBlocks');
|
|
@@ -67877,7 +68167,7 @@ _LedgerAtomicInterface_network = new WeakMap(), _LedgerAtomicInterface_subnet =
|
|
|
67877
68167
|
const baseFlagsStr = requirement.permissions.base.flags.join(', ');
|
|
67878
68168
|
const externalOffsetsStr = requirement.permissions.external.trueOffsets.join(', ');
|
|
67879
68169
|
const reqTargetKey = requirement.target?.publicKeyString.get();
|
|
67880
|
-
throw (new ledger_1.
|
|
68170
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_PERMISSIONS', `${accountPubKey} does not have required permissions to perform action on ${reqEntityKey}/${reqTargetKey} -- needs [${baseFlagsStr}]/[${externalOffsetsStr}]`));
|
|
67881
68171
|
}
|
|
67882
68172
|
}
|
|
67883
68173
|
}, _LedgerAtomicInterface_checkPermissionRequirements = async function _LedgerAtomicInterface_checkPermissionRequirements(effects) {
|
|
@@ -67927,7 +68217,7 @@ _LedgerAtomicInterface_network = new WeakMap(), _LedgerAtomicInterface_subnet =
|
|
|
67927
68217
|
throw (new Error(`Multisig quorum not found for ${multisigPubKey}`));
|
|
67928
68218
|
}
|
|
67929
68219
|
if (foundInfo.multisigQuorum > foundSingerLength) {
|
|
67930
|
-
throw (new ledger_1.
|
|
68220
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_PERMISSIONS', `Quorum of ${foundInfo.multisigQuorum} not reached for ${multisigPubKey} -- got ${foundSingerLength}`));
|
|
67931
68221
|
}
|
|
67932
68222
|
}
|
|
67933
68223
|
const checkPromises = [];
|
|
@@ -68025,7 +68315,7 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
|
|
|
68025
68315
|
if (ownerLength === 1) {
|
|
68026
68316
|
continue;
|
|
68027
68317
|
}
|
|
68028
|
-
throw (new ledger_1.
|
|
68318
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_OWNER_COUNT', `Invalid number of owners for ${identifierPubKey} - Got ${ownerLength}/1`));
|
|
68029
68319
|
}
|
|
68030
68320
|
const { balances } = await (0, common_1.computeLedgerEffect)({
|
|
68031
68321
|
checkRangeConstraints: true,
|
|
@@ -68036,10 +68326,10 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
|
|
|
68036
68326
|
for (const tokenPubKey in acctBalanceChanges) {
|
|
68037
68327
|
const { change, fellNegative, receiveValidated } = acctBalanceChanges[tokenPubKey];
|
|
68038
68328
|
if (fellNegative) {
|
|
68039
|
-
throw (new ledger_1.
|
|
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}`));
|
|
68040
68330
|
}
|
|
68041
68331
|
if (receiveValidated === false) {
|
|
68042
|
-
throw (new ledger_1.
|
|
68332
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_RECEIVE_NOT_MET', `${accountPubKey}/${tokenPubKey} did not receive enough of requested token. change: ${change}`));
|
|
68043
68333
|
}
|
|
68044
68334
|
}
|
|
68045
68335
|
}
|
|
@@ -68059,13 +68349,13 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
|
|
|
68059
68349
|
const prevBlockHash = block.previous;
|
|
68060
68350
|
seenBlockHashes.add(block.hash);
|
|
68061
68351
|
if (block.network !== __classPrivateFieldGet(this, _LedgerAtomicInterface_network, "f")) {
|
|
68062
|
-
throw (new ledger_1.
|
|
68352
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_NETWORK', 'Cannot vote on block for a different network'));
|
|
68063
68353
|
}
|
|
68064
68354
|
if (block.subnet !== __classPrivateFieldGet(this, _LedgerAtomicInterface_subnet, "f")) {
|
|
68065
|
-
throw (new ledger_1.
|
|
68355
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_SUBNET', 'Cannot vote on block for a different subnet'));
|
|
68066
68356
|
}
|
|
68067
68357
|
if (usedPreviousBlockHashes.has(prevBlockHash)) {
|
|
68068
|
-
throw (new ledger_1.
|
|
68358
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_PREVIOUS_ALREADY_USED', `Invalid reference to block, previous: ${prevBlockHash} has already been used`));
|
|
68069
68359
|
}
|
|
68070
68360
|
usedPreviousBlockHashes.add(prevBlockHash);
|
|
68071
68361
|
/**
|
|
@@ -68080,10 +68370,10 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
|
|
|
68080
68370
|
if (prevBlock !== undefined) {
|
|
68081
68371
|
predecessorBeingVotedOn = true;
|
|
68082
68372
|
if (!(prevBlock.account.comparePublicKey(block.account))) {
|
|
68083
|
-
throw (new ledger_1.
|
|
68373
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_CHAIN', 'Invalid chain, changes accounts'));
|
|
68084
68374
|
}
|
|
68085
68375
|
if (!seenBlockHashes.has(prevBlockHash)) {
|
|
68086
|
-
throw (new ledger_1.
|
|
68376
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_PREVIOUS_NOT_SEEN', `Invalid reference to block, out-of-order: ${prevBlockHash} has not already been seen`));
|
|
68087
68377
|
}
|
|
68088
68378
|
}
|
|
68089
68379
|
}
|
|
@@ -68265,7 +68555,7 @@ class Ledger {
|
|
|
68265
68555
|
shouldTryToRetry = (now - startTime) < retryConfig.timeout;
|
|
68266
68556
|
}
|
|
68267
68557
|
if (shouldTryToRetry) {
|
|
68268
|
-
if (ledger_1.
|
|
68558
|
+
if (ledger_1.KeetaNetLedgerError.isInstance(txnError)) {
|
|
68269
68559
|
if (txnError.shouldRetry) {
|
|
68270
68560
|
let retryDelay = 20;
|
|
68271
68561
|
if (txnError.retryDelay) {
|
|
@@ -75738,7 +76028,9 @@ async function generateInitialVoteStaple(options) {
|
|
|
75738
76028
|
},
|
|
75739
76029
|
{
|
|
75740
76030
|
type: block_1.default.Builder.OperationType.SET_INFO,
|
|
75741
|
-
name:
|
|
76031
|
+
name: options.baseTokenInfo?.currencyCode ?? '',
|
|
76032
|
+
description: options.baseTokenInfo?.name ?? '',
|
|
76033
|
+
metadata: options.baseTokenInfo ? btoa(JSON.stringify({ decimalPlaces: options.baseTokenInfo.decimalPlaces })) : '',
|
|
75742
76034
|
defaultPermission: new permissions_1.Permissions(['ACCESS'])
|
|
75743
76035
|
},
|
|
75744
76036
|
...additionalBaseTokenOperations
|
|
@@ -77446,7 +77738,7 @@ exports.Testing = { findRDN, blockHashesFromVote, feeFromVote };
|
|
|
77446
77738
|
|
|
77447
77739
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
77448
77740
|
exports.version = void 0;
|
|
77449
|
-
exports.version = '0.14.
|
|
77741
|
+
exports.version = '0.14.4+g6020a42a3e7fdf7cae2d3783e939f895ae1be911';
|
|
77450
77742
|
exports["default"] = exports.version;
|
|
77451
77743
|
|
|
77452
77744
|
|