Add import alias support for Cadence contracts #167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds import alias support to Flowkit, allowing contracts to be imported under different names while referencing a canonical contract's source code.
Example
flow.json Configuration
{ "contracts": { "FUSD": { "source": "./contracts/FUSD.cdc", "aliases": { "testnet": "0x9a0766d93b6608b7", "mainnet": "0x3c5959b568896393" } }, "FUSD1": { "source": "./contracts/FUSD.cdc", "aliases": { "testnet": "0xe223d8a629e49c68", "mainnet": "0x8d0e87b65159ae63" }, "canonical": "FUSD" }, "FUSD2": { "source": "./contracts/FUSD.cdc", "aliases": { "testnet": "0x0f9df91c9121c460", "mainnet": "0x754a90d51a1c8e1b" }, "canonical": "FUSD" } } }Import Syntax Conversion
Before Processing:
After Processing by Flowkit:
The canonical contract (
FUSD) uses regular import syntax, while alias contracts (FUSD1,FUSD2) use theimport X as Ysyntax, allowing multiple imports of the same contract with different names.