54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
export const NON_EVM_RELAY_LIFECYCLE = [
|
|
'initiate',
|
|
'observe_destination',
|
|
'confirm_finalize',
|
|
'reject_replay',
|
|
'refund_recover'
|
|
] as const;
|
|
|
|
export type NonEvmRelayLifecycleStep = (typeof NON_EVM_RELAY_LIFECYCLE)[number];
|
|
|
|
export type NonEvmExposureStatus =
|
|
| 'planned'
|
|
| 'operator_ready'
|
|
| 'public_ready'
|
|
| 'live'
|
|
| 'gated_by_chain138_prerequisites';
|
|
|
|
export interface NonEvmNetworkPolicy {
|
|
identifier: string;
|
|
relayMode: 'custom_relay' | 'custom_relay_scaffold' | 'parallel_program';
|
|
destinationProgramModel: string;
|
|
signerFundingPolicy: string;
|
|
finalityPolicy: string;
|
|
publicExposureStatus: Exclude<NonEvmExposureStatus, 'gated_by_chain138_prerequisites'>;
|
|
}
|
|
|
|
export interface NonEvmRelayObservation {
|
|
requestId: string;
|
|
lifecycleStep: NonEvmRelayLifecycleStep;
|
|
destinationReference?: string;
|
|
fulfillmentId?: string;
|
|
finalityValue?: number;
|
|
replayRejected?: boolean;
|
|
}
|
|
|
|
export function deriveExposureStatus(
|
|
policy: NonEvmNetworkPolicy,
|
|
checks: {
|
|
adapterPresent: boolean;
|
|
relaySurfacePresent: boolean;
|
|
chain138PrerequisitesReady: boolean;
|
|
}
|
|
): NonEvmExposureStatus {
|
|
if (!checks.adapterPresent || !checks.relaySurfacePresent) {
|
|
return 'planned';
|
|
}
|
|
|
|
if (!checks.chain138PrerequisitesReady) {
|
|
return 'gated_by_chain138_prerequisites';
|
|
}
|
|
|
|
return policy.publicExposureStatus;
|
|
}
|