Skip to content

Commit c26c803

Browse files
committed
Allow overriding the slot time for lightnet.
1 parent 8f7736e commit c26c803

20 files changed

+829
-750
lines changed

.eslintignore

-4
This file was deleted.

.eslintrc

-26
This file was deleted.

.husky/_/husky.sh

Whitespace-only changes.

.husky/pre-commit

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
npm run lint

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1717

1818
## Unreleased
1919

20-
## [0.22.2](https://github.com/o1-labs/zkapp-cli/compare/v0.22.1...v0.22.2) - 2024-12-1
20+
## [0.22.4](https://github.com/o1-labs/zkapp-cli/compare/v0.22.3...v0.22.4) - 2025-XX-XX
21+
22+
### Added
23+
24+
- Allow overriding the slot time for lightnet. [#TBA](https://github.com/o1-labs/zkapp-cli/pull/TBA)
25+
26+
## [0.22.2](https://github.com/o1-labs/zkapp-cli/compare/v0.22.1...v0.22.2) - 2024-12-01
2127

2228
### Changed
2329

eslint.config.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import js from '@eslint/js';
2+
import prettier from 'eslint-config-prettier';
3+
import globals from 'globals';
4+
import ts from 'typescript-eslint';
5+
6+
export default [
7+
{
8+
ignores: [
9+
'node_modules/',
10+
'build/',
11+
'reports/',
12+
'coverage',
13+
'package-lock.json',
14+
'**/GradientBG.js',
15+
'**/.eslintrc.cjs',
16+
'**/babel.config.cjs',
17+
'**/jest-resolver.cjs',
18+
],
19+
},
20+
js.configs.recommended,
21+
...ts.configs.recommended,
22+
prettier,
23+
{
24+
files: ['**/*.js', '**/*.ts'],
25+
languageOptions: {
26+
globals: {
27+
...globals.browser,
28+
...globals.node,
29+
...globals.jest,
30+
},
31+
},
32+
},
33+
{
34+
rules: {
35+
'@typescript-eslint/no-unused-expressions': 'off',
36+
'@typescript-eslint/no-explicit-any': 'off',
37+
'@typescript-eslint/no-unused-vars': [
38+
'warn',
39+
{ argsIgnorePattern: '^_' },
40+
],
41+
'@typescript-eslint/no-empty-object-type': 'off',
42+
},
43+
},
44+
];

examples/sudoku/ts/src/run.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ await tx.sign([zkAppPrivateKey, senderKey]).send();
4444

4545
console.log('Is the sudoku solved?', zkApp.isSolved.get().toBoolean());
4646

47-
let solution = solveSudoku(sudoku);
47+
const solution = solveSudoku(sudoku);
4848
if (solution === undefined) throw Error('cannot happen');
4949

5050
// submit a wrong solution
51-
let noSolution = cloneSudoku(solution);
51+
const noSolution = cloneSudoku(solution);
5252
noSolution[0][0] = (noSolution[0][0] % 9) + 1;
5353

5454
console.log('Submitting wrong solution...');
5555
try {
56-
let tx = await Mina.transaction(sender, async () => {
56+
const tx = await Mina.transaction(sender, async () => {
5757
await zkApp.submitSolution(Sudoku.from(sudoku), Sudoku.from(noSolution));
5858
});
5959
await tx.prove();

examples/sudoku/ts/src/sudoku.test.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('sudoku', () => {
1111
senderKey: PrivateKey;
1212

1313
beforeEach(async () => {
14-
let Local = await Mina.LocalBlockchain({ proofsEnabled: false });
14+
const Local = await Mina.LocalBlockchain({ proofsEnabled: false });
1515
Mina.setActiveInstance(Local);
1616
sender = Local.testAccounts[0];
1717
senderKey = sender.key;
@@ -27,10 +27,10 @@ describe('sudoku', () => {
2727
let isSolved = zkApp.isSolved.get().toBoolean();
2828
expect(isSolved).toBe(false);
2929

30-
let solution = solveSudoku(sudoku);
30+
const solution = solveSudoku(sudoku);
3131
if (solution === undefined) throw Error('cannot happen');
32-
let tx = await Mina.transaction(sender, async () => {
33-
let zkApp = new SudokuZkApp(zkAppAddress);
32+
const tx = await Mina.transaction(sender, async () => {
33+
const zkApp = new SudokuZkApp(zkAppAddress);
3434
await zkApp.submitSolution(Sudoku.from(sudoku), Sudoku.from(solution!));
3535
});
3636
await tx.prove();
@@ -43,15 +43,15 @@ describe('sudoku', () => {
4343
it('rejects an incorrect solution', async () => {
4444
await deploy(zkApp, zkAppPrivateKey, sudoku, sender, senderKey);
4545

46-
let solution = solveSudoku(sudoku);
46+
const solution = solveSudoku(sudoku);
4747
if (solution === undefined) throw Error('cannot happen');
4848

49-
let noSolution = cloneSudoku(solution);
49+
const noSolution = cloneSudoku(solution);
5050
noSolution[0][0] = (noSolution[0][0] % 9) + 1;
5151

5252
await expect(async () => {
53-
let tx = await Mina.transaction(sender, async () => {
54-
let zkApp = new SudokuZkApp(zkAppAddress);
53+
const tx = await Mina.transaction(sender, async () => {
54+
const zkApp = new SudokuZkApp(zkAppAddress);
5555
await zkApp.submitSolution(
5656
Sudoku.from(sudoku),
5757
Sudoku.from(noSolution)
@@ -61,7 +61,7 @@ describe('sudoku', () => {
6161
await tx.sign([senderKey]).send();
6262
}).rejects.toThrow(/array contains the numbers 1...9/);
6363

64-
let isSolved = zkApp.isSolved.get().toBoolean();
64+
const isSolved = zkApp.isSolved.get().toBoolean();
6565
expect(isSolved).toBe(false);
6666
});
6767
});
@@ -73,7 +73,7 @@ async function deploy(
7373
sender: PublicKey,
7474
senderKey: PrivateKey
7575
) {
76-
let tx = await Mina.transaction(sender, async () => {
76+
const tx = await Mina.transaction(sender, async () => {
7777
AccountUpdate.fundNewAccount(sender);
7878
await zkApp.deploy();
7979
await zkApp.update(Sudoku.from(sudoku));

examples/sudoku/ts/src/sudoku.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ class SudokuZkApp extends SmartContract {
4747
sudokuInstance: Sudoku,
4848
solutionInstance: Sudoku
4949
) {
50-
let sudoku = sudokuInstance.value;
51-
let solution = solutionInstance.value;
50+
const sudoku = sudokuInstance.value;
51+
const solution = solutionInstance.value;
5252

5353
// first, we check that the passed solution is a valid sudoku
5454

5555
// define helpers
56-
let range9 = Array.from({ length: 9 }, (_, i) => i);
57-
let oneTo9 = range9.map((i) => Field(i + 1));
56+
const range9 = Array.from({ length: 9 }, (_, i) => i);
57+
const oneTo9 = range9.map((i) => Field(i + 1));
5858

5959
function assertHas1To9(array: Field[]) {
6060
oneTo9
@@ -65,19 +65,19 @@ class SudokuZkApp extends SmartContract {
6565

6666
// check all rows
6767
for (let i = 0; i < 9; i++) {
68-
let row = solution[i];
68+
const row = solution[i];
6969
assertHas1To9(row);
7070
}
7171
// check all columns
7272
for (let j = 0; j < 9; j++) {
73-
let column = solution.map((row) => row[j]);
73+
const column = solution.map((row) => row[j]);
7474
assertHas1To9(column);
7575
}
7676
// check 3x3 squares
7777
for (let k = 0; k < 9; k++) {
78-
let [i0, j0] = divmod(k, 3);
79-
let square = range9.map((m) => {
80-
let [i1, j1] = divmod(m, 3);
78+
const [i0, j0] = divmod(k, 3);
79+
const square = range9.map((m) => {
80+
const [i1, j1] = divmod(m, 3);
8181
return solution[3 * i0 + i1][3 * j0 + j1];
8282
});
8383
assertHas1To9(square);
@@ -86,8 +86,8 @@ class SudokuZkApp extends SmartContract {
8686
// next, we check that the solution extends the initial sudoku
8787
for (let i = 0; i < 9; i++) {
8888
for (let j = 0; j < 9; j++) {
89-
let cell = sudoku[i][j];
90-
let solutionCell = solution[i][j];
89+
const cell = sudoku[i][j];
90+
const solutionCell = solution[i][j];
9191
// either the sudoku has nothing in it (indicated by a cell value of 0),
9292
// or it is equal to the solution
9393
Bool.or(cell.equals(0), cell.equals(solutionCell)).assertTrue(
@@ -97,7 +97,7 @@ class SudokuZkApp extends SmartContract {
9797
}
9898

9999
// finally, we check that the sudoku is the one that was originally deployed
100-
let sudokuHash = this.sudokuHash.getAndRequireEquals();
100+
const sudokuHash = this.sudokuHash.getAndRequireEquals();
101101

102102
sudokuInstance
103103
.hash()
@@ -109,6 +109,6 @@ class SudokuZkApp extends SmartContract {
109109
}
110110

111111
function divmod(k: number, n: number) {
112-
let q = Math.floor(k / n);
112+
const q = Math.floor(k / n);
113113
return [q, k - q * n];
114114
}

examples/tictactoe/ts/src/run.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from 'o1js';
2121
import { TicTacToe, Board } from './tictactoe.js';
2222

23-
let Local = await Mina.LocalBlockchain({ proofsEnabled: false });
23+
const Local = await Mina.LocalBlockchain({ proofsEnabled: false });
2424
Mina.setActiveInstance(Local);
2525
const [player1, player2] = Local.testAccounts;
2626
const player1Key = player1.key;
@@ -52,7 +52,7 @@ console.log('after transaction');
5252
let b = zkApp.board.get();
5353

5454
console.log('initial state of the zkApp');
55-
let zkAppState = Mina.getAccount(zkAppPublicKey);
55+
const zkAppState = Mina.getAccount(zkAppPublicKey);
5656

5757
for (const i in [0, 1, 2, 3, 4, 5, 6, 7]) {
5858
console.log('state', i, ':', zkAppState?.zkapp?.appState?.[i].toString());
@@ -99,7 +99,7 @@ await makeMove(player1, player1Key, 2, 2);
9999
b = zkApp.board.get();
100100
new Board(b).printState();
101101

102-
let isNextPlayer2 = zkApp.nextIsPlayer2.get();
102+
const isNextPlayer2 = zkApp.nextIsPlayer2.get();
103103

104104
console.log('did someone win?', isNextPlayer2 ? 'Player 1!' : 'Player 2!');
105105
// cleanup

examples/tictactoe/ts/src/tictactoe.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('tictactoe', () => {
1717
zkAppPrivateKey: PrivateKey;
1818

1919
beforeEach(async () => {
20-
let Local = await Mina.LocalBlockchain({ proofsEnabled: false });
20+
const Local = await Mina.LocalBlockchain({ proofsEnabled: false });
2121
Mina.setActiveInstance(Local);
2222

2323
[player1, player2] = Local.testAccounts;
@@ -62,7 +62,7 @@ describe('tictactoe', () => {
6262
await txn.sign([player1Key]).send();
6363

6464
// check next player
65-
let isNextPlayer2 = zkApp.nextIsPlayer2.get();
65+
const isNextPlayer2 = zkApp.nextIsPlayer2.get();
6666
expect(isNextPlayer2).toEqual(Bool(true));
6767
});
6868
});

examples/tictactoe/ts/src/tictactoe.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class Board {
3636

3737
constructor(serializedBoard: Field) {
3838
const bits = serializedBoard.toBits(18);
39-
let board = [];
39+
const board = [];
4040
for (let i = 0; i < 3; i++) {
41-
let row = [];
41+
const row = [];
4242
for (let j = 0; j < 3; j++) {
4343
const isPlayed = bits[i * 3 + j];
4444
const player = bits[i * 3 + j + 9];
@@ -50,8 +50,8 @@ class Board {
5050
}
5151

5252
serialize(): Field {
53-
let isPlayed = [];
54-
let player = [];
53+
const isPlayed = [];
54+
const player = [];
5555
for (let i = 0; i < 3; i++) {
5656
for (let j = 0; j < 3; j++) {
5757
isPlayed.push(this.board[i][j].isSome);
@@ -211,7 +211,7 @@ class TicTacToe extends SmartContract {
211211

212212
// 4. get and deserialize the board
213213
this.board.requireEquals(this.board.get()); // precondition that links this.board.get() to the actual on-chain state
214-
let board = new Board(this.board.get());
214+
const board = new Board(this.board.get());
215215

216216
// 5. update the board (and the state) with our move
217217
x.equals(Field(0))

0 commit comments

Comments
 (0)