From 82452a82d2a260b18b93e69cfcd57b971e59c04f Mon Sep 17 00:00:00 2001 From: Tom Haile Date: Tue, 21 Nov 2023 16:58:26 -0700 Subject: [PATCH] updated to create only the directories passed in to save flag, had issues with it trying to create the file as a directory. Added aliases in flow json to dep contracts --- internal/command/result.go | 5 +++- internal/super/flix.go | 49 ++++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/internal/command/result.go b/internal/command/result.go index b39758094..ed9be9266 100644 --- a/internal/command/result.go +++ b/internal/command/result.go @@ -23,6 +23,7 @@ import ( "errors" "fmt" "os" + "path/filepath" "strings" "github.com/onflow/flow-go-sdk/access/grpc" @@ -87,7 +88,9 @@ func outputResult(result string, saveFlag string, formatFlag string, filterFlag Fs: afero.NewOsFs(), } - err := af.MkdirAll(saveFlag, 0644) + // create directory if doesn't exist + dir := filepath.Dir(saveFlag) + err := af.MkdirAll(dir, 0644) if err != nil { return err } diff --git a/internal/super/flix.go b/internal/super/flix.go index a6ba01e50..fe659284b 100644 --- a/internal/super/flix.go +++ b/internal/super/flix.go @@ -355,18 +355,53 @@ func GetDeployedContracts(state *flowkit.State) []flixkit.Contracts { if err != nil { continue } - for _, contract := range contracts { + for _, c := range contracts { contract := flixkit.Contracts{ - contract.Name: flixkit.Networks{ - deployment.Network: flixkit.Network{ - Address: "0x" + contract.AccountAddress.String(), - FqAddress: "A." + contract.AccountAddress.String() + "." + contract.Name, - Contract: contract.Name, - }, + c.Name: flixkit.Networks{ + deployment.Network: createFlixNetworkContract( + networkContract{ + contractName: c.Name, + networkAddress: c.AccountAddress.String(), + }), }, } depContracts = append(depContracts, contract) } } + // Networks of interest + networks := []config.Network{ + config.MainnetNetwork, + config.TestnetNetwork, + } + + for _, net := range networks { + locAliases := state.AliasesForNetwork(net) + for name, addr := range locAliases { + contract := flixkit.Contracts{ + name: flixkit.Networks{ + net.Name: createFlixNetworkContract( + networkContract{ + contractName: name, + networkAddress: addr, + }), + }, + } + depContracts = append(depContracts, contract) + } + } + return depContracts } + +type networkContract struct { + contractName string + networkAddress string +} + +func createFlixNetworkContract(contract networkContract) flixkit.Network { + return flixkit.Network{ + Address: "0x" + contract.networkAddress, + FqAddress: "A." + contract.networkAddress + "." + contract.contractName, + Contract: contract.contractName, + } +}