/**
 * This code was AUTOGENERATED using the codama library.
 * Please DO NOT EDIT THIS FILE, instead use visitors
 * to add features, then rerun codama to update it.
 *
 * @see https://github.com/codama-idl/codama
 */

import {
  ClusterFilter,
  Context,
  Program,
  PublicKey,
} from '@metaplex-foundation/umi';
import { getDummyErrorFromCode, getDummyErrorFromName } from '../errors';

export const DUMMY_PROGRAM_ID =
  'Dummy1111111111111111111111111111111111' as PublicKey<'Dummy1111111111111111111111111111111111'>;

export function createDummyProgram(): Program {
  return {
    name: 'dummy',
    publicKey: DUMMY_PROGRAM_ID,
    getErrorFromCode(code: number, cause?: Error) {
      return getDummyErrorFromCode(code, this, cause);
    },
    getErrorFromName(name: string, cause?: Error) {
      return getDummyErrorFromName(name, this, cause);
    },
    isOnCluster() {
      return true;
    },
  };
}

export function getDummyProgram<T extends Program = Program>(
  context: Pick<Context, 'programs'>,
  clusterFilter?: ClusterFilter
): T {
  return context.programs.get<T>('dummy', clusterFilter);
}

export function getDummyProgramId(
  context: Pick<Context, 'programs'>,
  clusterFilter?: ClusterFilter
): PublicKey {
  return context.programs.getPublicKey(
    'dummy',
    DUMMY_PROGRAM_ID,
    clusterFilter
  );
}
