@keetanetwork/keetanet-client 0.12.2 → 0.14.2
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/api/index.d.ts +23 -2
- package/api/node.d.ts +7 -1
- package/api/p2p.d.ts +13 -0
- package/api/vote.d.ts +10 -0
- package/client/builder.d.ts +13 -6
- package/client/client_common_tests.d.ts +18 -0
- package/client/index-browser.d.ts +42 -14
- package/client/index-browser.js +2899 -1382
- package/client/index.d.ts +42 -14
- package/client/index.js +2138 -655
- package/config/index.d.ts +2 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/KeetaNetSDK.Client.html +14 -10
- package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +10 -0
- package/docs/classes/KeetaNetSDK.Referenced.Block.html +9 -5
- package/docs/classes/KeetaNetSDK.Referenced.BlockBuilder.html +3 -2
- 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 +4 -4
- 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.Certificate.html +6 -2
- package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +5 -2
- package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +3 -1
- package/docs/classes/KeetaNetSDK.Referenced.LedgerStorageTransactionBase.html +8 -0
- package/docs/classes/KeetaNetSDK.Referenced.P2PSwitch.html +6 -2
- package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +31 -27
- package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Stats.html +10 -4
- package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +10 -0
- package/docs/classes/KeetaNetSDK.Referenced.UserClientBuilder.html +4 -3
- package/docs/classes/KeetaNetSDK.Referenced.Vote.html +7 -3
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +3 -3
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +10 -8
- package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +32 -0
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +34 -0
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +11 -0
- package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +3 -3
- package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.html +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.UserClient.html +7 -2
- package/docs/enums/KeetaNetSDK.Referenced.BaseFlag.html +2 -1
- package/docs/enums/KeetaNetSDK.Referenced.BasePermissionGroup.html +3 -1
- package/docs/enums/KeetaNetSDK.Referenced.BlockPurpose.html +3 -0
- package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_helper.bufferToBigInt.html +1 -0
- 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.AccountInfo.html +4 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +3 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +3 -3
- 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.BlockCanonical.html → KeetaNetSDK.Referenced.BlockV1Canonical.html} +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1JSON.html +12 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1UnsignedCanonical.html +11 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +11 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2JSON.html +12 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2UnsignedCanonical.html +11 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.BuilderBlockOptions.html +3 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.ComputedBlocksEffectFields.html +3 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.CreateIdentifierRequest.html +4 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerConfig.html +5 -3
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +4 -4
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageTransactionBaseOptions.html +6 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +5 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +3 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PConfig.html +4 -2
- 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 +4 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.PrincipalACLWithInfoParsed.html +1 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.PublishOptions.html +5 -0
- 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 +5 -3
- package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +4 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.VoteJSON.html +3 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.VoteStapleJSON.html +2 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_config.ValidationConfig.html +2 -2
- 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/interfaces/KeetaNetSDK.Referenced.src_lib_utils_helper.InstanceSetConstructor.html +2 -2
- package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_asn1.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_helper.html +1 -1
- package/docs/types/KeetaNetSDK.Referenced.BlockASN1SchemaWithoutSignature.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.BlockJSON.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.BlockJSONIncomplete.html +1 -1
- package/docs/types/KeetaNetSDK.Referenced.BlockOperationASN1SchemaType.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.BlockOperationTypes.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.BlockSignature.html +2 -0
- package/docs/types/KeetaNetSDK.Referenced.BlockSignatureField.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.BlockSignerField.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.BlockSignerFieldJSON.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.BlockV1ASN1WithoutSignature.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.BlockV2ASN1WithoutSignature.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.CertificateBuilderParams.html +8 -3
- package/docs/types/KeetaNetSDK.Referenced.ComputedEffectOfBlocks.html +2 -2
- package/docs/types/KeetaNetSDK.Referenced.GetAccountStateAPIResponseFormatted.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.HashNames.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.MultisigAddress.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.MultisigSignerField.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.MultisigSignerFieldJSON.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.OmitLastArrayValue.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.P2PUpdateOptions.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.UserEditableAccountInfo.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.src_config.NetworkConfig.html +1 -1
- package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.Schema.html +1 -1
- package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.SchemaMap.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes-1.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.BlockOperationASN1Schema.html +2 -0
- package/docs/variables/KeetaNetSDK.Referenced.LedgerErrorCodes.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.VoteErrorCodes.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1CheckUtilities.html +1 -0
- package/lib/block/index.d.ts +104 -36
- package/lib/block/operations.d.ts +31 -3
- package/lib/error/block.d.ts +1 -1
- package/lib/error/certificate.d.ts +1 -1
- package/lib/error/ledger.d.ts +1 -1
- package/lib/error/vote.d.ts +1 -1
- package/lib/ledger/common.d.ts +14 -1
- package/lib/ledger/db_dynamodb.d.ts +7 -11
- package/lib/ledger/db_postgres.d.ts +12 -4
- package/lib/ledger/db_spanner.d.ts +6 -13
- package/lib/ledger/db_spanner_helper.d.ts +29 -6
- package/lib/ledger/db_sqlite.d.ts +12 -4
- package/lib/ledger/effects.d.ts +10 -9
- package/lib/ledger/index.d.ts +28 -10
- package/lib/ledger/types.d.ts +10 -1
- package/lib/node/utils.d.ts +5 -0
- package/lib/p2p.d.ts +32 -0
- package/lib/permissions.d.ts +5 -2
- package/lib/stats.d.ts +22 -3
- package/lib/utils/asn1.d.ts +22 -5
- package/lib/utils/certificate.d.ts +38 -1
- package/lib/utils/helper.d.ts +2 -1
- package/lib/utils/static-types.d.ts +11 -0
- package/lib/vote.d.ts +55 -20
- package/package.json +1 -1
- package/version.d.ts +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSON.html +0 -11
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockUnsignedCanonical.html +0 -11
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageTransactionBase.html +0 -6
- package/docs/types/KeetaNetSDK.Referenced.CreateIdentifierRequest.html +0 -6
package/lib/block/index.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import type { GenericAccount } from '../account';
|
|
2
|
-
import Account from '../account';
|
|
1
|
+
import type { GenericAccount, MultisigAddress } from '../account';
|
|
2
|
+
import Account, { AccountKeyAlgorithm } from '../account';
|
|
3
3
|
import { BufferStorage } from '../utils/buffer';
|
|
4
4
|
import * as ASN1 from '../utils/asn1';
|
|
5
5
|
import type { ToJSONSerializable, ToJSONSerializableOptions } from '../utils/conversion';
|
|
6
6
|
import * as Operations from './operations';
|
|
7
|
+
export declare enum BlockPurpose {
|
|
8
|
+
GENERIC = 0,
|
|
9
|
+
FEE = 1
|
|
10
|
+
}
|
|
7
11
|
export declare enum AdjustMethod {
|
|
8
12
|
ADD = 0,
|
|
9
13
|
SUBTRACT = 1,
|
|
10
14
|
SET = 2
|
|
11
15
|
}
|
|
12
|
-
export declare function
|
|
16
|
+
export declare function toAdjustMethod(value: unknown): AdjustMethod;
|
|
13
17
|
type BlockHashString = string & {
|
|
14
18
|
readonly __blockhash: never;
|
|
15
19
|
};
|
|
@@ -41,8 +45,9 @@ type BlockSignature = Buffer;
|
|
|
41
45
|
/**
|
|
42
46
|
* Representation of the block
|
|
43
47
|
*/
|
|
44
|
-
export interface
|
|
48
|
+
export interface BlockV1JSON {
|
|
45
49
|
version: 1;
|
|
50
|
+
purpose?: BlockPurpose.GENERIC;
|
|
46
51
|
date: string | Date;
|
|
47
52
|
previous: string | BlockHash;
|
|
48
53
|
network: string | NetworkID;
|
|
@@ -52,16 +57,37 @@ export interface BlockJSON {
|
|
|
52
57
|
signature: string | BlockSignature;
|
|
53
58
|
operations: Operations.BlockJSONOperations[] | Operations.BlockOperations[];
|
|
54
59
|
}
|
|
55
|
-
export type
|
|
60
|
+
export type BlockV1JSONIncomplete = Partial<BlockV1JSON>;
|
|
56
61
|
/**
|
|
57
62
|
* Output of block suitable to JSON serialization
|
|
58
63
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Representation of the block V2
|
|
66
|
+
*/
|
|
67
|
+
export interface BlockV2JSON {
|
|
68
|
+
version: 2;
|
|
69
|
+
purpose: BlockPurpose;
|
|
70
|
+
date: string | Date;
|
|
71
|
+
previous: string | BlockHash;
|
|
72
|
+
network: string | NetworkID;
|
|
73
|
+
subnet?: string | SubnetID;
|
|
74
|
+
account: string | GenericAccount;
|
|
75
|
+
signer: BlockSignerFieldJSON;
|
|
76
|
+
signatures: (string | BlockSignature)[];
|
|
77
|
+
operations: (Operations.BlockJSONOperations | Operations.BlockOperations)[];
|
|
78
|
+
}
|
|
79
|
+
export type BlockV2JSONIncomplete = Partial<BlockV2JSON>;
|
|
80
|
+
export type BlockJSONOutput = ReturnType<Block['toJSON']>;
|
|
81
|
+
export type BlockJSONOutputSerialized = ToJSONSerializable<BlockJSONOutput>;
|
|
82
|
+
export type BlockJSONOutputIncomplete = Partial<BlockJSONOutputSerialized>;
|
|
83
|
+
export type BlockJSON = (Omit<BlockV1JSON, 'version'> | Omit<BlockV2JSON, 'version'>) & {
|
|
84
|
+
version: number;
|
|
85
|
+
};
|
|
86
|
+
export type BlockJSONIncomplete = Partial<BlockJSON>;
|
|
61
87
|
/**
|
|
62
88
|
* Map input to our values
|
|
63
89
|
*/
|
|
64
|
-
interface
|
|
90
|
+
interface BlockV1UnsignedCanonical {
|
|
65
91
|
version: 1;
|
|
66
92
|
date: Date;
|
|
67
93
|
previous: BlockHash;
|
|
@@ -70,17 +96,45 @@ interface BlockUnsignedCanonical {
|
|
|
70
96
|
operations: Operations.BlockOperations[];
|
|
71
97
|
network: NetworkID;
|
|
72
98
|
subnet: SubnetID | undefined;
|
|
73
|
-
signature
|
|
99
|
+
signature?: never;
|
|
74
100
|
}
|
|
75
|
-
interface
|
|
101
|
+
interface BlockV1Canonical extends Omit<BlockV1UnsignedCanonical, 'signature'> {
|
|
76
102
|
signature: BlockSignature;
|
|
77
103
|
}
|
|
78
|
-
|
|
104
|
+
interface BlockV2UnsignedCanonical {
|
|
105
|
+
version: 2;
|
|
106
|
+
date: Date;
|
|
107
|
+
purpose: BlockPurpose;
|
|
108
|
+
previous: BlockHash;
|
|
109
|
+
account: GenericAccount;
|
|
110
|
+
signer: BlockSignerField;
|
|
111
|
+
operations: Operations.BlockOperations[];
|
|
112
|
+
network: NetworkID;
|
|
113
|
+
subnet: SubnetID | undefined;
|
|
114
|
+
signatures?: never;
|
|
115
|
+
}
|
|
116
|
+
interface BlockV2Canonical extends Omit<BlockV2UnsignedCanonical, 'signatures'> {
|
|
117
|
+
signatures: BlockSignature[];
|
|
118
|
+
}
|
|
119
|
+
type OmitLastArrayValue<T> = Required<T> extends [...infer Head, any] ? Head : never;
|
|
120
|
+
type BlockV1ASN1WithoutSignature = ASN1.ValidateASN1.SchemaMap<OmitLastArrayValue<typeof BlockV1ASN1Schema>>;
|
|
121
|
+
type BlockV2ASN1WithoutSignature = ASN1.ValidateASN1.SchemaMap<OmitLastArrayValue<typeof BlockV2ASN1Schema.contains>>;
|
|
122
|
+
type MultisigSignerFieldJSON = [MultisigAddress | string, (MultisigSignerField | Account | string)[]];
|
|
123
|
+
type BlockSignerFieldJSON = Account | string | MultisigSignerFieldJSON;
|
|
124
|
+
type BlockASN1SchemaWithoutSignature = BlockV1ASN1WithoutSignature | {
|
|
125
|
+
type: 'context';
|
|
126
|
+
kind: 'explicit';
|
|
127
|
+
value: 1;
|
|
128
|
+
contains: BlockV2ASN1WithoutSignature;
|
|
129
|
+
};
|
|
130
|
+
type MultisigSignerField = [MultisigAddress, (MultisigSignerField | Account)[]];
|
|
131
|
+
type BlockSignerField = Account | [MultisigAddress, BlockSignerField[]];
|
|
132
|
+
type BlockSignatureField = [BlockSignature, ...BlockSignature[]];
|
|
79
133
|
/**
|
|
80
134
|
* Block: An item which contains a number of operations (transactions) which
|
|
81
135
|
* originated from an account at a particular instant
|
|
82
136
|
*/
|
|
83
|
-
export declare class Block implements
|
|
137
|
+
export declare class Block implements Omit<BlockV2Canonical, 'version'> {
|
|
84
138
|
#private;
|
|
85
139
|
static isInstance: (obj: any, strict?: boolean) => obj is Block;
|
|
86
140
|
static Hash: typeof BlockHash;
|
|
@@ -98,32 +152,41 @@ export declare class Block implements BlockCanonical {
|
|
|
98
152
|
};
|
|
99
153
|
static NO_PREVIOUS: string;
|
|
100
154
|
static AdjustMethod: typeof AdjustMethod;
|
|
155
|
+
static Purpose: typeof BlockPurpose;
|
|
101
156
|
static Builder: typeof BlockBuilder;
|
|
102
|
-
readonly version: 1;
|
|
157
|
+
readonly version: 1 | 2;
|
|
158
|
+
readonly purpose: BlockPurpose;
|
|
103
159
|
readonly date: Date;
|
|
104
160
|
readonly previous: BlockHash;
|
|
105
161
|
readonly account: GenericAccount;
|
|
106
|
-
readonly
|
|
107
|
-
readonly operations: BlockCanonical['operations'];
|
|
162
|
+
readonly operations: BlockV2Canonical['operations'];
|
|
108
163
|
readonly network: NetworkID;
|
|
109
164
|
readonly subnet: SubnetID | undefined;
|
|
110
|
-
readonly
|
|
111
|
-
readonly
|
|
165
|
+
readonly signer: BlockSignerField;
|
|
166
|
+
readonly signatures: BlockSignatureField;
|
|
167
|
+
get principal(): Account<AccountKeyAlgorithm.ECDSA_SECP256K1 | AccountKeyAlgorithm.ED25519 | AccountKeyAlgorithm.ECDSA_SECP256R1> | MultisigAddress;
|
|
112
168
|
readonly $opening: boolean;
|
|
113
|
-
static fromUnsignedJSON(input:
|
|
114
|
-
static isValidJSON(block:
|
|
115
|
-
|
|
169
|
+
static fromUnsignedJSON(input: BlockV1UnsignedCanonical | BlockV2UnsignedCanonical): Promise<Block>;
|
|
170
|
+
static isValidJSON<Version extends 1 | 2>(block: unknown, version?: Version): block is ({
|
|
171
|
+
1: BlockV1JSON;
|
|
172
|
+
2: BlockV2JSON;
|
|
173
|
+
}[Version]);
|
|
174
|
+
constructor(input: Buffer | ArrayBuffer | BlockJSON | BlockJSONOutput | BlockJSONOutputSerialized | Block | string);
|
|
116
175
|
static getAccountOpeningHash(account: GenericAccount): BlockHash;
|
|
117
|
-
toBytes(
|
|
118
|
-
protected static
|
|
176
|
+
toBytes(includeSignatures?: boolean): ArrayBuffer;
|
|
177
|
+
protected static getV1ASN1ContainerWithoutSignature(input: BlockV1UnsignedCanonical | BlockV1Canonical): BlockV1ASN1WithoutSignature;
|
|
178
|
+
protected static getV2ASN1ContainerWithoutSignature(input: BlockV2UnsignedCanonical | BlockV2Canonical): BlockV2ASN1WithoutSignature;
|
|
179
|
+
protected static getASN1ContainerWithoutSignature(input: BlockV1UnsignedCanonical | BlockV1Canonical | BlockV2UnsignedCanonical | BlockV2Canonical): BlockASN1SchemaWithoutSignature;
|
|
119
180
|
toJSON(options?: ToJSONSerializableOptions): {
|
|
120
181
|
$binary?: string;
|
|
121
|
-
|
|
182
|
+
signature?: string;
|
|
183
|
+
signatures?: string[];
|
|
184
|
+
version: 1 | 2;
|
|
122
185
|
date: Date;
|
|
123
186
|
previous: BlockHash;
|
|
124
187
|
account: GenericAccount;
|
|
125
|
-
|
|
126
|
-
|
|
188
|
+
purpose: BlockPurpose;
|
|
189
|
+
signer: Account | [MultisigAddress, any[]];
|
|
127
190
|
network: bigint;
|
|
128
191
|
subnet: bigint | undefined;
|
|
129
192
|
operations: Operations.ExportedJSONOperation[];
|
|
@@ -140,7 +203,7 @@ export declare class Block implements BlockCanonical {
|
|
|
140
203
|
*/
|
|
141
204
|
get hash(): BlockHash;
|
|
142
205
|
}
|
|
143
|
-
export declare class BlockBuilder
|
|
206
|
+
export declare class BlockBuilder {
|
|
144
207
|
#private;
|
|
145
208
|
static isInstance: (obj: any, strict?: boolean) => obj is BlockBuilder;
|
|
146
209
|
static OperationType: typeof Operations.OperationType;
|
|
@@ -157,32 +220,35 @@ export declare class BlockBuilder implements BlockJSONIncomplete {
|
|
|
157
220
|
MANAGE_CERTIFICATE: typeof Operations.BlockOperationMANAGE_CERTIFICATE;
|
|
158
221
|
};
|
|
159
222
|
static NO_PREVIOUS: string;
|
|
160
|
-
constructor(block?: BlockJSONIncomplete |
|
|
223
|
+
constructor(block?: BlockJSON | BlockJSONIncomplete | BlockJSONOutputSerialized | ReturnType<Block['toJSON']> | Block | ArrayBuffer | string);
|
|
161
224
|
protected get currentBlock(): Block | BlockJSONIncomplete;
|
|
162
225
|
protected get currentWIP(): BlockJSONIncomplete;
|
|
163
226
|
protected get currentBlockSealed(): Block;
|
|
164
227
|
toJSON(opts?: ToJSONSerializableOptions): {
|
|
165
228
|
$binary?: string;
|
|
166
|
-
|
|
229
|
+
signature?: string;
|
|
230
|
+
signatures?: string[];
|
|
231
|
+
version: 1 | 2;
|
|
167
232
|
date: Date;
|
|
168
233
|
previous: BlockHash;
|
|
169
234
|
account: GenericAccount;
|
|
170
|
-
|
|
171
|
-
|
|
235
|
+
purpose: BlockPurpose;
|
|
236
|
+
signer: Account | [MultisigAddress, any[]];
|
|
172
237
|
network: bigint;
|
|
173
238
|
subnet: bigint | undefined;
|
|
174
239
|
operations: Operations.ExportedJSONOperation[];
|
|
175
240
|
$hash: BlockHash;
|
|
176
241
|
$opening: boolean;
|
|
177
242
|
} | {
|
|
178
|
-
version:
|
|
243
|
+
version: number | undefined;
|
|
179
244
|
date: Date | undefined;
|
|
180
245
|
previous: BlockHash | undefined;
|
|
181
246
|
account: GenericAccount | undefined;
|
|
182
|
-
signer:
|
|
247
|
+
signer: BlockSignerFieldJSON | undefined;
|
|
183
248
|
network: bigint | undefined;
|
|
184
249
|
subnet: bigint | undefined;
|
|
185
250
|
operations: Operations.BlockOperations[] | undefined;
|
|
251
|
+
purpose: BlockPurpose;
|
|
186
252
|
$opening: boolean | undefined;
|
|
187
253
|
};
|
|
188
254
|
seal(): Promise<Block>;
|
|
@@ -190,8 +256,8 @@ export declare class BlockBuilder implements BlockJSONIncomplete {
|
|
|
190
256
|
get sealed(): boolean;
|
|
191
257
|
get block(): Block | undefined;
|
|
192
258
|
get hash(): BlockHash | undefined;
|
|
193
|
-
set signer(signer:
|
|
194
|
-
get signer():
|
|
259
|
+
set signer(signer: BlockV2JSONIncomplete['signer'] | BlockV2JSON['signer']);
|
|
260
|
+
get signer(): BlockV2JSON['signer'] | undefined;
|
|
195
261
|
set account(account: string | GenericAccount | undefined);
|
|
196
262
|
get account(): GenericAccount | undefined;
|
|
197
263
|
set previous(blockhash: string | BlockHash | undefined);
|
|
@@ -199,8 +265,10 @@ export declare class BlockBuilder implements BlockJSONIncomplete {
|
|
|
199
265
|
get $opening(): boolean | undefined;
|
|
200
266
|
set date(date: Date | string | undefined);
|
|
201
267
|
get date(): Date | undefined;
|
|
202
|
-
set version(version:
|
|
203
|
-
get version():
|
|
268
|
+
set version(version: number | undefined);
|
|
269
|
+
get version(): number | undefined;
|
|
270
|
+
set purpose(purpose: BlockPurpose | undefined);
|
|
271
|
+
get purpose(): BlockPurpose;
|
|
204
272
|
set network(network: NetworkID | string | undefined);
|
|
205
273
|
get network(): NetworkID | undefined;
|
|
206
274
|
set subnet(subnet: SubnetID | string | undefined);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ValidateASN1 } from '../utils/asn1';
|
|
2
2
|
import type { DeepMutable } from '../utils/helper';
|
|
3
|
-
import type { GenericAccount, IdentifierAddress, TokenAddress, TokenPublicKeyString } from '../account';
|
|
4
|
-
import Account from '../account';
|
|
3
|
+
import type { GenericAccount, IdentifierAddress, IdentifierKeyAlgorithm, TokenAddress, TokenPublicKeyString } from '../account';
|
|
4
|
+
import Account, { AccountKeyAlgorithm } from '../account';
|
|
5
5
|
import type { AcceptedPermissionTypes } from '../permissions';
|
|
6
6
|
import { Permissions } from '../permissions';
|
|
7
7
|
import type { ToJSONSerializable } from '../utils/conversion';
|
|
8
8
|
import Block, { AdjustMethod } from '.';
|
|
9
9
|
import { Certificate, CertificateBundle, CertificateHash } from '../utils/certificate';
|
|
10
|
+
import type { MultisigConfig } from '../ledger/types';
|
|
10
11
|
/**
|
|
11
12
|
* All supported operations
|
|
12
13
|
*/
|
|
@@ -110,6 +111,20 @@ declare const BlockOperationASN1SchemaBase: {
|
|
|
110
111
|
readonly CREATE_IDENTIFIER: [{
|
|
111
112
|
readonly name: "identifier";
|
|
112
113
|
readonly schema: typeof ValidateASN1.IsOctetString;
|
|
114
|
+
}, {
|
|
115
|
+
readonly name: "createArguments";
|
|
116
|
+
readonly schema: {
|
|
117
|
+
readonly optional: {
|
|
118
|
+
readonly choice: [{
|
|
119
|
+
readonly type: "context";
|
|
120
|
+
readonly kind: "explicit";
|
|
121
|
+
readonly value: 7;
|
|
122
|
+
readonly contains: readonly [{
|
|
123
|
+
readonly sequenceOf: typeof ValidateASN1.IsOctetString;
|
|
124
|
+
}, typeof ValidateASN1.IsInteger];
|
|
125
|
+
}];
|
|
126
|
+
};
|
|
127
|
+
};
|
|
113
128
|
}];
|
|
114
129
|
readonly TOKEN_ADMIN_SUPPLY: [{
|
|
115
130
|
readonly name: "amount";
|
|
@@ -264,9 +279,16 @@ declare class BlockOperationSET_REP extends BlockOperation implements BlockJSONO
|
|
|
264
279
|
/**
|
|
265
280
|
* TokenCreate Operation
|
|
266
281
|
*/
|
|
282
|
+
interface BaseIdentifierCreateArguments<KeyType extends IdentifierKeyAlgorithm> {
|
|
283
|
+
type: KeyType;
|
|
284
|
+
}
|
|
285
|
+
interface MultiSigIdentifierCreateArguments extends BaseIdentifierCreateArguments<AccountKeyAlgorithm.MULTISIG>, MultisigConfig {
|
|
286
|
+
}
|
|
287
|
+
export type IdentifierCreateArguments = MultiSigIdentifierCreateArguments;
|
|
267
288
|
export interface BlockJSONOperationCREATE_IDENTIFIER extends BlockJSONOperation {
|
|
268
289
|
type: OperationType.CREATE_IDENTIFIER;
|
|
269
290
|
identifier: IdentifierAddress | string;
|
|
291
|
+
createArguments?: ToJSONSerializable<IdentifierCreateArguments> | IdentifierCreateArguments;
|
|
270
292
|
}
|
|
271
293
|
declare class BlockOperationCREATE_IDENTIFIER extends BlockOperation implements BlockJSONOperationCREATE_IDENTIFIER {
|
|
272
294
|
#private;
|
|
@@ -275,6 +297,8 @@ declare class BlockOperationCREATE_IDENTIFIER extends BlockOperation implements
|
|
|
275
297
|
constructor(input: BlockJSONOperationCREATE_IDENTIFIER);
|
|
276
298
|
set identifier(identifier: string | IdentifierAddress);
|
|
277
299
|
get identifier(): IdentifierAddress;
|
|
300
|
+
set createArguments(input: IdentifierCreateArguments | ToJSONSerializable<IdentifierCreateArguments> | undefined);
|
|
301
|
+
get createArguments(): IdentifierCreateArguments | undefined;
|
|
278
302
|
validate(context: BlockOperationValidateContext): void;
|
|
279
303
|
toJSON(): BlockJSONOperationCREATE_IDENTIFIER;
|
|
280
304
|
}
|
|
@@ -441,7 +465,11 @@ export declare function ExportBlockOperations(operations: BlockOperations[]): ((
|
|
|
441
465
|
value: OperationType.MODIFY_PERMISSIONS;
|
|
442
466
|
kind: "explicit";
|
|
443
467
|
}) | (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
|
|
444
|
-
contains: [Buffer
|
|
468
|
+
contains: [Buffer, (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
|
|
469
|
+
contains: [Buffer[], bigint];
|
|
470
|
+
value: 7;
|
|
471
|
+
kind: "explicit";
|
|
472
|
+
}) | undefined];
|
|
445
473
|
value: OperationType.CREATE_IDENTIFIER;
|
|
446
474
|
kind: "explicit";
|
|
447
475
|
}) | (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
|
package/lib/error/block.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeetaNetError } from '.';
|
|
2
2
|
declare const BlockErrorType: "BLOCK";
|
|
3
|
-
declare const BlockErrorCodes: readonly ["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", "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"];
|
|
3
|
+
declare const BlockErrorCodes: readonly ["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"];
|
|
4
4
|
export type BlockErrorCode = `${typeof BlockErrorType}_${typeof BlockErrorCodes[number]}`;
|
|
5
5
|
export default class KeetaNetBlockError extends KeetaNetError {
|
|
6
6
|
static isInstance: (obj: any, strict?: boolean) => obj is KeetaNetBlockError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeetaNetError } from '.';
|
|
2
2
|
declare const CertificateErrorType: "CERTIFICATE";
|
|
3
|
-
declare const BlockErrorCodes: readonly ["DUPLICATE_INCLUDED", "ORPHAN_FOUND", "CYCLE_FOUND", "SECONDARY_GRAPH"];
|
|
3
|
+
declare const BlockErrorCodes: readonly ["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"];
|
|
4
4
|
export type CertificateErrorCode = `${typeof CertificateErrorType}_${typeof BlockErrorCodes[number]}`;
|
|
5
5
|
export default class KeetaNetCertificateError extends KeetaNetError {
|
|
6
6
|
static isInstance: (obj: any, strict?: boolean) => obj is KeetaNetCertificateError;
|
package/lib/error/ledger.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeetaNetError } from '.';
|
|
2
2
|
declare const LedgerErrorType: "LEDGER";
|
|
3
|
-
declare const LedgerErrorCodes: readonly ["TRANSACTION_ABORTED", "INVALID_CHAIN", "INVALID_NETWORK", "INVALID_SUBNET", "NOT_EMPTY", "NOT_OPENING", "NOT_SUCCESSOR", "INVALID_PERMISSIONS", "INVALID_OWNER_COUNT", "INVALID_BALANCE", "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"];
|
|
3
|
+
declare const LedgerErrorCodes: readonly ["BLOCK_ALREADY_EXISTS", "TRANSACTION_ABORTED", "INVALID_CHAIN", "INVALID_NETWORK", "INVALID_SUBNET", "NOT_EMPTY", "NOT_OPENING", "NOT_SUCCESSOR", "INVALID_PERMISSIONS", "INVALID_OWNER_COUNT", "INVALID_BALANCE", "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", "FEE_AMOUNT_MISMATCH", "FEE_TOKEN_MISMATCH", "FEE_MISSING", "MISSING_REQUIRED_FEE_BLOCK", "PERM_VOTE_WITH_QUOTE", "QUOTE_MISMATCH", "REQUIRED_FEE_MISMATCH"];
|
|
4
4
|
export type LedgerErrorCode = `${typeof LedgerErrorType}_${typeof LedgerErrorCodes[number]}`;
|
|
5
5
|
export declare class KeetaNetLedgerError extends KeetaNetError {
|
|
6
6
|
static isInstance: (obj: any, strict?: boolean) => obj is KeetaNetLedgerError;
|
package/lib/error/vote.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeetaNetError } from '.';
|
|
2
2
|
declare const VoteErrorType: "VOTE";
|
|
3
|
-
declare const VoteErrorCodes: readonly ["SERIAL_MISMATCH", "INVALID_VERSION", "INVALID_CONSTRUCTION", "INVALID_CONSTRUCTION_JSON", "SIGNATURE_INVALID", "EXPIRED", "INVALID_VALIDITY", "MOMENT_BEFORE_VALIDITY_FROM", "STAPLE_INVALID_CONSTRUCTION", "STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_COUNT", "STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_MISSING", "STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_ORDER", "STAPLE_DUPLICATE_VOTE_ISSUER", "STAPLE_PERMANENCE_MISMATCH", "BUILDER_INVALID_CONSTRUCTION", "BUILDER_INVALID_BLOCK_TYPE", "BUILDER_INVALID_SERIAL", "BUILDER_INVALID_VALID_TO_FROM", "MALFORMED_WRAPPER", "MALFORMED_VOTE_WRAPPER", "MALFORMED_VOTE_CONTENT", "MALFORMED_VOTE_CONTENT_EXTRA_DATA", "MALFORMED_VOTE_VERSION", "MALFORMED_VOTE_SERIAL", "MALFORMED_VOTE_SIGNATURE_INFORMATION", "MALFORMED_VOTE_ISSUER_INFORMATION", "MALFORMED_VOTE_SUBJECT_INFORMATION", "MALFORMED_VOTE_VALIDITY_INFORMATION", "MALFORMED_VOTE_SERIAL", "MALFORMED_VOTE_EXTENSIONS", "MALFORMED_VOTE_EXTENSIONS_DATA", "MALFORMED_VOTE_EXTENSIONS_VALUE", "MALFORMED_VOTE_EXTENSIONS_VALUE_OID", "MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL", "MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL_TYPE", "MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_ISSUER", "MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_WRAPPER", "MALFORMED_VOTE_SIGNATURE_SCHEME_ECDSA_INVALID_CURVE", "MALFORMED_VOTE_SIGNATURE_UNSUPPORTED_SCHEME", "MALFORMED_VOTE_SUBJECT_PUBLIC_KEY_INFORMATION", "MALFORMED_VOTE_SIGNATURE_VALUE", "MALFORMED_VOTE_NO_BLOCKS_FOUND", "MALFORMED_STAPLE", "MALFORMED_STAPLE_BLOCKS", "MALFORMED_STAPLE_BLOCKS_AT_LEAST_ONE", "MALFORMED_STAPLE_VOTES", "MALFORMED_STAPLE_VOTES_AT_LEAST_ONE", "MALFORMED_FIND_RDN_INVALID_TYPE", "MALFORMED_FIND_RDN_MUST_HAVE_ONE", "MALFORMED_FIND_RDN_PART_WELL_FORMED", "MALFORMED_FIND_RDN_MUST_BE_SET", "MALFORMED_FIND_RDN_TYPE_MUST_BE_OID", "MALFORMED_HASHES_FROM_VOTE_INVALID_INPUT", "MALFORMED_HASHES_FROM_VOTE_INVALID_TYPE", "MALFORMED_HASHES_FROM_VOTE_INVALID_CONTEXT_SPECIFIC", "MALFORMED_HASHES_FROM_VOTE_DATA_NEEDS_OID", "MALFORMED_HASHES_FROM_VOTE_DATA_HASH_DATA_MUST_BE_SEQUENCE", "MALFORMED_HASHES_FROM_VOTE_DATA_NOT_TWO_ITEMS", "MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_FUNC", "MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_TYPE", "MALFORMED_HASHES_FROM_VOTE_DATA_SECOND_MUST_BE_SEQUENCE", "MALFORMED_FEES_AMOUNT", "MALFORMED_FEES_FROM_VOTE_INVALID_INPUT", "MALFORMED_FEES_IN_PERMANENT_VOTE", "MALFORMED_FEES_PAY_TO_INVALID", "MALFORMED_FEES_TOKEN_NOT_TOKEN"];
|
|
3
|
+
declare const VoteErrorCodes: readonly ["SERIAL_MISMATCH", "INVALID_VERSION", "INVALID_CONSTRUCTION", "INVALID_CONSTRUCTION_JSON", "SIGNATURE_INVALID", "EXPIRED", "INVALID_VALIDITY", "MOMENT_BEFORE_VALIDITY_FROM", "STAPLE_INVALID_CONSTRUCTION", "STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_COUNT", "STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_MISSING", "STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_ORDER", "STAPLE_DUPLICATE_VOTE_ISSUER", "STAPLE_PERMANENCE_MISMATCH", "BUILDER_INVALID_CONSTRUCTION", "BUILDER_INVALID_BLOCK_TYPE", "BUILDER_INVALID_SERIAL", "BUILDER_INVALID_VALID_TO_FROM", "MALFORMED_WRAPPER", "MALFORMED_VOTE_WRAPPER", "MALFORMED_VOTE_CONTENT", "MALFORMED_VOTE_CONTENT_EXTRA_DATA", "MALFORMED_VOTE_VERSION", "MALFORMED_VOTE_SERIAL", "MALFORMED_VOTE_SIGNATURE_INFORMATION", "MALFORMED_VOTE_ISSUER_INFORMATION", "MALFORMED_VOTE_SUBJECT_INFORMATION", "MALFORMED_VOTE_VALIDITY_INFORMATION", "MALFORMED_VOTE_SERIAL", "MALFORMED_VOTE_EXTENSIONS", "MALFORMED_VOTE_EXTENSIONS_DATA", "MALFORMED_VOTE_EXTENSIONS_VALUE", "MALFORMED_VOTE_EXTENSIONS_VALUE_OID", "MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL", "MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL_TYPE", "MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_ISSUER", "MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_WRAPPER", "MALFORMED_VOTE_SIGNATURE_SCHEME_ECDSA_INVALID_CURVE", "MALFORMED_VOTE_SIGNATURE_UNSUPPORTED_SCHEME", "MALFORMED_VOTE_SUBJECT_PUBLIC_KEY_INFORMATION", "MALFORMED_VOTE_SIGNATURE_VALUE", "MALFORMED_VOTE_NO_BLOCKS_FOUND", "MALFORMED_STAPLE", "MALFORMED_STAPLE_BLOCKS", "MALFORMED_STAPLE_BLOCKS_AT_LEAST_ONE", "MALFORMED_STAPLE_VOTES", "MALFORMED_STAPLE_VOTES_AT_LEAST_ONE", "MALFORMED_FIND_RDN_INVALID_TYPE", "MALFORMED_FIND_RDN_MUST_HAVE_ONE", "MALFORMED_FIND_RDN_PART_WELL_FORMED", "MALFORMED_FIND_RDN_MUST_BE_SET", "MALFORMED_FIND_RDN_TYPE_MUST_BE_OID", "MALFORMED_HASHES_FROM_VOTE_INVALID_INPUT", "MALFORMED_HASHES_FROM_VOTE_INVALID_TYPE", "MALFORMED_HASHES_FROM_VOTE_INVALID_CONTEXT_SPECIFIC", "MALFORMED_HASHES_FROM_VOTE_DATA_NEEDS_OID", "MALFORMED_HASHES_FROM_VOTE_DATA_HASH_DATA_MUST_BE_SEQUENCE", "MALFORMED_HASHES_FROM_VOTE_DATA_NOT_TWO_ITEMS", "MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_FUNC", "MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_TYPE", "MALFORMED_HASHES_FROM_VOTE_DATA_SECOND_MUST_BE_SEQUENCE", "MALFORMED_FEES_AMOUNT", "MALFORMED_FEES_FROM_VOTE_INVALID_INPUT", "MALFORMED_FEES_IN_PERMANENT_VOTE", "MALFORMED_FEES_PAY_TO_INVALID", "MALFORMED_FEES_TOKEN_NOT_TOKEN", "FEE_IS_QUOTE", "FEE_QUOTE_MISSING_FEES", "FEE_NOT_QUOTE", "MALFORMED_FEES_KIND_MISSING", "MALFORMED_FEES_QUOTE_INVALID"];
|
|
4
4
|
export type VoteErrorCode = `${typeof VoteErrorType}_${typeof VoteErrorCodes[number]}`;
|
|
5
5
|
export default class KeetaNetVoteError extends KeetaNetError {
|
|
6
6
|
static isInstance: (obj: any, strict?: boolean) => obj is KeetaNetVoteError;
|
package/lib/ledger/common.d.ts
CHANGED
|
@@ -57,6 +57,8 @@ interface ComputeLedgerEffectOptions<T extends boolean, P extends boolean, W ext
|
|
|
57
57
|
baseToken: TokenAddress;
|
|
58
58
|
}
|
|
59
59
|
export declare function validateSupply(amount: bigint, network: bigint): void;
|
|
60
|
+
export declare function validateBlockSignerCount(amount: bigint, network: bigint): void;
|
|
61
|
+
export declare function validateBlockSignerDepth(depth: bigint, network: bigint): void;
|
|
60
62
|
/**
|
|
61
63
|
* Compute effects on the ledger from block effects
|
|
62
64
|
*/
|
|
@@ -87,6 +89,7 @@ type AccountInfoUnparsedRow = {
|
|
|
87
89
|
description?: string;
|
|
88
90
|
metadata?: string;
|
|
89
91
|
supply?: bigint | string;
|
|
92
|
+
multisigQuorum?: bigint | string;
|
|
90
93
|
defaultBasePermission?: string | bigint | BaseSet;
|
|
91
94
|
defaultExternalPermission?: string | bigint | ExternalSet;
|
|
92
95
|
};
|
|
@@ -116,10 +119,20 @@ export declare abstract class LedgerStorageBase {
|
|
|
116
119
|
}>;
|
|
117
120
|
_formatAccountInfoFromRow(account: GenericAccount, row?: AccountInfoUnparsedRow | undefined): AccountInfo;
|
|
118
121
|
_validateAccountInfoKeys(account: GenericAccount, info: Partial<AccountInfo>): void;
|
|
122
|
+
/**
|
|
123
|
+
* @param moment - The date to use as the base for the timestamp.
|
|
124
|
+
* @param momentBits - The number of bits to use for the timestamp
|
|
125
|
+
* @param totalLength - The total length of the generated number in bits
|
|
126
|
+
* @param randomData - A hexadecimal string to use as the random data.
|
|
127
|
+
* @param timestampFuzzMS - The number of milliseconds to fuzz the timestamp by, defaults to 1n (precise).
|
|
128
|
+
* @param optimistic - If true, the timestamp will be incremented by 1 quanta, defaults to false.
|
|
129
|
+
* @returns A bigint representing the noisy timestamp.
|
|
130
|
+
*/
|
|
131
|
+
_generateNoisyTimestamp(moment: Date, momentBits: bigint, totalLength: bigint, randomData: Buffer, timestampFuzzMS?: number | bigint, optimistic?: boolean): bigint;
|
|
119
132
|
getHeadBlock(transaction: any, account: GenericAccount, from: LedgerSelector): Promise<Block | null>;
|
|
120
133
|
getVotesFromPrevious(transaction: any, prevBlock: BlockHash, from: LedgerSelector, issuer?: Account): Promise<Vote[] | null>;
|
|
121
134
|
protected abstract gcBatch(transaction: any): Promise<boolean>;
|
|
122
|
-
gc(transaction: any): Promise<boolean>;
|
|
135
|
+
gc(transaction: any, timeLimitMS?: number): Promise<boolean>;
|
|
123
136
|
}
|
|
124
137
|
export declare function assertLedgerStorage(value: string): LedgerStorage;
|
|
125
138
|
export {};
|
|
@@ -3,11 +3,11 @@ import { Block, BlockHash } from '../block';
|
|
|
3
3
|
import type { VoteBlockHash, VoteBlockHashMap } from '../vote';
|
|
4
4
|
import type { GenericAccount, IdentifierAddress, TokenAddress } from '../account';
|
|
5
5
|
import Account from '../account';
|
|
6
|
-
import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions,
|
|
6
|
+
import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions, LedgerStorageTransactionBaseOptions } from '../ledger';
|
|
7
|
+
import { LedgerStorageTransactionBase } from '../ledger';
|
|
7
8
|
import type { AccountInfo, ACLRow, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates } from './types';
|
|
8
9
|
import { LedgerStorageBase } from './common';
|
|
9
10
|
import type { ComputedEffectOfBlocks } from './effects';
|
|
10
|
-
import type Node from '../node';
|
|
11
11
|
import type { CertificateHash } from '../utils/certificate';
|
|
12
12
|
declare const dynamoDBTableNames: readonly ["votes", "voteUIDs", "permissions", "accountInfo", "accountOwners", "accountCertificates", "blocks", "balances", "weight", "heapBlocks", "heapStorage", "chain", "delegation", "serial", "kv"];
|
|
13
13
|
declare const optionalDynamoDbTables: readonly ["kv"];
|
|
@@ -22,13 +22,9 @@ export interface DynamoDBConfig {
|
|
|
22
22
|
transactionSize?: number;
|
|
23
23
|
batchUpdateSize?: number;
|
|
24
24
|
}
|
|
25
|
-
declare class DynamoDBTransaction
|
|
25
|
+
declare class DynamoDBTransaction extends LedgerStorageTransactionBase {
|
|
26
26
|
#private;
|
|
27
|
-
|
|
28
|
-
readonly moment: Date;
|
|
29
|
-
readonly identifier: string;
|
|
30
|
-
readonly readOnly: boolean;
|
|
31
|
-
constructor(config: DynamoDBConfig, ledger: Ledger, log: LedgerConfig['log'], dbDynamoDB: DBDynamoDB, transactionBase: LedgerStorageTransactionBase);
|
|
27
|
+
constructor(config: DynamoDBConfig, ledger: Ledger, log: LedgerConfig['log'], dbDynamoDB: DBDynamoDB, transactionBase: LedgerStorageTransactionBaseOptions);
|
|
32
28
|
commit(): Promise<void>;
|
|
33
29
|
abort(): Promise<void>;
|
|
34
30
|
delegatedWeight(rep?: Account | InstanceType<typeof Account.Set>): Promise<bigint>;
|
|
@@ -41,7 +37,7 @@ declare class DynamoDBTransaction implements LedgerStorageTransactionBase {
|
|
|
41
37
|
getBlockHeight(blockHash: BlockHash, account: GenericAccount): Promise<bigint | null>;
|
|
42
38
|
getVotes(block: BlockHash, from: LedgerSelector, issuer?: Account, transactionAlreadyVerifiedActiveByCaller?: boolean): Promise<Vote[] | null>;
|
|
43
39
|
getVoteStaple(stapleBlockHashes: VoteBlockHash[], from?: LedgerSelector): Promise<VoteBlockHashMap<VoteStaple | null>>;
|
|
44
|
-
getHistory(account: GenericAccount, start: VoteBlockHash | null, limit: number): Promise<VoteBlockHash[]>;
|
|
40
|
+
getHistory(account: GenericAccount | null, start: VoteBlockHash | null, limit: number): Promise<VoteBlockHash[]>;
|
|
45
41
|
getVotesFromMultiplePrevious(prevBlocks: BlockHash[], from: LedgerSelector, issuer?: Account): Promise<{
|
|
46
42
|
[hash: string]: Vote[] | null;
|
|
47
43
|
}>;
|
|
@@ -72,7 +68,7 @@ export declare class DBDynamoDB extends LedgerStorageBase implements LedgerStora
|
|
|
72
68
|
createTables: (config: DynamoDBConfig) => Promise<void>;
|
|
73
69
|
};
|
|
74
70
|
init(config: LedgerConfig, ledger: Ledger): void;
|
|
75
|
-
beginTransaction(transactionBase:
|
|
71
|
+
beginTransaction(transactionBase: LedgerStorageTransactionBaseOptions): Promise<DynamoDBTransaction>;
|
|
76
72
|
commitTransaction(transaction: DynamoDBTransaction): Promise<void>;
|
|
77
73
|
abortTransaction(transaction: DynamoDBTransaction): Promise<void>;
|
|
78
74
|
evaluateError(error: any): Promise<any>;
|
|
@@ -86,7 +82,7 @@ export declare class DBDynamoDB extends LedgerStorageBase implements LedgerStora
|
|
|
86
82
|
getBlockHeight(transaction: DynamoDBTransaction, blockHash: BlockHash, account: GenericAccount): Promise<bigint | null>;
|
|
87
83
|
getVotes(transaction: DynamoDBTransaction, block: BlockHash, from: LedgerSelector): Promise<Vote[] | null>;
|
|
88
84
|
getVoteStaples(transaction: DynamoDBTransaction, stapleBlockHashes: VoteBlockHash[], from?: LedgerSelector): Promise<VoteBlockHashMap<VoteStaple | null>>;
|
|
89
|
-
getHistory(transaction: DynamoDBTransaction, account: GenericAccount, start: VoteBlockHash | null, limit?: number): Promise<VoteBlockHash[]>;
|
|
85
|
+
getHistory(transaction: DynamoDBTransaction, account: GenericAccount | null, start: VoteBlockHash | null, limit?: number): Promise<VoteBlockHash[]>;
|
|
90
86
|
getVotesFromMultiplePrevious(transaction: DynamoDBTransaction, prevBlocks: BlockHash[], from: LedgerSelector, issuer?: Account): Promise<{
|
|
91
87
|
[hash: string]: Vote[] | null;
|
|
92
88
|
}>;
|
|
@@ -3,7 +3,8 @@ import { Block, BlockHash } from '../block';
|
|
|
3
3
|
import type { VoteBlockHash, VoteBlockHashMap } from '../vote';
|
|
4
4
|
import type { GenericAccount, IdentifierAddress, TokenAddress } from '../account';
|
|
5
5
|
import Account, { AccountKeyAlgorithm } from '../account';
|
|
6
|
-
import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions,
|
|
6
|
+
import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions, LedgerStorageTransactionBaseOptions } from '../ledger';
|
|
7
|
+
import { LedgerStorageTransactionBase } from '../ledger';
|
|
7
8
|
import type { AccountInfo, ACLRow, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates } from './types';
|
|
8
9
|
import { LedgerStorageBase } from './common';
|
|
9
10
|
import type { PoolClient as PostgresPoolClient } from 'pg';
|
|
@@ -11,9 +12,10 @@ import { Pool as PostgresPool } from 'pg';
|
|
|
11
12
|
import type { ComputedEffectOfBlocks } from './effects';
|
|
12
13
|
import LedgerRequestCache from './cache';
|
|
13
14
|
import type { CertificateHash } from '../utils/certificate';
|
|
14
|
-
|
|
15
|
+
declare class PostgresTransaction extends LedgerStorageTransactionBase {
|
|
15
16
|
client: PostgresPoolClient;
|
|
16
17
|
cache: LedgerRequestCache;
|
|
18
|
+
constructor(transactionBase: LedgerStorageTransactionBaseOptions, db: PostgresPoolClient);
|
|
17
19
|
}
|
|
18
20
|
interface PostgresSelectOptions {
|
|
19
21
|
forUpdate?: boolean;
|
|
@@ -24,7 +26,7 @@ export declare class DBPostgres extends LedgerStorageBase implements LedgerStora
|
|
|
24
26
|
constructor();
|
|
25
27
|
init(config: LedgerConfig, ledger: Ledger): void;
|
|
26
28
|
destroy(): Promise<void>;
|
|
27
|
-
beginTransaction(transactionBase:
|
|
29
|
+
beginTransaction(transactionBase: LedgerStorageTransactionBaseOptions): Promise<PostgresTransaction>;
|
|
28
30
|
commitTransaction(transaction: PostgresTransaction): Promise<void>;
|
|
29
31
|
abortTransaction(transaction: PostgresTransaction): Promise<void>;
|
|
30
32
|
cache(transaction: PostgresTransaction): LedgerRequestCache;
|
|
@@ -45,9 +47,15 @@ export declare class DBPostgres extends LedgerStorageBase implements LedgerStora
|
|
|
45
47
|
adjust(transaction: PostgresTransaction, input: VoteStaple, changes: ComputedEffectOfBlocks, mayDefer?: boolean, completedStaples?: Set<string>): Promise<VoteStaple[]>;
|
|
46
48
|
getBlock(transaction: PostgresTransaction, block: BlockHash, from: LedgerSelector): Promise<Block | null>;
|
|
47
49
|
getBlockHeight(transaction: PostgresTransaction, blockHash: BlockHash, account: GenericAccount): Promise<bigint | null>;
|
|
50
|
+
getBlockHeights(transaction: PostgresTransaction, toFetch: {
|
|
51
|
+
blockHash: BlockHash;
|
|
52
|
+
account: GenericAccount;
|
|
53
|
+
}[]): Promise<{
|
|
54
|
+
[blockHash: string]: bigint | null;
|
|
55
|
+
}>;
|
|
48
56
|
getVotes(transaction: PostgresTransaction, block: BlockHash, from: LedgerSelector, issuer?: GenericAccount): Promise<Vote[] | null>;
|
|
49
57
|
getVoteStaples(transaction: PostgresTransaction, stapleBlockHashes: VoteBlockHash[], from?: LedgerSelector): Promise<VoteBlockHashMap<VoteStaple | null>>;
|
|
50
|
-
getHistory(transaction: PostgresTransaction, account: GenericAccount, start: VoteBlockHash | null, limit?: number): Promise<VoteBlockHash[]>;
|
|
58
|
+
getHistory(transaction: PostgresTransaction, account: GenericAccount | null, start: VoteBlockHash | null, limit?: number): Promise<VoteBlockHash[]>;
|
|
51
59
|
getBlockFromPrevious(transaction: PostgresTransaction, prevBlock: BlockHash, from: LedgerSelector): Promise<Block | null>;
|
|
52
60
|
getVotesFromMultiplePrevious(transaction: PostgresTransaction, prevBlocks: BlockHash[], from: LedgerSelector, issuer?: Account): Promise<{
|
|
53
61
|
[hash: string]: Vote[] | null;
|
|
@@ -4,15 +4,14 @@ import { BlockHash } from '../block';
|
|
|
4
4
|
import type { VoteBlockHash, VoteBlockHashMap } from '../vote';
|
|
5
5
|
import type { GenericAccount, IdentifierAddress, TokenAddress } from '../account';
|
|
6
6
|
import Account from '../account';
|
|
7
|
-
import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions,
|
|
7
|
+
import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions, LedgerStorageTransactionBaseOptions } from '../ledger';
|
|
8
|
+
import { LedgerStorageTransactionBase } from '../ledger';
|
|
8
9
|
import type { AccountInfo, ACLRow, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates } from './types';
|
|
9
10
|
import type { KVStorageProviderAPI } from '../kv';
|
|
10
11
|
import { LedgerStorageBase } from './common';
|
|
11
|
-
import Stats from '../stats';
|
|
12
12
|
import type { Database as GoogleSpannerDatabase } from '@google-cloud/spanner';
|
|
13
13
|
import type { TableColumn, FilteredResponseRow, IndexName, TableName, QueryRow as HelperQueryRow, QueryRows } from './db_spanner_helper';
|
|
14
14
|
import type { ComputedEffectOfBlocks } from './effects';
|
|
15
|
-
import type Node from '../node';
|
|
16
15
|
import type { CertificateHash } from '../utils/certificate';
|
|
17
16
|
type QueryRow<T extends TableName> = HelperQueryRow<T> | QueryRows<T>;
|
|
18
17
|
type ReadOptions = {
|
|
@@ -33,15 +32,10 @@ type SpannerReadResponse<T extends TableName, C extends TableColumn<T>[]> = {
|
|
|
33
32
|
interface SpannerTransactionOptions {
|
|
34
33
|
strongRead?: boolean;
|
|
35
34
|
}
|
|
36
|
-
export declare class SpannerTransaction
|
|
35
|
+
export declare class SpannerTransaction extends LedgerStorageTransactionBase {
|
|
37
36
|
#private;
|
|
38
|
-
readonly node: Node | undefined;
|
|
39
|
-
readonly moment: Date;
|
|
40
|
-
readonly identifier: string;
|
|
41
|
-
readonly readOnly: boolean;
|
|
42
37
|
readonly options: SpannerTransactionOptions;
|
|
43
|
-
|
|
44
|
-
constructor(database: GoogleSpannerDatabase, options: SpannerTransactionOptions, transactionBase: LedgerStorageTransactionBase);
|
|
38
|
+
constructor(database: GoogleSpannerDatabase, options: SpannerTransactionOptions, transactionBase: LedgerStorageTransactionBaseOptions);
|
|
45
39
|
evaluateError(error: any): any;
|
|
46
40
|
beginTransaction(identifier: string, strongRead?: boolean): Promise<void>;
|
|
47
41
|
endTransaction(mode: 'COMMIT' | 'ROLLBACK'): Promise<void>;
|
|
@@ -49,7 +43,6 @@ export declare class SpannerTransaction implements LedgerStorageTransactionBase
|
|
|
49
43
|
upsert<T extends TableName, R extends QueryRow<T>>(table: T, query: R): void;
|
|
50
44
|
delete<T extends TableName, R extends QueryRow<T>>(table: T, query: R): void;
|
|
51
45
|
read<T extends TableName, I extends IndexName | undefined, C extends TableColumn<T>[], X extends ReadRequest<T>>(table: T, index: I, columns: C, request: X): Promise<SpannerReadResponse<T, C>>;
|
|
52
|
-
addStatsChange(...changes: Parameters<Stats['incr']>[]): void;
|
|
53
46
|
}
|
|
54
47
|
/**
|
|
55
48
|
* Ledger Configuration for Google Spanner
|
|
@@ -69,7 +62,7 @@ export declare class DBSpanner extends LedgerStorageBase implements LedgerStorag
|
|
|
69
62
|
constructor();
|
|
70
63
|
init(config: LedgerConfig, ledger: Ledger): void;
|
|
71
64
|
destroy(): Promise<void>;
|
|
72
|
-
beginTransaction(transactionBase:
|
|
65
|
+
beginTransaction(transactionBase: LedgerStorageTransactionBaseOptions): Promise<SpannerTransaction>;
|
|
73
66
|
commitTransaction(transaction: SpannerTransaction): Promise<void>;
|
|
74
67
|
abortTransaction(transaction: SpannerTransaction): Promise<void>;
|
|
75
68
|
evaluateError(error: any): Promise<any>;
|
|
@@ -93,7 +86,7 @@ export declare class DBSpanner extends LedgerStorageBase implements LedgerStorag
|
|
|
93
86
|
getBlockHeight(transaction: SpannerTransaction, blockHash: BlockHash, account: GenericAccount): Promise<bigint | null>;
|
|
94
87
|
getVotes(transaction: SpannerTransaction, blockHash: BlockHash, from: LedgerSelector): Promise<Vote[] | null>;
|
|
95
88
|
getVoteStaples(transaction: SpannerTransaction, stapleBlockHashes: VoteBlockHash[], from?: LedgerSelector): Promise<VoteBlockHashMap<VoteStaple | null>>;
|
|
96
|
-
getHistory(transaction: SpannerTransaction, account: GenericAccount, start: VoteBlockHash | null, limit?: number): Promise<VoteBlockHash[]>;
|
|
89
|
+
getHistory(transaction: SpannerTransaction, account: GenericAccount | null, start: VoteBlockHash | null, limit?: number): Promise<VoteBlockHash[]>;
|
|
97
90
|
getBlockFromPrevious(transaction: SpannerTransaction, prevBlock: BlockHash, from: LedgerSelector): Promise<Block | null>;
|
|
98
91
|
getVotesFromMultiplePrevious(transaction: SpannerTransaction, prevBlocks: BlockHash[], from: LedgerSelector, issuer?: Account): Promise<{
|
|
99
92
|
[hash: string]: Vote[] | null;
|