Skip to content

Commit

Permalink
Merge pull request #681 from o1-labs/rename-assertions-fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Trivo25 committed Jan 18, 2023
2 parents 60f6bb8 + 02eb9d9 commit 7b2d719
Show file tree
Hide file tree
Showing 18 changed files with 86,265 additions and 85,525 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `AccountUpdate.fundNewAccount()` now enables funding multiple accounts at once, and deprecates the `initialBalance` argument
- New option `enforceTransactionLimits` for `LocalBlockchain` (default value: `true`), to disable the enforcement of protocol transaction limits (maximum events, maximum sequence events and enforcing certain layout of `AccountUpdate`s depending on their authorization) https://github.com/o1-labs/snarkyjs/pull/620
- Change the default `send` permissions (for sending MINA or tokens) that get set when deploying a zkApp, from `signature()` to `proof()` https://github.com/o1-labs/snarkyjs/pull/648
- Functions for making assertions and comparisons have been renamed to their long form, instead of the initial abbreviation. Old function names have been deprecated https://github.com/o1-labs/snarkyjs/pull/681
- `.lt` -> `.lessThan`
- `.lte` -> `.lessThanOrEqual`
- `.gt` -> `.greaterThan`
- `.gte` -> `greaterThanOrEqual`
- `.assertLt` -> `.assertLessThan`
- `.assertLte` -> `.assertLessThanOrEqual`
- `.assertGt` -> `.assertGreaterThan`
- `.assertGte` -> `assertGreaterThanOrEqual`
- `.assertBoolean` -> `.assertBool`

### Deprecated

Expand All @@ -50,6 +60,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `this.setValue()` in favor of `this.account.<field>.set()`
- `Mina.transaction(privateKey: PrivateKey, ...)` in favor of new signature `Mina.transaction(publicKey: PublicKey, ...)`
- `AccountUpdate.createSigned(privateKey: PrivateKey)` in favor of new signature `AccountUpdate.createSigned(publicKey: PublicKey)` https://github.com/o1-labs/snarkyjs/pull/637
- `.lt`, `.lte`, `gt`, `gte`, `.assertLt`, `.assertLte`, `.assertGt`, `.assertGte` have been deprecated. https://github.com/o1-labs/snarkyjs/pull/681

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion src/examples/simple_zkapp_berkeley.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SimpleZkapp extends SmartContract {
@method update(y: Field) {
let x = this.x.get();
this.x.assertEquals(x);
y.assertGt(0);
y.assertGreaterThan(0);
this.x.set(x.add(y));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/examples/zkapps/voting/membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export class Membership_ extends SmartContract {

let balance = accountUpdate.account.balance.get();

balance.assertGte(participantPreconditions.minMina);
balance.assertLte(participantPreconditions.maxMina);
balance.assertGreaterThanOrEqual(participantPreconditions.minMina);
balance.assertLessThanOrEqual(participantPreconditions.maxMina);

let accumulatedMembers = this.accumulatedMembers.get();
this.accumulatedMembers.assertEquals(accumulatedMembers);
Expand Down
16 changes: 8 additions & 8 deletions src/examples/zkapps/voting/voting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class Voting_ extends SmartContract {
this.network.globalSlotSinceGenesis.assertEquals(currentSlot);

// can only register voters before the election has started
currentSlot.assertLte(electionPreconditions.startElection);
currentSlot.assertLessThanOrEqual(electionPreconditions.startElection);

// can only register voters if their balance is gte the minimum amount required
// this snippet pulls the account data of an address from the network
Expand All @@ -126,8 +126,8 @@ export class Voting_ extends SmartContract {

let balance = accountUpdate.account.balance.get();

balance.assertGte(voterPreconditions.minMina);
balance.assertLte(voterPreconditions.maxMina);
balance.assertGreaterThanOrEqual(voterPreconditions.minMina);
balance.assertLessThanOrEqual(voterPreconditions.maxMina);

let VoterContract: Membership_ = new Membership_(voterAddress);
let exists = VoterContract.addEntry(member);
Expand All @@ -149,7 +149,7 @@ export class Voting_ extends SmartContract {
this.network.globalSlotSinceGenesis.assertEquals(currentSlot);

// can only register candidates before the election has started
currentSlot.assertLte(electionPreconditions.startElection);
currentSlot.assertLessThanOrEqual(electionPreconditions.startElection);

// can only register candidates if their balance is gte the minimum amount required
// and lte the maximum amount
Expand All @@ -165,8 +165,8 @@ export class Voting_ extends SmartContract {

let balance = accountUpdate.account.balance.get();

balance.assertGte(candidatePreconditions.minMina);
balance.assertLte(candidatePreconditions.maxMina);
balance.assertGreaterThanOrEqual(candidatePreconditions.minMina);
balance.assertLessThanOrEqual(candidatePreconditions.maxMina);

let CandidateContract: Membership_ = new Membership_(candidateAddress);
let exists = CandidateContract.addEntry(member);
Expand Down Expand Up @@ -204,8 +204,8 @@ export class Voting_ extends SmartContract {

// we can only vote in the election period time frame
currentSlot
.gte(electionPreconditions.startElection)
.and(currentSlot.lte(electionPreconditions.endElection))
.greaterThanOrEqual(electionPreconditions.startElection)
.and(currentSlot.lessThanOrEqual(electionPreconditions.endElection))
.assertTrue();

// verifying that both the voter and the candidate are actually part of our member set
Expand Down
Loading

0 comments on commit 7b2d719

Please sign in to comment.