Last active
April 16, 2020 03:38
-
-
Save NewAlexandria/7f0c6d9cdb2e5c9adeb0b7ce0e3d711f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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) | |
// transaction states: | |
// - pre_authorize | |
// - identity | |
// - subscription | |
// - kyc_aml | |
// - registry_update | |
// - confirm | |
// a method for a [transaction-state, action] is likely to be reusable for any Transaction Type | |
// it is possible that a validator for an action may be re-usable, with some conditional logic | |
// as a guide, it would be better to be verbose, and combine later | |
const preAuthorizeRequest = (context, event) => { | |
return true; //context.dealTransaction.transaction['preAuthorize'].files[0]; | |
}; | |
const preAuthorizeSubmit = (context, event) => { | |
return true; //context.dealTransaction.transaction['preAuthorize'].files[0]; | |
}; | |
const preAuthorizeReview = (context, event) => { | |
return true; //context.dealTransaction.transaction['preAuthorize'].files[0]; | |
}; | |
const identityVerificationRequest = (context, event) => { | |
return true; //context.dealTransaction.transaction['identity'].files[0]; | |
}; | |
const identityVerificationSubmit = (context, event) => { | |
return true; //context.dealTransaction.transaction['identity'].files[0]; | |
}; | |
const identityVerificationReview = (context, event) => { | |
return true; //context.dealTransaction.transaction['identity'].files[0]; | |
}; | |
const subscriptionAgrRequest = (context, event) => { | |
return true; //context.dealTransaction.transaction['subscription'].files[0]; | |
}; | |
const subscriptionAgrSubmit = (context, event) => { | |
return true; //context.dealTransaction.transaction['subscription'].files[0]; | |
}; | |
const subscriptionAgrReview = (context, event) => { | |
return true; //context.dealTransaction.transaction['subscription'].files[0]; | |
}; | |
const kycAmlReview = (context, event) => { | |
return true; //context.dealTransaction.transaction['kycAml'].files[0]; | |
}; | |
const kycAmlSubmit = (context, event) => { | |
return true; //context.dealTransaction.transaction['kycAml'].files[0]; | |
}; | |
const shareholderRegistryReview = (context, event) => { | |
return true; //context.dealTransaction.transaction['RegistryUpdate'].files[0]; | |
}; | |
const shareholderRegistrySubmit = (context, event) => { | |
return true; //context.dealTransaction.transaction['RegistryUpdate'].files[0]; | |
}; | |
const contractNoteReview = (context, event) => { | |
return true; //context.dealTransaction.transaction['confirm'].files[0]; | |
}; | |
const finalizeSettlementReview = (context, event) => { | |
return true; //context.dealTransaction.transaction['confirm'].files[0]; | |
}; | |
const completedReview = (context, event) => { | |
return true; //context.dealTransaction.transaction['confirm'].files[0]; | |
}; | |
const pre_authorize_actions = { | |
initial: 'REQUEST', | |
states: { | |
REQUEST: { | |
on: { | |
DOC_SEND: [ | |
{ | |
target: 'SUBMIT', | |
cond: preAuthorizeRequest | |
}, | |
{ target: 'REQUEST' } | |
] | |
} | |
}, | |
SUBMIT: { | |
on: { | |
DOC_RETURN: [ | |
{ | |
target: 'REVIEW', | |
cond: preAuthorizeSubmit | |
}, | |
{ target: 'SUBMIT' } | |
] | |
} | |
}, | |
REVIEW: { | |
on: { | |
REQUEST_UPDATE: 'SUBMIT', | |
DONE: [ | |
{ | |
target: '#IDENTITY_VERIFICATION', | |
internal: false, | |
cond: preAuthorizeReview | |
}, | |
{ target: 'REVIEW' } | |
] | |
} | |
} | |
} | |
}; | |
const identity_verification_actions = { | |
initial: 'REQUEST', | |
states: { | |
REQUEST: { | |
on: { | |
DOC_SEND: [ | |
{ | |
target: 'SUBMIT', | |
cond: identityVerificationRequest | |
}, | |
{ target: 'REQUEST' } | |
] | |
} | |
}, | |
SUBMIT: { | |
on: { | |
DOC_RETURN: [ | |
{ | |
target: 'REVIEW', | |
cond: identityVerificationSubmit | |
}, | |
{ target: 'SUBMIT' } | |
] | |
} | |
}, | |
REVIEW: { | |
on: { | |
REQUEST_UPDATE: 'SUBMIT', | |
DONE: [ | |
{ | |
target: '#SUBSCRIPTION_AGR', | |
internal: false, | |
cond: identityVerificationReview | |
}, | |
{ target: 'REVIEW' } | |
] | |
} | |
} | |
} | |
}; | |
const subscription_agr_actions = { | |
initial: 'REQUEST', | |
states: { | |
REQUEST: { | |
on: { | |
DOC_SEND: [ | |
{ | |
target: 'SUBMIT', | |
cond: subscriptionAgrRequest | |
}, | |
{ target: 'REQUEST' } | |
] | |
} | |
}, | |
SUBMIT: { | |
on: { | |
DOC_RETURN: [ | |
{ | |
target: 'REVIEW', | |
cond: subscriptionAgrSubmit | |
}, | |
{ target: 'SUBMIT' } | |
] | |
} | |
}, | |
REVIEW: { | |
on: { | |
REQUEST_UPDATE: 'SUBMIT', | |
DONE: [ | |
{ | |
target: '#KYC_AML', | |
internal: false, | |
cond: subscriptionAgrReview | |
}, | |
{ target: 'REVIEW' } | |
] | |
} | |
} | |
} | |
}; | |
const kyc_aml_actions = { | |
initial: 'SUBMIT', | |
states: { | |
SUBMIT: { | |
on: { | |
DOC_RETURN: [ | |
{ | |
target: 'REVIEW', | |
cond: kycAmlSubmit | |
}, | |
{ target: 'SUBMIT' } | |
] | |
} | |
}, | |
REVIEW: { | |
on: { | |
REQUEST_UPDATE: 'SUBMIT', | |
DONE: [ | |
{ | |
target: '#SHAREHOLDER_REGISTRY', | |
internal: false, | |
cond: kycAmlReview | |
}, | |
{ target: 'REVIEW' } | |
] | |
} | |
} | |
} | |
}; | |
const shareholder_registry_actions = { | |
initial: 'SUBMIT', | |
states: { | |
SUBMIT: { | |
on: { | |
DOC_RETURN: [ | |
{ | |
target: 'REVIEW', | |
cond: shareholderRegistrySubmit | |
}, | |
{ target: 'SUBMIT' } | |
] | |
} | |
}, | |
REVIEW: { | |
on: { | |
REQUEST_UPDATE: 'SUBMIT', | |
DONE: [ | |
{ | |
target: '#CONTRACT_NOTE', | |
internal: false, | |
cond: shareholderRegistryReview | |
}, | |
{ target: 'REVIEW' } | |
] | |
} | |
} | |
} | |
}; | |
const contract_note_actions = { | |
initial: 'REVIEW', | |
states: { | |
REVIEW: { | |
on: { | |
DONE: { | |
target: '#FINALIZE_SETTLEMENT', | |
internal: false, | |
cond: contractNoteReview | |
} | |
} | |
} | |
} | |
}; | |
const finalize_settlement_actions = { | |
initial: 'REVIEW', | |
states: { | |
REVIEW: { | |
on: { | |
'': { | |
target: '#COMPLETED', | |
internal: false, | |
cond: finalizeSettlementReview | |
} | |
} | |
} | |
} | |
}; | |
const completed_actions = { | |
initial: 'REVIEW', | |
states: { | |
REVIEW: { | |
on: { | |
COMPLETED: { | |
type:'final', | |
cond: completedReview | |
} | |
} | |
} | |
} | |
}; | |
const dealMachine = Machine({ | |
id: 'primary_new_ubo', | |
initial: 'PRE_AUTHORIZE', | |
context: { | |
transaction: null, | |
user: null, | |
appContext: null | |
}, | |
states: { | |
PRE_AUTHORIZE: { | |
id: 'PRE_AUTHORIZE', | |
...pre_authorize_actions | |
}, | |
IDENTITY_VERIFICATION: { | |
id: 'IDENTITY_VERIFICATION', | |
...identity_verification_actions | |
}, | |
SUBSCRIPTION_AGR: { | |
id: 'SUBSCRIPTION_AGR', | |
...subscription_agr_actions | |
}, | |
KYC_AML: { | |
id: 'KYC_AML', | |
...kyc_aml_actions | |
}, | |
SHAREHOLDER_REGISTRY: { | |
id: 'SHAREHOLDER_REGISTRY', | |
...shareholder_registry_actions | |
}, | |
CONTRACT_NOTE: { | |
id: 'CONTRACT_NOTE', | |
...contract_note_actions | |
}, | |
FINALIZE_SETTLEMENT: { | |
id: 'FINALIZE_SETTLEMENT', | |
...finalize_settlement_actions | |
}, | |
COMPLETED: { | |
id: 'COMPLETED', | |
...completed_actions | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment