import { BigNumber } from "ethers" ; import { Address , HexString , Bytes32 } from "../basic" ; export type AppIdentity = { channelNonce : BigNumber ; participants : Address [ ] ; multisigAddress : Address ; appDefinition : Address ; defaultTimeout : BigNumber ; } ; export type AppChallenge = { appStateHash : HexString ; versionNumber : BigNumber ; finalizesAt : BigNumber ; status : ChallengeStatus ; } ; export enum ChallengeStatus { NO_CHALLENGE = 0 , IN_DISPUTE = 1 , IN_ONCHAIN_PROGRESSION = 2 , EXPLICITLY_FINALIZED = 3 , OUTCOME_SET = 4 } export type SignedAppChallengeUpdate = { appStateHash : Bytes32 ; versionNumber : BigNumber ; timeout : BigNumber ; signatures : string [ ] ; } ; export type SignedCancelChallengeRequest = { versionNumber : BigNumber ; signatures : string [ ] ; } ; const StateProgressedEventName = "StateProgressed" ; export type StateProgressedEventPayload = { identityHash : string ; action : string ; versionNumber : BigNumber ; timeout : BigNumber ; turnTaker : Address ; signature : string ; chainId : number ; } ; const ChallengeUpdatedEventName = "ChallengeUpdated" ; export type ChallengeUpdatedEventPayload = { identityHash : Bytes32 ; status : ChallengeStatus ; appStateHash : Bytes32 ; versionNumber : BigNumber ; finalizesAt : BigNumber ; chainId : number ; } ; export const ChallengeEvents = { [ ChallengeUpdatedEventName ] : ChallengeUpdatedEventName , [ StateProgressedEventName ] : StateProgressedEventName , } as const ; export type ChallengeEvent = keyof typeof ChallengeEvents ; interface ChallengeEventsMap { [ ChallengeUpdatedEventName ] : ChallengeUpdatedEventPayload ; [ StateProgressedEventName ] : StateProgressedEventPayload ; } export type ChallengeEventData = { [ P in keyof ChallengeEventsMap ] : ChallengeEventsMap [ P ] ; } ; export type MixinSetStateParams = { appIdentity : AppIdentity ; req : SignedAppChallengeUpdate ; } ; export type MixinProgressStateParams = MixinSetStateParams & { oldAppState : string ; action : string ; } ; export type MixinCancelChallengeParams = { appIdentity : AppIdentity ; req : SignedCancelChallengeRequest ; } ; export type MixinSetAndProgressStateParams = { appIdentity : AppIdentity ; req1 : SignedAppChallengeUpdate ; req2 : SignedAppChallengeUpdate ; appState : string ; action : string ; } ; export type MixinSetOutcomeParams = { appIdentity : AppIdentity ; finalState : string ; } ;