Skip to content

Commit

Permalink
feat: enable sign mode textual
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed Jun 12, 2024
1 parent 5a62bd9 commit 40d7b6e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
18 changes: 17 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package app

import (
"fmt"
sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -330,6 +332,21 @@ func NewComposableApp(
appOpts,
)

// optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper)
enabledSignModes := append(authtx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL)
txConfigOpts := authtx.ConfigOptions{
EnabledSignModes: enabledSignModes,
TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper),
}
txConfig, err = authtx.NewTxConfigWithOptions(
appCodec,
txConfigOpts,
)
if err != nil {
panic(err)
}
app.txConfig = txConfig

// custompfm.NewIBCMiddleware()
// transferModule := transfer.NewAppModule(app.TransferKeeper)
transferModule := customibctransfer.NewAppModule(appCodec, app.TransferKeeper, app.BankKeeper)
Expand Down Expand Up @@ -446,7 +463,6 @@ func NewComposableApp(
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
vestingtypes.ModuleName,
ibcexported.ModuleName,
genutiltypes.ModuleName,
Expand Down
16 changes: 7 additions & 9 deletions cmd/picad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package cmd

import (
"errors"
"fmt"
"io"
"os"

cmtcfg "github.com/cometbft/cometbft/config"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/tx"

Expand Down Expand Up @@ -35,7 +35,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/cosmos-sdk/x/genutil"

tmcfg "github.com/cometbft/cometbft/config"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"

Expand Down Expand Up @@ -97,8 +96,6 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
return err
}

fmt.Println("hoank123", initClientCtx.Offline)

// This needs to go after ReadFromClientConfig, as that function
// sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode
// is only available if the client is online.
Expand All @@ -122,10 +119,9 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
return err
}
customAppTemplate, customAppConfig := initAppConfig()
customCMTConfig := initCometBFTConfig()

customTMConfig := initTendermintConfig()

return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig)
return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customCMTConfig)
},
}

Expand All @@ -143,8 +139,10 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
return rootCmd, encodingConfig
}

func initTendermintConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()
// initCometBFTConfig helps to override default CometBFT Config values.
// return cmtcfg.DefaultConfig if no custom configuration is required for the application.
func initCometBFTConfig() *cmtcfg.Config {
cfg := cmtcfg.DefaultConfig()

// these values put a higher strain on node memory
// cfg.P2P.MaxNumInboundPeers = 100
Expand Down
4 changes: 3 additions & 1 deletion scripts/run-node-two-validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ update_test_genesis '.app_state["stakingmiddleware"]["params"]["blocks_per_epoch
update_test_genesis '.app_state["mint"]["params"]["mint_denom"]="'$DENOM'"'
update_test_genesis '.app_state["gov"]["params"]["min_deposit"]=[{"denom":"'$DENOM'","amount": "1"}]'
update_test_genesis '.app_state["crisis"]["constant_fee"]={"denom":"'$DENOM'","amount":"1000"}'
update_test_genesis '.app_state["slashing"]["params"]["signed_blocks_window"]="6"'
update_test_genesis '.app_state["slashing"]["params"]["signed_blocks_window"]="4"'
update_test_genesis '.app_state["slashing"]["params"]["downtime_jail_duration"]="5s"'


# Collect genesis tx
$BINARY collect-gentxs --home $HOME_DIR
Expand Down

0 comments on commit 40d7b6e

Please sign in to comment.