import { Context } from 'vm';

import { extractUser, getAuthenticated, User } from '@coinweb/contract-kit';

export const getUser = (context: Context): User => {
  const auth = getAuthenticated(context.tx);

  if (!auth) {
    return {
      auth: 'manual',
      payload: 'manual',
    } satisfies User;
  }

  return extractUser(auth);
};
