diff --git a/CHANGELOG.md b/CHANGELOG.md index d764c6fb32..bd8549a11a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,10 +15,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 _Security_ in case of vulnerabilities. --> -## [Unreleased](https://github.com/o1-labs/snarkyjs/compare/5f20f496...HEAD) +## [Unreleased](https://github.com/o1-labs/snarkyjs/compare/d880bd6e...HEAD) (no unreleased changes yet) +## [0.7.3](https://github.com/o1-labs/snarkyjs/compare/5f20f496...d880bd6e) + +### Fixed + +- Bug in `deploy()` when initializing a contract that already exists https://github.com/o1-labs/snarkyjs/pull/588 + +### Deprecated + +- `Mina.BerkeleyQANet` in favor of the clearer-named `Mina.Network` https://github.com/o1-labs/snarkyjs/pull/588 + ## [0.7.2](https://github.com/o1-labs/snarkyjs/compare/705f58d3...5f20f496) ### Added diff --git a/package-lock.json b/package-lock.json index c2503fc4fa..7977f559e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "snarkyjs", - "version": "0.7.2", + "version": "0.7.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "snarkyjs", - "version": "0.7.2", + "version": "0.7.3", "license": "Apache-2.0", "dependencies": { "env": "^0.0.2", diff --git a/package.json b/package.json index cd3b801f57..f53decf0da 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "snarkyjs", "description": "JavaScript bindings for SnarkyJS", - "version": "0.7.2", + "version": "0.7.3", "license": "Apache-2.0", "type": "module", "main": "./dist/web/index.js", diff --git a/src/examples/simple_zkapp_berkeley.ts b/src/examples/simple_zkapp_berkeley.ts index 1d07ac9ea9..c2cb4cfc38 100644 --- a/src/examples/simple_zkapp_berkeley.ts +++ b/src/examples/simple_zkapp_berkeley.ts @@ -42,9 +42,7 @@ class SimpleZkapp extends SmartContract { } // you can use this with any spec-compliant graphql endpoint -let Berkeley = Mina.BerkeleyQANet( - 'https://proxy.berkeley.minaexplorer.com/graphql' -); +let Berkeley = Mina.Network('https://proxy.berkeley.minaexplorer.com/graphql'); Mina.setActiveInstance(Berkeley); // to use this test, change this private key to an account which has enough MINA to pay fees diff --git a/src/lib/mina.ts b/src/lib/mina.ts index cba8508e65..ea4354422e 100644 --- a/src/lib/mina.ts +++ b/src/lib/mina.ts @@ -33,6 +33,7 @@ import { Types } from 'src/index.js'; export { createTransaction, BerkeleyQANet, + Network, LocalBlockchain, currentTransaction, CurrentTransaction, @@ -546,7 +547,10 @@ function LocalBlockchain({ }; } -function RemoteBlockchain(graphqlEndpoint: string): Mina { +/** + * Represents the Mina blockchain running on a real network + */ +function Network(graphqlEndpoint: string): Mina { let accountCreationFee = UInt64.from(defaultAccountCreationFee); Fetch.setGraphqlEndpoint(graphqlEndpoint); return { @@ -614,17 +618,23 @@ function RemoteBlockchain(graphqlEndpoint: string): Mina { txn.sign(); let [response, error] = await Fetch.sendZkapp(txn.toJSON()); + let errors: any[] | undefined; if (error === undefined) { if (response!.data === null && (response as any).errors?.length > 0) { - console.log('got graphql errors', (response as any).errors); - } else { - console.log('got graphql response', response?.data); + console.log( + 'got graphql errors', + JSON.stringify((response as any).errors, null, 2) + ); + errors = (response as any).errors; } } else { console.log('got fetch error', error); + errors = [error]; } return { + data: response?.data, + errors, async wait() { console.log( 'Info: waiting for inclusion in a block is not implemented yet.' @@ -662,8 +672,13 @@ function RemoteBlockchain(graphqlEndpoint: string): Mina { }; } +/** + * + * @deprecated This is deprecated in favor of {@link Mina.Network}, which is exactly the same function. + * The name `BerkeleyQANet` was misleading because it suggested that this is specific to a particular network. + */ function BerkeleyQANet(graphqlEndpoint: string) { - return RemoteBlockchain(graphqlEndpoint); + return Network(graphqlEndpoint); } let activeInstance: Mina = { diff --git a/src/lib/zkapp.ts b/src/lib/zkapp.ts index fb0e3863e8..4b0f31e445 100644 --- a/src/lib/zkapp.ts +++ b/src/lib/zkapp.ts @@ -720,7 +720,7 @@ class SmartContract { // init if this account is not yet deployed or has no verification key on it let shouldInit = !Mina.hasAccount(this.address) || - Mina.getAccount(this.address).verificationKey !== undefined; + Mina.getAccount(this.address).verificationKey === undefined; if (!shouldInit) return; if (zkappKey) this.init(zkappKey); else this.init();