Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [#1091](https://github.com/crypto-org-chain/chain-main/pull/1091) Update cometbft to `0.38.13`, sdk to `v0.50.10` and memiavl to latest.
- [#1091](https://github.com/crypto-org-chain/chain-main/pull/1091) Upgrade cometbft to v0.38.13, cosmos-sdk to `v0.50.10`.
- [#1099](https://github.com/crypto-org-chain/chain-main/pull/1099) Avoid negative coin amount error when query supply liquid of non BaseCoinUnit.
- [#1152](https://github.com/crypto-org-chain/chain-main/pull/1152) Fix unsuppored sign mode SIGN_MODE_TEXTUAL for bank transfer.

*Dec 6, 2023*

Expand Down
22 changes: 20 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"net/http"
"os"
"path/filepath"
"slices"

"github.com/gorilla/mux"
"github.com/spf13/cast"
Expand Down Expand Up @@ -55,6 +56,7 @@
sdk "github.com/cosmos/cosmos-sdk/types"
mempool "github.com/cosmos/cosmos-sdk/types/mempool"
"github.com/cosmos/cosmos-sdk/types/module"
sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -63,6 +65,7 @@
"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 @@ -361,6 +364,21 @@
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)

Check warning on line 379 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L379

Added line #L379 was not covered by tests
}
app.txConfig = txConfig
app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[stakingtypes.StoreKey]),
Expand Down Expand Up @@ -549,7 +567,7 @@
app.ModuleManager = module.NewManager(
genutil.NewAppModule(
app.AccountKeeper, app.StakingKeeper, app,
encodingConfig.TxConfig,
txConfig,
),
auth.NewAppModule(appCodec, app.AccountKeeper, nil, app.GetSubspace(authtypes.ModuleName)),
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
Expand Down Expand Up @@ -745,7 +763,7 @@
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SignModeHandler: txConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
IBCKeeper: app.IBCKeeper,
Expand Down
33 changes: 31 additions & 2 deletions cmd/chain-maind/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"io"
"os"
"path/filepath"
"slices"
"time"

clientcfg "github.com/cosmos/cosmos-sdk/client/config"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/tx/signing"

"cosmossdk.io/log"
tmcfg "github.com/cometbft/cometbft/config"
Expand All @@ -34,6 +36,8 @@
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
Expand Down Expand Up @@ -70,6 +74,11 @@
WithHomeDir(app.DefaultNodeHome).
WithViper(EnvPrefix)

initClientCtx, err := clientcfg.ReadDefaultValuesFromDefaultClientConfig(initClientCtx)
if err != nil {
panic(err)

Check warning on line 79 in cmd/chain-maind/app/app.go

View check run for this annotation

Codecov / codecov/patch

cmd/chain-maind/app/app.go#L79

Added line #L79 was not covered by tests
}

rootCmd := &cobra.Command{
Use: "chain-maind",
Short: "Cronos.org Chain app",
Expand All @@ -78,6 +87,7 @@
cmd.SetOut(cmd.OutOrStdout())
cmd.SetErr(cmd.ErrOrStderr())

initClientCtx = initClientCtx.WithCmdContext(cmd.Context())
initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags())
if err != nil {
return err
Expand All @@ -86,6 +96,27 @@
if err != nil {
return err
}

// 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.
if !initClientCtx.Offline {
enabledSignModes := slices.Clone(tx.DefaultSignModes)
enabledSignModes = append(enabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
txConfigOpts := tx.ConfigOptions{
EnabledSignModes: enabledSignModes,
TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx),
}
txConfig, err := tx.NewTxConfigWithOptions(
initClientCtx.Codec,
txConfigOpts,
)
if err != nil {
return err
}

Check warning on line 116 in cmd/chain-maind/app/app.go

View check run for this annotation

Codecov / codecov/patch

cmd/chain-maind/app/app.go#L115-L116

Added lines #L115 - L116 were not covered by tests

initClientCtx = initClientCtx.WithTxConfig(txConfig)
}
if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
return err
}
Expand All @@ -99,8 +130,6 @@
initRootCmd(rootCmd, encodingConfig, tempApp.BasicModuleManager)

autoCliOpts := tempApp.AutoCliOpts()
initClientCtx, _ = clientcfg.ReadDefaultValuesFromDefaultClientConfig(initClientCtx)
// autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
autoCliOpts.ClientCtx = initClientCtx

if err := autoCliOpts.EnhanceRootCommand(rootCmd); 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 @@ -104,3 +104,14 @@ def test_statesync(cluster):
# discovery_time is set to 5 seconds, add extra seconds for processing
wait_for_block(cluster.cosmos_cli(i), 10)
print("successfully syncing")


def test_textual(cluster):
cli = cluster.cosmos_cli()
rsp = cli.transfer(
cli.address("community"),
cli.address("signer2"),
"1cro",
sign_mode="textual",
)
assert rsp["code"] == 0, rsp["raw_log"]
Loading