import { providers } from "ethers" ; import EventEmitter from "eventemitter3" ; import { INodeApiClient } from "./api" ; import { Address , DecString , PublicIdentifier , PublicKey , UrlString } from "./basic" ; import { IChannelSigner } from "./crypto" ; import { EventName } from "./events" ; import { ILoggerService } from "./logger" ; import { MethodNames } from "./methods" ; import { JsonRpcRequest } from "./rpc" ; import { WithdrawalMonitorObject , IStoreService } from "./store" ; import { StateChannelJSON } from "./state" ; import { enumify } from "./utils" ; import { MinimalTransaction , SetStateCommitmentJSON , ConditionalTransactionCommitmentJSON , } from "./commitments" ; import { MiddlewareMap } from "./middleware" ; export const ChannelMethods = enumify ( { ... MethodNames , chan_isSigner : "chan_isSigner" , chan_config : "chan_config" , chan_enable : "chan_enable" , chan_signMessage : "chan_signMessage" , chan_encrypt : "chan_encrypt" , chan_decrypt : "chan_decrypt" , chan_restoreState : "chan_restoreState" , chan_getUserWithdrawal : "chan_getUserWithdrawal" , chan_setUserWithdrawal : "chan_setUserWithdrawal" , chan_setStateChannel : "chan_setStateChannel" , chan_walletDeposit : "chan_walletDeposit" , chan_getSchemaVersion : "chan_getSchemaVersion" , chan_updateSchemaVersion : "chan_updateSchemaVersion" , } ) ; export type ChannelMethods = typeof ChannelMethods [ keyof typeof ChannelMethods ] ; export type ChannelProviderConfig = { signerAddress : Address ; multisigAddress ? : Address ; nodeUrl : UrlString ; userIdentifier : PublicIdentifier ; } ; export interface CFChannelProviderOptions { ethProvider : providers . JsonRpcProvider ; signer : IChannelSigner ; node : INodeApiClient ; store : IStoreService ; middlewareMap ? : MiddlewareMap ; logger ? : ILoggerService ; skipSync ? : boolean ; } export type WalletDepositParams = { amount : DecString ; assetId : Address ; } ; export class ConnextEventEmitter extends EventEmitter < string | ChannelMethods | EventName > { } export interface IRpcConnection extends ConnextEventEmitter { connected : boolean ; send ( payload ) : Promise < any > ; open ( ) : Promise < void > ; close ( ) : Promise < void > ; } export interface IChannelProvider extends ConnextEventEmitter { connected : boolean ; connection : IRpcConnection ; enable ( ) : Promise < ChannelProviderConfig > ; send ( method , params ) : Promise < any > ; close ( ) : Promise < void > ; config : ChannelProviderConfig | undefined ; multisigAddress : Address | undefined ; signerAddress : Address | undefined ; on ( event , listener ) : any ; once ( event , listener ) : any ; removeAllListeners ( ) : any ; isSigner ( ) : Promise < boolean > ; signMessage ( message ) : Promise < string > ; encrypt ( message , publicKey ) : Promise < string > ; decrypt ( encryptedPreImage ) : Promise < string > ; walletDeposit ( params ) : Promise < string > ; getUserWithdrawals ( ) : Promise < WithdrawalMonitorObject [ ] > ; setUserWithdrawal ( withdrawal , remove ? ) : Promise < void > ; restoreState ( state ? ) : Promise < void > ; setStateChannel ( channel , setupCommitment , setStateCommitments , conditionalCommitments ) : Promise < void > ; getSchemaVersion ( ) : Promise < number > ; updateSchemaVersion ( version ? ) : Promise < void > ; }