Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(pact-project-proposal): initial proposal #1686

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions packages/pocs/pact-project-proposal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Concept of project management for Pact projects

Inspired by npm package- and tsconfig project-management.

A `pact-project.json` needs to be in every package.

> When that doesn't exist, it can be made by a depending project. It'll then
> include a "source" property that points to the source files.

The `pact-project.json` has properties that'll describe the project:

- `name` (optional): is used to reference the project, or show in logs or error
messages
- `description` (optional): description of the contents of the pact project
- `dependencies` (optional): an list of dependencies that need to be made
available for the project to work properly
- `dependencyTree`: an list of objects that define a smart contract and its
dependencies (recursively through `dependencies`)
- `path`: the path to the contract that needs to be available for the
depending project to work
- `dependencies`: a list of object that define this contracts' dependencies.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this makes sense, but we need to tease out some structure here:

  1. What does it mean to be a unit of distribution, as in, what is considered a singular, self-contained unit that can be delivered via its source code and deployed on the blockchain in an automatic fashion? I think this is a good start. You'll also probably want to include the install script (tx.yaml or smth) as a field in this distribution. I imagine deploy would only understand how to upload and deploy to a network if that were present.
  2. What does it mean to be a project, distinct from a unit of distribution? I would deploy a unit of distribution, but what would i build upon? A project, to me, should contain the following:
    • A list of dependencies, and a specification for where they're being stored, whether we have a default location local to the project, or user-specified.
    • A distinction between source and test directories, and tools to test that i could compose with deployment to build a CI/CD pipeline.
    • directories I could specify to dump FV or coverage artifacts

Together, i think 1 and 2 would be enough of a start to talk about a fully fledged "Pact Project" .

HTH


# How should this be used

A tool can interpret the `pact-project.json` to do various tasks

## `kadena project`

- `install` make dependencies available through downloading or other mechanism
- `verify` verify that all dependencies are available
- `deploy` will check whether the target network has the contracts available,
and deploys them where needed (new or upgrade deployment)

# Example files

There are 3 files in this project

- [`./pact-project.json`](./pact-project.json) an example of a project config
- [`./chainweb-pact-project.json`](./chainweb-pact-project.json) an example of
what a project file could look like when the target project has no
`pact-project.json`
- [`structure.graphql`](./structure.graphql) a formalized description of the
contents of a `pact-project.json`
18 changes: 18 additions & 0 deletions packages/pocs/pact-project-proposal/chainweb-pact-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "chainweb-pact",
"description": "Chainweb Pact Project",
"source": "[email protected]:kadena-io/chainweb-pact.git",
"dependencies": [
"[email protected]:other-user/my-other-dependency.git"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of content address-ability here. We should figure out how to reference contract hashes directly with some nice syntax. Having github support would be killer to mix with that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thought a day later: supporting commit hashes, as opposed to git repos would be preferable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like this to be similar to how NPM allows to use dependencies. This includes various ways of specifying versions, git urls, github urls (kadena-community/a-repo#commit-sh) etc

https://docs.npmjs.com/cli/v10/configuring-npm/package-json#dependencies

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine by me, but we should specify the variations in syntax that we plan to support beforehand.

],
"contracts": [
{
"path": "./utils.pact",
"dependencies": [
{
"path": "./some-other-contract.pact"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash or checksum would be nice to include here.

]
}
]
}
17 changes: 17 additions & 0 deletions packages/pocs/pact-project-proposal/pact-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "my-pact-project",
"dependencies": [
"[email protected]:alber70g/my-project.git/pact/pact-project.json",
"./chainweb-config.json"
],
"dependencyTree": [
{
"path": "./coin.pact",
"dependencies": [
{
"path": "./fungible-v2.pact"
}
]
}
]
}
25 changes: 25 additions & 0 deletions packages/pocs/pact-project-proposal/structure.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Project file that describes the structure of a pact project
`pact-project.json`
"""
type PactConfig {
name: String
description: String

"""
optional: sources if the pact smart contracts are external
Used to map the content of "source" to a "pact-project"
"""
source: String
dependencies: [ConfigPointerString!]
dependencyTree: [SmartContract!]
}

type ConfigPointerString {
value: String
}

type SmartContract {
path: String!
dependencies: [SmartContract]
}
Loading