From a5fdfb2e1cc511e5415c5a7e210f7b91b37dee17 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 31 Oct 2023 08:37:39 +0100 Subject: [PATCH 1/6] update readme-dev with new workflows --- README-dev.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/README-dev.md b/README-dev.md index 2cd50c025c..e77b02b95d 100644 --- a/README-dev.md +++ b/README-dev.md @@ -11,16 +11,19 @@ npm run build ./run src/examples/api_exploration.ts ``` -## Build and run the web version +## Run examples in the browser ```sh npm install npm run build:web -npm run serve:web + +./run-in-browser.js src/examples/api_exploration.ts ``` To see the test running in a web browser, go to `http://localhost:8000/`. +Note: Some of our examples don't work on the web because they use Node.js APIs. + ## Run tests - Unit tests @@ -50,7 +53,7 @@ To see the test running in a web browser, go to `http://localhost:8000/`. ## Branch Compatibility -o1js is mostly used to write Mina Smart Contracts and must be compatible with the latest Berkeley Testnet, or soon Mainnet. +o1js is mostly used to write Mina Smart Contracts and must be compatible with the latest Berkeley Testnet, or soon Mainnet. The OCaml code is in the o1js-bindings repository, not directly in o1js. @@ -58,17 +61,20 @@ To maintain compatibility between the repositories and build o1js from the [Mina The following branches are compatible: -| repository | mina -> o1js -> o1js-bindings | -| ---------- | ------------------------------------- | -| branches | rampup -> main -> main | -| | berkeley -> berkeley -> berkeley | -| | develop -> develop -> develop | +| repository | mina -> o1js -> o1js-bindings | +| ---------- | -------------------------------- | +| branches | o1js-main -> main -> main | +| | berkeley -> berkeley -> berkeley | +| | develop -> develop -> develop | ## Run the GitHub actions locally + You can execute the CI locally by using [act](https://github.com/nektos/act). First generate a GitHub token and use: + ``` act -j Build-And-Test-Server --matrix test_type:"Simple integration tests" -s $GITHUB_TOKEN ``` + to execute the job "Build-And-Test-Server for the test type `Simple integration tests`. From 5162e280ed84fe8a10d9870527f23e87f1d745cd Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 31 Oct 2023 08:45:25 +0100 Subject: [PATCH 2/6] package.json grooming --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 1ade0ac845..8afc4990a4 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "node": ">=16.4.0" }, "scripts": { - "type-check": "tsc --noEmit", "dev": "npx tsc -p tsconfig.node.json && node src/build/copy-to-dist.js", "make": "make -C ../../.. snarkyjs", "make:no-types": "npm run clean && make -C ../../.. snarkyjs_no_types", @@ -53,15 +52,14 @@ "build:web": "rimraf ./dist/web && node src/build/buildWeb.js", "build:examples": "rimraf ./dist/examples && npx tsc -p tsconfig.examples.json || exit 0", "build:docs": "npx typedoc", - "serve:web": "cp src/bindings/compiled/web_bindings/server.js src/bindings/compiled/web_bindings/index.html src/examples/simple_zkapp.js dist/web && node dist/web/server.js", "prepublish:web": "NODE_ENV=production node src/build/buildWeb.js", "prepublish:node": "npm run build && NODE_ENV=production node src/build/buildNode.js", "prepublishOnly": "npm run prepublish:web && npm run prepublish:node", "dump-vks": "./run src/examples/vk_regression.ts --bundle --dump ./src/examples/regression_test.json", "format": "prettier --write --ignore-unknown **/*", - "test": "./run-jest-tests.sh", "clean": "rimraf ./dist && rimraf ./src/bindings/compiled/_node_bindings", "clean-all": "npm run clean && rimraf ./tests/report && rimraf ./tests/test-artifacts", + "test": "./run-jest-tests.sh", "test:integration": "./run-integration-tests.sh", "test:unit": "./run-unit-tests.sh", "test:e2e": "rimraf ./tests/report && rimraf ./tests/test-artifacts && npx playwright test", From a20f367c3aefb55a3a3edffd3fb8c0dad1b8e1a5 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 31 Oct 2023 08:51:03 +0100 Subject: [PATCH 3/6] move example code from compiled bindings to examples folder --- package.json | 2 +- src/examples/plain-html/index.html | 15 +++++++++++ src/examples/plain-html/server.js | 42 ++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/examples/plain-html/index.html create mode 100644 src/examples/plain-html/server.js diff --git a/package.json b/package.json index 8afc4990a4..9e126225c0 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "test:integration": "./run-integration-tests.sh", "test:unit": "./run-unit-tests.sh", "test:e2e": "rimraf ./tests/report && rimraf ./tests/test-artifacts && npx playwright test", - "e2e:prepare-server": "npm run build:examples && (cp -rf dist/examples dist/web || :) && node src/build/e2eTestsBuildHelper.js && cp -rf src/bindings/compiled/web_bindings/index.html src/bindings/compiled/web_bindings/server.js tests/artifacts/html/*.html tests/artifacts/javascript/*.js dist/web", + "e2e:prepare-server": "npm run build:examples && (cp -rf dist/examples dist/web || :) && node src/build/e2eTestsBuildHelper.js && cp -rf src/examples/plain-html/index.html src/examples/plain-html/server.js tests/artifacts/html/*.html tests/artifacts/javascript/*.js dist/web", "e2e:run-server": "node dist/web/server.js", "e2e:install": "npx playwright install --with-deps", "e2e:show-report": "npx playwright show-report tests/report" diff --git a/src/examples/plain-html/index.html b/src/examples/plain-html/index.html new file mode 100644 index 0000000000..0678fde35a --- /dev/null +++ b/src/examples/plain-html/index.html @@ -0,0 +1,15 @@ + + + + + hello-snarkyjs + + + + +
Check out the console (F12)
+ + diff --git a/src/examples/plain-html/server.js b/src/examples/plain-html/server.js new file mode 100644 index 0000000000..dc7679626c --- /dev/null +++ b/src/examples/plain-html/server.js @@ -0,0 +1,42 @@ +import fs from 'node:fs/promises'; +import path from 'node:path'; +import http from 'node:http'; + +const port = 8000; +const defaultHeaders = { + 'content-type': 'text/html', + 'Cross-Origin-Embedder-Policy': 'require-corp', + 'Cross-Origin-Opener-Policy': 'same-origin', +}; + +const server = http.createServer(async (req, res) => { + let file = '.' + req.url; + console.log(file); + + if (file === './') file = './index.html'; + let content; + try { + content = await fs.readFile(path.resolve('./dist/web', file), 'utf8'); + } catch (err) { + res.writeHead(404, defaultHeaders); + res.write('404'); + res.end(); + return; + } + + const extension = path.basename(file).split('.').pop(); + const contentType = { + html: 'text/html', + js: 'application/javascript', + map: 'application/json', + }[extension]; + const headers = { ...defaultHeaders, 'content-type': contentType }; + + res.writeHead(200, headers); + res.write(content); + res.end(); +}); + +server.listen(port, () => { + console.log(`Server is running on: http://localhost:${port}`); +}); From 126dddeb34bd3fe842e3bb08f9adc7a86b52c5c0 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 31 Oct 2023 08:51:09 +0100 Subject: [PATCH 4/6] bindings --- src/bindings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindings b/src/bindings index 5e5befc857..e247e50af4 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 5e5befc8579393dadb96be1917642f860624ed07 +Subproject commit e247e50af4c952a72b13b5a6754c6d2677d9d721 From 8d803a20c66127f8f9ba7ed13b6a39f37da284d0 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 31 Oct 2023 15:11:52 +0100 Subject: [PATCH 5/6] changelog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d97e6b1ead..2588d44c1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm --> -## [Unreleased](https://github.com/o1-labs/o1js/compare/045faa7...HEAD) +## [Unreleased](https://github.com/o1-labs/o1js/compare/e8e7510e1...HEAD) + +> No unreleased changes yet + +## [0.14.0](https://github.com/o1-labs/o1js/compare/045faa7...e8e7510e1) ### Breaking changes From 8bd47f1d881e8658b463cd35cfd024739a5b81bb Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 31 Oct 2023 15:12:01 +0100 Subject: [PATCH 6/6] 0.14.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e8dc3eebf8..640490462f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "o1js", - "version": "0.13.1", + "version": "0.14.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "o1js", - "version": "0.13.1", + "version": "0.14.0", "license": "Apache-2.0", "dependencies": { "blakejs": "1.2.1", diff --git a/package.json b/package.json index 6367d83de1..7fadc8b5f5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "o1js", "description": "TypeScript framework for zk-SNARKs and zkApps", - "version": "0.13.1", + "version": "0.14.0", "license": "Apache-2.0", "homepage": "https://github.com/o1-labs/o1js/", "keywords": [