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

Checking of imported contract failed if not specified for deployment #319

Closed
aacoimbra opened this issue May 10, 2023 · 7 comments
Closed
Assignees

Comments

@aacoimbra
Copy link

Problem

Extension raises error when importing a contract that is not manually deployed but instead automatically deployed in the emulator such as the FlowToken contract.

image

Given the following flow.json file, importing NonFungibleToken will work, but importing FlowToken will not.
This behavior also occurs for other automatically deployed contracts.

{
    "contracts": {
        "FlowToken": {
            "source": "./cadence/contracts/FlowToken.cdc",
            "aliases": {
                "emulator": "0ae53cb6e3f42a79"
            }
        },
        "NonFungibleToken": {
            "source": "./cadence/contracts/NonFungibleToken.cdc"
        },
    },
    "networks": {
        "emulator": "127.0.0.1:3569"
    },
    "accounts": {
        "emulator-account": {
            "address": "f8d6e0586b0a20c7",
            "key": "d6458c0a5d0903987dccbc630e7b8f48975ae55a115baca1f4decce5b78057ed"
        }
    },
    "deployments": {
        "emulator": {
            "emulator-account": [
                "NonFungibleToken"
            ]
        }
    }
}

Steps to Reproduce

Copy flow.json above and create the folder strucure complying with "./cadence/contracts/NonFungibleToken.cdc" and paste the contracts.
Attempt to import FlowToken in a .cdc file.

Workaround

Making the following change to flow.json will avoid raising an error when importing, but will unnecessarily deploy the contract to emulator-account.

    "deployments": {
        "emulator": {
            "emulator-account": [
                "NonFungibleToken",
                "FlowToken"
            ]
        }
    }

This issue can be reliably reproduced.
Extension version v1.2.0.
OS: Windows 11

@sideninja
Copy link
Contributor

@aacoimbra thanks for reporting this, but this is by design, we intentionally check only the contracts you have in the deployments section, because there might be different contracts deployed for different networks.
The issue I see tho, is that, obviously one part of the process is broken here. So if I understand you deployed a contract to an account using the "deploy contract" button inside the vscode? and then you had issues importing it?

@DylanTinianov DylanTinianov added the bug Something isn't working label May 11, 2023
@aacoimbra
Copy link
Author

@sideninja Actually I’m not using the extension to deploy contracts or send transactions, I’m doing this using the fcl.
My goal here is to have the intellisense features of the extension.

@aacoimbra
Copy link
Author

To be clear, in this case I want to run the emulator with only default contracts, and deploy all my contracts and run transactions with fcl, to simulate exactly how it will be in production. But if I don't specify the contracts for deployment in flow.json, the intellisense features of the extenseion won't work for any contract or transactions I'm creating.

@sideninja
Copy link
Contributor

@aacoimbra Unfortunately that's how we know what is that you are importing. Unless you use file path location to the contract, which I don't advise, we can't know which contract your import references unless you specify that in configuration flow.json. There are tools that do that for you like flow dev, but otherwise I'm not sure how do you think this could work without it?

@sideninja sideninja removed the bug Something isn't working label May 22, 2023
@sideninja
Copy link
Contributor

Also note that if you use flow setup to setup your project you get most of the standard contracts already in the flow.json.

@sideninja
Copy link
Contributor

However, the IntelliSense for contracts you defined an alias for (like the FlowToken above) should work without adding them to the deployments section. But you must make sure that contract was actually deployed.

@DylanTinianov DylanTinianov moved this to 🔖 Ready for Pickup in 🌊 Flow 4D Jun 5, 2023
@jribbink
Copy link
Contributor

This should be solved by onflow/cadence-tools#224 (pending a new release of the language server and Flow CLI)

@github-project-automation github-project-automation bot moved this from 🔖 Ready for Pickup to ✅ Done in 🌊 Flow 4D Oct 29, 2023
@jribbink jribbink self-assigned this Oct 29, 2023
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