Last active
September 28, 2020 16:57
-
-
Save PaulRBerg/4307883571cd95bee1dd992ecc567d23 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const setFundedContext = assign({ | |
alice: 50, | |
bob: 50, | |
dai: 100, | |
}); | |
const setFundedAndRewardedContext = assign({ | |
alice: 50, | |
bob: 50, | |
dai: 0, | |
eth: 1, | |
}); | |
const fetchMachine = Machine({ | |
id: 'guarantorPool', | |
initial: 'pristine', | |
context: { | |
alice: 0, | |
bob: 0, | |
dai: 0, | |
eth: 0, | |
}, | |
states: { | |
pristine: { | |
on: { | |
FUND: { | |
target: 'funded', | |
actions: setFundedContext, | |
}, | |
}, | |
}, | |
funded: { | |
on: { | |
REWARD: { | |
target: 'fundedAndRewarded', | |
actions: setFundedAndRewardedContext, | |
}, | |
}, | |
}, | |
fundedAndRewarded: { | |
on: { | |
EXIT: 'pristine', | |
WITHDRAW: 'funded', | |
}, | |
}, | |
}, | |
}, | |
{ | |
actions: { | |
setFundedContext, | |
setFundedAndRewardedContext, | |
}, | |
}, | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment