Skip to content

Commit ece2e8b

Browse files
authored
Minor fixes - Dev feedback
Minor fixes - Dev feedback
2 parents e184aee + c5758da commit ece2e8b

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

examples/zkapps/01-hello-world/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const zkAppAddress = zkAppPrivateKey.toPublicKey();
1919
// create an instance of Square - and deploy it to zkAppAddress
2020
const zkAppInstance = new Square(zkAppAddress);
2121
const deployTxn = await Mina.transaction(deployerAccount, async () => {
22+
// 1 Mina fee is required to create a new account for the zkApp
23+
// This line means the deployer account will pay the fee for any account created in this transaction
2224
AccountUpdate.fundNewAccount(deployerAccount);
2325
await zkAppInstance.deploy();
2426
});

examples/zkapps/02-private-inputs-and-hash-functions/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const zkAppAddress = zkAppPrivateKey.toPublicKey();
2020

2121
const zkAppInstance = new IncrementSecret(zkAppAddress);
2222
const deployTxn = await Mina.transaction(deployerAccount, async () => {
23+
// 1 Mina fee is required to create a new account for the zkApp
24+
// This line means the deployer account will pay the fee for any account created in this transaction
2325
AccountUpdate.fundNewAccount(deployerAccount);
2426
await zkAppInstance.deploy();
2527
await zkAppInstance.initState(salt, Field(750));

examples/zkapps/05-common-types-and-functions/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ const senderPrivateKey = senderPublicKey.key;
179179

180180
// deploy the smart contract
181181
const deployTxn = await Mina.transaction(deployerAccount, async () => {
182+
// 1 Mina fee is required to create a new account for the zkApp
183+
// This line means the deployer account will pay the fee for any account created in this transaction
182184
AccountUpdate.fundNewAccount(deployerAccount);
183185
await zkApp.deploy();
184186
// get the root of the new tree to use as the initial tree root

examples/zkapps/10-account-updates/src/ProofsOnlyZkApp.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,15 @@ export class ProofsOnlyZkApp extends SmartContract {
3434
}
3535

3636
@method async init() {
37-
this.account.provedState.getAndRequireEquals();
38-
this.account.provedState.get().assertFalse();
37+
this.account.provedState.getAndRequireEquals().assertFalse();
3938

4039
super.init();
4140
this.num.set(Field(1));
4241
this.calls.set(Field(0));
4342
}
4443

4544
@method async add(incrementBy: Field) {
46-
this.account.provedState.getAndRequireEquals();
47-
this.account.provedState.get().assertTrue();
45+
this.account.provedState.getAndRequireEquals().assertTrue();
4846

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

5553
@method async incrementCalls() {
56-
this.account.provedState.getAndRequireEquals();
57-
this.account.provedState.get().assertTrue();
54+
this.account.provedState.getAndRequireEquals().assertTrue();
5855

5956
const calls = this.calls.getAndRequireEquals();
6057
this.calls.set(calls.add(Field(1)));
6158
}
6259

6360
@method async callSecondary(secondaryAddr: PublicKey) {
64-
this.account.provedState.getAndRequireEquals();
65-
this.account.provedState.get().assertTrue();
61+
this.account.provedState.getAndRequireEquals().assertTrue();
6662

6763
const secondaryContract = new SecondaryZkApp(secondaryAddr);
6864
const num = this.num.getAndRequireEquals();

examples/zkapps/anonymous-message-board/src/message.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ export class Message extends SmartContract {
5353
const signerPublicKey = signerPrivateKey.toPublicKey();
5454

5555
// Get approved public keys
56-
const user1 = this.user1.get();
57-
const user2 = this.user2.get();
58-
const user3 = this.user3.get();
56+
const user1 = this.user1.getAndRequireEquals();
57+
const user2 = this.user2.getAndRequireEquals();
58+
const user3 = this.user3.getAndRequireEquals();
5959

6060
// Assert that signerPublicKey is one of the approved public keys
6161
signerPublicKey
6262
.equals(user1)
6363
.or(signerPublicKey.equals(user2))
6464
.or(signerPublicKey.equals(user3))
65-
.assertEquals(true);
65+
.assertTrue();
6666

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

7070
// Compute new messageHistoryHash
71-
const oldHash = this.messageHistoryHash.get();
71+
const oldHash = this.messageHistoryHash.getAndRequireEquals();
7272
const newHash = Poseidon.hash([message, oldHash]);
7373

7474
// Update on-chain messageHistoryHash

0 commit comments

Comments
 (0)