diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ec2a9fefe..9711340795 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * [#1609](https://github.com/crypto-org-chain/cronos/pull/1609) Fix query address-by-acc-num by account_id instead of id. * [#1611](https://github.com/crypto-org-chain/cronos/pull/1611) Fix multisig account failed on threshold encode after send tx. +* [#1617](https://github.com/crypto-org-chain/cronos/pull/1617) Fix unsuppored sign mode SIGN_MODE_TEXTUAL for bank transfer. *Sep 13, 2024* diff --git a/app/app.go b/app/app.go index 6f1f68ed31..b068b08b88 100644 --- a/app/app.go +++ b/app/app.go @@ -13,6 +13,7 @@ import ( "os" "path/filepath" stdruntime "runtime" + "slices" "sort" "filippo.io/age" @@ -62,6 +63,7 @@ import ( mempool "github.com/cosmos/cosmos-sdk/types/mempool" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/msgservice" + sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" @@ -69,6 +71,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/posthandler" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" @@ -514,6 +517,21 @@ func New( authAddr, logger, ) + // optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper) + enabledSignModes := slices.Clone(authtx.DefaultSignModes) + enabledSignModes = append(enabledSignModes, 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 app.StakingKeeper = stakingkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), @@ -981,7 +999,7 @@ func New( app.SetPreBlocker(app.PreBlocker) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - if err := app.setAnteHandler(encodingConfig.TxConfig, + if err := app.setAnteHandler(txConfig, cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted)), cast.ToStringSlice(appOpts.Get(FlagBlockedAddresses)), ); err != nil { diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index 623b1284aa..820a2c6635 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -985,3 +985,14 @@ def test_multi_acc(cronos): acc = cli.account(multi_addr) res = cli.account_by_num(acc["account"]["value"]["base_account"]["account_number"]) assert res["account_address"] == multi_addr + + +def test_textual(cronos): + cli = cronos.cosmos_cli() + rsp = cli.transfer( + cli.address("validator"), + cli.address("signer2"), + "1basetcro", + sign_mode="textual", + ) + assert rsp["code"] == 0, rsp["raw_log"]