onflow/cadence-tools

[LS] String import resolution does not work with aliases

Closed this issue · 0 comments

Current Behavior

Currently, string imports are resolved only from the deployments section of flow.json, however, are not resolved from aliased cotrats. This means that when checking contracts, particularly with pre-deployed/core contracts, imports may not resolve properly.

(see integration/flow.go)
Screenshot 2023-10-19 at 2 12 24 PM

Expected Behavior

The LS should recognize contracts deployed contracts outside of the deployments section as well (aliases). This probably means simply resolving anything from the contracts section of flow.json regardless of whether they appear in deployments or not.

Steps To Reproduce

Try to use this project in VSCode with Cadence extension.

contracts/foo/Foo.cdc

import "NonFungibleToken"

pub contract Foo {}

flow.json

{
	"contracts": {
		"Foo": "cadence/contracts/foo/Foo.cdc",
		"NonFungibleToken": {
			"source": "cadence/contracts/standard/NonFungibleToken.cdc",
			"aliases": {
				"emulator": "f8d6e0586b0a20c7"
			}
		}
	},
	"networks": {
		"emulator": "127.0.0.1:3569",
		"mainnet": "access.mainnet.nodes.onflow.org:9000",
		"sandboxnet": "access.sandboxnet.nodes.onflow.org:9000",
		"testnet": "access.devnet.nodes.onflow.org:9000"
	},
	"accounts": {
		"default": {
			"address": "ff8975b2fe6fb6f1",
			"key": "4656ee827102b8b4f5c34b4b29afad3d75f61284f52e9b9573cade37b1b7bda4"
		},
		"emulator-account": {
			"address": "f8d6e0586b0a20c7",
			"key": "4656ee827102b8b4f5c34b4b29afad3d75f61284f52e9b9573cade37b1b7bda4"
		},
		"foo": {
			"address": "e9dd1081676bbc90",
			"key": "4656ee827102b8b4f5c34b4b29afad3d75f61284f52e9b9573cade37b1b7bda4"
		},
		"standard": {
			"address": "0dbaa95c7691bc4f",
			"key": "4656ee827102b8b4f5c34b4b29afad3d75f61284f52e9b9573cade37b1b7bda4"
		}
	},
	"deployments": {
		"emulator": {
			"default": [],
			"foo": [
				"Foo"
			],
			"standard": []
		}
	}
}

You will see this error

Screenshot 2023-10-19 at 3 04 39 PM

Environment

- LS Version: v0.32.0
- Network: Emulator