Skip to content

Commit

Permalink
Web3 1195 readme and slack / github release notes (#16)
Browse files Browse the repository at this point in the history
* docs: update README and add commitlint configuration in CI pipeline for automated release notes

* chore: update build-publish workflow and add conventional-changelog-cli
  • Loading branch information
rushby authored Nov 11, 2024
1 parent ca45b4e commit 22754bc
Show file tree
Hide file tree
Showing 9 changed files with 1,563 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
Expand All @@ -30,6 +32,9 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run commitlint
run: npx commitlint --from origin/main --to HEAD

- name: Lint
run: npm run lint

Expand Down
37 changes: 36 additions & 1 deletion .github/workflows/ci-publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
Expand All @@ -47,10 +49,43 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc

- name: Generate Release Notes
id: generate_release_notes
run: |
git fetch --tags
current_tag="v${{ env.package_version }}"
last_tag=$(git tag --sort=-creatordate | grep -B1 "$current_tag" | head -n 1)
if [ -z "$last_tag" ]; then
echo "No previous tag found. Generating release notes for all history."
npx conventional-changelog -p angular -o release_notes.md
else
echo "Generating release notes from $last_tag to $current_tag."
npx conventional-changelog -p angular -o release_notes.md --from "$last_tag" --to "$current_tag"
fi
if [ ! -s release_notes.md ]; then
echo "Error: No new conventional commits found to generate release notes."
exit 1
fi
echo "release_notes<<EOF" >> $GITHUB_ENV
cat release_notes.md >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Publish to npm
id: publish
run: npm publish --ignore-scripts

- name: Create GitHub Release
if: ${{ steps.publish.outcome == 'success' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$current_tag" -F release_notes.md -t "Release $current_tag"
- name: Send Slack Notification for Publish
if: ${{ steps.publish.outcome == 'success' }}
uses: slackapi/[email protected]
Expand All @@ -62,7 +97,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*:tada: :zk-logo-icon-square-black: zkVerifyJS Package v${{ env.package_version }} Published :zk-logo-icon-square-black: :tada:*\n\n*Build URL:* <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Click here to view the build>\n\n*Published Package:* <https://www.npmjs.com/package/zkverifyjs/v/${{ env.package_version }}|zkverifyjs@${{ env.package_version }}>"
"text": "*:tada: :zk-logo-icon-square-black: zkVerifyJS Package v${{ env.package_version }} Published :zk-logo-icon-square-black: :tada:*\n\n*Build URL:* <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Click here to view the build>\n\n*Published Package:* <https://www.npmjs.com/package/zkverifyjs/v/${{ env.package_version }}|zkverifyjs@${{ env.package_version }}>\n\n*Release Notes:*\n```${{ env.release_notes }}```"
}
}
]
Expand Down
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
2 changes: 1 addition & 1 deletion DEV_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ act workflow_dispatch -j build-and-test -P ubuntu-latest=ghcr.io/catthehacker/ub
### Publish Package

```shell
act workflow_dispatch -j publish-package -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest --network host
act workflow_dispatch -j build-and-publish -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest --network host
```

## Run Tests
Expand Down
54 changes: 40 additions & 14 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ const { events, transactionResult } = await session
.nonce(1) // Set the nonce (optional)
.waitForPublishedAttestation() // Wait for the attestation to be published (optional)
.withRegisteredVk() // Indicate that the verification key is already registered (optional)
.execute({ proofData: { proof, publicSignals, vk } }); // Execute the verification with the provided proof data
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
}); // Execute the verification with the provided proof data

```

Expand All @@ -108,7 +112,11 @@ const { events, transactionResult } = await session
```typescript
const { events, transactionResult } = await session.verify()
.groth16()
.execute({ proofData: { proof, publicSignals, vk } });
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});

events.on('ErrorEvent', (eventData) => {
console.error(JSON.stringify(eventData));
Expand All @@ -133,7 +141,11 @@ const vkTransactionInfo: VKRegistrationTransactionInfo = await transactionResult
const {events: verifyEvents, transactionResult: verifyTransactionResult} = await session.verify()
.fflonk()
.withRegisteredVk() // Option needs to be specified as we're using the registered statement hash.
.execute({ proofData: { proof, publicSignals, vkTransactionInfo.statementHash } });
.execute({ proofData: {
vk: vkTransactionInfo.statementHash!,
proof: proof,
publicSignals: publicSignals }
});;

const verifyTransactionInfo: VerifyTransactionInfo = await verifyTransactionResult;
```
Expand All @@ -148,13 +160,11 @@ You can listen for transaction events using the events emitter. Common events in
* `error`: Triggered if an error occurs during the transaction process.

```typescript
const { events, transactionResult } = await session.verify().risc0().execute({
proofData: {
proof,
publicSignals,
vk
}
});
const { events, transactionResult } = await session.verify().risc0().execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});;

