import { storiesOf } from '@storybook/react' ; import { interpret } from 'xstate' ; import { Participant } from '@statechannels/client-api-schema' ; import { simpleEthAllocation , BN } from '@statechannels/wallet-core' ; import React from 'react' ; import { workflow , config , WorkflowContext } from '../../workflows/confirm' ; import { logger } from '../../logger' ; import { Store } from '../../store' ; import { ConfirmCreateChannel } from '../workflows/confirm-create-channel-workflow' ; import { renderComponentInFrontOfApp } from './helpers' ; const store = new Store ( ) ; store . initialize ( [ '0x8624ebe7364bb776f891ca339f0aaa820cc64cc9fca6a28eec71e6d8fc950f29' ] ) ; const alice = { participantId : 'a' , signingAddress : '0xa' , destination : '0xad' } ; const bob = { participantId : 'b' , signingAddress : '0xb' , destination : '0xbd' } ; const testContext = { participants : [ alice , bob ] , outcome : simpleEthAllocation ( [ ] ) , appDefinition : '0x00' , appData : '0x00' , chainId : '0' , challengeDuration : BN . from ( 1 ) } ; if ( config . states ) { Object . keys ( config . states ) . forEach ( state => { const machine = interpret < any , any , any > ( workflow ( testContext ) . withContext ( testContext ) , { devTools : true } ) ; machine . onEvent ( event => logger . info ( event . type ) ) . start ( state ) ; storiesOf ( 'Workflows / Confirm Create Channel' , module ) . add ( state . toString ( ) , renderComponentInFrontOfApp ( < ConfirmCreateChannel service = { machine } / > ) ) ; machine . stop ( ) ; } ) ; }