feat: expand non-evm relay and route planning support
This commit is contained in:
53
services/non-evm-relay/lifecycle.ts
Normal file
53
services/non-evm-relay/lifecycle.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user