import { SpendingValidator } from '@lucid-evolution/lucid';
import { _pythFeedValidator } from '../../validators/pyth-feed-validator';
import { applyParamsToScript } from '@evolution-sdk/evolution/uplc';
import { PythFeedParams, serialisePythFeedParams } from './types';

export const mkPythFeedValidator = (
  params: PythFeedParams,
): SpendingValidator => {
  return {
    type: 'PlutusV3',
    script: applyParamsToScript(_pythFeedValidator.cborHex, [
      serialisePythFeedParams(params),
    ]),
  };
};
