Class Project

Abstraction for connecting @truffle/db to a Truffle project

This class affords an interface between Truffle and @truffle/db, specifically for the purposes of ingesting @truffle/workflow-compile results and contract instance information from @truffle/contract-schema artifact files.

Unless you are building tools that work with Truffle's various packages directly, you probably don't need to use this class.

Example

To instantiate this abstraction:

import { connect, Project } from "@truffle/db";

const db = connect({
// ...
});

const project = await Project.initialize({
db,
project: {
directory: "/path/to/project/dir"
}
});

Hierarchy

Constructor

Truffle-specific

Other

Processor

Constructor

Truffle-specific

  • Accept a compilation result and process it to save all relevant resources ([[DataModel.Source | Source]], [[DataModel.Bytecode | Bytecode]], [[DataModel.Compilation | Compilation]], [[DataModel.Contract | Contract]])

    This returns the same WorkflowCompileResult but with additional references to each of the added resources.

    Parameters

    • options: {
          result: WorkflowCompileResult;
      }
      • result: WorkflowCompileResult

    Returns Promise<{
        compilations: Project.LoadCompile.Compilation[];
        contracts: Project.LoadCompile.Contract[];
    }>

Other

  • Update name pointers for this project. Currently affords name-keeping for [[DataModel.Network | Network]] and [[DataModel.Contract | Contract]] resources (e.g., naming [[DataModel.ContractInstance | ContractInstance]] resources is not supported directly)

    This saves [[DataModel.NameRecord | NameRecord]] and [[DataModel.ProjectName | ProjectName]] resources to @truffle/db.

    Returns a list of NameRecord resources for completeness, although these may be regarded as an internal concern. ProjectName resources are not returned because they are mutable; returned representations would be impermanent.

    Type Parameters

    Parameters

    Returns Promise<{
        assignments: {
            [K in Resources.NamedCollectionName]: Resources.IdObject<"nameRecords">[]
        };
    }>

    Example

    await project.assignNames({
    assignments: {
    contracts: [
    { id: "<contract1-id>" },
    { id: "<contract2-id>" },
    // ...
    }
    }
    });

Processor

  • Run a given [[Process.Processor | Processor]] with specified arguments.

    This method is a [[Meta.Process.ProcessorRunner | ProcessorRunner]] and can be used to await (e.g.) the processors defined by [[Process.resources | Process's resources]].

    Type Parameters

    • A extends unknown[]

    • T = any

    • R extends undefined | RequestType = undefined

    Parameters

    • processor: Processor<A, T, R>
    • Rest ...args: A

    Returns Promise<T>

Generated using TypeDoc