30 lines
782 B
JavaScript
30 lines
782 B
JavaScript
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
exports.nextPhase = nextPhase;
|
||
|
|
exports.canAdvance = canAdvance;
|
||
|
|
const ORDER = [
|
||
|
|
'RECEIVED',
|
||
|
|
'VALIDATED',
|
||
|
|
'VERBIAGE_ROLLED',
|
||
|
|
'FINERACT_POSTED',
|
||
|
|
'HYBX_RAIL_DISPATCHED',
|
||
|
|
'ISO20022_ARCHIVED',
|
||
|
|
'CHAIN_MINT_REQUESTED',
|
||
|
|
'SETTLED',
|
||
|
|
];
|
||
|
|
function nextPhase(current) {
|
||
|
|
if (current === 'FAILED' || current === 'SETTLED')
|
||
|
|
return null;
|
||
|
|
const idx = ORDER.indexOf(current);
|
||
|
|
if (idx < 0 || idx >= ORDER.length - 1)
|
||
|
|
return null;
|
||
|
|
return ORDER[idx + 1];
|
||
|
|
}
|
||
|
|
function canAdvance(from, to) {
|
||
|
|
const fi = ORDER.indexOf(from);
|
||
|
|
const ti = ORDER.indexOf(to);
|
||
|
|
if (fi < 0 || ti < 0)
|
||
|
|
return to === 'FAILED';
|
||
|
|
return ti === fi + 1 || to === 'FAILED';
|
||
|
|
}
|