Created
April 28, 2020 01:25
-
-
Save andrewgordstewart/e973ea444fb1e26145869ec6fe567eb7 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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