import { Context, extractContractInfo } from '@coinweb/contract-kit';

import { HISTORY_CODES } from '../../module/history/shared';
import { Exception } from '../features';

export const getCallParameters = (context: Context) => {
  const { authenticated, providedCweb } = extractContractInfo(context.tx);

  if (!providedCweb) {
    throw new Exception({
      code: HISTORY_CODES.BAD_REQUEST,
      message: 'Cweb was not provided',
    });
  }

  return {
    availableCweb: providedCweb,
    authInfo: authenticated,
  };
};
