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

Web3 1195 readme and slack / github release notes #16

Merged
merged 7 commits into from
Nov 11, 2024
Merged
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
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/slack-github-action@v1.25.0
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