import { ChannelConstants, Participant, SignedStateVarsWithHash, SignedStateWithHash, Address, SignedState, Uint256, AllocationItem } from '@statechannels/wallet-core'; import { JSONSchema, Model, Pojo, QueryContext, ModelOptions, TransactionOrKnex } from 'objection'; import { ChannelResult, FundingStrategy } from '@statechannels/client-api-schema'; import { Bytes32, Uint48, Destination } from '../type-aliases'; import { ChannelState } from '../protocols/state'; import { EngineError, Values } from '../errors/engine-error'; import { SigningWallet } from './signing-wallet'; import { Funding } from './funding'; import { ObjectiveModel } from './objective'; import { ChainServiceRequest } from './chain-service-request'; import { AdjudicatorStatusModel } from './adjudicator-status'; import { State } from './channel/state'; export declare const REQUIRED_COLUMNS: readonly ["chainId", "appDefinition", "channelNonce", "challengeDuration", "participants", "vars", "fundingStrategy", "isLedgerChannel"]; export declare const OPTIONAL_COLUMNS: readonly ["fundingLedgerChannelId"]; export declare const COMPUTED_COLUMNS: readonly ["channelId", "signingAddress"]; export declare const CHANNEL_COLUMNS: ("chainId" | "channelId" | "participants" | "channelNonce" | "appDefinition" | "challengeDuration" | "vars" | "signingAddress" | "fundingStrategy" | "isLedgerChannel" | "fundingLedgerChannelId")[]; export interface RequiredColumns { readonly chainId: Bytes32; readonly appDefinition: Address; readonly channelNonce: Uint48; readonly challengeDuration: Uint48; readonly participants: Participant[]; readonly vars: SignedStateVarsWithHash[]; readonly signingAddress: Address; readonly fundingStrategy: FundingStrategy; readonly isLedgerChannel: boolean; } export declare type ComputedColumns = { readonly channelId: Destination; }; declare type ChannelColumns = RequiredColumns & ComputedColumns; export declare class Channel extends Model implements ChannelColumns { readonly id: number; channelId: Destination; vars: SignedStateVarsWithHash[]; readonly chainId: Bytes32; readonly appDefinition: Address; readonly channelNonce: Uint48; readonly challengeDuration: Uint48; readonly participants: Participant[]; readonly signingAddress: Address; readonly signingWallet: SigningWallet; readonly funding: Funding[]; readonly adjudicatorStatus: AdjudicatorStatusModel; readonly chainServiceRequests: ChainServiceRequest[]; readonly fundingStrategy: FundingStrategy; readonly isLedgerChannel: boolean; readonly fundingLedgerChannelId: Bytes32; readonly initialSupport: SignedState[]; static get jsonSchema(): JSONSchema; static tableName: string; static relationMappings: { signingWallet: { relation: import("objection").RelationType; modelClass: typeof SigningWallet; join: { from: string; to: string; }; }; funding: { relation: import("objection").RelationType; modelClass: typeof Funding; join: { from: string; to: string; }; }; adjudicatorStatus: { relation: import("objection").RelationType; modelClass: typeof AdjudicatorStatusModel; join: { from: string; to: string; }; }; objectivesChannels: { relation: import("objection").RelationType; modelClass: typeof ObjectiveModel; join: { from: string; through: { from: string; to: string; }; to: string; }; }; chainServiceRequests: { relation: import("objection").RelationType; modelClass: typeof ChainServiceRequest; join: { from: string; to: string; }; }; }; static jsonAttributes: string[]; static forId(channelId: Bytes32, txOrKnex: TransactionOrKnex): Promise; static setInitialSupport(channelId: string, support: SignedState[], txOrKnex: TransactionOrKnex): Promise; static setLedger(channelId: Bytes32, txOrKnex: TransactionOrKnex): Promise; static isLedger(channelId: Bytes32, txOrKnex: TransactionOrKnex): Promise; static getLedgerChannels(participants: Participant[], txOrKnex: TransactionOrKnex): Promise; $beforeValidate(jsonSchema: JSONSchema, json: Pojo, _opt: ModelOptions): JSONSchema; $beforeInsert(ctx: QueryContext): void; get protocolState(): ChannelState; get channelResult(): ChannelResult; get myIndex(): number; get channelConstants(): ChannelConstants; get sortedStates(): Array; get myAddress(): Address; get myParticipantInfo(): Participant; get myTurn(): boolean; get isSupported(): boolean; get support(): Array; get hasConclusionProof(): boolean; get supported(): SignedStateWithHash | undefined; get isSupportedByMe(): boolean; get latestSignedByMe(): SignedStateWithHash | undefined; get latest(): SignedStateWithHash; get latestTurnNum(): number; /** * Return the unique state at a given turnNumber * * @remarks * Returns undefined if there is no state, or if there's more than one state, with turnNum * * @param turnNum - The turnNum that the state should have * @returns The unique state if there is one, undefined otherwise */ uniqueStateAt(turnNum: number): State | undefined; /** * Return the latest state that all participants have signed * * @remarks * Returns undefined if there is no such state, or if there's more than one state, with turnNum * * @returns The unique state if there is one, undefined otherwise */ get latestFullySignedState(): State | undefined; private get _supported(); get signedByMe(): SignedStateWithHash[]; private get _latestSupportedByMe(); get signedStates(): Array; get isLedger(): boolean; get isNullApp(): boolean; get isAppChannel(): boolean; get isRunning(): boolean; /** * Have we signed a prefund state (or later) */ get prefundSigned(): boolean; /** * Have we signed a postfund state (or later) */ get postfundSigned(): boolean; /** * Have all participants signed a consistent preFund state? */ get preFundComplete(): boolean; /** * Have all participants signed a consistent postFund state? */ get postFundComplete(): boolean; get isFullyDirectFunded(): boolean; get isPartlyDirectFunded(): boolean; private isDirectFunded; /** * Returns a triple of balance [targetBefore, targetAfter, targetTotal], where * - targetBefore is the balance where I should start depositing * - targetAfter should be the balance where I stop depositing * - targetTotal is the total amount that should be in the channel * * @param channel */ get fundingMilestones(): { targetBefore: Uint256; targetAfter: Uint256; targetTotal: Uint256; }; /** * WARNING: The below logic assumes * 1. Each destination occurs at most once. * 2. We only care about a single destination. * One reason to drop (2), for instance, is to support ledger top-ups with as few state updates as possible. */ allocationItemForParticipantIndex(index: number): AllocationItem | undefined; get myAmount(): Uint256; get opponentAmount(): Uint256; private mySignature; get nParticipants(): number; private get _support(); get otherParticipants(): Participant[]; get myParticipantId(): string; } export declare function isChannelError(err: any): err is ChannelError; export declare function isChannelMissingError(err: any): err is ChannelError; export declare class ChannelError extends EngineError { readonly data: any; readonly type: "ChannelError"; static readonly reasons: { readonly invalidChannelId: "Invalid channel id"; readonly incorrectHash: "Incorrect hash"; readonly channelMissing: "No channel found with id"; readonly noSupportedState: "The channel is expected to contain supported state"; readonly indexNotInChannel: "The participant index is greater than the number of participants in the channel"; readonly destinationNotInAllocations: "The destination is not in the channel allocatons"; }; constructor(reason: Values, data?: any); } export {}; //# sourceMappingURL=channel.d.ts.map