Skip to content

Instantly share code, notes, and snippets.

@andrewgordstewart
Created April 28, 2020 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewgordstewart/e973ea444fb1e26145869ec6fe567eb7 to your computer and use it in GitHub Desktop.
Save andrewgordstewart/e973ea444fb1e26145869ec6fe567eb7 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const guards = {};
const customActions = {};
const config = {
key: 'create-and-fund',
initial: 'preFundSetup',
on: {'xstate.error': {target: 'failure'}},
states: {
preFundSetup: {
initial: 'getPreFundSetup',
states: {
getPreFundSetup: {
invoke: {src: 'getPreFundSetup', onDone: 'supportState', onError: undefined}
},
supportState: {
invoke: {
id: undefined,
src: 'supportState',
data: (_, {data}) => data,
onDone: 'done',
onError: undefined
},
entry: undefined
},
done: {type: 'final'}
},
onDone: [
{target: 'direct', cond: ctx => true},
{target: 'virtual', cond: ctx => true}
]
},
direct: {
initial: 'depositing',
states: {
depositing: {
initial: 'getDepositingInfo',
states: {
getDepositingInfo: {
invoke: {src: 'getDepositingInfo', onDone: 'depositing', onError: undefined}
},
depositing: {
invoke: {
id: undefined,
src: 'depositing',
data: (_, {data}) => data,
onDone: 'done',
onError: undefined
},
entry: undefined
},
done: {type: 'final'}
},
onDone: 'updateFunding'
},
updateFunding: {invoke: {src: 'setFundingToDirect', onDone: 'done'}},
done: {type: 'final'}
},
onDone: 'postFundSetup'
},
virtual: {
initial: 'reserveFunds',
entry: ['triggerObjective'],
states: {
reserveFunds: {invoke: {src: 'reserveFunds', onDone: 'virtualFunding'}},
virtualFunding: {
initial: 'getObjective',
states: {
getObjective: {
invoke: {src: 'getObjective', onDone: 'virtualFunding', onError: undefined}
},
virtualFunding: {
invoke: {
id: undefined,
src: 'virtualFunding',
data: (_, {data}) => data,
onDone: 'done',
onError: undefined
},
entry: 'assignJointChannelId'
},
done: {type: 'final'}
},
onDone: 'updateFunding'
},
updateFunding: {invoke: {src: 'setFundingToVirtual', onDone: 'done'}},
done: {type: 'final'}
},
onDone: 'postFundSetup'
},
postFundSetup: {
initial: 'getPostFundSetup',
states: {
getPostFundSetup: {
invoke: {src: 'getPostFundSetup', onDone: 'supportState', onError: undefined}
},
supportState: {
invoke: {
id: undefined,
src: 'supportState',
data: (_, {data}) => data,
onDone: 'done',
onError: undefined
},
entry: undefined
},
done: {type: 'final'}
},
onDone: 'success'
},
success: {type: 'final'},
failure: {}
}
};
const machine = Machine(config, {guards, actions: customActions});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment