Skip to content

Commit

Permalink
Merge branch 'main' into feature/improve-web-worker-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ymekuria committed Sep 23, 2024
2 parents f1331dd + ece2e8b commit ed01873
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions examples/zkapps/01-hello-world/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": 1,
"networks": {}
}
"deployAliases": {}
}
2 changes: 2 additions & 0 deletions examples/zkapps/01-hello-world/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const zkAppAddress = zkAppPrivateKey.toPublicKey();
// create an instance of Square - and deploy it to zkAppAddress
const zkAppInstance = new Square(zkAppAddress);
const deployTxn = await Mina.transaction(deployerAccount, async () => {
// 1 Mina fee is required to create a new account for the zkApp
// This line means the deployer account will pay the fee for any account created in this transaction
AccountUpdate.fundNewAccount(deployerAccount);
await zkAppInstance.deploy();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": 1,
"networks": {}
}
"deployAliases": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const zkAppAddress = zkAppPrivateKey.toPublicKey();

const zkAppInstance = new IncrementSecret(zkAppAddress);
const deployTxn = await Mina.transaction(deployerAccount, async () => {
// 1 Mina fee is required to create a new account for the zkApp
// This line means the deployer account will pay the fee for any account created in this transaction
AccountUpdate.fundNewAccount(deployerAccount);
await zkAppInstance.deploy();
await zkAppInstance.initState(salt, Field(750));
Expand Down
2 changes: 1 addition & 1 deletion examples/zkapps/04-zkapp-browser-ui/contracts/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": 1,
"deployAliases": {}
}
}
4 changes: 2 additions & 2 deletions examples/zkapps/05-common-types-and-functions/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": 1,
"networks": {}
}
"deployAliases": {}
}
2 changes: 2 additions & 0 deletions examples/zkapps/05-common-types-and-functions/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ const senderPrivateKey = senderPublicKey.key;

// deploy the smart contract
const deployTxn = await Mina.transaction(deployerAccount, async () => {
// 1 Mina fee is required to create a new account for the zkApp
// This line means the deployer account will pay the fee for any account created in this transaction
AccountUpdate.fundNewAccount(deployerAccount);
await zkApp.deploy();
// get the root of the new tree to use as the initial tree root
Expand Down
2 changes: 1 addition & 1 deletion examples/zkapps/07-oracles/contracts/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": 1,
"deployAliases": {}
}
}
4 changes: 2 additions & 2 deletions examples/zkapps/09-recursion/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": 1,
"networks": {}
}
"deployAliases": {}
}
12 changes: 4 additions & 8 deletions examples/zkapps/10-account-updates/src/ProofsOnlyZkApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ export class ProofsOnlyZkApp extends SmartContract {
}

@method async init() {
this.account.provedState.getAndRequireEquals();
this.account.provedState.get().assertFalse();
this.account.provedState.getAndRequireEquals().assertFalse();

super.init();
this.num.set(Field(1));
this.calls.set(Field(0));
}

@method async add(incrementBy: Field) {
this.account.provedState.getAndRequireEquals();
this.account.provedState.get().assertTrue();
this.account.provedState.getAndRequireEquals().assertTrue();

const num = this.num.getAndRequireEquals();
this.num.set(num.add(incrementBy));
Expand All @@ -53,16 +51,14 @@ export class ProofsOnlyZkApp extends SmartContract {
}

@method async incrementCalls() {
this.account.provedState.getAndRequireEquals();
this.account.provedState.get().assertTrue();
this.account.provedState.getAndRequireEquals().assertTrue();

const calls = this.calls.getAndRequireEquals();
this.calls.set(calls.add(Field(1)));
}

@method async callSecondary(secondaryAddr: PublicKey) {
this.account.provedState.getAndRequireEquals();
this.account.provedState.get().assertTrue();
this.account.provedState.getAndRequireEquals().assertTrue();

const secondaryContract = new SecondaryZkApp(secondaryAddr);
const num = this.num.getAndRequireEquals();
Expand Down
10 changes: 5 additions & 5 deletions examples/zkapps/anonymous-message-board/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ export class Message extends SmartContract {
const signerPublicKey = signerPrivateKey.toPublicKey();

// Get approved public keys
const user1 = this.user1.get();
const user2 = this.user2.get();
const user3 = this.user3.get();
const user1 = this.user1.getAndRequireEquals();
const user2 = this.user2.getAndRequireEquals();
const user3 = this.user3.getAndRequireEquals();

// Assert that signerPublicKey is one of the approved public keys
signerPublicKey
.equals(user1)
.or(signerPublicKey.equals(user2))
.or(signerPublicKey.equals(user3))
.assertEquals(true);
.assertTrue();

// Update on-chain message state
this.message.set(message);

// Compute new messageHistoryHash
const oldHash = this.messageHistoryHash.get();
const oldHash = this.messageHistoryHash.getAndRequireEquals();
const newHash = Poseidon.hash([message, oldHash]);

// Update on-chain messageHistoryHash
Expand Down

0 comments on commit ed01873

Please sign in to comment.