import { AppInstanceJson } from "./app"; import { Address, Bytes32 } from "./basic"; import { ConditionalTransactionCommitmentJSON, MinimalTransaction, SetStateCommitmentJSON, } from "./commitments"; import { StateChannelJSON } from "./state"; import { IWatcherStoreService } from "./watcher"; export const ConnextNodeStorePrefix = "INDRA_NODE_CF_CORE"; export const ConnextClientStorePrefix = "INDRA_CLIENT_CF_CORE"; export type StorePair = { path: string; value: any; }; export interface IBackupService { restore(): Promise; backup(pair: StorePair): Promise; } // Used to monitor node submitted withdrawals on behalf of user export type WithdrawalMonitorObject = { retry: number; tx: MinimalTransaction; withdrawalTx: string; }; export const STORE_SCHEMA_VERSION = 1; // TODO: merge IWatcherStoreService & IStoreService? // IWatcherStoreService contains all event/challenge storage methods // in addition to all the getters for the setters defined below export interface IStoreService extends IWatcherStoreService { ///// Schema version updateSchemaVersion(version?: number): Promise; ///// Client Store Methods getUserWithdrawals(): Promise; saveUserWithdrawal(withdrawalObject: WithdrawalMonitorObject): Promise; removeUserWithdrawal(toRemove: WithdrawalMonitorObject): Promise; ///// State channels createStateChannel( stateChannel: StateChannelJSON, signedSetupCommitment: MinimalTransaction, signedFreeBalanceUpdate: SetStateCommitmentJSON, ): Promise; updateNumProposedApps( multisigAddress: string, numProposedApps: number, stateChannel?: StateChannelJSON, ): Promise; ///// App proposals createAppProposal( multisigAddress: Address, appProposal: AppInstanceJson, numProposedApps: number, signedSetStateCommitment: SetStateCommitmentJSON, signedConditionalTxCommitment: ConditionalTransactionCommitmentJSON, stateChannel?: StateChannelJSON, ): Promise; removeAppProposal( multisigAddress: Address, appIdentityHash: Bytes32, stateChannel?: StateChannelJSON, ): Promise; // proposals dont need to be updated ///// App instances createAppInstance( multisigAddress: Address, appInstance: AppInstanceJson, freeBalanceAppInstance: AppInstanceJson, signedFreeBalanceUpdate: SetStateCommitmentJSON, stateChannel?: StateChannelJSON, ): Promise; updateAppInstance( multisigAddress: Address, appInstance: AppInstanceJson, signedSetStateCommitment: SetStateCommitmentJSON, stateChannel?: StateChannelJSON, ): Promise; removeAppInstance( multisigAddress: Address, appInstance: AppInstanceJson, freeBalanceAppInstance: AppInstanceJson, signedFreeBalanceUpdate: SetStateCommitmentJSON, stateChannel?: StateChannelJSON, ): Promise; ///// Resetting methods clear(): Promise; restore(): Promise; init(): Promise; close(): Promise; }