Skip to content

Commit

Permalink
updated to create only the directories passed in to save flag, had is…
Browse files Browse the repository at this point in the history
…sues with it trying to create the file as a directory. Added aliases in flow json to dep contracts
  • Loading branch information
bthaile committed Nov 21, 2023
1 parent 28034bf commit 82452a8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
5 changes: 4 additions & 1 deletion internal/command/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/onflow/flow-go-sdk/access/grpc"
Expand Down Expand Up @@ -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
}
Expand Down
49 changes: 42 additions & 7 deletions internal/super/flix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

0 comments on commit 82452a8

Please sign in to comment.