Skip to content

Commit

Permalink
Defined deploy script for contract, updated o1js (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
silimarius authored Sep 15, 2023
1 parent b1c91e3 commit 3bd1c15
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 48 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: mv ./README.md ./zk-states/
- run: cd zk-states-contracts && yarn npm publish --access public --tolerate-republish
- run: cd zk-states && yarn npm publish --access public --tolerate-republish
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7427,9 +7427,9 @@ __metadata:
languageName: node
linkType: hard

"o1js@npm:^0.12.1":
version: 0.12.1
resolution: "o1js@npm:0.12.1"
"o1js@npm:^0.13.0":
version: 0.13.0
resolution: "o1js@npm:0.13.0"
dependencies:
blakejs: 1.2.1
detect-gpu: ^5.0.5
Expand All @@ -7439,7 +7439,7 @@ __metadata:
tslib: ^2.3.0
bin:
snarky-run: src/build/run.js
checksum: 50b21fa4a69490ca2018f850a17336a71cf4c6e2bd1607acf3f24394ca86e22065c68c6bf323ecd3fb7adabcc8c258b7be78db5b6ccf1ba60ea7b104a3a90098
checksum: d5b0f81702fa32d986c77aa3e4d2ed1146d1e32dd9f274d85a921a3401aae497a6d315e9b685e790fa2dc98fb7519f37d1ef3d1269ac76c217e65e54a75d8f2d
languageName: node
linkType: hard

Expand Down Expand Up @@ -9856,13 +9856,13 @@ __metadata:
husky: ^7.0.1
jest: ^27.3.1
lint-staged: ^11.0.1
o1js: ^0.12.1
o1js: ^0.13.0
prettier: ^2.3.2
ts-jest: ^27.0.7
typescript: ^4.7.2
zod: ^3.22.2
peerDependencies:
o1js: 0.12.*
o1js: 0.13.*
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -9913,7 +9913,7 @@ __metadata:
eslint-plugin-react-hooks: ^4.6.0
eslint-plugin-vitest: ^0.2.8
jsdom: ^22.1.0
o1js: ^0.12.1
o1js: ^0.13.0
prettier: ^3.0.0
react: ^18.2.0
react-dom: ^18.2.0
Expand All @@ -9931,7 +9931,7 @@ __metadata:
zod: ^3.21.4
zustand: ^4.3.9
peerDependencies:
o1js: ">=0.12.1"
o1js: ">=0.13.0"
react: ">=18.0.0"
react-dom: ">=18.0.0"
zustand: ">=4.3.9"
Expand Down
25 changes: 1 addition & 24 deletions zk-states-contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
# Mina zkApp: Zk States Contract

This template uses TypeScript.

## How to build

```sh
npm run build
```

## How to run tests

```sh
npm run test
npm run testw # watch mode
```

## How to run coverage

```sh
npm run coverage
```

## License

[Apache-2.0](LICENSE)
Mina contract and program for [zk-states](https://www.npmjs.com/package/zk-states) library.
12 changes: 8 additions & 4 deletions zk-states-contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "zk-states-contracts",
"version": "0.0.0",
"version": "0.0.2",
"author": "Marius Sili (https://github.com/silimarius)",
"private": true,
"description": "Mina program and contract for zk-states library",
"keywords": [
"mina-zkapp",
"mina-zk-app",
Expand All @@ -12,6 +12,10 @@
"type": "module",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"files": [
"build/**/*"
],
"license": "MIT",
"scripts": {
"clean": "rm -rf build/",
"build": "tsc",
Expand Down Expand Up @@ -42,13 +46,13 @@
"husky": "^7.0.1",
"jest": "^27.3.1",
"lint-staged": "^11.0.1",
"o1js": "^0.12.1",
"o1js": "^0.13.0",
"prettier": "^2.3.2",
"ts-jest": "^27.0.7",
"typescript": "^4.7.2",
"zod": "^3.22.2"
},
"peerDependencies": {
"o1js": "0.12.*"
"o1js": "0.13.*"
}
}
6 changes: 3 additions & 3 deletions zk-states/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zk-states",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"description": "Verifiable state manager for React based on o1js & Mina protocol",
"typesVersions": {
Expand Down Expand Up @@ -75,7 +75,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-vitest": "^0.2.8",
"jsdom": "^22.1.0",
"o1js": "^0.12.1",
"o1js": "^0.13.0",
"prettier": "^3.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -91,7 +91,7 @@
"zustand": "^4.3.9"
},
"peerDependencies": {
"o1js": ">=0.12.1",
"o1js": ">=0.13.0",
"react": ">=18.0.0",
"react-dom": ">=18.0.0",
"zustand": ">=4.3.9"
Expand Down
15 changes: 9 additions & 6 deletions zk-states/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const createZKState = <T extends object>(
workerClient: ZkAppWorkerClient,
createState: StateCreator<T, [], []>,
networkName: MinaNetwork = "berkeley",
appPublicKeyBase58 = "B62qrquKapqyBXxtEBGQTUKLzHeD7xJnxG1qro83HjXhFj7rBiLTuXD",
appPublicKeyBase58 = "B62qnQqrPW5Cx71WavaPjUfUzdx1eEgfnFXEqeQV9m8DKJn3bUW4BF8",
) => {
const useZKStore = create<T & { rollback: (oldState: T) => void }>(
zkImpl(
Expand Down Expand Up @@ -93,7 +93,14 @@ export const createZKState = <T extends object>(

const proof = await workerClient.init(
{ appPublicKey58: appPublicKeyBase58 },
() => {},
(event) => {
switch (event.updateType) {
case "initializationProgress": {
setInitializationProgress(event.status);
break;
}
}
},
(payload) => {
switch (payload.updateType) {
case "latestProof": {
Expand Down Expand Up @@ -121,10 +128,6 @@ export const createZKState = <T extends object>(
setProofFailed(false);
break;
}
case "initializationProgress": {
setInitializationProgress(workerRes.status);
break;
}
}
},
);
Expand Down
5 changes: 3 additions & 2 deletions zk-states/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ interface InititializationProgressUpdate {
}

export type UIUpdate =
| InititializationProgressUpdate
| LatestProofUpdate
| UpdateQueueUpdate
| IsProvingUpdate
Expand All @@ -140,7 +139,9 @@ interface WorkerErrorUpdate {
updateType: "workerError";
}

export type WorkerStateUpdate = WorkerErrorUpdate;
export type WorkerStateUpdate =
| WorkerErrorUpdate
| InititializationProgressUpdate;

export interface TxRes {
transaction: string;
Expand Down
1 change: 0 additions & 1 deletion zk-states/src/zkAppWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
fetchAccountArgsSchema,
initArgsSchema,
setMinaNetworkArgsSchema,
InitializationProgress,
} from "./types";
import { logger } from "./utils";

Expand Down

0 comments on commit 3bd1c15

Please sign in to comment.