diff --git a/internal/dependencymanager/add.go b/internal/dependencymanager/add.go index d589d89dd..736a3b4c7 100644 --- a/internal/dependencymanager/add.go +++ b/internal/dependencymanager/add.go @@ -20,15 +20,19 @@ package dependencymanager import ( "fmt" + "strings" - "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/spf13/cobra" "github.com/onflow/flowkit/v2" "github.com/onflow/flowkit/v2/output" + flowGo "github.com/onflow/flow-go/model/flow" + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type addFlagsCollection struct { @@ -77,8 +81,9 @@ func add( } // First check if the dependency is a core contract. - if isCoreContract(dep) { - if err := installer.AddByCoreContractName(dep, addFlags.name); err != nil { + coreContractName := findCoreContractCaseInsensitive(dep) + if coreContractName != "" { + if err := installer.AddByCoreContractName(coreContractName, addFlags.name); err != nil { logger.Error(fmt.Sprintf("Error: %v", err)) return nil, err } @@ -93,3 +98,12 @@ func add( return nil, nil } + +func findCoreContractCaseInsensitive(name string) string { + for _, contract := range systemcontracts.SystemContractsForChain(flowGo.Mainnet).All() { + if strings.EqualFold(contract.Name, name) { + return contract.Name + } + } + return "" +}