feat: tx with generate-only and offline shouldn't use chain id (#10710)
<!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description chain-id shouldn't be required for creating a tx with --generate-only and --offline ref: #9407 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
This commit is contained in:
parent
ed05fa8446
commit
21e6f7ce7b
@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Features
|
||||
|
||||
* [\#10710](https://github.com/cosmos/cosmos-sdk/pull/10710) Chain-id shouldn't be required for creating a transaction with both --generate-only and --offline flags.
|
||||
* [\#10703](https://github.com/cosmos/cosmos-sdk/pull/10703) Create a new grantee account, if the grantee of an authorization does not exist.
|
||||
* [\#10592](https://github.com/cosmos/cosmos-sdk/pull/10592) Add a `DecApproxEq` function that checks to see if `|d1 - d2| < tol` for some Dec `d1, d2, tol`.
|
||||
* [\#10393](https://github.com/cosmos/cosmos-sdk/pull/10393) Add `HasSupply` method to bank keeper to ensure that input denom actually exists on chain.
|
||||
|
||||
@ -28,6 +28,8 @@ type Factory struct {
|
||||
timeoutHeight uint64
|
||||
gasAdjustment float64
|
||||
chainID string
|
||||
offline bool
|
||||
generateOnly bool
|
||||
memo string
|
||||
fees sdk.Coins
|
||||
tip *tx.Tip
|
||||
@ -64,6 +66,8 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory {
|
||||
accountRetriever: clientCtx.AccountRetriever,
|
||||
keybase: clientCtx.Keyring,
|
||||
chainID: clientCtx.ChainID,
|
||||
offline: clientCtx.Offline,
|
||||
generateOnly: clientCtx.GenerateOnly,
|
||||
gas: gasSetting.Gas,
|
||||
simulateAndExecute: gasSetting.Simulate,
|
||||
accountNumber: accNum,
|
||||
@ -220,7 +224,11 @@ func (f Factory) WithTimeoutHeight(height uint64) Factory {
|
||||
// BuildUnsignedTx builds a transaction to be signed given a set of messages.
|
||||
// Once created, the fee, memo, and messages are set.
|
||||
func (f Factory) BuildUnsignedTx(msgs ...sdk.Msg) (client.TxBuilder, error) {
|
||||
if f.chainID == "" {
|
||||
if f.offline && f.generateOnly {
|
||||
if f.chainID != "" {
|
||||
return nil, fmt.Errorf("chain ID cannot be used when offline and generate-only flags are set")
|
||||
}
|
||||
} else if f.chainID == "" {
|
||||
return nil, fmt.Errorf("chain ID required but not specified")
|
||||
}
|
||||
|
||||
|
||||
@ -414,6 +414,23 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||
},
|
||||
false, 0, &sdk.TxResponse{},
|
||||
},
|
||||
{
|
||||
"chain-id shouldn't be used with offline and generate-only flags",
|
||||
val.Address,
|
||||
val.Address,
|
||||
sdk.NewCoins(
|
||||
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)),
|
||||
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)),
|
||||
),
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
fmt.Sprintf("--%s=true", flags.FlagOffline),
|
||||
fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
|
||||
},
|
||||
true, 0, &sdk.TxResponse{},
|
||||
},
|
||||
{
|
||||
"not enough fees",
|
||||
val.Address,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user