Migrate x/genutil to use TxConfig (#6734)
* Update genutil collect and gentx to use TxGenerator * Remove print statement * Use Tx in genutil DeliverGenTxs * Use Tx in genutil genesis_state * Use Tx in ValidateGenesis * Use amino txJSONDecoder and txBinaryEncoder in genutil InitGenesis * Use TxConfig in place of TxGenerator * Add gentx tests * Remove commented line * Test fixes * Apply suggestions from code review Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> * Fixes * Fixes * Fixes * Fixes * Remove unneeded test case (doesn't apply to proto marshaling) * linting * Refactor to use new TxEncodingConfig interface in genutil module * Replace golang/protobuf with gogo/protobuf package * Use TxEncodingConfig in InitTestnet * Remove old amino.go file * Use TxJSONDecoder in genutil ValidateGenesis * Add parameter to ValidateGenesis to resolve the tx JSON decoder issue * Address review feedback Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com> Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Alexander Bezobchuk
Jack Zampolin
Aaron Craelius
Aaron Craelius
mergify[bot]
parent
3bafd8255a
commit
f59df68a97
@@ -13,6 +13,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
tmcfg "github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
@@ -278,16 +280,21 @@ func New(t *testing.T, cfg Config) *Network {
|
||||
require.NoError(t, err)
|
||||
|
||||
memo := fmt.Sprintf("%s@%s:%s", nodeIDs[i], p2pURL.Hostname(), p2pURL.Port())
|
||||
tx := authtypes.NewStdTx([]sdk.Msg{createValMsg}, authtypes.StdFee{}, []authtypes.StdSignature{}, memo) //nolint:staticcheck // SA1019: authtypes.StdFee is deprecated
|
||||
txBldr := authtypes.TxBuilder{}.
|
||||
txBuilder := cfg.TxConfig.NewTxBuilder()
|
||||
require.NoError(t, txBuilder.SetMsgs(createValMsg))
|
||||
txBuilder.SetMemo(memo)
|
||||
|
||||
txFactory := tx.Factory{}
|
||||
txFactory = txFactory.
|
||||
WithChainID(cfg.ChainID).
|
||||
WithMemo(memo).
|
||||
WithKeybase(kb)
|
||||
WithKeybase(kb).
|
||||
WithTxConfig(cfg.TxConfig)
|
||||
|
||||
signedTx, err := txBldr.SignStdTx(nodeDirName, tx, false)
|
||||
err = tx.Sign(txFactory, nodeDirName, txBuilder)
|
||||
require.NoError(t, err)
|
||||
|
||||
txBz, err := cfg.Codec.MarshalJSON(signedTx)
|
||||
txBz, err := cfg.TxConfig.TxJSONEncoder()(txBuilder.GetTx())
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, writeFile(fmt.Sprintf("%v.json", nodeDirName), gentxsDir, txBz))
|
||||
|
||||
|
||||
@@ -105,7 +105,8 @@ func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
appState, err := genutil.GenAppStateFromConfig(cfg.Codec, tmCfg, initCfg, *genDoc, banktypes.GenesisBalancesIterator{})
|
||||
appState, err := genutil.GenAppStateFromConfig(cfg.Codec, cfg.TxConfig,
|
||||
tmCfg, initCfg, *genDoc, banktypes.GenesisBalancesIterator{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user