events.on('includedInBlock', (eventData) => {
console.log('Transaction included in block:', eventData);
Expand All @@ -180,7 +190,11 @@ To await the final result of the transaction, use the transactionResult promise.
```typescript
const { events, transactionResult } = await session.verify()
.groth16()
.execute({ proofData: { proof, publicSignals, vk } })
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});;

const result = await transactionResult;
console.log('Final transaction result:', result);
Expand All @@ -193,7 +207,11 @@ Wait for the NewElement event to be published before the transaction info is ret
```typescript
const { events, transactionResult } = await session.verify().risc0()
.waitForPublishedAttestation()
.execute({ proofData: { proof, publicSignals, vk } });
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});;

const transactionInfo: VerifyTransactionInfo = await transactionResult;

Expand All @@ -215,7 +233,11 @@ async function executeVerificationTransaction(proof: unknown, publicSignals: unk
// Execute the verification transaction
const { events, transactionResult } = await session.verify().risc0()
.waitForPublishedAttestation()
.execute({ proofData: { proof, publicSignals, vk } });
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});;

// Listen for the 'includedInBlock' event
events.on(ZkVerifyEvents.IncludedInBlock, (eventData) => {
Expand Down Expand Up @@ -295,7 +317,11 @@ const { events, transactionResult } = await session.verify()
.nonce(1)
.waitForPublishedAttestation()
.withRegisteredVk()
.execute({ proofData: { proof, publicSignals, vk } }); // 1. Directly pass proof data
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});; // 1. Directly pass proof data
// .execute({ extrinsic: submittableExtrinsic }); // 2. OR pass in a pre-built SubmittableExtrinsic

```
Expand Down
54 changes: 40 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,23 @@ const { events, transactionResult } = await session
.nonce(1) // Set the nonce (optional)
.waitForPublishedAttestation() // Wait for the attestation to be published (optional)
.withRegisteredVk() // Indicate that the verification key is already registered (optional)
.execute({ proofData: { proof, publicSignals, vk } }); // Execute the verification with the provided proof data
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
}); // Execute the verification with the provided proof data

```

2. Frontend after establishing a session with `withWallet()`
```typescript
const { events, transactionResult } = await session.verify()
.groth16()
.execute({ proofData: { proof, publicSignals, vk } });
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});

events.on('ErrorEvent', (eventData) => {
console.error(JSON.stringify(eventData));
Expand All @@ -150,7 +158,11 @@ const vkTransactionInfo: VKRegistrationTransactionInfo = await transactionResult
const {events: verifyEvents, transactionResult: verifyTransactionResult} = await session.verify()
.fflonk()
.withRegisteredVk() // Option needs to be specified as we're using the registered statement hash.
.execute({ proofData: { proof, publicSignals, vkTransactionInfo.statementHash } });
.execute({ proofData: {
vk: vkTransactionInfo.statementHash!,
proof: proof,
publicSignals: publicSignals }
});;

const verifyTransactionInfo: VerifyTransactionInfo = await verifyTransactionResult;
```
Expand All @@ -165,13 +177,11 @@ You can listen for transaction events using the events emitter. Common events in
- `error`: Triggered if an error occurs during the transaction process.

```typescript
const { events, transactionResult } = await session.verify().risc0().execute({
proofData: {
proof,
publicSignals,
vk
}
});
const { events, transactionResult } = await session.verify().risc0().execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});;

events.on('includedInBlock', (eventData) => {
console.log('Transaction included in block:', eventData);
Expand All @@ -197,7 +207,11 @@ To await the final result of the transaction, use the transactionResult promise.
```typescript
const { events, transactionResult } = await session.verify()
.groth16()
.execute({ proofData: { proof, publicSignals, vk } })
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});;

const result = await transactionResult;
console.log('Final transaction result:', result);
Expand All @@ -210,7 +224,11 @@ Wait for the NewElement event to be published before the transaction info is ret
```typescript
const { events, transactionResult } = await session.verify().risc0()
.waitForPublishedAttestation()
.execute({ proofData: { proof, publicSignals, vk } });
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});;

const transactionInfo: VerifyTransactionInfo = await transactionResult;

Expand All @@ -232,7 +250,11 @@ async function executeVerificationTransaction(proof: unknown, publicSignals: unk
// Execute the verification transaction
const { events, transactionResult } = await session.verify().risc0()
.waitForPublishedAttestation()
.execute({ proofData: { proof, publicSignals, vk } });
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});;

// Listen for the 'includedInBlock' event
events.on(ZkVerifyEvents.IncludedInBlock, (eventData) => {
Expand Down Expand Up @@ -311,7 +333,11 @@ const { events, transactionResult } = await session.verify()
.nonce(1)
.waitForPublishedAttestation()
.withRegisteredVk()
.execute({ proofData: { proof, publicSignals, vk } }); // 1. Directly pass proof data
.execute({ proofData: {
vk: vk,
proof: proof,
publicSignals: publicSignals }
});; // 1. Directly pass proof data
// .execute({ extrinsic: submittableExtrinsic }); // 2. OR pass in a pre-built SubmittableExtrinsic

```
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
Loading

0 comments on commit 22754bc

Please sign in to comment.