Skip to content

Commit c7aaacb

Browse files
committed
Merge branch 'feature/community-files'
2 parents f18a81d + 7e8469d commit c7aaacb

File tree

9 files changed

+260
-50
lines changed

9 files changed

+260
-50
lines changed

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: "🐛 Bug"
2+
description: File a bug/issue
3+
title: "[BUG] <title>"
4+
labels: ["bug", "triage"]
5+
# projects: []
6+
# assignees: []
7+
body:
8+
- type: markdown
9+
attributes:
10+
value: |
11+
Thanks for taking the time to fill out this bug report!
12+
13+
Remember, contributions to this repository should follow its [contributing guidelines](../blob/develop/docs/CONTRIBUTING.md).
14+
- type: checkboxes
15+
attributes:
16+
label: Is there an existing issue for this?
17+
description: Please search to see if an issue already exists for the bug you encountered.
18+
options:
19+
- label: I have searched the existing issues
20+
required: true
21+
- type: textarea
22+
attributes:
23+
label: Current Behavior
24+
description: A concise description of what you're experiencing.
25+
validations:
26+
required: false
27+
- type: textarea
28+
attributes:
29+
label: Expected Behavior
30+
description: A concise description of what you expected to happen.
31+
validations:
32+
required: false
33+
- type: textarea
34+
attributes:
35+
label: Steps To Reproduce
36+
description: Steps to reproduce the behavior.
37+
placeholder: |
38+
1. In this environment...
39+
1. With this config...
40+
1. Run '...'
41+
1. See error...
42+
validations:
43+
required: false
44+
- type: textarea
45+
attributes:
46+
label: Environment
47+
description: |
48+
examples:
49+
- **Packages**: @ckb-cobuild/cobuild@0.0.4
50+
- **OS**: Ubuntu 20.04
51+
- **Node**: v21.5.0
52+
- **pnpm**: 8.6.12
53+
value: |
54+
- **Packages**:
55+
- **OS**:
56+
- **Node**:
57+
- **pnpm**:
58+
validations:
59+
required: false
60+
- type: textarea
61+
attributes:
62+
label: Anything else?
63+
description: |
64+
Links? References? Anything that will give us more context about the issue you are encountering!
65+
66+
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blank_issues_enabled: true

.github/ISSUE_TEMPLATE/feature.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "✨ Feature"
2+
description: Request a feature
3+
title: "[Feature] <title>"
4+
labels: ["feature", "triage"]
5+
# projects: []
6+
# assignees: []
7+
body:
8+
- type: markdown
9+
attributes:
10+
value: |
11+
Thanks for taking the time to fill out this feature request!
12+
13+
Remember, contributions to this repository should follow its [contributing guidelines](../blob/develop/docs/CONTRIBUTING.md).
14+
- type: checkboxes
15+
attributes:
16+
label: Is there an existing issue for this?
17+
description: Please search to see if an issue already exists for the feature you are requesting.
18+
options:
19+
- label: I have searched the existing issues
20+
required: true
21+
- type: textarea
22+
attributes:
23+
label: Describe The Problem
24+
description: Please present a concise description of the problem to be addressed by this feature request. Please be clear what parts of the problem are considered to be in-scope and out-of-scope.
25+
validations:
26+
required: true
27+
- type: textarea
28+
attributes:
29+
label: Suggest A Solution
30+
description: |
31+
A concise description of your preferred solution. If there are multiple solutions, please present each one separately. Save comparisons for the very end.
32+
placeholder: |
33+
Things to address include:
34+
- Details of the technical implementation
35+
- Tradeoffs made in design decisions
36+
- Caveats and considerations for the future
37+
validations:
38+
required: false
39+
- type: textarea
40+
attributes:
41+
label: Anything else?
42+
description: |
43+
Links? References? Anything that will give us more context about the feature you are requesting!
44+
45+
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
46+
validations:
47+
required: false

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, synchronize]
7+
8+
jobs:
9+
build:
10+
name: Build and Test
11+
timeout-minutes: 15
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node: ["18", "lts/*", "latest"]
17+
run:
18+
- pnpm build
19+
- pnpm lint
20+
- pnpm test
21+
22+
steps:
23+
- name: Check out code
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 2
27+
28+
- uses: pnpm/action-setup@v2.4.0
29+
with:
30+
version: 8.6.12
31+
32+
- name: Setup Node.js environment
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: ${{ matrix.node }}
36+
cache: "pnpm"
37+
38+
- name: Install dependencies
39+
run: pnpm install
40+
41+
- name: Run Command
42+
run: ${{ matrix.run }}

.github/workflows/pnpm.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

COPYING

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 ian
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# CKB DAO Cobuild POC
1+
# CKB DAO Cobuild PoC
2+
3+
- [Contributing Guidelines](docs/CONTRIBUTING.md)
4+
- [Guidelines for PoC Reviewers](docs/poc-review-guide.md)
25

