import { Transaction, TransactionOrKnex } from 'objection'; import { Outcome, SignedStateWithHash, StateVariables, ChannelConstants, Participant, SignedState, Address, PrivateKey } from '@statechannels/wallet-core'; import { Payload as WirePayload, SignedState as WireSignedState } from '@statechannels/wire-format'; import { ChannelResult, FundingStrategy } from '@statechannels/client-api-schema'; import { ethers } from 'ethers'; import Knex from 'knex'; import { Logger } from 'pino'; import { Channel } from '../models/channel'; import { ChannelState } from '../protocols/state'; import { Bytes32, Uint256, Bytes } from '../type-aliases'; import { Funding, TransferredOutEntry } from '../models/funding'; import { WalletObjective } from '../models/objective'; import { LedgerRequest } from '../models/ledger-request'; export declare type AppHandler = (tx: Transaction, channelRecord: Channel) => T; export declare type MissingAppHandler = (channelId: string) => T; export declare class Store { readonly knex: Knex; readonly timingMetrics: boolean; readonly skipEvmValidation: boolean; readonly chainNetworkID: string; readonly logger: Logger; constructor(knex: Knex, timingMetrics: boolean, skipEvmValidation: boolean, chainNetworkID: string, logger?: Logger); addSigningKey(privateKey: PrivateKey): Promise; getOrCreateSigningAddress(wallet?: ethers.Wallet): Promise
; /** * Ensure a channel is only update-able by some criticable code within a transaction. * * @param channelId application channel Id * @param criticalCode critical code to be executed while holding a lock on channelId * @param onChannelMissing An optional handler that is called when the channel cannot be found. Defaults to throwMissingChannel * @param fetchSigningWallet Whether the signing wallets for a channel should be fetched when querying for the channel. Defaults to false * * This excutes `criticalCode` within the context of a SQL transaction, after first acquiring a row-level * lock on a single row in the Channels table. This guarantees that at most one `criticalCode` can be * executing concurrently across all wallets. */ lockApp(channelId: Bytes32, criticalCode: AppHandler, onChannelMissing?: MissingAppHandler, fetchSigningWallet?: boolean): Promise; transaction(callback: (tx: Transaction) => Promise): Promise; signState(channel: Channel, vars: StateVariables, tx: Transaction): Promise; addMyState(channel: Channel, signedState: SignedStateWithHash, tx: Transaction): Promise; getChannelState(channelId: Bytes32, tx?: Transaction): Promise; getChannel(channelId: Bytes32, tx?: Transaction): Promise; getAndLockChannel(channelId: Bytes32, tx: Transaction): Promise; getStates(channelId: Bytes32, tx?: Transaction): Promise<{ states: SignedStateWithHash[]; channelState: ChannelState; }>; getObjectivesByIds(objectiveIds: string[]): Promise; getChannels(): Promise; /** * Returns all channels that are not finalized on chain */ getNonFinalizedChannels(): Promise; getLedgerChannels(participants: Participant[]): Promise; pushMessage(message: WirePayload): Promise<{ channelIds: Bytes32[]; channelResults: ChannelResult[]; storedObjectives: WalletObjective[]; }>; getObjectives(channelIds: Bytes32[], tx?: Transaction): Promise; getApprovedObjectiveIds(channelIds: Bytes32[], tx?: Transaction): Promise; getApprovedObjectives(): Promise>; updateObjectiveProgressDate(objectiveIds: string[]): Promise; getLedgersWithNewRequestsIds(tx?: Transaction): Promise; approveObjective(objectiveId: string, tx?: Transaction): Promise; markObjectiveStatus(objective: O, status: 'succeeded' | 'failed', tx?: Transaction): Promise; private bytecodeCache; getBytecode(appDefinition: Address, tx: Transaction): Promise; upsertBytecode(chainNetworkId: string, appDefinition: Address, bytecode: Bytes): Promise; getObjective(objectiveId: string, tx?: TransactionOrKnex): Promise; /** * Gets and locks the objective with the supplied id * @param objectiveId * @param tx */ getAndLockObjective(objectiveId: string, tx: Transaction): Promise; isLedger(channelId: Bytes32, tx?: Transaction): Promise; getLedgerRequest(channelId: Bytes32, type: 'fund' | 'defund', tx?: Transaction): Promise; getChannelIdsPendingLedgerFundingFrom(ledgerChannelIds: Bytes32[], tx?: Transaction): Promise; getLedgerChannelIdsFundingChannels(channelToBeFunded: Bytes32[], tx?: Transaction): Promise; filterChannelIdsByIsLedger(maybeLedgerChannelIds: Bytes32[], tx?: Transaction): Promise; getActiveLedgerRequests(ledgerChannelId: Bytes32, tx?: Transaction): Promise; markLedgerRequests(channelIds: Bytes32[], type: 'fund' | 'defund', status: 'succeeded' | 'failed' | 'pending', tx?: TransactionOrKnex): Promise; /** * Add a new state into the database. * * @param channelId - the channel ID the state refers to * @param state - the new signed state to be added * @param tx - an existing database transaction context * * This function serves as both a data validator (ensure the state is valid) and * an efficient operator on the database. */ addSignedState(channelId: string, wireState: WireSignedState, tx: Transaction): Promise; createChannel(constants: ChannelConstants, appData: Bytes, outcome: Outcome, fundingStrategy: FundingStrategy, role?: 'app' | 'ledger', fundingLedgerChannelId?: Bytes32): Promise<{ channel: ChannelState; firstSignedState: SignedState; objective: WalletObjective; }>; setInitialSupport(channelId: string, support: SignedState[], tx?: Transaction): Promise; updateFunding(channelId: string, fromAmount: Uint256, asset: Address): Promise; insertAdjudicatorStatus(channelId: string, finalizedAt: number, states: SignedState[]): Promise; markAdjudicatorStatusAsFinalized(channelId: string, blockNumber: number, blockTimestamp: number, finalizedAt: number): Promise; updateTransferredOut(channelId: string, asset: Address, transferredOut: TransferredOutEntry[], newHoldings: string): Promise; nextNonce(signingAddresses: Address[]): Promise; fundingRequestExists(channelId: string, tx: Transaction): Promise; getFunding(channelId: string, asset: Address, tx: Transaction): Promise; } //# sourceMappingURL=store.d.ts.map