Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions evm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# EVM App Changelog

## [`v0.1.2`](https://github.com/ignite/apps/releases/tag/evm/v0.1.2)

- [#239](https://github.com/ignite/apps/pull/239) Set default token decimal to 18 as recommended.
- [#239](https://github.com/ignite/apps/pull/239) Fix export genesis for ibc transfer wrapped module.

## [`v0.1.1`](https://github.com/ignite/apps/releases/tag/evm/v0.1.1)

- [#235](https://github.com/ignite/apps/pull/235) Wire EVM mempool and correct start command.
Expand Down
4 changes: 2 additions & 2 deletions evm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module github.com/ignite/apps/evm
go 1.24.1

require (
cosmossdk.io/math v1.5.3
github.com/cosmos/cosmos-sdk v0.53.4
github.com/gobuffalo/genny/v2 v2.1.0
github.com/gobuffalo/plush/v4 v4.1.22
github.com/hashicorp/go-plugin v1.6.3
Expand All @@ -17,7 +19,6 @@ require (
cosmossdk.io/depinject v1.2.1 // indirect
cosmossdk.io/errors v1.0.2 // indirect
cosmossdk.io/log v1.6.1 // indirect
cosmossdk.io/math v1.5.3 // indirect
cosmossdk.io/schema v1.1.0 // indirect
cosmossdk.io/store v1.1.2 // indirect
cosmossdk.io/x/tx v0.14.0 // indirect
Expand Down Expand Up @@ -61,7 +62,6 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.1.1 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
github.com/cosmos/cosmos-sdk v0.53.4 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.7.0 // indirect
Expand Down
34 changes: 34 additions & 0 deletions evm/template/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ package template
import (
"embed"
"io/fs"
"math"
"os"
"path/filepath"

"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/plush/v4"

sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"

configchain "github.com/ignite/cli/v29/ignite/config/chain"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/gomodule"
"github.com/ignite/cli/v29/ignite/pkg/gomodulepath"
Expand Down Expand Up @@ -53,6 +58,10 @@ func NewEVMGenerator(chain *chain.Chain) (*genny.Generator, error) {
return nil, errors.Errorf("failed to update go.mod: %w", err)
}

if err := updateConfigYaml(chain); err != nil {
return nil, errors.Errorf("failed to update config.yaml: %w", err)
}

g.RunFn(commandsModify(appPath, binaryName))
g.RunFn(rootModify(appPath, binaryName))
g.RunFn(appModify(appPath, binaryName))
Expand Down Expand Up @@ -82,3 +91,28 @@ func updateDependencies(appPath string) error {

return os.WriteFile(filepath.Join(appPath, "go.mod"), data, 0o644)
}

const defaultValPower = 1

// updateConfigYaml updates the default bond tokens.
// this is required as the chain uses 18 decimals.
func updateConfigYaml(c *chain.Chain) error {
igniteConfig, err := c.Config()
if err != nil {
return err
}

coins := sdk.NewCoin(igniteConfig.DefaultDenom, sdkmath.NewInt((defaultValPower * int64(math.Pow10(18)))))
igniteConfig.Validators[0].Bonded = coins.String()
for i, account := range igniteConfig.Accounts {
if account.Name == igniteConfig.Validators[0].Name {
igniteConfig.Accounts[i].Coins = []string{coins.String()}
}
}

if err := configchain.Save(*igniteConfig, c.ConfigPath()); err != nil {
return err
}

return nil
}
18 changes: 18 additions & 0 deletions evm/template/generator_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func appModify(appPath, binaryName string) genny.RunFn {
// change imports
content, err := xast.AppendImports(
f.String(),
xast.WithImport("math/big"),
xast.WithImport("cosmossdk.io/math"),
xast.WithNamedImport("feegrantkeeper", "cosmossdk.io/x/feegrant/keeper"),
xast.WithNamedImport("_", "github.com/ethereum/go-ethereum/eth/tracers/js"),
xast.WithNamedImport("_", "github.com/ethereum/go-ethereum/eth/tracers/native"),
Expand Down Expand Up @@ -53,6 +55,22 @@ func appModify(appPath, binaryName string) genny.RunFn {
1,
)

// change decimal to 18
content, err = xast.InsertGlobal(
content,
xast.GlobalTypeConst,
xast.WithGlobal("BaseDenomUnit", "int64", "18"),
)

content, err = xast.ModifyFunction(
content,
"init",
xast.AppendFuncCode(`// Update power reduction for 18-decimal base unit
sdk.DefaultPowerReduction = math.NewIntFromBigInt(
new(big.Int).Exp(big.NewInt(10), big.NewInt(BaseDenomUnit), nil),
)`),
)

// append modules
content, err = xast.ModifyStruct(
content,
Expand Down
7 changes: 7 additions & 0 deletions evm/template/generator_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func rootModify(appPath, binaryName string) genny.RunFn {
content, err := xast.AppendImports(
f.String(),
xast.WithNamedImport("cosmosevmkeyring", "github.com/cosmos/evm/crypto/keyring"),
xast.WithNamedImport("ibctransferevm", "github.com/cosmos/evm/x/ibc/transfer"),
xast.WithNamedImport("ibctransfer", "github.com/cosmos/ibc-go/v10/modules/apps/transfer"),
xast.WithNamedImport("ibctransfertypes", "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"),
)
if err != nil {
return err
Expand All @@ -97,6 +100,10 @@ func rootModify(appPath, binaryName string) genny.RunFn {
for name, mod := range evmModules {
moduleBasicManager[name] = module.CoreAppModuleBasicAdaptor(name, mod)
autoCliOpts.Modules[name] = mod
}
// Fix basic manager transfer wrapping
moduleBasicManager[ibctransfertypes.ModuleName] = ibctransferevm.AppModuleBasic{
AppModuleBasic: &ibctransfer.AppModuleBasic{},
}`,
5),
)
Expand Down
2 changes: 1 addition & 1 deletion evolve/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func initEVABCI(
return err
}

coins := sdk.NewCoin("stake", sdkmath.NewInt((defaultValPower * int64(math.Pow10(6)))))
coins := sdk.NewCoin(igniteConfig.DefaultDenom, sdkmath.NewInt((defaultValPower * int64(math.Pow10(6)))))
igniteConfig.Validators[0].Bonded = coins.String()
for i, account := range igniteConfig.Accounts {
if account.Name == igniteConfig.Validators[0].Name {
Expand Down
Loading