Skip to content

Commit

Permalink
Clean up deploy and log full errors to the console (#408)
Browse files Browse the repository at this point in the history
Co-authored-by: ymekuria <[email protected]>
  • Loading branch information
mitschabaude and ymekuria authored May 11, 2023
1 parent d940348 commit a405ac2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zkapp-cli",
"version": "0.8.1",
"version": "0.8.2",
"description": "CLI to create a zkApp (\"zero-knowledge app\") for Mina Protocol.",
"keywords": [
"cli",
Expand Down
15 changes: 5 additions & 10 deletions src/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async function deploy({ alias, yes }) {
if (process.platform === 'win32') {
snarkyjsImportPath = 'file://' + snarkyjsImportPath;
}
let { PrivateKey, Mina, Bool } = await import(snarkyjsImportPath);
let { PrivateKey, Mina } = await import(snarkyjsImportPath);

const graphQLUrl = config.deployAliases[alias]?.url ?? DEFAULT_GRAPHQL;

Expand Down Expand Up @@ -268,7 +268,9 @@ async function deploy({ alias, yes }) {
// Attempt to import the private key from the `keys` directory. This private key will be used to deploy the zkApp.
let privateKey;
try {
privateKey = fs.readJSONSync(`${DIR}/${config.deployAliases[alias].keyPath}`).privateKey;
privateKey = fs.readJSONSync(
`${DIR}/${config.deployAliases[alias].keyPath}`
).privateKey;
} catch (_) {
log(
red(
Expand Down Expand Up @@ -360,14 +362,7 @@ async function deploy({ alias, yes }) {
Mina.setActiveInstance(Network);
let tx = await Mina.transaction({ sender: zkAppAddress, fee }, () => {
let zkapp = new zkApp(zkAppAddress);
zkapp.deploy({ verificationKey, zkappKey: zkAppPrivateKey });
// manually patch the tx (TODO: have this implemented properly in snarkyjs)
// remove the nonce precondition
zkapp.self.body.preconditions.account.nonce.isSome = Bool(false);
// don't increment the nonce
zkapp.self.body.incrementNonce = Bool(false);
// use full commitment (means with include the fee payer in the signature, so we're protected against replays)
zkapp.self.body.useFullCommitment = Bool(true);
zkapp.deploy({ verificationKey });
});
return { tx, json: tx.sign([zkAppPrivateKey]).toJSON() };
});
Expand Down
1 change: 1 addition & 0 deletions src/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ async function step(str, fn) {
} catch (err) {
spin.fail(str);
console.error(' ' + red(err)); // maintain expected indentation
console.log(err);
process.exit(1);
}
}
Expand Down

0 comments on commit a405ac2

Please sign in to comment.