Umi — API References - v1.3.0
    Preparing search index...

    Interface ProgramRepositoryInterface

    Defines the interface for a program repository. It allows us to register and retrieve programs when needed.

    interface ProgramRepositoryInterface {
        add(program: Program, overrides?: boolean): void;
        all(clusterFilter?: ClusterFilter): Program[];
        bind(abstract: string, concrete: string | PublicKey): void;
        clone(): ProgramRepositoryInterface;
        get<T extends Program = Program>(
            identifier: string | PublicKey,
            clusterFilter?: ClusterFilter,
        ): T;
        getPublicKey(
            identifier: string | PublicKey,
            fallback?: PublicKeyInput,
            clusterFilter?: ClusterFilter,
        ): PublicKey;
        has(identifier: string | PublicKey, clusterFilter?: ClusterFilter): boolean;
        resolveError(
            error: ErrorWithLogs,
            transaction: Transaction,
        ): null | ProgramError;
        unbind(abstract: string): void;
    }
    Index

    Methods

    • Registers a new program in the repository.

      Parameters

      • program: Program

        The program to register.

      • Optionaloverrides: boolean

        Whether to register and prioritize the given program even if a program with the same public key already exists. Defaults to true.

      Returns void

    • Gets all programs from the repository matching the given cluster filter. Defaults to getting all programs from the current cluster.

      Parameters

      • OptionalclusterFilter: ClusterFilter

        The cluster filter to apply. Defaults to "current".

      Returns Program[]

    • Creates a binding between a name and a program identifier. This can be used to create redirections or aliases when resolving programs.

      Parameters

      • abstract: string

        The name of the binding.

      • concrete: string | PublicKey

        The identifier this binding should resolve to.

      Returns void

    • Gets a program from the repository. Throws an error if the program is not found.

      Type Parameters

      • T extends Program = Program

        The type of the program to retrieve. Defaults to Program.

      Parameters

      • identifier: string | PublicKey

        The name or public key of the program to retrieve.

      • OptionalclusterFilter: ClusterFilter

        The cluster filter to apply. Defaults to "current".

      Returns T

    • Gets the public key of a program from the repository, with an optional fallback public key.

      Throws an error if the program is not found and no fallback is provided.

      Parameters

      • identifier: string | PublicKey

        The name or public key of the program to retrieve.

      • Optionalfallback: PublicKeyInput

        The fallback public key to use if the program is not found. Defaults to not using a fallback public key.

      • OptionalclusterFilter: ClusterFilter

        The cluster filter to apply. Defaults to "current".

      Returns PublicKey

    • Whether a given program is registered in the repository.

      Parameters

      • identifier: string | PublicKey

        The name or public key of the program to check.

      • OptionalclusterFilter: ClusterFilter

        The cluster filter to apply. Defaults to "current".

      Returns boolean

    • Resolves a custom program error from a transaction error.

      Parameters

      • error: ErrorWithLogs

        The raw error to resolve containing the program logs.

      • transaction: Transaction

        The transaction that caused the error.

      Returns null | ProgramError

      The resolved program error, or null if the error cannot be resolved.

    • Removes a binding using its name.

      Parameters

      • abstract: string

        The name of the binding to remove.

      Returns void