feat: add customized Ledger support (#12935)
This commit is contained in:
+1
-1
@@ -258,7 +258,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err
|
||||
// If the `from` signer account is a ledger key, we need to use
|
||||
// SIGN_MODE_AMINO_JSON, because ledger doesn't support proto yet.
|
||||
// ref: https://github.com/cosmos/cosmos-sdk/issues/8109
|
||||
if keyType == keyring.TypeLedger && clientCtx.SignModeStr != flags.SignModeLegacyAminoJSON {
|
||||
if keyType == keyring.TypeLedger && clientCtx.SignModeStr != flags.SignModeLegacyAminoJSON && !clientCtx.LedgerHasProtobuf {
|
||||
fmt.Println("Default sign-mode 'direct' not supported by Ledger, using sign-mode 'amino-json'.")
|
||||
clientCtx = clientCtx.WithSignModeStr(flags.SignModeLegacyAminoJSON)
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ type Context struct {
|
||||
FeePayer sdk.AccAddress
|
||||
FeeGranter sdk.AccAddress
|
||||
Viper *viper.Viper
|
||||
LedgerHasProtobuf bool
|
||||
PreprocessTxHook PreprocessTxFn
|
||||
|
||||
// IsAux is true when the signer is an auxiliary signer (e.g. the tipper).
|
||||
@@ -266,6 +267,13 @@ func (ctx Context) WithAux(isAux bool) Context {
|
||||
return ctx
|
||||
}
|
||||
|
||||
// WithLedgerHasProto returns the context with the provided boolean value, indicating
|
||||
// whether the target Ledger application can support Protobuf payloads.
|
||||
func (ctx Context) WithLedgerHasProtobuf(val bool) Context {
|
||||
ctx.LedgerHasProtobuf = val
|
||||
return ctx
|
||||
}
|
||||
|
||||
// WithPreprocessTxHook returns the context with the provided preprocessing hook, which
|
||||
// enables chains to preprocess the transaction using the builder.
|
||||
func (ctx Context) WithPreprocessTxHook(preprocessFn PreprocessTxFn) Context {
|
||||
|
||||
Reference in New Issue
Block a user