@@ -3,12 +3,17 @@ package template
33import (
44 "embed"
55 "io/fs"
6+ "math"
67 "os"
78 "path/filepath"
89
910 "github.com/gobuffalo/genny/v2"
1011 "github.com/gobuffalo/plush/v4"
1112
13+ sdkmath "cosmossdk.io/math"
14+ sdk "github.com/cosmos/cosmos-sdk/types"
15+
16+ configchain "github.com/ignite/cli/v29/ignite/config/chain"
1217 "github.com/ignite/cli/v29/ignite/pkg/errors"
1318 "github.com/ignite/cli/v29/ignite/pkg/gomodule"
1419 "github.com/ignite/cli/v29/ignite/pkg/gomodulepath"
@@ -53,6 +58,10 @@ func NewEVMGenerator(chain *chain.Chain) (*genny.Generator, error) {
5358 return nil , errors .Errorf ("failed to update go.mod: %w" , err )
5459 }
5560
61+ if err := updateConfigYaml (chain ); err != nil {
62+ return nil , errors .Errorf ("failed to update config.yaml: %w" , err )
63+ }
64+
5665 g .RunFn (commandsModify (appPath , binaryName ))
5766 g .RunFn (rootModify (appPath , binaryName ))
5867 g .RunFn (appModify (appPath , binaryName ))
@@ -82,3 +91,28 @@ func updateDependencies(appPath string) error {
8291
8392 return os .WriteFile (filepath .Join (appPath , "go.mod" ), data , 0o644 )
8493}
94+
95+ const defaultValPower = 1
96+
97+ // updateConfigYaml updates the default bond tokens.
98+ // this is required as the chain uses 18 decimals.
99+ func updateConfigYaml (c * chain.Chain ) error {
100+ igniteConfig , err := c .Config ()
101+ if err != nil {
102+ return err
103+ }
104+
105+ coins := sdk .NewCoin (igniteConfig .DefaultDenom , sdkmath .NewInt ((defaultValPower * int64 (math .Pow10 (18 )))))
106+ igniteConfig .Validators [0 ].Bonded = coins .String ()
107+ for i , account := range igniteConfig .Accounts {
108+ if account .Name == igniteConfig .Validators [0 ].Name {
109+ igniteConfig .Accounts [i ].Coins = []string {coins .String ()}
110+ }
111+ }
112+
113+ if err := configchain .Save (* igniteConfig , c .ConfigPath ()); err != nil {
114+ return err
115+ }
116+
117+ return nil
118+ }
0 commit comments