import { VoteStaple, Vote } from '../vote'; import { Block, BlockHash } from '../block'; import type { VoteBlockHash, VoteBlockHashMap } from '../vote'; import type { GenericAccount, IdentifierAddress, TokenAddress } from '../account'; import Account, { AccountKeyAlgorithm } from '../account'; import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions, LedgerStorageTransactionBaseOptions, IdempotentKey } from '../ledger'; import { LedgerStorageTransactionBase } from '../ledger'; import type { ACLRow, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates, AccountInfoForType } from './types'; import { LedgerStorageBase } from './common'; import type { ComputedEffectOfBlocks } from './effects'; import type { CertificateHash } from '../utils/certificate'; declare const dynamoDBTableNames: readonly ["votes", "voteUIDs", "permissions", "accountInfo", "accountOwners", "accountCertificates", "blocks", "balances", "weight", "heapBlocks", "heapStorage", "chain", "delegation", "serial", "kv"]; declare const optionalDynamoDbTables: readonly ["kv"]; type TableName = typeof dynamoDBTableNames[number]; type OptionalTableName = typeof optionalDynamoDbTables[number]; type DynamoDbTables = { [K in TableName]: string; }; type DynamoDbTablesWithOptional = Omit & Partial>; export interface DynamoDBConfig { tables: DynamoDbTablesWithOptional; transactionSize?: number; batchUpdateSize?: number; } declare class DynamoDBTransaction extends LedgerStorageTransactionBase { #private; constructor(config: DynamoDBConfig, ledger: Ledger, log: LedgerConfig['log'], dbDynamoDB: DBDynamoDB, transactionBase: LedgerStorageTransactionBaseOptions); commit(): Promise; abort(): Promise; delegatedWeight(rep?: Account | InstanceType): Promise; getBalance(account: GenericAccount, token: TokenAddress): Promise; getAllBalances(account: GenericAccount): Promise; adjustDefer(input: VoteStaple): Promise; adjust(input: VoteStaple, changes: ComputedEffectOfBlocks, mayDefer?: boolean, completedStaples?: Set): Promise; addPendingVote(blocksAndVotes: VoteStaple): Promise; getBlock(block: BlockHash, from: LedgerSelector): Promise; getBlockHeight(blockHash: BlockHash, account: GenericAccount): Promise; getVotes(block: BlockHash, from: LedgerSelector, issuer?: Account, transactionAlreadyVerifiedActiveByCaller?: boolean): Promise; getVoteStaple(stapleBlockHashes: VoteBlockHash[], from?: LedgerSelector): Promise>; getHistory(account: GenericAccount | null, start: VoteBlockHash | null, limit: number): Promise; getVotesFromMultiplePrevious(prevBlocks: BlockHash[], from: LedgerSelector, issuer?: Account): Promise<{ [hash: string]: Vote[] | null; }>; getBlockHashFromPrevious(prevBlock: BlockHash, from: LedgerSelector): Promise; /** * Find a block whose "previous" is the value "prevBlock" -- that is, * blocks that succeed this block in a chain */ getBlockFromPrevious(prevBlock: BlockHash, from: LedgerSelector, transactionAlreadyVerifiedActiveByCaller?: boolean): Promise; getHeadBlocks(accounts: GenericAccount[], from: LedgerSelector): Promise<{ [publicKey: string]: Block | null; }>; getAccountRep(userAccount: GenericAccount | string): Promise; getAccountInfo(account: Account | string): Promise>; listOwners(identifier: IdentifierAddress): Promise; listACLsByEntity(entity: GenericAccount): Promise; listACLsByPrincipal(principal: ACLRow['principal'], entityList?: GenericAccount[]): Promise; getVotesAfter(moment: Date, startKey?: string, options?: GetVotesAfterOptions): Promise; getAccountCertificates(account: GenericAccount): Promise; getAccountCertificateByHash(account: GenericAccount, hash: CertificateHash): Promise; gcBatch(): Promise; } export declare class DBDynamoDB extends LedgerStorageBase implements LedgerStorageAPI { #private; ledgerConfig: LedgerConfig | null; static Testing: { deleteTables: (config: DynamoDBConfig) => Promise; createTables: (config: DynamoDBConfig) => Promise; }; init(config: LedgerConfig, ledger: Ledger): void; beginTransaction(transactionBase: LedgerStorageTransactionBaseOptions): Promise; commitTransaction(transaction: DynamoDBTransaction): Promise; abortTransaction(transaction: DynamoDBTransaction): Promise; evaluateError(error: any): Promise; delegatedWeight(transaction: DynamoDBTransaction, rep?: Account | InstanceType): Promise; getBalance(transaction: DynamoDBTransaction, account: GenericAccount, token: TokenAddress): Promise; getAllBalances(transaction: DynamoDBTransaction, account: GenericAccount): Promise; protected adjustDefer(transaction: DynamoDBTransaction, input: VoteStaple): Promise; adjust(transaction: DynamoDBTransaction, input: VoteStaple, changes: ComputedEffectOfBlocks, mayDefer?: boolean): Promise; addPendingVote(transaction: DynamoDBTransaction, blocksAndVote: VoteStaple): Promise; getBlock(transaction: DynamoDBTransaction, block: BlockHash, from: LedgerSelector): Promise; getBlockHeight(transaction: DynamoDBTransaction, blockHash: BlockHash, account: GenericAccount): Promise; getVotes(transaction: DynamoDBTransaction, block: BlockHash, from: LedgerSelector): Promise; getVoteStaples(transaction: DynamoDBTransaction, stapleBlockHashes: VoteBlockHash[], from?: LedgerSelector): Promise>; getHistory(transaction: DynamoDBTransaction, account: GenericAccount | null, start: VoteBlockHash | null, limit?: number): Promise; getVotesFromMultiplePrevious(transaction: DynamoDBTransaction, prevBlocks: BlockHash[], from: LedgerSelector, issuer?: Account): Promise<{ [hash: string]: Vote[] | null; }>; getBlockFromPrevious(transaction: DynamoDBTransaction, block: BlockHash, from: LedgerSelector): Promise; getHeadBlocks(transaction: DynamoDBTransaction, accounts: GenericAccount[], from: LedgerSelector): Promise<{ [publicKey: string]: Block | null; }>; getAccountRep(transaction: DynamoDBTransaction, account: GenericAccount | string): Promise; getAccountInfo(transaction: DynamoDBTransaction, account: Account | string): Promise>; listOwners(transaction: DynamoDBTransaction, identifier: IdentifierAddress): Promise; listACLsByPrincipal(transaction: DynamoDBTransaction, principal: ACLRow['principal'], entityList?: GenericAccount[]): Promise; listACLsByEntity(transaction: DynamoDBTransaction, entity: GenericAccount): Promise; getVotesAfter(transaction: DynamoDBTransaction, moment: Date, startKey?: string): Promise; getAccountCertificates(transaction: DynamoDBTransaction, account: GenericAccount): Promise; getAccountCertificateByHash(transaction: DynamoDBTransaction, account: GenericAccount, hash: CertificateHash): Promise; getNextSerialNumber(): Promise; gcBatch(transaction: DynamoDBTransaction): Promise; getIdempotentBlockHash(_ignored_transaction: DynamoDBTransaction, _ignored_idempotent: IdempotentKey, _ignored_from: LedgerSelector): Promise; stats(): Promise; } export default DBDynamoDB; type DynamoDBAttrTypes = 'S' | 'N' | 'B'; type DynamoDBKey = { type: DynamoDBAttrTypes; name: string; }; type DynamoDBKeys = { hashKey: DynamoDBKey; rangeKey?: DynamoDBKey; gsi?: (Omit & { name: string; })[]; lsi?: (Required> & { name: string; })[]; }; type DynamoDBSchema = { [name: string]: DynamoDBKeys; }; /** * Testing routines */ export declare const Testing: { deleteTables(config: DynamoDBConfig): Promise; getSchema(names: DynamoDBConfig["tables"]): DynamoDBSchema; createTables(config: DynamoDBConfig): Promise; };