Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
45930 committed Sep 18, 2024
1 parent b29bb90 commit 05cb9b4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
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
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: 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
6 changes: 1 addition & 5 deletions examples/zkapps/10-account-updates/src/ProofsOnlyZkApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ 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));
Expand All @@ -44,7 +43,6 @@ export class ProofsOnlyZkApp extends SmartContract {

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

const num = this.num.getAndRequireEquals();
this.num.set(num.add(incrementBy));
Expand All @@ -54,15 +52,13 @@ export class ProofsOnlyZkApp extends SmartContract {

@method async incrementCalls() {
this.account.provedState.getAndRequireEquals();
this.account.provedState.get().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();

const secondaryContract = new SecondaryZkApp(secondaryAddr);
const num = this.num.getAndRequireEquals();
Expand Down
4 changes: 2 additions & 2 deletions examples/zkapps/anonymous-message-board/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ export class Message extends SmartContract {
.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 05cb9b4

Please sign in to comment.