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

Deploy a smart contract within a folder #593

Open
iam-dev opened this issue Feb 23, 2024 · 5 comments
Open

Deploy a smart contract within a folder #593

iam-dev opened this issue Feb 23, 2024 · 5 comments

Comments

@iam-dev
Copy link

iam-dev commented Feb 23, 2024

Describe the bug

I'm trying to deploy a smart contract within a folder.
Folder structure:

  • src
    -- guardians
    --- GuardianZkApp.ts

Command:


zk deploy               
✔ Which deploy alias do you want to deploy to? · berkeley
✔ Build project
✔ Generate build.json
✔ Choose smart contract to deploy · GuardianZkApp
  Your config.json was updated to always use this
  smart contract when deploying to this deploy alias.

Error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '../build/src/GuardianZkApp.js' imported from /../.nvm/versions/node/v20.11.0/lib/node_modules/zkapp-cli/src/lib/deploy.js
  at finalizeResolution (node:internal/modules/esm/resolve:264:11)
  at moduleResolve (node:internal/modules/esm/resolve:917:10)
  at defaultResolve (node:internal/modules/esm/resolve:1130:11)
  at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
  at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
  at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
  at ModuleLoader.import (node:internal/modules/esm/loader:328:34)
  at importModuleDynamically (node:internal/modules/esm/translators:158:35)
  at importModuleDynamicallyCallback (node:internal/modules/esm/utils:207:14)
  at deploy (file:///Users/iamdev/.nvm/versions/node/v20.11.0/lib/node_modules/zkapp-cli/src/lib/deploy.js:247:32)
  at async Object.handler (file:///../.nvm/versions/node/v20.11.0/lib/node_modules/zkapp-cli/src/bin/index.js:127:21) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///../build/src/GuardianZkApp.js'
}

Steps to Reproduce

  1. Create a smart contract within a new folder.
  2. zk deploy
  3. choose the new smart contract
  4. Error occurred

System Info

Be sure to include the following system information when submitting a GitHub issue:

  System:
    OS: macOS 14.3.1
    CPU: (8) arm64 Apple M2
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
  npmPackages:
    o1js: 0.16.2
  npmGlobalPackages:
    zkapp-cli: 0.17.2

Severity

serious, but I can work around it

Additional Information

No response

@iam-dev
Copy link
Author

iam-dev commented Feb 23, 2024

Build folder structure:
Scherm­afbeelding 2024-02-23 om 10 48 04

@ymekuria
Copy link
Collaborator

ymekuria commented Feb 23, 2024

Thanks for bringing this up @iam-dev. We will take a look at this. Are you experiencing the same problem if all your contracts are directly in the src folder and not nested? Did you enter zk config before entering zk deploy?

@iam-dev
Copy link
Author

iam-dev commented Feb 23, 2024

No, this works fine under src folder

@emlautarom1
Copy link

emlautarom1 commented Apr 8, 2024

I can confirm this issue is still present on version 0.18.0. I also had to move the contract to the top level src folder to solve this issue.

The source of the issue seems to be the usage of basename which should probably be resolve in order to use absolute paths:

return path.basename(file);

@Shigoto-dev19
Copy link
Contributor

@iam-dev Could you confirm if this issue is still occurring? I tried to reproduce it but couldn't encounter the problem. As long as I include the zkApp name in config.json, it deploys successfully, even when located in a nested folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants