@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-browser.js
CHANGED
|
@@ -114577,24 +114577,16 @@ function client_fromOffsetArray(setOffsets) {
|
|
|
114577
114577
|
return val;
|
|
114578
114578
|
}
|
|
114579
114579
|
client_bitfield_defineProperty(src_client_BitField, "isInstance", client_checkableGenerator(client_BitField));
|
|
114580
|
-
;// ./src/lib/error/
|
|
114581
|
-
var
|
|
114582
|
-
function
|
|
114583
|
-
function
|
|
114584
|
-
function
|
|
114580
|
+
;// ./src/lib/error/base.ts
|
|
114581
|
+
var client_KeetaNetErrorBase;
|
|
114582
|
+
function client_base_defineProperty(e, r, t) { return (r = client_base_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
114583
|
+
function client_base_toPropertyKey(t) { var i = client_base_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
114584
|
+
function client_base_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
114585
114585
|
|
|
114586
|
-
|
|
114587
|
-
await expect(test).rejects.toThrow(expect.objectContaining({
|
|
114588
|
-
code: code
|
|
114589
|
-
}));
|
|
114590
|
-
}
|
|
114591
|
-
class src_client_KeetaNetError extends Error {
|
|
114586
|
+
class src_client_KeetaNetErrorBase extends Error {
|
|
114592
114587
|
constructor(code, message, validation) {
|
|
114593
114588
|
super(message);
|
|
114594
|
-
|
|
114595
|
-
if (!type) {
|
|
114596
|
-
type = 'GENERIC';
|
|
114597
|
-
}
|
|
114589
|
+
const type = (validation === null || validation === void 0 ? void 0 : validation.type) || 'GENERIC';
|
|
114598
114590
|
if (validation !== undefined) {
|
|
114599
114591
|
const prefix = `${validation.type}_`;
|
|
114600
114592
|
const validPrefix = code.startsWith(prefix);
|
|
@@ -114607,9 +114599,16 @@ class src_client_KeetaNetError extends Error {
|
|
|
114607
114599
|
this.code = code;
|
|
114608
114600
|
this.type = type;
|
|
114609
114601
|
}
|
|
114602
|
+
toJSON() {
|
|
114603
|
+
return {
|
|
114604
|
+
type: this.type,
|
|
114605
|
+
code: this.code,
|
|
114606
|
+
message: this.message
|
|
114607
|
+
};
|
|
114608
|
+
}
|
|
114610
114609
|
}
|
|
114611
|
-
|
|
114612
|
-
|
|
114610
|
+
client_KeetaNetErrorBase = src_client_KeetaNetErrorBase;
|
|
114611
|
+
client_base_defineProperty(src_client_KeetaNetErrorBase, "isInstance", client_checkableGenerator(client_KeetaNetErrorBase, false));
|
|
114613
114612
|
;// ./src/lib/error/permissions.ts
|
|
114614
114613
|
var client_KeetaNetPermissionsError;
|
|
114615
114614
|
function client_permissions_defineProperty(e, r, t) { return (r = client_permissions_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -114619,7 +114618,8 @@ function client_permissions_toPrimitive(t, r) { if ("object" != typeof t || !t)
|
|
|
114619
114618
|
|
|
114620
114619
|
const client_PermissionsErrorType = 'PERMISSIONS';
|
|
114621
114620
|
const client_PermissionsErrorCodes = ['CANNOT_MIX_FLAGS_AND_TYPES', 'EXTERNAL_OFFSET_TOO_LARGE', 'INVALID_EXTERNAL_FLAG', 'INVALID_FLAG', 'INVALID_FLAG_ASSERTION'];
|
|
114622
|
-
|
|
114621
|
+
const client_FullPermissionsErrorCodes = client_PermissionsErrorCodes.map(code => `${client_PermissionsErrorType}_${code}`);
|
|
114622
|
+
class src_client_KeetaNetPermissionsError extends src_client_KeetaNetErrorBase {
|
|
114623
114623
|
constructor(code, message) {
|
|
114624
114624
|
super(code, message, {
|
|
114625
114625
|
type: client_PermissionsErrorType,
|
|
@@ -115225,7 +115225,8 @@ function client_block_toPrimitive(t, r) { if ("object" != typeof t || !t) return
|
|
|
115225
115225
|
|
|
115226
115226
|
const client_BlockErrorType = 'BLOCK';
|
|
115227
115227
|
const client_BlockErrorCodes = ['INVALID_TYPE', 'INVALID_VERSION', 'NO_MULTIPLE_SET_REP', 'IDENTIFIER_NEED_DEFAULT_PERMISSIONS', 'CANNOT_SEND_NON_TOKEN', 'TOKEN_RECEIVE_DIFFERS', 'ONLY_TOKEN_OP', 'ONLY_IDENTIFIER_OP', 'NO_TOKEN_OP', 'NO_IDENTIFIER_OP', 'INVALID_SIGNER', 'INVALID_PURPOSE_VALIDATION', 'INVALID_MULTISIG_QUORUM', 'INVALID_MULTISIG_SIGNER_DEPTH', 'INVALID_MULTISIG_SIGNER_COUNT', 'INVALID_MULTISIG_SIGNER_DUPLICATE', 'INVALID_CREATE_IDENTIFIER_ARGS', 'NO_MULTISIG_OP', 'IDENTIFIER_INVALID', 'GENERAL_FIELD_INVALID', 'PERMISSIONS_INVALID_DEFAULT', 'PERMISSIONS_INVALID_ENTITY', 'PERMISSIONS_INVALID_PRINCIPAL', 'PERMISSIONS_INVALID_TARGET', 'INVALID_ACCOUNT_TYPE', 'NO_ADMIN_ON_TARGET', 'PREVIOUS_SELF', 'NO_DELEGATE_ADMIN', 'NO_MODIFY_PERMISSION_DUPE', 'CANNOT_FORWARD_TO_SELF', 'EXACT_TRUE_WHEN_FORWARDING', 'CERTIFICATE_SUBJECT_MISMATCH', 'NO_DUPLICATE_CERTIFICATE_OPERATION', 'INTERMEDIATE_CERTIFICATES_ONLY_ADD', 'INVALID_CERTIFICATE_VALUE', 'EXTERNAL_TOO_LONG', 'EXTERNAL_INVALID', 'EXTERNAL_MISSING', 'SUPPLY_INVALID'];
|
|
115228
|
-
|
|
115228
|
+
const client_FullBlockErrorCodes = client_BlockErrorCodes.map(code => `${client_BlockErrorType}_${code}`);
|
|
115229
|
+
class src_client_KeetaNetBlockError extends src_client_KeetaNetErrorBase {
|
|
115229
115230
|
constructor(code, message) {
|
|
115230
115231
|
super(code, message, {
|
|
115231
115232
|
type: client_BlockErrorType,
|
|
@@ -115325,12 +115326,13 @@ function client_certificate_toPrimitive(t, r) { if ("object" != typeof t || !t)
|
|
|
115325
115326
|
|
|
115326
115327
|
|
|
115327
115328
|
const client_CertificateErrorType = 'CERTIFICATE';
|
|
115328
|
-
const
|
|
115329
|
-
|
|
115329
|
+
const client_CertificateErrorCodes = ['DUPLICATE_INCLUDED', 'ORPHAN_FOUND', 'CYCLE_FOUND', 'SECONDARY_GRAPH', 'MISSING_FIELD', 'SIGNATURE_ALGORITHM_MISMATCH', 'SELF_SIGNED_VALIDATION_FAILED', 'CHAIN_VERIFICATION_FAILED', 'DUPLICATE_EXTENSION', 'EXTENSION_NOT_PROCESSED', 'INVALID_SIGNATURE_ALGORITHM', 'INVALID_GRAPH_COUNT', 'MOMENT_INVALID', 'INVALID_VERSION'];
|
|
115330
|
+
const client_FullCertificateErrorCodes = client_CertificateErrorCodes.map(code => `${client_CertificateErrorType}_${code}`);
|
|
115331
|
+
class src_client_KeetaNetCertificateError extends src_client_KeetaNetErrorBase {
|
|
115330
115332
|
constructor(code, message) {
|
|
115331
115333
|
super(code, message, {
|
|
115332
115334
|
type: client_CertificateErrorType,
|
|
115333
|
-
codes:
|
|
115335
|
+
codes: client_CertificateErrorCodes
|
|
115334
115336
|
});
|
|
115335
115337
|
}
|
|
115336
115338
|
}
|
|
@@ -116736,23 +116738,34 @@ client_utils_certificate_defineProperty(src_client_Certificate, "Hash", src_clie
|
|
|
116736
116738
|
*/
|
|
116737
116739
|
client_utils_certificate_defineProperty(src_client_Certificate, "certificateObjectTypeID", '8d05dca5-5f42-4dc9-8bf9-f534c6570994:CERTIFICATE');
|
|
116738
116740
|
;// ./src/lib/error/ledger.ts
|
|
116739
|
-
var client_KeetaNetLedgerError;
|
|
116741
|
+
var client_KeetaNetLedgerError, client_KeetaNetLedgerVoteError;
|
|
116740
116742
|
function client_ledger_defineProperty(e, r, t) { return (r = client_ledger_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
116741
116743
|
function client_ledger_toPropertyKey(t) { var i = client_ledger_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
116742
116744
|
function client_ledger_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
116743
116745
|
|
|
116744
116746
|
|
|
116745
116747
|
const client_LedgerErrorType = 'LEDGER';
|
|
116746
|
-
const
|
|
116748
|
+
const client_LedgerBaseErrorCodes = ['BLOCK_ALREADY_EXISTS', 'TRANSACTION_ABORTED', 'INVALID_CHAIN', 'INVALID_NETWORK', 'INVALID_SUBNET', 'INVALID_PERMISSIONS', 'INVALID_OWNER_COUNT', 'INVALID_BALANCE', 'NOT_EMPTY', 'PREVIOUS_ALREADY_USED', 'PREVIOUS_NOT_SEEN', 'SUCCESSOR_VOTE_EXISTS', 'INSUFFICIENT_VOTING_WEIGHT', 'INVALID_ACCOUNT_INFO_KEY', 'RECEIVE_NOT_MET', 'DUPLICATE_VOTE_FOUND', 'CANNOT_EXCHANGE_PERM_VOTE', 'BLOCKS_DIFFER_FROM_VOTED_ON', 'NO_PERM_WITHOUT_SELF_TEMP', 'DUPLICATE_VOTE_ISSUER_FOUND', 'OTHER', 'MISSING_BLOCKS',
|
|
116747
116749
|
// Fee Errors
|
|
116748
116750
|
'FEE_AMOUNT_MISMATCH', 'FEE_TOKEN_MISMATCH', 'FEE_MISSING', 'MISSING_REQUIRED_FEE_BLOCK', 'PERM_VOTE_WITH_QUOTE', 'QUOTE_MISMATCH', 'REQUIRED_FEE_MISMATCH'];
|
|
116749
|
-
|
|
116751
|
+
|
|
116752
|
+
// Errors that can trigger rep sync
|
|
116753
|
+
const client_LedgerVoteErrorCodes = ['NOT_SUCCESSOR', 'NOT_OPENING'];
|
|
116754
|
+
const client_FullLedgerErrorCodes = [...client_LedgerBaseErrorCodes, ...client_LedgerVoteErrorCodes].map(code => `${client_LedgerErrorType}_${code}`);
|
|
116755
|
+
const client_FullLedgerBaseErrorCode = client_LedgerBaseErrorCodes.map(code => `${client_LedgerErrorType}_${code}`);
|
|
116756
|
+
const client_FullLedgerVoteErrorCodes = client_LedgerVoteErrorCodes.map(code => `${client_LedgerErrorType}_${code}`);
|
|
116757
|
+
const client_ledgerBaseErrorCodeSet = new Set(client_FullLedgerBaseErrorCode);
|
|
116758
|
+
const client_ledgerVoteErrorCodeSet = new Set(client_FullLedgerVoteErrorCodes);
|
|
116759
|
+
class client_ledger_KeetaNetLedgerError extends src_client_KeetaNetErrorBase {
|
|
116760
|
+
static assertValidLedgerErrorCode(code) {
|
|
116761
|
+
return client_ledgerBaseErrorCodeSet.has(code);
|
|
116762
|
+
}
|
|
116750
116763
|
constructor(code, message) {
|
|
116751
116764
|
let shouldRetry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
116752
116765
|
let retryDelay = arguments.length > 3 ? arguments[3] : undefined;
|
|
116753
116766
|
super(code, message, {
|
|
116754
116767
|
type: client_LedgerErrorType,
|
|
116755
|
-
codes:
|
|
116768
|
+
codes: client_LedgerBaseErrorCodes
|
|
116756
116769
|
});
|
|
116757
116770
|
client_ledger_defineProperty(this, "type", client_LedgerErrorType);
|
|
116758
116771
|
this.shouldRetry = shouldRetry;
|
|
@@ -116763,7 +116776,30 @@ class client_ledger_KeetaNetLedgerError extends src_client_KeetaNetError {
|
|
|
116763
116776
|
}
|
|
116764
116777
|
client_KeetaNetLedgerError = client_ledger_KeetaNetLedgerError;
|
|
116765
116778
|
client_ledger_defineProperty(client_ledger_KeetaNetLedgerError, "isInstance", client_checkableGenerator(client_KeetaNetLedgerError));
|
|
116766
|
-
|
|
116779
|
+
class src_client_KeetaNetLedgerVoteError extends src_client_KeetaNetErrorBase {
|
|
116780
|
+
static assertValidLedgerErrorCode(code) {
|
|
116781
|
+
return client_ledgerVoteErrorCodeSet.has(code);
|
|
116782
|
+
}
|
|
116783
|
+
constructor(code, message, accounts) {
|
|
116784
|
+
super(code, message, {
|
|
116785
|
+
type: client_LedgerErrorType,
|
|
116786
|
+
codes: client_LedgerVoteErrorCodes
|
|
116787
|
+
});
|
|
116788
|
+
client_ledger_defineProperty(this, "type", client_LedgerErrorType);
|
|
116789
|
+
client_ledger_defineProperty(this, "shouldRetry", false);
|
|
116790
|
+
this.accounts = accounts;
|
|
116791
|
+
}
|
|
116792
|
+
toJSON() {
|
|
116793
|
+
return {
|
|
116794
|
+
...super.toJSON(),
|
|
116795
|
+
accounts: [...this.accounts.values()].map(function (account) {
|
|
116796
|
+
return account.publicKeyString.get();
|
|
116797
|
+
})
|
|
116798
|
+
};
|
|
116799
|
+
}
|
|
116800
|
+
}
|
|
116801
|
+
client_KeetaNetLedgerVoteError = src_client_KeetaNetLedgerVoteError;
|
|
116802
|
+
client_ledger_defineProperty(src_client_KeetaNetLedgerVoteError, "isInstance", client_checkableGenerator(client_KeetaNetLedgerVoteError));
|
|
116767
116803
|
;// ./src/lib/ledger/common.ts
|
|
116768
116804
|
function client_common_classPrivateMethodInitSpec(e, a) { client_common_checkPrivateRedeclaration(e, a), a.add(e); }
|
|
116769
116805
|
function client_common_checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
@@ -120151,7 +120187,8 @@ function client_account_toPrimitive(t, r) { if ("object" != typeof t || !t) retu
|
|
|
120151
120187
|
|
|
120152
120188
|
const client_AccountErrorType = 'ACCOUNT';
|
|
120153
120189
|
const client_AccountErrorCodes = ['INVALID_PREFIX', 'INVALID_KEYTYPE', 'INVALID_KEYTYPE_EXTERNAL', 'PASSPHRASE_WEAK', 'INVALID_CONSTRUCTION', 'NO_IDENTIFIER_SIGN', 'NO_IDENTIFIER_VERIFY', 'INVALID_IDENTIFIER_CONSTRUCTION', 'SEED_INDEX_UNDEFINED', 'SEED_INDEX_NEGATIVE', 'SEED_INDEX_NOT_INT', 'SEED_INDEX_TOO_LARGE', 'ENCRYPTION_NOT_SUPPORTED'];
|
|
120154
|
-
|
|
120190
|
+
const client_FullAccountErrorCodes = client_AccountErrorCodes.map(code => `${client_AccountErrorType}_${code}`);
|
|
120191
|
+
class src_client_KeetaNetAccountError extends src_client_KeetaNetErrorBase {
|
|
120155
120192
|
constructor(code, message) {
|
|
120156
120193
|
super(code, message, {
|
|
120157
120194
|
type: client_AccountErrorType,
|
|
@@ -122282,7 +122319,8 @@ const client_VoteErrorCodes = [
|
|
|
122282
122319
|
'MALFORMED_FEES_AMOUNT', 'MALFORMED_FEES_FROM_VOTE_INVALID_INPUT', 'MALFORMED_FEES_IN_PERMANENT_VOTE', 'MALFORMED_FEES_PAY_TO_INVALID', 'MALFORMED_FEES_TOKEN_NOT_TOKEN',
|
|
122283
122320
|
// Fee Quote Errors
|
|
122284
122321
|
'FEE_IS_QUOTE', 'FEE_QUOTE_MISSING_FEES', 'FEE_NOT_QUOTE', 'MALFORMED_FEES_KIND_MISSING', 'MALFORMED_FEES_QUOTE_INVALID'];
|
|
122285
|
-
|
|
122322
|
+
const client_FullVoteErrorCodes = client_VoteErrorCodes.map(code => `${client_VoteErrorType}_${code}`);
|
|
122323
|
+
class src_client_KeetaNetVoteError extends src_client_KeetaNetErrorBase {
|
|
122286
122324
|
constructor(code, message) {
|
|
122287
122325
|
super(code, message, {
|
|
122288
122326
|
type: client_VoteErrorType,
|
|
@@ -125572,7 +125610,7 @@ var client_kind = /*#__PURE__*/new WeakMap();
|
|
|
125572
125610
|
var client_ledger_privateKey = /*#__PURE__*/new WeakMap();
|
|
125573
125611
|
var client_computeFeeFromBlocks = /*#__PURE__*/new WeakMap();
|
|
125574
125612
|
var client_ledger_storage = /*#__PURE__*/new WeakMap();
|
|
125575
|
-
var
|
|
125613
|
+
var client_ledger = /*#__PURE__*/new WeakMap();
|
|
125576
125614
|
var src_client_cache = /*#__PURE__*/new WeakMap();
|
|
125577
125615
|
var client_transaction = /*#__PURE__*/new WeakMap();
|
|
125578
125616
|
var client_LedgerAtomicInterface_brand = /*#__PURE__*/new WeakSet();
|
|
@@ -125588,7 +125626,7 @@ class client_LedgerAtomicInterface {
|
|
|
125588
125626
|
client_ledger_classPrivateFieldInitSpec(this, client_ledger_privateKey, void 0);
|
|
125589
125627
|
client_ledger_classPrivateFieldInitSpec(this, client_computeFeeFromBlocks, void 0);
|
|
125590
125628
|
client_ledger_classPrivateFieldInitSpec(this, client_ledger_storage, void 0);
|
|
125591
|
-
client_ledger_classPrivateFieldInitSpec(this,
|
|
125629
|
+
client_ledger_classPrivateFieldInitSpec(this, client_ledger, void 0);
|
|
125592
125630
|
client_ledger_classPrivateFieldInitSpec(this, src_client_cache, void 0);
|
|
125593
125631
|
client_ledger_classPrivateFieldInitSpec(this, client_transaction, void 0);
|
|
125594
125632
|
client_ledger_classPrivateFieldSet(client_network, this, config.network);
|
|
@@ -125596,7 +125634,7 @@ class client_LedgerAtomicInterface {
|
|
|
125596
125634
|
client_ledger_classPrivateFieldSet(client_kind, this, config.kind);
|
|
125597
125635
|
client_ledger_classPrivateFieldSet(client_ledger_privateKey, this, config.privateKey);
|
|
125598
125636
|
client_ledger_classPrivateFieldSet(client_computeFeeFromBlocks, this, config.computeFeeFromBlocks);
|
|
125599
|
-
client_ledger_classPrivateFieldSet(
|
|
125637
|
+
client_ledger_classPrivateFieldSet(client_ledger, this, ledger);
|
|
125600
125638
|
client_ledger_classPrivateFieldSet(client_ledger_storage, this, storage);
|
|
125601
125639
|
client_ledger_classPrivateFieldSet(client_transaction, this, _transaction2);
|
|
125602
125640
|
|
|
@@ -125618,7 +125656,7 @@ class client_LedgerAtomicInterface {
|
|
|
125618
125656
|
const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
125619
125657
|
client_ledger_classPrivateFieldSet(client_transaction, this, null);
|
|
125620
125658
|
await client_ledger_classPrivateFieldGet(client_ledger_storage, this).commitTransaction(transaction);
|
|
125621
|
-
(_classPrivateFieldGet2 = client_ledger_classPrivateFieldGet(
|
|
125659
|
+
(_classPrivateFieldGet2 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet2 === void 0 || _classPrivateFieldGet2.stats.merge(transaction.statsPending);
|
|
125622
125660
|
}
|
|
125623
125661
|
async abort() {
|
|
125624
125662
|
const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
@@ -125627,22 +125665,22 @@ class client_LedgerAtomicInterface {
|
|
|
125627
125665
|
}
|
|
125628
125666
|
async vote(blocks, otherVotes, quote) {
|
|
125629
125667
|
if (blocks.length === 0) {
|
|
125630
|
-
throw new
|
|
125668
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_MISSING_BLOCKS', 'At least one block is required to issue a vote');
|
|
125631
125669
|
}
|
|
125632
125670
|
if (!client_ledger_classPrivateFieldGet(client_ledger_privateKey, this)) {
|
|
125633
125671
|
throw new Error('Cannot vote on block, no private key loaded');
|
|
125634
125672
|
}
|
|
125635
|
-
if (client_ledger_classPrivateFieldGet(
|
|
125636
|
-
throw new Error(`May not issue votes in read-only mode, in ${client_ledger_classPrivateFieldGet(
|
|
125673
|
+
if (client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode !== 'read-write') {
|
|
125674
|
+
throw new Error(`May not issue votes in read-only mode, in ${client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode} mode`);
|
|
125637
125675
|
}
|
|
125638
125676
|
const privateKey = client_ledger_classPrivateFieldGet(client_ledger_privateKey, this);
|
|
125639
125677
|
const ledgerPubKey = privateKey.publicKeyString.get();
|
|
125640
125678
|
if (quote !== undefined) {
|
|
125641
125679
|
if (otherVotes !== undefined) {
|
|
125642
|
-
throw new
|
|
125680
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_PERM_VOTE_WITH_QUOTE', 'Quote should not be included when requesting permanent votes');
|
|
125643
125681
|
}
|
|
125644
125682
|
if (!quote.issuer.comparePublicKey(ledgerPubKey)) {
|
|
125645
|
-
throw new
|
|
125683
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match issuer public key');
|
|
125646
125684
|
}
|
|
125647
125685
|
}
|
|
125648
125686
|
const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
@@ -125652,13 +125690,13 @@ class client_LedgerAtomicInterface {
|
|
|
125652
125690
|
* us and the blocks are in the same order as the set of
|
|
125653
125691
|
* blocks we are voting on now
|
|
125654
125692
|
*/
|
|
125693
|
+
let hasFeeBlock = false;
|
|
125655
125694
|
if (otherVotes !== undefined) {
|
|
125656
125695
|
let foundOurVote = false;
|
|
125657
125696
|
const seenVoteUIDs = new Set();
|
|
125658
125697
|
const seenVoteIssuers = new client_lib_account.Set();
|
|
125659
|
-
const possibleFeeBlock = blocks.at(-1);
|
|
125660
|
-
let hasFeeBlock = false;
|
|
125661
125698
|
let blockCount = blocks.length;
|
|
125699
|
+
const possibleFeeBlock = blocks.at(-1);
|
|
125662
125700
|
if ((possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.purpose) === client_BlockPurpose.FEE) {
|
|
125663
125701
|
hasFeeBlock = true;
|
|
125664
125702
|
blockCount--;
|
|
@@ -125666,13 +125704,13 @@ class client_LedgerAtomicInterface {
|
|
|
125666
125704
|
const requiredFees = new Map();
|
|
125667
125705
|
for (const checkVote of otherVotes) {
|
|
125668
125706
|
if (checkVote.quote === true) {
|
|
125669
|
-
throw new
|
|
125707
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_PERM_VOTE_WITH_QUOTE', 'Cannot request permanent votes with quotes');
|
|
125670
125708
|
}
|
|
125671
125709
|
if (seenVoteUIDs.has(checkVote.$id)) {
|
|
125672
|
-
throw new
|
|
125710
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_DUPLICATE_VOTE_FOUND', 'Duplicate vote UID found');
|
|
125673
125711
|
}
|
|
125674
125712
|
if (seenVoteIssuers.has(checkVote.issuer)) {
|
|
125675
|
-
throw new
|
|
125713
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_DUPLICATE_VOTE_ISSUER_FOUND', 'Multiple votes found from same issuer');
|
|
125676
125714
|
}
|
|
125677
125715
|
seenVoteIssuers.add(checkVote.issuer);
|
|
125678
125716
|
seenVoteUIDs.add(checkVote.$id);
|
|
@@ -125680,7 +125718,7 @@ class client_LedgerAtomicInterface {
|
|
|
125680
125718
|
requiredFees.set(checkVote.issuer, checkVote.fee);
|
|
125681
125719
|
}
|
|
125682
125720
|
if (checkVote.$permanent) {
|
|
125683
|
-
throw new
|
|
125721
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_CANNOT_EXCHANGE_PERM_VOTE', 'Asked to exchange a permanent vote for a permanent vote');
|
|
125684
125722
|
}
|
|
125685
125723
|
let blocksDifferFromVoteBlocks = checkVote.blocks.length !== blockCount;
|
|
125686
125724
|
|
|
@@ -125694,7 +125732,7 @@ class client_LedgerAtomicInterface {
|
|
|
125694
125732
|
}
|
|
125695
125733
|
}
|
|
125696
125734
|
if (blocksDifferFromVoteBlocks) {
|
|
125697
|
-
throw new
|
|
125735
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_BLOCKS_DIFFER_FROM_VOTED_ON', 'Asked to exchange different number of blocks for a permanent vote');
|
|
125698
125736
|
}
|
|
125699
125737
|
if (checkVote.issuer.comparePublicKey(ledgerPubKey)) {
|
|
125700
125738
|
foundOurVote = true;
|
|
@@ -125702,10 +125740,10 @@ class client_LedgerAtomicInterface {
|
|
|
125702
125740
|
}
|
|
125703
125741
|
if (requiredFees.size > 0) {
|
|
125704
125742
|
if (!hasFeeBlock) {
|
|
125705
|
-
throw new
|
|
125743
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_MISSING_REQUIRED_FEE_BLOCK', 'Missing fee block but votes require it');
|
|
125706
125744
|
}
|
|
125707
125745
|
if (requiredFees.size !== (possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length)) {
|
|
125708
|
-
throw new
|
|
125746
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees');
|
|
125709
125747
|
}
|
|
125710
125748
|
}
|
|
125711
125749
|
|
|
@@ -125714,13 +125752,13 @@ class client_LedgerAtomicInterface {
|
|
|
125714
125752
|
const foundFee = possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.find(operation => {
|
|
125715
125753
|
var _fee$payTo, _fee$token;
|
|
125716
125754
|
const expectedPayTo = (_fee$payTo = fee.payTo) !== null && _fee$payTo !== void 0 ? _fee$payTo : issuer;
|
|
125717
|
-
const expectedToken = (_fee$token = fee.token) !== null && _fee$token !== void 0 ? _fee$token : client_ledger_classPrivateFieldGet(
|
|
125755
|
+
const expectedToken = (_fee$token = fee.token) !== null && _fee$token !== void 0 ? _fee$token : client_ledger_classPrivateFieldGet(client_ledger, this).baseToken;
|
|
125718
125756
|
if (operation.type === client_OperationType.SEND && operation.to.comparePublicKey(expectedPayTo)) {
|
|
125719
125757
|
if (operation.amount !== fee.amount) {
|
|
125720
|
-
throw new
|
|
125758
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_FEE_AMOUNT_MISMATCH', `Fee Amount Mismatch, found: ${operation.amount} expected: ${fee.amount}`);
|
|
125721
125759
|
}
|
|
125722
125760
|
if (!operation.token.comparePublicKey(expectedToken)) {
|
|
125723
|
-
throw new
|
|
125761
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_FEE_TOKEN_MISMATCH', `Fee Token Mismatch, found: ${operation.token.publicKeyString.get()} expected: ${expectedToken.publicKeyString.get()}`);
|
|
125724
125762
|
}
|
|
125725
125763
|
return true;
|
|
125726
125764
|
}
|
|
@@ -125728,11 +125766,11 @@ class client_LedgerAtomicInterface {
|
|
|
125728
125766
|
});
|
|
125729
125767
|
if (foundFee === undefined) {
|
|
125730
125768
|
var _fee$payTo$publicKeyS, _fee$payTo2;
|
|
125731
|
-
throw new
|
|
125769
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_FEE_MISSING', `Missing Required Fee for ${(_fee$payTo$publicKeyS = (_fee$payTo2 = fee.payTo) === null || _fee$payTo2 === void 0 ? void 0 : _fee$payTo2.publicKeyString.get()) !== null && _fee$payTo$publicKeyS !== void 0 ? _fee$payTo$publicKeyS : issuer.publicKeyString.get()}`);
|
|
125732
125770
|
}
|
|
125733
125771
|
}
|
|
125734
125772
|
if (!foundOurVote) {
|
|
125735
|
-
throw new
|
|
125773
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_NO_PERM_WITHOUT_SELF_TEMP', 'Asked to give a permanent vote without a temporary vote from us');
|
|
125736
125774
|
}
|
|
125737
125775
|
}
|
|
125738
125776
|
const allLedgerHeads = await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateBlocksForVote).call(this, blocks);
|
|
@@ -125742,15 +125780,15 @@ class client_LedgerAtomicInterface {
|
|
|
125742
125780
|
const accountHead = allHeads[account.publicKeyString.get()];
|
|
125743
125781
|
if (accountHead === null) {
|
|
125744
125782
|
if (!expectedBlock.$opening) {
|
|
125745
|
-
throw new
|
|
125783
|
+
throw new src_client_KeetaNetLedgerVoteError('LEDGER_NOT_OPENING', 'Cannot vote on non-opening block for an empty account', needToGetHeadFor);
|
|
125746
125784
|
}
|
|
125747
125785
|
continue;
|
|
125748
125786
|
}
|
|
125749
125787
|
if (expectedBlock.$opening) {
|
|
125750
|
-
throw new
|
|
125788
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_NOT_EMPTY', 'Cannot vote on opening block for a non-empty account');
|
|
125751
125789
|
}
|
|
125752
125790
|
if (expectedBlock.previous.toString() !== accountHead.toString()) {
|
|
125753
|
-
throw new
|
|
125791
|
+
throw new src_client_KeetaNetLedgerVoteError('LEDGER_NOT_SUCCESSOR', 'The block is not the successor to the account head block', needToGetHeadFor);
|
|
125754
125792
|
}
|
|
125755
125793
|
}
|
|
125756
125794
|
|
|
@@ -125776,7 +125814,7 @@ class client_LedgerAtomicInterface {
|
|
|
125776
125814
|
mayReplace = !ourVote.$permanent && ourVote.issuer.comparePublicKey(ledgerPubKey);
|
|
125777
125815
|
}
|
|
125778
125816
|
if (!mayReplace) {
|
|
125779
|
-
throw new
|
|
125817
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_SUCCESSOR_VOTE_EXISTS', `We cannot vote for this block (hash=${block.hash.toString()}), we have an existing vote for a successor (previous votes = ${JSON.stringify(client_toJSONSerializable(previousVotes))})`);
|
|
125780
125818
|
}
|
|
125781
125819
|
}
|
|
125782
125820
|
}
|
|
@@ -125791,13 +125829,20 @@ class client_LedgerAtomicInterface {
|
|
|
125791
125829
|
return vote;
|
|
125792
125830
|
}
|
|
125793
125831
|
|
|
125832
|
+
/**
|
|
125833
|
+
* Validate ledger outcome again before permanent votes if blocks includes a fee block
|
|
125834
|
+
*/
|
|
125835
|
+
if (hasFeeBlock) {
|
|
125836
|
+
await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateLedgerOutcome).call(this, blocks);
|
|
125837
|
+
}
|
|
125838
|
+
|
|
125794
125839
|
/**
|
|
125795
125840
|
* Validate the votes are sufficient weight and grant
|
|
125796
125841
|
* our permanent vote
|
|
125797
125842
|
*/
|
|
125798
125843
|
const votesSufficient = await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateVotingWeight).call(this, otherVotes);
|
|
125799
125844
|
if (votesSufficient !== true) {
|
|
125800
|
-
throw new
|
|
125845
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Unable to create a vote from these votes, they do not represent enough voting power');
|
|
125801
125846
|
}
|
|
125802
125847
|
|
|
125803
125848
|
/**
|
|
@@ -125826,7 +125871,7 @@ class client_LedgerAtomicInterface {
|
|
|
125826
125871
|
async add(votesAndBlocks, from) {
|
|
125827
125872
|
var _classPrivateFieldGet3, _classPrivateFieldGet4, _classPrivateFieldGet5, _classPrivateFieldGet6;
|
|
125828
125873
|
const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
125829
|
-
switch (client_ledger_classPrivateFieldGet(
|
|
125874
|
+
switch (client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode) {
|
|
125830
125875
|
case 'read-only':
|
|
125831
125876
|
throw new Error('Cannot add blocks to a read-only ledger');
|
|
125832
125877
|
case 'bootstrap-only':
|
|
@@ -125838,7 +125883,7 @@ class client_LedgerAtomicInterface {
|
|
|
125838
125883
|
case 'no-voting':
|
|
125839
125884
|
break;
|
|
125840
125885
|
default:
|
|
125841
|
-
throw new Error(`internal error: invalid ledger write mode: ${client_ledger_classPrivateFieldGet(
|
|
125886
|
+
throw new Error(`internal error: invalid ledger write mode: ${client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode}`);
|
|
125842
125887
|
}
|
|
125843
125888
|
const {
|
|
125844
125889
|
votes,
|
|
@@ -125860,19 +125905,19 @@ class client_LedgerAtomicInterface {
|
|
|
125860
125905
|
throw new Error('Can only insert permanent votes');
|
|
125861
125906
|
}
|
|
125862
125907
|
}
|
|
125863
|
-
const weightTiming = (_classPrivateFieldGet3 = client_ledger_classPrivateFieldGet(
|
|
125908
|
+
const weightTiming = (_classPrivateFieldGet3 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.timing.startTime('db-add/getWeight');
|
|
125864
125909
|
const votesSufficient = await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateVotingWeight).call(this, votesAndBlocks.votes);
|
|
125865
125910
|
if (votesSufficient !== true) {
|
|
125866
|
-
throw new
|
|
125911
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_INSUFFICIENT_VOTING_WEIGHT', 'Votes attached do not represent enough voting power');
|
|
125867
125912
|
}
|
|
125868
125913
|
weightTiming === null || weightTiming === void 0 || weightTiming.end();
|
|
125869
|
-
const changesTiming = (_classPrivateFieldGet4 = client_ledger_classPrivateFieldGet(
|
|
125870
|
-
const changes = client_computeEffectOfBlocks(votesAndBlocks.blocks, client_ledger_classPrivateFieldGet(
|
|
125914
|
+
const changesTiming = (_classPrivateFieldGet4 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.timing.startTime('db-add/computeEffectOfBlocks');
|
|
125915
|
+
const changes = client_computeEffectOfBlocks(votesAndBlocks.blocks, client_ledger_classPrivateFieldGet(client_ledger, this));
|
|
125871
125916
|
changesTiming === null || changesTiming === void 0 || changesTiming.end();
|
|
125872
|
-
const adjustTiming = (_classPrivateFieldGet5 = client_ledger_classPrivateFieldGet(
|
|
125917
|
+
const adjustTiming = (_classPrivateFieldGet5 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.timing.startTime('db-add/adjust');
|
|
125873
125918
|
const voteStaples = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).adjust(transaction, votesAndBlocks, changes);
|
|
125874
125919
|
adjustTiming === null || adjustTiming === void 0 || adjustTiming.end();
|
|
125875
|
-
const postambleTiming = (_classPrivateFieldGet6 = client_ledger_classPrivateFieldGet(
|
|
125920
|
+
const postambleTiming = (_classPrivateFieldGet6 = client_ledger_classPrivateFieldGet(client_ledger, this).node) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.timing.startTime('db-add/postamble');
|
|
125876
125921
|
/**
|
|
125877
125922
|
* Add all the block hashes to the node checksum
|
|
125878
125923
|
*/
|
|
@@ -126180,8 +126225,8 @@ class client_LedgerAtomicInterface {
|
|
|
126180
126225
|
return await client_ledger_classPrivateFieldGet(client_ledger_storage, this).gc(transaction, timeLimitMS);
|
|
126181
126226
|
}
|
|
126182
126227
|
async getFee(blocks, effectsInput) {
|
|
126183
|
-
const effects = effectsInput !== null && effectsInput !== void 0 ? effectsInput : client_computeEffectOfBlocks(blocks, client_ledger_classPrivateFieldGet(
|
|
126184
|
-
return client_ledger_classPrivateFieldGet(client_computeFeeFromBlocks, this).call(this, client_ledger_classPrivateFieldGet(
|
|
126228
|
+
const effects = effectsInput !== null && effectsInput !== void 0 ? effectsInput : client_computeEffectOfBlocks(blocks, client_ledger_classPrivateFieldGet(client_ledger, this));
|
|
126229
|
+
return client_ledger_classPrivateFieldGet(client_computeFeeFromBlocks, this).call(this, client_ledger_classPrivateFieldGet(client_ledger, this), blocks, effects);
|
|
126185
126230
|
}
|
|
126186
126231
|
async _testingRunStorageFunction(code) {
|
|
126187
126232
|
const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
@@ -126209,7 +126254,7 @@ async function client_validateVotingWeight(votes) {
|
|
|
126209
126254
|
*/
|
|
126210
126255
|
if (totalVotingPower === 0n) {
|
|
126211
126256
|
const foundTrustedVote = votes.find(vote => {
|
|
126212
|
-
return vote.issuer.comparePublicKey(client_ledger_classPrivateFieldGet(
|
|
126257
|
+
return vote.issuer.comparePublicKey(client_ledger_classPrivateFieldGet(client_ledger, this).initialTrustedAccount);
|
|
126213
126258
|
});
|
|
126214
126259
|
return foundTrustedVote !== undefined;
|
|
126215
126260
|
}
|
|
@@ -126262,7 +126307,7 @@ async function client_checkSingleAccountPermissions(account, requirements, accou
|
|
|
126262
126307
|
const baseFlagsStr = requirement.permissions.base.flags.join(', ');
|
|
126263
126308
|
const externalOffsetsStr = requirement.permissions.external.trueOffsets.join(', ');
|
|
126264
126309
|
const reqTargetKey = (_requirement$target = requirement.target) === null || _requirement$target === void 0 ? void 0 : _requirement$target.publicKeyString.get();
|
|
126265
|
-
throw new
|
|
126310
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_PERMISSIONS', `${accountPubKey} does not have required permissions to perform action on ${reqEntityKey}/${reqTargetKey} -- needs [${baseFlagsStr}]/[${externalOffsetsStr}]`);
|
|
126266
126311
|
}
|
|
126267
126312
|
}
|
|
126268
126313
|
}
|
|
@@ -126321,7 +126366,7 @@ async function client_checkPermissionRequirements(effects) {
|
|
|
126321
126366
|
throw new Error(`Multisig quorum not found for ${multisigPubKey}`);
|
|
126322
126367
|
}
|
|
126323
126368
|
if (foundInfo.multisigQuorum > foundSingerLength) {
|
|
126324
|
-
throw new
|
|
126369
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_PERMISSIONS', `Quorum of ${foundInfo.multisigQuorum} not reached for ${multisigPubKey} -- got ${foundSingerLength}`);
|
|
126325
126370
|
}
|
|
126326
126371
|
}
|
|
126327
126372
|
const checkPromises = [];
|
|
@@ -126370,7 +126415,7 @@ async function client_validateLedgerOutcome(blocks) {
|
|
|
126370
126415
|
break;
|
|
126371
126416
|
}
|
|
126372
126417
|
};
|
|
126373
|
-
const effects = client_computeEffectOfBlocks(blocks, client_ledger_classPrivateFieldGet(
|
|
126418
|
+
const effects = client_computeEffectOfBlocks(blocks, client_ledger_classPrivateFieldGet(client_ledger, this));
|
|
126374
126419
|
const accountEffects = effects.accounts;
|
|
126375
126420
|
const allAccountsChanges = Object.values(accountEffects);
|
|
126376
126421
|
|
|
@@ -126442,13 +126487,13 @@ async function client_validateLedgerOutcome(blocks) {
|
|
|
126442
126487
|
if (ownerLength === 1) {
|
|
126443
126488
|
continue;
|
|
126444
126489
|
}
|
|
126445
|
-
throw new
|
|
126490
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_OWNER_COUNT', `Invalid number of owners for ${identifierPubKey} - Got ${ownerLength}/1`);
|
|
126446
126491
|
}
|
|
126447
126492
|
const {
|
|
126448
126493
|
balances
|
|
126449
126494
|
} = await client_computeLedgerEffect({
|
|
126450
126495
|
checkRangeConstraints: true,
|
|
126451
|
-
baseToken: client_ledger_classPrivateFieldGet(
|
|
126496
|
+
baseToken: client_ledger_classPrivateFieldGet(client_ledger, this).baseToken
|
|
126452
126497
|
}, accountEffects, client_ledger_classPrivateFieldGet(client_ledger_storage, this), client_ledger_classPrivateFieldGet(client_network, this), client_ledger_classPrivateFieldGet(client_transaction, this));
|
|
126453
126498
|
for (const accountPubKey in balances) {
|
|
126454
126499
|
const acctBalanceChanges = balances[accountPubKey];
|
|
@@ -126459,10 +126504,10 @@ async function client_validateLedgerOutcome(blocks) {
|
|
|
126459
126504
|
receiveValidated
|
|
126460
126505
|
} = acctBalanceChanges[tokenPubKey];
|
|
126461
126506
|
if (fellNegative) {
|
|
126462
|
-
throw new
|
|
126507
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_BALANCE', `Resulting balance becomes negative at one+ point(s) during this transaction for account/token ${accountPubKey}/${tokenPubKey}: change ${change}`);
|
|
126463
126508
|
}
|
|
126464
126509
|
if (receiveValidated === false) {
|
|
126465
|
-
throw new
|
|
126510
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_RECEIVE_NOT_MET', `${accountPubKey}/${tokenPubKey} did not receive enough of requested token. change: ${change}`);
|
|
126466
126511
|
}
|
|
126467
126512
|
}
|
|
126468
126513
|
}
|
|
@@ -126483,13 +126528,13 @@ async function client_validateBlocksForVote(blocks) {
|
|
|
126483
126528
|
const prevBlockHash = block.previous;
|
|
126484
126529
|
seenBlockHashes.add(block.hash);
|
|
126485
126530
|
if (block.network !== client_ledger_classPrivateFieldGet(client_network, this)) {
|
|
126486
|
-
throw new
|
|
126531
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_NETWORK', 'Cannot vote on block for a different network');
|
|
126487
126532
|
}
|
|
126488
126533
|
if (block.subnet !== client_ledger_classPrivateFieldGet(client_subnet, this)) {
|
|
126489
|
-
throw new
|
|
126534
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_SUBNET', 'Cannot vote on block for a different subnet');
|
|
126490
126535
|
}
|
|
126491
126536
|
if (usedPreviousBlockHashes.has(prevBlockHash)) {
|
|
126492
|
-
throw new
|
|
126537
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_PREVIOUS_ALREADY_USED', `Invalid reference to block, previous: ${prevBlockHash} has already been used`);
|
|
126493
126538
|
}
|
|
126494
126539
|
usedPreviousBlockHashes.add(prevBlockHash);
|
|
126495
126540
|
|
|
@@ -126505,10 +126550,10 @@ async function client_validateBlocksForVote(blocks) {
|
|
|
126505
126550
|
if (prevBlock !== undefined) {
|
|
126506
126551
|
predecessorBeingVotedOn = true;
|
|
126507
126552
|
if (!prevBlock.account.comparePublicKey(block.account)) {
|
|
126508
|
-
throw new
|
|
126553
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_CHAIN', 'Invalid chain, changes accounts');
|
|
126509
126554
|
}
|
|
126510
126555
|
if (!seenBlockHashes.has(prevBlockHash)) {
|
|
126511
|
-
throw new
|
|
126556
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_PREVIOUS_NOT_SEEN', `Invalid reference to block, out-of-order: ${prevBlockHash} has not already been seen`);
|
|
126512
126557
|
}
|
|
126513
126558
|
}
|
|
126514
126559
|
}
|
|
@@ -126520,8 +126565,8 @@ async function client_validateBlocksForVote(blocks) {
|
|
|
126520
126565
|
}
|
|
126521
126566
|
async function client_voteOrQuoteWithFees(blocks, type, quote) {
|
|
126522
126567
|
var _quote$fee;
|
|
126523
|
-
if (client_ledger_classPrivateFieldGet(
|
|
126524
|
-
throw new Error(`May not issue votes in read-only mode, in ${client_ledger_classPrivateFieldGet(
|
|
126568
|
+
if (client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode !== 'read-write') {
|
|
126569
|
+
throw new Error(`May not issue votes in read-only mode, in ${client_ledger_classPrivateFieldGet(client_ledger, this).ledgerWriteMode} mode`);
|
|
126525
126570
|
}
|
|
126526
126571
|
if (!client_ledger_classPrivateFieldGet(client_ledger_privateKey, this)) {
|
|
126527
126572
|
throw new Error('Cannot vote on block, no private key loaded');
|
|
@@ -126701,7 +126746,7 @@ class src_client_Ledger {
|
|
|
126701
126746
|
shouldTryToRetry = now - startTime < retryConfig.timeout;
|
|
126702
126747
|
}
|
|
126703
126748
|
if (shouldTryToRetry) {
|
|
126704
|
-
if (
|
|
126749
|
+
if (client_ledger_KeetaNetLedgerError.isInstance(txnError)) {
|
|
126705
126750
|
if (txnError.shouldRetry) {
|
|
126706
126751
|
let retryDelay = 20;
|
|
126707
126752
|
if (txnError.retryDelay) {
|
|
@@ -126970,11 +127015,11 @@ class src_client_Ledger {
|
|
|
126970
127015
|
client_Ledger = src_client_Ledger;
|
|
126971
127016
|
client_lib_ledger_defineProperty(src_client_Ledger, "Kind", client_LedgerKind);
|
|
126972
127017
|
client_lib_ledger_defineProperty(src_client_Ledger, "isInstance", client_checkableGenerator(client_Ledger));
|
|
126973
|
-
/* harmony default export */ const
|
|
127018
|
+
/* harmony default export */ const src_client_ledger = (src_client_Ledger);
|
|
126974
127019
|
// EXTERNAL MODULE: ws (ignored)
|
|
126975
127020
|
var client_ws_ignored_ = __webpack_require__(4708);
|
|
126976
127021
|
;// ./src/version.ts
|
|
126977
|
-
const client_version = '0.14.
|
|
127022
|
+
const client_version = '0.14.4+g6020a42a3e7fdf7cae2d3783e939f895ae1be911';
|
|
126978
127023
|
/* harmony default export */ const client_src_version = ((/* unused pure expression or super */ null && (client_version)));
|
|
126979
127024
|
;// ./src/lib/p2p.ts
|
|
126980
127025
|
/* provided dependency */ var client_p2p_Buffer = __webpack_require__(8287)["Buffer"];
|
|
@@ -129039,13 +129084,13 @@ class src_client_Node {
|
|
|
129039
129084
|
this.baseToken = baseToken;
|
|
129040
129085
|
|
|
129041
129086
|
/* XXX:TODO: Compute ledger kind from node kind */
|
|
129042
|
-
const ledgerKind =
|
|
129087
|
+
const ledgerKind = src_client_ledger.Kind.REPRESENTATIVE;
|
|
129043
129088
|
this.config = config;
|
|
129044
129089
|
const initialTrustedAccount = config.initialTrustedAccount;
|
|
129045
129090
|
if (initialTrustedAccount.hasPrivateKey) {
|
|
129046
129091
|
throw new Error('There is no reason for us to have the private key in setup of the initialTrustedAccount');
|
|
129047
129092
|
}
|
|
129048
|
-
this.ledger = new
|
|
129093
|
+
this.ledger = new src_client_ledger({
|
|
129049
129094
|
privateKey: config.ledgerPrivateKey,
|
|
129050
129095
|
network: config.network,
|
|
129051
129096
|
subnet: config.subnet,
|
|
@@ -129197,6 +129242,144 @@ client_Node = src_client_Node;
|
|
|
129197
129242
|
client_node_defineProperty(src_client_Node, "Kind", client_node_NodeKind);
|
|
129198
129243
|
client_node_defineProperty(src_client_Node, "isInstance", client_checkableGenerator(client_Node));
|
|
129199
129244
|
/* harmony default export */ const client_node = (src_client_Node);
|
|
129245
|
+
;// ./src/lib/error/api.ts
|
|
129246
|
+
var client_KeetaNetAPIError;
|
|
129247
|
+
function client_api_defineProperty(e, r, t) { return (r = client_api_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
129248
|
+
function client_api_toPropertyKey(t) { var i = client_api_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
129249
|
+
function client_api_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
129250
|
+
|
|
129251
|
+
|
|
129252
|
+
const client_APIErrorType = 'API';
|
|
129253
|
+
const client_APIErrorCodes = ['INVALID_LIMIT', 'INVALID_SIDE', 'INVALID_START', 'LIMIT_NOT_NUMBER', 'LIMIT_NOT_GREATER_THAN_ZERO', 'REP_MISSING', 'START_MISSING'];
|
|
129254
|
+
const client_FullAPIErrorCodes = client_APIErrorCodes.map(code => `${client_APIErrorType}_${code}`);
|
|
129255
|
+
class src_client_KeetaNetAPIError extends src_client_KeetaNetErrorBase {
|
|
129256
|
+
constructor(code, message) {
|
|
129257
|
+
super(code, message, {
|
|
129258
|
+
type: client_APIErrorType,
|
|
129259
|
+
codes: client_APIErrorCodes
|
|
129260
|
+
});
|
|
129261
|
+
}
|
|
129262
|
+
}
|
|
129263
|
+
client_KeetaNetAPIError = src_client_KeetaNetAPIError;
|
|
129264
|
+
client_api_defineProperty(src_client_KeetaNetAPIError, "isInstance", client_checkableGenerator(client_KeetaNetAPIError));
|
|
129265
|
+
;// ./src/lib/error/client.ts
|
|
129266
|
+
var client_KeetaNetClientError;
|
|
129267
|
+
function client_client_defineProperty(e, r, t) { return (r = client_client_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
129268
|
+
function client_client_toPropertyKey(t) { var i = client_client_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
129269
|
+
function client_client_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
129270
|
+
|
|
129271
|
+
|
|
129272
|
+
const client_ClientErrorType = 'CLIENT';
|
|
129273
|
+
const client_ClientErrorCodes = ['BUILDER_AMOUNT_IS_ZERO', 'BUILDER_CANNOT_READ_BEFORE_RENDER', 'BUILDER_REQUIRES_PRIVATE_KEY', 'BUILDER_USER_CLIENT_REQUIRED', 'PUBLISH_AID_NOT_AVAILABLE', 'SIGNER_REQUIRES_PRIVATE_KEY'];
|
|
129274
|
+
const client_FullClientErrorCodes = client_ClientErrorCodes.map(code => `${client_ClientErrorType}_${code}`);
|
|
129275
|
+
class src_client_KeetaNetClientError extends src_client_KeetaNetErrorBase {
|
|
129276
|
+
constructor(code, message) {
|
|
129277
|
+
super(code, message, {
|
|
129278
|
+
type: client_ClientErrorType,
|
|
129279
|
+
codes: client_ClientErrorCodes
|
|
129280
|
+
});
|
|
129281
|
+
}
|
|
129282
|
+
}
|
|
129283
|
+
client_KeetaNetClientError = src_client_KeetaNetClientError;
|
|
129284
|
+
client_client_defineProperty(src_client_KeetaNetClientError, "isInstance", client_checkableGenerator(client_KeetaNetClientError));
|
|
129285
|
+
;// ./src/lib/error/kv.ts
|
|
129286
|
+
var client_KeetaNetKVError;
|
|
129287
|
+
function client_error_kv_defineProperty(e, r, t) { return (r = client_error_kv_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
129288
|
+
function client_error_kv_toPropertyKey(t) { var i = client_error_kv_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
129289
|
+
function client_error_kv_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
129290
|
+
|
|
129291
|
+
|
|
129292
|
+
const client_KVErrorType = 'KV';
|
|
129293
|
+
const client_KVErrorCodes = ['TTL_NOT_SUPPORTED', 'KEY_ALREADY_EXISTS'];
|
|
129294
|
+
const client_FullKVErrorCodes = client_KVErrorCodes.map(code => `${client_KVErrorType}_${code}`);
|
|
129295
|
+
class src_client_KeetaNetKVError extends src_client_KeetaNetErrorBase {
|
|
129296
|
+
constructor(code, message) {
|
|
129297
|
+
super(code, message, {
|
|
129298
|
+
type: client_KVErrorType,
|
|
129299
|
+
codes: client_KVErrorCodes
|
|
129300
|
+
});
|
|
129301
|
+
}
|
|
129302
|
+
}
|
|
129303
|
+
client_KeetaNetKVError = src_client_KeetaNetKVError;
|
|
129304
|
+
client_error_kv_defineProperty(src_client_KeetaNetKVError, "isInstance", client_checkableGenerator(client_KeetaNetKVError));
|
|
129305
|
+
;// ./src/lib/error/index.ts
|
|
129306
|
+
|
|
129307
|
+
|
|
129308
|
+
|
|
129309
|
+
|
|
129310
|
+
|
|
129311
|
+
|
|
129312
|
+
|
|
129313
|
+
|
|
129314
|
+
|
|
129315
|
+
|
|
129316
|
+
|
|
129317
|
+
const client_allErrorCodesWithoutPrefix = [...client_AccountErrorCodes, ...client_APIErrorCodes, ...client_BlockErrorCodes, ...client_CertificateErrorCodes, ...client_ClientErrorCodes, ...client_KVErrorCodes, ...client_LedgerBaseErrorCodes, ...client_LedgerVoteErrorCodes, ...client_PermissionsErrorCodes, ...client_VoteErrorCodes];
|
|
129318
|
+
const client_allFullErrorCodes = [...client_FullAccountErrorCodes, ...client_FullAPIErrorCodes, ...client_FullBlockErrorCodes, ...client_FullCertificateErrorCodes, ...client_FullClientErrorCodes, ...client_FullKVErrorCodes, ...client_FullLedgerErrorCodes, ...client_FullPermissionsErrorCodes, ...client_FullVoteErrorCodes];
|
|
129319
|
+
const client_errorCodeSet = new Set(client_allFullErrorCodes);
|
|
129320
|
+
async function client_ExpectErrorCode(code, test) {
|
|
129321
|
+
await expect(test).rejects.toThrow(expect.objectContaining({
|
|
129322
|
+
code: code
|
|
129323
|
+
}));
|
|
129324
|
+
}
|
|
129325
|
+
class client_KeetaNetError extends src_client_KeetaNetErrorBase {
|
|
129326
|
+
static assertValidErrorCode(code) {
|
|
129327
|
+
return client_errorCodeSet.has(code);
|
|
129328
|
+
}
|
|
129329
|
+
static fromJSON(json) {
|
|
129330
|
+
if (typeof json === 'object' && json !== null && 'type' in json && 'code' in json && 'message' in json) {
|
|
129331
|
+
const {
|
|
129332
|
+
type,
|
|
129333
|
+
code,
|
|
129334
|
+
message
|
|
129335
|
+
} = json;
|
|
129336
|
+
if (typeof type !== 'string' || typeof code !== 'string' || typeof message !== 'string') {
|
|
129337
|
+
return new Error('Invalid JSON for KeetaNetError (bad type or code or message)');
|
|
129338
|
+
}
|
|
129339
|
+
if (type === 'LEDGER') {
|
|
129340
|
+
let shouldRetry;
|
|
129341
|
+
let retryDelay;
|
|
129342
|
+
if ('shouldRetry' in json) {
|
|
129343
|
+
if (typeof json.shouldRetry !== 'boolean') {
|
|
129344
|
+
return new Error('Invalid JSON for KeetaNetLedgerError (bad shouldRetry)');
|
|
129345
|
+
}
|
|
129346
|
+
shouldRetry = json.shouldRetry;
|
|
129347
|
+
}
|
|
129348
|
+
if ('retryDelay' in json) {
|
|
129349
|
+
if (typeof json.retryDelay !== 'number') {
|
|
129350
|
+
return new Error('Invalid JSON for KeetaNetLedgerError (bad retryDelay)');
|
|
129351
|
+
}
|
|
129352
|
+
retryDelay = json.retryDelay;
|
|
129353
|
+
}
|
|
129354
|
+
if (src_client_KeetaNetLedgerVoteError.assertValidLedgerErrorCode(code)) {
|
|
129355
|
+
if (!('accounts' in json) || !Array.isArray(json.accounts)) {
|
|
129356
|
+
return new Error('Invalid JSON for KeetaNetLedgerVoteError (bad accounts)');
|
|
129357
|
+
}
|
|
129358
|
+
const accountsArray = json.accounts.map(account => {
|
|
129359
|
+
return client_lib_account.fromPublicKeyString(account);
|
|
129360
|
+
});
|
|
129361
|
+
const accounts = new client_lib_account.Set(accountsArray);
|
|
129362
|
+
return new src_client_KeetaNetLedgerVoteError(code, message, accounts);
|
|
129363
|
+
} else if (client_ledger_KeetaNetLedgerError.assertValidLedgerErrorCode(code)) {
|
|
129364
|
+
return new client_ledger_KeetaNetLedgerError(code, message, shouldRetry, retryDelay);
|
|
129365
|
+
}
|
|
129366
|
+
}
|
|
129367
|
+
if (this.assertValidErrorCode(code)) {
|
|
129368
|
+
return new client_KeetaNetError(code, message, {
|
|
129369
|
+
type,
|
|
129370
|
+
codes: client_allErrorCodesWithoutPrefix
|
|
129371
|
+
});
|
|
129372
|
+
}
|
|
129373
|
+
}
|
|
129374
|
+
if (typeof json === 'object' && json !== null && 'message' in json) {
|
|
129375
|
+
if (typeof json.message !== 'string') {
|
|
129376
|
+
return new Error('Invalid JSON for KeetaNetError (bad message)');
|
|
129377
|
+
}
|
|
129378
|
+
return new Error(json.message);
|
|
129379
|
+
}
|
|
129380
|
+
return new Error('Unknown error');
|
|
129381
|
+
}
|
|
129382
|
+
}
|
|
129200
129383
|
// EXTERNAL MODULE: ./node_modules/bloom-filters/dist/api.js
|
|
129201
129384
|
var client_api = __webpack_require__(5652);
|
|
129202
129385
|
;// ./src/lib/utils/bloom.ts
|
|
@@ -129270,6 +129453,7 @@ function client_deserializeBloomFilter(input) {
|
|
|
129270
129453
|
// Blocks that will return from generateInitialVoteStaple if you are adding supply
|
|
129271
129454
|
|
|
129272
129455
|
async function client_generateInitialVoteStaple(options) {
|
|
129456
|
+
var _options$baseTokenInf, _options$baseTokenInf2, _options$baseTokenInf3, _options$baseTokenInf4;
|
|
129273
129457
|
const {
|
|
129274
129458
|
network,
|
|
129275
129459
|
initialTrustedAccount,
|
|
@@ -129330,9 +129514,11 @@ async function client_generateInitialVoteStaple(options) {
|
|
|
129330
129514
|
permissions: new client_permissions_Permissions(['OWNER'])
|
|
129331
129515
|
}, {
|
|
129332
129516
|
type: client_lib_block.Builder.OperationType.SET_INFO,
|
|
129333
|
-
name: '',
|
|
129334
|
-
description: '',
|
|
129335
|
-
metadata:
|
|
129517
|
+
name: (_options$baseTokenInf = (_options$baseTokenInf2 = options.baseTokenInfo) === null || _options$baseTokenInf2 === void 0 ? void 0 : _options$baseTokenInf2.currencyCode) !== null && _options$baseTokenInf !== void 0 ? _options$baseTokenInf : '',
|
|
129518
|
+
description: (_options$baseTokenInf3 = (_options$baseTokenInf4 = options.baseTokenInfo) === null || _options$baseTokenInf4 === void 0 ? void 0 : _options$baseTokenInf4.name) !== null && _options$baseTokenInf3 !== void 0 ? _options$baseTokenInf3 : '',
|
|
129519
|
+
metadata: options.baseTokenInfo ? btoa(JSON.stringify({
|
|
129520
|
+
decimalPlaces: options.baseTokenInfo.decimalPlaces
|
|
129521
|
+
})) : '',
|
|
129336
129522
|
defaultPermission: new client_permissions_Permissions(['ACCESS'])
|
|
129337
129523
|
}, ...additionalBaseTokenOperations]
|
|
129338
129524
|
}).seal();
|
|
@@ -129412,8 +129598,8 @@ async function client_generateInitialVoteStaple(options) {
|
|
|
129412
129598
|
*/
|
|
129413
129599
|
Account: client_lib_account,
|
|
129414
129600
|
Block: client_lib_block,
|
|
129415
|
-
Error:
|
|
129416
|
-
Ledger:
|
|
129601
|
+
Error: client_KeetaNetError,
|
|
129602
|
+
Ledger: src_client_ledger,
|
|
129417
129603
|
Node: client_node,
|
|
129418
129604
|
P2P: client_p2p,
|
|
129419
129605
|
Permissions: client_permissions_Permissions,
|
|
@@ -129430,25 +129616,6 @@ async function client_generateInitialVoteStaple(options) {
|
|
|
129430
129616
|
Certificate: client_utils_certificate_namespaceObject
|
|
129431
129617
|
}
|
|
129432
129618
|
});
|
|
129433
|
-
;// ./src/lib/error/client.ts
|
|
129434
|
-
var client_KeetaNetClientError;
|
|
129435
|
-
function client_client_defineProperty(e, r, t) { return (r = client_client_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
129436
|
-
function client_client_toPropertyKey(t) { var i = client_client_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
129437
|
-
function client_client_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
129438
|
-
|
|
129439
|
-
|
|
129440
|
-
const client_ClientErrorType = 'CLIENT';
|
|
129441
|
-
const client_ClientErrorCodes = ['BUILDER_AMOUNT_IS_ZERO', 'BUILDER_CANNOT_READ_BEFORE_RENDER', 'BUILDER_REQUIRES_PRIVATE_KEY', 'BUILDER_USER_CLIENT_REQUIRED', 'PUBLISH_AID_NOT_AVAILABLE', 'SIGNER_REQUIRES_PRIVATE_KEY'];
|
|
129442
|
-
class src_client_KeetaNetClientError extends src_client_KeetaNetError {
|
|
129443
|
-
constructor(code, message) {
|
|
129444
|
-
super(code, message, {
|
|
129445
|
-
type: client_ClientErrorType,
|
|
129446
|
-
codes: client_ClientErrorCodes
|
|
129447
|
-
});
|
|
129448
|
-
}
|
|
129449
|
-
}
|
|
129450
|
-
client_KeetaNetClientError = src_client_KeetaNetClientError;
|
|
129451
|
-
client_client_defineProperty(src_client_KeetaNetClientError, "isInstance", client_checkableGenerator(client_KeetaNetClientError));
|
|
129452
129619
|
;// ./src/client/builder.ts
|
|
129453
129620
|
/* provided dependency */ var client_builder_Buffer = __webpack_require__(8287)["Buffer"];
|
|
129454
129621
|
var client_PendingAccount, client_UserClientBuilder;
|
|
@@ -130429,6 +130596,7 @@ function client_client_assertClassBrand(e, t, n) { if ("function" == typeof e ?
|
|
|
130429
130596
|
|
|
130430
130597
|
|
|
130431
130598
|
|
|
130599
|
+
|
|
130432
130600
|
|
|
130433
130601
|
|
|
130434
130602
|
/*
|
|
@@ -130807,9 +130975,10 @@ class src_client_Client {
|
|
|
130807
130975
|
* @return The account information
|
|
130808
130976
|
*/
|
|
130809
130977
|
async getAccountInfo(account) {
|
|
130978
|
+
let rep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'ANY';
|
|
130810
130979
|
account = client_lib_account.toAccount(account);
|
|
130811
130980
|
const accountPubKey = account.publicKeyString.get();
|
|
130812
|
-
const result = await client_client_assertClassBrand(client_Client_brand, this, src_client_api).call(this,
|
|
130981
|
+
const result = await client_client_assertClassBrand(client_Client_brand, this, src_client_api).call(this, rep, 'GET /node/ledger/account/:account', {
|
|
130813
130982
|
args: {
|
|
130814
130983
|
account: accountPubKey
|
|
130815
130984
|
}
|
|
@@ -131699,6 +131868,64 @@ class src_client_Client {
|
|
|
131699
131868
|
}
|
|
131700
131869
|
return voteStaple;
|
|
131701
131870
|
}
|
|
131871
|
+
|
|
131872
|
+
/**
|
|
131873
|
+
* Sync any partially-published account artifacts
|
|
131874
|
+
*
|
|
131875
|
+
* @param account Account to sync
|
|
131876
|
+
* @param publish Publish the synced staple to the network (default is true)
|
|
131877
|
+
*/
|
|
131878
|
+
async syncAccount(account) {
|
|
131879
|
+
let publish = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
131880
|
+
let reps = arguments.length > 2 ? arguments[2] : undefined;
|
|
131881
|
+
await client_client_classPrivateFieldGet(client_updateRepsPromise, this);
|
|
131882
|
+
if (reps === undefined) {
|
|
131883
|
+
reps = this.representatives;
|
|
131884
|
+
}
|
|
131885
|
+
const repAccountInfoPromises = [];
|
|
131886
|
+
for (const rep of reps) {
|
|
131887
|
+
repAccountInfoPromises.push((async () => {
|
|
131888
|
+
const info = await this.getAccountInfo(account, rep);
|
|
131889
|
+
return {
|
|
131890
|
+
rep,
|
|
131891
|
+
info
|
|
131892
|
+
};
|
|
131893
|
+
})());
|
|
131894
|
+
}
|
|
131895
|
+
const accountInfoSettled = await Promise.allSettled(repAccountInfoPromises);
|
|
131896
|
+
const accountInfo = [];
|
|
131897
|
+
for (const info of accountInfoSettled) {
|
|
131898
|
+
if (info.status === 'fulfilled') {
|
|
131899
|
+
accountInfo.push(info.value);
|
|
131900
|
+
}
|
|
131901
|
+
}
|
|
131902
|
+
const accountInfoSorted = accountInfo.sort(function (a, b) {
|
|
131903
|
+
var _a$info$currentHeadBl, _b$info$currentHeadBl;
|
|
131904
|
+
return Number(BigInt((_a$info$currentHeadBl = a.info.currentHeadBlockHeight) !== null && _a$info$currentHeadBl !== void 0 ? _a$info$currentHeadBl : -1) - BigInt((_b$info$currentHeadBl = b.info.currentHeadBlockHeight) !== null && _b$info$currentHeadBl !== void 0 ? _b$info$currentHeadBl : -1));
|
|
131905
|
+
});
|
|
131906
|
+
if (accountInfoSorted[0].info.currentHeadBlockHeight === accountInfoSorted[accountInfoSorted.length - 1].info.currentHeadBlockHeight) {
|
|
131907
|
+
// Block Heights match so return
|
|
131908
|
+
return null;
|
|
131909
|
+
}
|
|
131910
|
+
let lowestHead = accountInfoSorted[0].info.currentHeadBlock;
|
|
131911
|
+
if (lowestHead === null) {
|
|
131912
|
+
lowestHead = client_lib_block.getAccountOpeningHash(account).toString();
|
|
131913
|
+
}
|
|
131914
|
+
|
|
131915
|
+
// Get the missing successor block and vote staple from the rep with the highest block height
|
|
131916
|
+
const successorBlock = await this.getSuccessorBlock(lowestHead, accountInfoSorted[accountInfoSorted.length - 1].rep);
|
|
131917
|
+
if (successorBlock === null) {
|
|
131918
|
+
return null;
|
|
131919
|
+
}
|
|
131920
|
+
const successorStaple = await this.getVoteStaple(successorBlock.hash, 'main', accountInfoSorted[accountInfoSorted.length - 1].rep);
|
|
131921
|
+
if (successorStaple === null) {
|
|
131922
|
+
return null;
|
|
131923
|
+
}
|
|
131924
|
+
if (publish === true) {
|
|
131925
|
+
await this.transmitStaple(successorStaple, [accountInfoSorted[0].rep]);
|
|
131926
|
+
}
|
|
131927
|
+
return successorStaple;
|
|
131928
|
+
}
|
|
131702
131929
|
async getVoteQuotes(blocks) {
|
|
131703
131930
|
return await client_client_assertClassBrand(client_Client_brand, this, client_requestQuotes).call(this, blocks);
|
|
131704
131931
|
}
|
|
@@ -131730,7 +131957,8 @@ async function client_apiRaw(rep, api, method) {
|
|
|
131730
131957
|
...options
|
|
131731
131958
|
};
|
|
131732
131959
|
let delay = 1;
|
|
131733
|
-
let result
|
|
131960
|
+
let result;
|
|
131961
|
+
let resultThrow;
|
|
131734
131962
|
for (let retry = 0; retry < Number.MAX_SAFE_INTEGER; retry++) {
|
|
131735
131963
|
if (rep === 'ANY') {
|
|
131736
131964
|
var _classPrivateFieldGet4;
|
|
@@ -131787,7 +132015,18 @@ async function client_apiRaw(rep, api, method) {
|
|
|
131787
132015
|
try {
|
|
131788
132016
|
const errorInfo = await response.json();
|
|
131789
132017
|
if (errorInfo.error === true) {
|
|
131790
|
-
|
|
132018
|
+
const keetaNetError = client_KeetaNetError.fromJSON(errorInfo);
|
|
132019
|
+
try {
|
|
132020
|
+
if (src_client_KeetaNetLedgerVoteError.isInstance(keetaNetError)) {
|
|
132021
|
+
for (const account of keetaNetError.accounts) {
|
|
132022
|
+
await this.syncAccount(account);
|
|
132023
|
+
}
|
|
132024
|
+
continue;
|
|
132025
|
+
}
|
|
132026
|
+
} catch {
|
|
132027
|
+
// ignored error parsing KeetaNet Error just return original
|
|
132028
|
+
}
|
|
132029
|
+
resultThrow = keetaNetError;
|
|
131791
132030
|
break;
|
|
131792
132031
|
}
|
|
131793
132032
|
} catch (errorResponse) {
|
|
@@ -131849,13 +132088,8 @@ async function client_apiRaw(rep, api, method) {
|
|
|
131849
132088
|
break;
|
|
131850
132089
|
}
|
|
131851
132090
|
if (resultThrow) {
|
|
131852
|
-
|
|
131853
|
-
|
|
131854
|
-
error.type = resultThrow.type;
|
|
131855
|
-
throw error;
|
|
131856
|
-
} else {
|
|
131857
|
-
throw new Error(resultThrow.message);
|
|
131858
|
-
}
|
|
132091
|
+
const toThrow = client_KeetaNetError.fromJSON(resultThrow);
|
|
132092
|
+
throw toThrow;
|
|
131859
132093
|
}
|
|
131860
132094
|
return result;
|
|
131861
132095
|
}
|
|
@@ -132436,7 +132670,8 @@ class src_client_UserClient {
|
|
|
132436
132670
|
const {
|
|
132437
132671
|
delegateTo = this.client.representatives[0].key,
|
|
132438
132672
|
addSupplyAmount,
|
|
132439
|
-
voteSerial = 0n
|
|
132673
|
+
voteSerial = 0n,
|
|
132674
|
+
baseTokenInfo
|
|
132440
132675
|
} = initOpts;
|
|
132441
132676
|
if (this.signer === null) {
|
|
132442
132677
|
throw new Error('May not initialize chain with a read-only UserClient (signer is null)');
|
|
@@ -132452,7 +132687,8 @@ class src_client_UserClient {
|
|
|
132452
132687
|
delegateTo: delegateTo,
|
|
132453
132688
|
recipient: client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options).assertAccount(),
|
|
132454
132689
|
amount: addSupplyAmount
|
|
132455
|
-
}
|
|
132690
|
+
},
|
|
132691
|
+
baseTokenInfo
|
|
132456
132692
|
});
|
|
132457
132693
|
return await this.client.transmitStaple(voteStaple);
|
|
132458
132694
|
}
|
|
@@ -132557,9 +132793,10 @@ class src_client_UserClient {
|
|
|
132557
132793
|
* @return The vote staple that was generated and whether it was able to be published
|
|
132558
132794
|
*/
|
|
132559
132795
|
async publishBuilder(builder) {
|
|
132560
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
132561
|
-
|
|
132562
|
-
|
|
132796
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
132797
|
+
if (options.generateFeeBlock === undefined) {
|
|
132798
|
+
options.generateFeeBlock = client_client_classPrivateFieldGet(client_client_config, this).generateFeeBlock;
|
|
132799
|
+
}
|
|
132563
132800
|
if (!client_client_classPrivateFieldGet(client_client_config, this).usePublishAid) {
|
|
132564
132801
|
return await client_client_classPrivateFieldGet(client_client, this).transmitBuilder(builder, this.network, options);
|
|
132565
132802
|
}
|
|
@@ -132678,15 +132915,18 @@ class src_client_UserClient {
|
|
|
132678
132915
|
try {
|
|
132679
132916
|
const builder = this.initBuilder(options);
|
|
132680
132917
|
builder.send(client_lib_account.toAccount(to), BigInt(amount), client_lib_account.toAccount(token), external);
|
|
132681
|
-
|
|
132918
|
+
const publish = await this.publishBuilder(builder);
|
|
132919
|
+
return publish;
|
|
132682
132920
|
} catch (transmitError) {
|
|
132683
132921
|
let error = true;
|
|
132684
132922
|
if (retries < 2) {
|
|
132685
|
-
if (
|
|
132686
|
-
|
|
132687
|
-
|
|
132688
|
-
|
|
132689
|
-
|
|
132923
|
+
if (client_KeetaNetError.isInstance(transmitError)) {
|
|
132924
|
+
if (transmitError.code === 'LEDGER_SUCCESSOR_VOTE_EXISTS') {
|
|
132925
|
+
const staple = await this.recover(true, options);
|
|
132926
|
+
if (staple) {
|
|
132927
|
+
error = false;
|
|
132928
|
+
return await this.send(to, amount, token, external, options, retries + 1);
|
|
132929
|
+
}
|
|
132690
132930
|
}
|
|
132691
132931
|
}
|
|
132692
132932
|
}
|
|
@@ -132926,6 +133166,18 @@ class src_client_UserClient {
|
|
|
132926
133166
|
return await client_client_classPrivateFieldGet(client_client, this).recoverAccount(client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options), publish);
|
|
132927
133167
|
}
|
|
132928
133168
|
|
|
133169
|
+
/**
|
|
133170
|
+
* Sync any partially-published account artifacts
|
|
133171
|
+
*
|
|
133172
|
+
* @param publish Publish the recovered staple to the network
|
|
133173
|
+
* (default: true)
|
|
133174
|
+
* @param options User client options (common options)
|
|
133175
|
+
*/
|
|
133176
|
+
async sync(publish) {
|
|
133177
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
133178
|
+
return await client_client_classPrivateFieldGet(client_client, this).syncAccount(client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options), publish);
|
|
133179
|
+
}
|
|
133180
|
+
|
|
132929
133181
|
/**
|
|
132930
133182
|
* Register a callback for change messages and set up a websocket filtered to our account only.
|
|
132931
133183
|
* Also set up long timeout polling for changes in case the websocket misses a change update
|
|
@@ -133147,7 +133399,7 @@ async function client_publishWithPublishAid(blocks) {
|
|
|
133147
133399
|
publish: json.publish
|
|
133148
133400
|
};
|
|
133149
133401
|
} catch (publishError) {
|
|
133150
|
-
if (
|
|
133402
|
+
if (client_KeetaNetError.isInstance(publishError)) {
|
|
133151
133403
|
throw publishError;
|
|
133152
133404
|
} else if (publishError instanceof Error) {
|
|
133153
133405
|
throw new src_client_KeetaNetClientError('CLIENT_PUBLISH_AID_NOT_AVAILABLE', `Publish Aid not available: ${publishError.message}`);
|