36
## Disclaimer
47

docs/CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing Guidelines
2+
3+
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4+
5+
- Reporting a bug
6+
- Discussing the current state of the code
7+
- Submitting a fix
8+
- Proposing new features
9+
- Becoming a maintainer
10+
11+
## We Develop with Github
12+
13+
We use github to host code, to track issues and feature requests, as well as accept pull requests.
14+
15+
## Pull Requests and [Changesets](https://github.com/changesets/changesets)
16+
17+
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
18+
19+
1. Fork the repo and create your branch from `main`.
20+
2. If you've added code that should be tested, add tests.
21+
3. If you've changed APIs, update the documentation.
22+
4. Ensure the test suite passes.
23+
5. Make sure your code lints.
24+
6. Use a consistent coding style. Use prettier to format your code.
25+
7. Issue that pull request!
26+
27+
## License
28+
29+
By contributing, you agree that your contributions will be licensed under its MIT License.
30+
31+
## Report bugs using Github's [issues](../../../issues)
32+
33+
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](../../../issues/new/choose); it's that easy!

docs/poc-review-guide.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# PoC Review Guide
2+
3+
Cobuild is still under active development. Please refer to [ckb-transaction-cobuild-poc](https://github.com/cryptape/ckb-transaction-cobuild-poc) for contract supports.
4+
5+
The core principle of the PoC is how the CKB system DAO would look like if it supports Cobuild.
6+
7+
The general workflow to build transactions in Cobuild:
8+
9+
1. Create an empty **BuildingPacket** structure to initiate building a new transaction.
10+
2. (Type Script Phase) Users perform some operations often by submitting forms. For each operation:
11+
- a. Find the corresponding papp (name for dapp in Cobuid) and create an **Action**.
12+
- b. Let the papp process the **Action**. Update transaction in the **BuildingPacket** structure and add the **Action** as a message Action to `BuildingPacketV1.message.actions`
13+
3. (Fee Estimation Phase) Estimate witnesses size for fee calculation.
14+
- a. Ensure all message **Action**s have been completed.
15+
- b. (Optional) Remove message **Action**s that are experimental. For example, before DAO updates its contract, the DAO operations as message **Action**s are not validated. It's better to remove it to avoid inconsistent data.
16+
- c. For each lock script group: choose Cobuild or WitnessArgs layout and set the witness to enough size for fee estimation.
17+
- d. If there're witnesses are using `SighashAll` or `SighashAllOnly`. Set the first of such witnesses to `SighashAll` and put message **Action**s into it, and the remaining to `SighashAllOnly`.
18+
- e. If there's no such witnesses, and there's at least one message **Action**, add a `SighashAll` witness at a position beyond the number of inputs and save message **Action**s in it.
19+
- f. Estimate tx size and pay fee. If there are new cells added, ensure the witness size is correct for fee estimation.
20+
4. (Lock Script Phase) Prepare to finalize the transaction. For each lock script group:
21+
- a. Set witness for digest computation.
22+
- b. Compute the digest for the script group.
23+
- c. Connect wallet to create signatures from digests.
24+
- d. Store the signature into the witness.
25+
5. Finish, send the transaction to CKB.
26+
27+
## Map Code To Steps
28+
29+
The core is the step 2. There will be a framework to handle 1, 3, 4, 5, I just build a minimal framework to make the PoC work.
30+
31+
1. `src/lib/cobuild/types.js`: Cobuild data structures definition.
32+
2. `src/lib/papps/dao`: DAO papp
33+
- a.
34+
- `src/lib/papps/dao/schema.js`: Action.data schema
35+
- `src/lib/papps/dao/action-creators.js`: Functions to create Action.data for DAO.
36+
- b. `src/lib/papps/dao/lumos-callbacks.js`: Build transactions based on DAO message actions.
37+
3. `src/lib/cobuild/fee-manager.js`: See the function `payFee` and `storeWitnessForFeeEstimation`
38+
4. `src/lib/cobuild/lock-actions.js`: See the function `prepareLockActions`.
39+
- a/b. `src/lib/cobuild/general-lock-actions.js`: See the function `prepareLockActionWithWitnessStore`
40+
- c. `src/lib/wallet/selector.js` acts as a gateway to connect different wallets and create signatures.
41+
- c. `src/lib/cobuild/general-lock-actions.js`: See the function `applyLockAction`
42+
5. `src/app/u/[wallet]/[connection]/submit-building-packet.js`: a simple UI to send tx and query its status.
43+
44+
Remarks:
45+
46+
- `src/lib/cobuild/react/building-packet-review.js`: UI to review the building packet for signing.

0 commit comments

Comments
 (0)