Skip to content

Instantly share code, notes, and snippets.

@andrewgordstewart
Created March 11, 2020 19:31
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/c50887fa48ab4b4cd89ed8641d918739 to your computer and use it in GitHub Desktop.
Save andrewgordstewart/c50887fa48ab4b4cd89ed8641d918739 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const config = {
key: 'virtual-defunding-as-leaf',
initial: 'checkChannels',
states: {
checkChannels: {
invoke: {src: 'checkChannelsService', onDone: 'closeTarget'},
exit: {type: 'xstate.assign', assignment: (_, {data}) => data}
},
closeTarget: {
initial: 'finalTargetState',
states: {
finalTargetState: {
invoke: {src: 'finalTargetState', onDone: 'supportState', onError: undefined}
},
supportState: {
invoke: {id: undefined, src: 'supportState', data: (_, {data}) => data, onDone: 'done'}
},
done: {type: 'final'}
},
onDone: 'defundTarget'
},
defundTarget: {
initial: 'finalJointChannelUpdate',
states: {
finalJointChannelUpdate: {
invoke: {src: 'finalJointChannelUpdate', onDone: 'supportState', onError: undefined}
},
supportState: {
invoke: {id: undefined, src: 'supportState', data: (_, {data}) => data, onDone: 'done'}
},
done: {type: 'final'}
},
onDone: 'defundGuarantor',
exit: ['deleteTargetChannel']
},
defundGuarantor: {
initial: 'defundGuarantorInLedger',
states: {
defundGuarantorInLedger: {
invoke: {src: 'defundGuarantorInLedger', onDone: 'supportState', onError: undefined}
},
supportState: {
invoke: {id: undefined, src: 'supportState', data: (_, {data}) => data, onDone: 'done'}
},
done: {type: 'final'}
},
onDone: 'success',
exit: ['deleteJointChannel', 'deleteGuarantorChannel']
},
success: {type: 'final'}
}
};
const guards = {};
const customActions = {};
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