Skip to content

Commit

Permalink
Problem: unsuppored sign mode SIGN_MODE_TEXTUAL in bank transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 3, 2024
1 parent 3766e6a commit f6fa3b7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
20 changes: 19 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"path/filepath"
stdruntime "runtime"
"slices"
"sort"

"filippo.io/age"
Expand Down Expand Up @@ -62,13 +63,15 @@ 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"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"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"
Expand Down Expand Up @@ -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]),
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit f6fa3b7

Please sign in to comment.