Skip to content

Commit

Permalink
Release 0.19.0 (#606)
Browse files Browse the repository at this point in the history
Co-authored-by: Serhii Shymkiv <[email protected]>
  • Loading branch information
ymekuria and shimkiv authored Apr 9, 2024
1 parent 1f2e2dd commit 4d6b933
Show file tree
Hide file tree
Showing 18 changed files with 1,879 additions and 6,518 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Unreleased

## [0.19.0](https://github.com/o1-labs/zkapp-cli/compare/v18.0...v19.0) - 2024-03-06

### Breaking changes

- The CLI, templates, and examples have been updated to be compatible with the latest version `0.18.0` of `o1js` that was released to be compatible with the `Devnet` upgrade. This includes updating all code with async circuits, and removing all deprecated APIs. [#606](https://github.com/o1-labs/zkapp-cli/pull/606)

### Changed

- Add support to deploy smart contracts that verify ZkProgram proofs. [#547](https://github.com/o1-labs/zkapp-cli/pull/547)
Expand Down
14 changes: 7 additions & 7 deletions examples/sudoku/ts/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const zkApp = new SudokuZkApp(zkAppAddress);

console.log('Deploying and initializing Sudoku...');
await SudokuZkApp.compile();
let tx = await Mina.transaction(sender, () => {
let tx = await Mina.transaction(sender, async () => {
AccountUpdate.fundNewAccount(sender);
zkApp.deploy();
zkApp.update(Sudoku.from(sudoku));
await zkApp.deploy();
await zkApp.update(Sudoku.from(sudoku));
});
await tx.prove();
/**
Expand All @@ -52,8 +52,8 @@ noSolution[0][0] = (noSolution[0][0] % 9) + 1;

console.log('Submitting wrong solution...');
try {
let tx = await Mina.transaction(sender, () => {
zkApp.submitSolution(Sudoku.from(sudoku), Sudoku.from(noSolution));
let tx = await Mina.transaction(sender, async () => {
await zkApp.submitSolution(Sudoku.from(sudoku), Sudoku.from(noSolution));
});
await tx.prove();
await tx.sign([senderKey]).send();
Expand All @@ -65,8 +65,8 @@ console.log('Is the sudoku solved?', zkApp.isSolved.get().toBoolean());

// submit the actual solution
console.log('Submitting solution...');
tx = await Mina.transaction(sender, () => {
zkApp.submitSolution(Sudoku.from(sudoku), Sudoku.from(solution!));
tx = await Mina.transaction(sender, async () => {
await zkApp.submitSolution(Sudoku.from(sudoku), Sudoku.from(solution!));
});
await tx.prove();
await tx.sign([senderKey]).send();
Expand Down
17 changes: 10 additions & 7 deletions examples/sudoku/ts/src/sudoku.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ describe('sudoku', () => {

let solution = solveSudoku(sudoku);
if (solution === undefined) throw Error('cannot happen');
let tx = await Mina.transaction(sender, () => {
let tx = await Mina.transaction(sender, async () => {
let zkApp = new SudokuZkApp(zkAppAddress);
zkApp.submitSolution(Sudoku.from(sudoku), Sudoku.from(solution!));
await zkApp.submitSolution(Sudoku.from(sudoku), Sudoku.from(solution!));
});
await tx.prove();
await tx.sign([senderKey]).send();
Expand All @@ -50,9 +50,12 @@ describe('sudoku', () => {
noSolution[0][0] = (noSolution[0][0] % 9) + 1;

await expect(async () => {
let tx = await Mina.transaction(sender, () => {
let tx = await Mina.transaction(sender, async () => {
let zkApp = new SudokuZkApp(zkAppAddress);
zkApp.submitSolution(Sudoku.from(sudoku), Sudoku.from(noSolution));
await zkApp.submitSolution(
Sudoku.from(sudoku),
Sudoku.from(noSolution)
);
});
await tx.prove();
await tx.sign([senderKey]).send();
Expand All @@ -70,10 +73,10 @@ async function deploy(
sender: PublicKey,
senderKey: PrivateKey
) {
let tx = await Mina.transaction(sender, () => {
let tx = await Mina.transaction(sender, async () => {
AccountUpdate.fundNewAccount(sender);
zkApp.deploy();
zkApp.update(Sudoku.from(sudoku));
await zkApp.deploy();
await zkApp.update(Sudoku.from(sudoku));
});
await tx.prove();
// this tx needs .sign(), because `deploy()` adds an account update that requires signature authorization
Expand Down
9 changes: 6 additions & 3 deletions examples/sudoku/ts/src/sudoku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ class SudokuZkApp extends SmartContract {
* to ensure the entire state is overwritten.
* however, it's good to have an example which tests the CLI's ability to handle init() decorated with `@method`.
*/
@method init() {
@method async init() {
super.init();
}

@method update(sudokuInstance: Sudoku) {
@method async update(sudokuInstance: Sudoku) {
this.sudokuHash.set(sudokuInstance.hash());
this.isSolved.set(Bool(false));
}

@method submitSolution(sudokuInstance: Sudoku, solutionInstance: Sudoku) {
@method async submitSolution(
sudokuInstance: Sudoku,
solutionInstance: Sudoku
) {
let sudoku = sudokuInstance.value;
let solution = solutionInstance.value;

Expand Down
8 changes: 4 additions & 4 deletions examples/tictactoe/ts/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const zkApp = new TicTacToe(zkAppPublicKey);

// Create a new instance of the contract
console.log('\n\n====== DEPLOYING ======\n\n');
const txn = await Mina.transaction(player1, () => {
const txn = await Mina.transaction(player1, async () => {
AccountUpdate.fundNewAccount(player1);
zkApp.deploy();
zkApp.startGame(player1, player2);
await zkApp.deploy();
await zkApp.startGame(player1, player2);
});
await txn.prove();
/**
Expand Down Expand Up @@ -115,7 +115,7 @@ async function makeMove(
const [x, y] = [Field(x0), Field(y0)];
const txn = await Mina.transaction(currentPlayer, async () => {
const signature = Signature.create(currentPlayerKey, [x, y]);
zkApp.play(currentPlayer, signature, x, y);
await zkApp.play(currentPlayer, signature, x, y);
});
await txn.prove();
await txn.sign([currentPlayerKey]).send();
Expand Down
12 changes: 6 additions & 6 deletions examples/tictactoe/ts/src/tictactoe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ describe('tictactoe', () => {

it('generates and deploys tictactoe', async () => {
const zkApp = new TicTacToe(zkAppAddress);
const txn = await Mina.transaction(player1, () => {
const txn = await Mina.transaction(player1, async () => {
AccountUpdate.fundNewAccount(player1);
zkApp.deploy();
zkApp.startGame(player1, player2);
await zkApp.deploy();
await zkApp.startGame(player1, player2);
});
await txn.prove();
await txn.sign([zkAppPrivateKey, player1Key]).send();
Expand All @@ -42,10 +42,10 @@ describe('tictactoe', () => {
const zkApp = new TicTacToe(zkAppAddress);

// deploy
let txn = await Mina.transaction(player1, () => {
let txn = await Mina.transaction(player1, async () => {
AccountUpdate.fundNewAccount(player1);
zkApp.deploy();
zkApp.startGame(player1, player2);
await zkApp.deploy();
await zkApp.startGame(player1, player2);
});
await txn.prove();
await txn.sign([zkAppPrivateKey, player1Key]).send();
Expand Down
9 changes: 7 additions & 2 deletions examples/tictactoe/ts/src/tictactoe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class TicTacToe extends SmartContract {
this.player2.set(PublicKey.empty());
}

@method startGame(player1: PublicKey, player2: PublicKey) {
@method async startGame(player1: PublicKey, player2: PublicKey) {
// you can only start a new game if the current game is done
this.gameDone.requireEquals(Bool(true));
this.gameDone.set(Bool(false));
Expand All @@ -176,7 +176,12 @@ class TicTacToe extends SmartContract {
// 0 | x x x
// 1 | x x x
// 2 | x x x
@method play(pubkey: PublicKey, signature: Signature, x: Field, y: Field) {
@method async play(
pubkey: PublicKey,
signature: Signature,
x: Field,
y: Field
) {
// 1. if the game is already finished, abort.
this.gameDone.requireEquals(Bool(false)); // precondition on this.gameDone

Expand Down
Loading

0 comments on commit 4d6b933

Please sign in to comment.