Skip to content

Commit

Permalink
Merge pull request #1209 from o1-labs/docs/readme-dev-update
Browse files Browse the repository at this point in the history
Readme and repo grooming, release 0.14
  • Loading branch information
mitschabaude authored Oct 31, 2023
2 parents 9da5972 + 8bd47f1 commit 99963da
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 17 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 14 additions & 8 deletions README-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,25 +53,28 @@ 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.

To maintain compatibility between the repositories and build o1js from the [Mina repository](https://github.com/MinaProtocol/mina), make changes to its core, such as the OCaml-bindings in the [o1js-bindings repository](https://github.com/o1-labs/o1js-bindings), you must follow a certain branch compatibility pattern:

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

<!-- The test example should stay in sync with a real value set in .github/workflows/build-actions.yml -->

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`.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -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",
Expand All @@ -54,19 +53,18 @@
"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 --tsconfig ./tsconfig.web.json",
"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",
"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"
Expand Down
2 changes: 1 addition & 1 deletion src/bindings
15 changes: 15 additions & 0 deletions src/examples/plain-html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>hello-snarkyjs</title>
<script type="importmap">
{ "imports": { "snarkyjs": "./index.js" } }
</script>
<script type="module" src="./simple_zkapp.js">
</script>
</head>
<body>
<div>Check out the console (F12)</div>
</body>
</html>
42 changes: 42 additions & 0 deletions src/examples/plain-html/server.js
Original file line number Diff line number Diff line change
@@ -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('<html><body>404</body><html>');
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}`);
});

0 comments on commit 99963da

Please sign in to comment.