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

Improve error handling when smart contract is not found #586

Merged
merged 15 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Unreleased

### Changed

- Improve error handling when imported smart contract is not found. [#586](https://github.com/o1-labs/zkapp-cli/pull/586)

## [0.17.1](https://github.com/o1-labs/zkapp-cli/compare/v17.0...v17.1) - 2024-02-17

### Changed

- Improve error handling for zk deploy when feepayer has insufficient permissions. [#580](https://github.com/o1-labs/zkapp-cli/pull/580)
- Update `getCachedFeepayerAliases()` logic to prevent edge case bugs. [#581](https://github.com/o1-labs/zkapp-cli/pull/581)

- Improve error handling for zk deploy when fee payer has insufficient permissions. [#580](https://github.com/o1-labs/zkapp-cli/pull/580)

- Automate "zk config" if Lightnet is in use. [#579](https://github.com/o1-labs/zkapp-cli/pull/579)
- The `--lightnet` option was added to `zk config` in order to automatically configures zkApp project's deploy aliases.
- The [Lightnet](https://docs.minaprotocol.com/zkapps/testing-zkapps-lightnet) should be up and running before executing the `zk config --lightnet` command.
Expand Down
25 changes: 7 additions & 18 deletions src/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,29 +239,18 @@ export async function deploy({ alias, yes }) {
contractName
);

let smartContractImports;
try {
let smartContractImportPath = `${projectRoot}/build/src/${smartContractFile}`;
if (process.platform === 'win32') {
smartContractImportPath = 'file://' + smartContractImportPath;
}
smartContractImports = await import(smartContractImportPath);
} catch (_) {
log(
chalk.red(
` Failed to find the "${contractName}" smart contract in your build directory.\n Please confirm that your config.json contains the name of the smart contract that you want to deploy to this deploy alias.`
)
);

process.exit(1);
let smartContractImportPath = `${projectRoot}/build/src/${smartContractFile}`;
if (process.platform === 'win32') {
smartContractImportPath = 'file://' + smartContractImportPath;
}

// Attempt to import the smart contract class to deploy from the user's file.
const smartContractImports = await import(smartContractImportPath);

// If we cannot find the named export log an error message and return early.
if (!(contractName in smartContractImports)) {
if (smartContractImports && !(contractName in smartContractImports)) {
log(
chalk.red(
` Failed to find the "${contractName}" smart contract in your build directory.\n Check that you have exported your smart contract class using a named export and try again.`
` Failed to find the "${contractName}" smart contract in your build directory.\n Please confirm that your config.json contains the name of the smart \n contract that you want to deploy using this deploy alias, check that\n you have exported your smart contract class using a named export and try again.`
)
);

Expand Down
Loading