From aa185fdd6f677874ee7fb065c28671ba4569985b Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 24 Sep 2024 06:54:45 -0700 Subject: [PATCH 1/2] Make add by core contract case insensitive --- internal/dependencymanager/add.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/internal/dependencymanager/add.go b/internal/dependencymanager/add.go index d589d89dd..f3e96d5c6 100644 --- a/internal/dependencymanager/add.go +++ b/internal/dependencymanager/add.go @@ -21,14 +21,17 @@ package dependencymanager import ( "fmt" - "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 +80,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 +97,12 @@ func add( return nil, nil } + +func findCoreContractCaseInsensitive(name string) string { + for _, contract := range systemcontracts.SystemContractsForChain(flowGo.Mainnet).All() { + if name == contract.Name { + return contract.Name + } + } + return "" +} From d91415dfc6cf847961b98b5c81c38dd07a0b5bbf Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 24 Sep 2024 10:19:06 -0700 Subject: [PATCH 2/2] make it actually case insensitive --- internal/dependencymanager/add.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/dependencymanager/add.go b/internal/dependencymanager/add.go index f3e96d5c6..736a3b4c7 100644 --- a/internal/dependencymanager/add.go +++ b/internal/dependencymanager/add.go @@ -20,6 +20,7 @@ package dependencymanager import ( "fmt" + "strings" "github.com/onflow/flow-go/fvm/systemcontracts" @@ -100,7 +101,7 @@ func add( func findCoreContractCaseInsensitive(name string) string { for _, contract := range systemcontracts.SystemContractsForChain(flowGo.Mainnet).All() { - if name == contract.Name { + if strings.EqualFold(contract.Name, name) { return contract.Name } }