Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Sep 24, 2024
1 parent 1d8c5b6 commit a37be85
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 9 additions & 4 deletions internal/super/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,15 @@ func generateContract(
) (result command.Result, err error) {
g := generator.NewGenerator("", state, logger, false, true)
name := util.StripCDCExtension(args[0])
err = g.Create(
generator.ContractTemplate{Name: name},
generator.TestTemplate{Name: name + "_test", Data: map[string]interface{}{"ContractName": "Counter"}},
)

templates := []generator.TemplateItem{
generator.ContractTemplate{Name: name, SkipTests: generateFlags.SkipTests, SaveState: true},
}
if !generateFlags.SkipTests {
templates = append(templates, generator.TestTemplate{Name: name + "_test", Data: map[string]interface{}{"ContractName": "Counter"}})
}

err = g.Create()
return nil, err
}

Expand Down
8 changes: 4 additions & 4 deletions internal/super/generator/contract_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type ContractTemplate struct {
Account string
TemplatePath string
Data map[string]interface{}
skipTests bool
saveState bool
SkipTests bool
SaveState bool
}

var _ TemplateItem = ContractTemplate{}
Expand Down Expand Up @@ -50,7 +50,7 @@ func (c ContractTemplate) GetTargetPath() string {
func (c ContractTemplate) UpdateState(state *flowkit.State) error {
var aliases config.Aliases

if c.skipTests != true {
if c.SkipTests != true {
aliases = config.Aliases{{
Network: config.TestingNetwork.Name,
Address: flowsdk.HexToAddress("0x0000000000000007"),
Expand All @@ -65,7 +65,7 @@ func (c ContractTemplate) UpdateState(state *flowkit.State) error {

state.Contracts().AddOrUpdate(contract)

if c.saveState {
if c.SaveState {
err := state.SaveDefault() // TODO: Support adding a target project directory
if err != nil {
return fmt.Errorf("error saving to flow.json: %w", err)
Expand Down

0 comments on commit a37be85

Please sign in to comment.