Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename assertions to long form #681

Merged
merged 15 commits into from
Jan 18, 2023
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