Skip to content

Commit

Permalink
fix: partly revert #15123
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed May 9, 2023
1 parent 2f21cb5 commit be11aa4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions client/tx/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) (Factory, e
if flagSet.Changed(flags.FlagAccountNumber) && flagSet.Changed(flags.FlagSequence) {
accNum, _ = flagSet.GetUint64(flags.FlagAccountNumber)
accSeq, _ = flagSet.GetUint64(flags.FlagSequence)
if accNum == 0 || accSeq == 0 {
return Factory{}, errors.New("account-number and sequence cannot be both zero when in offline mode")
}
} else {
return Factory{}, errors.New("account-number and sequence must be set in offline mode")
}
Expand Down Expand Up @@ -471,14 +474,19 @@ func (f Factory) Prepare(clientCtx client.Context) (Factory, error) {
}

initNum, initSeq := fc.accountNumber, fc.sequence
if initNum == 0 && initSeq == 0 {
if initNum == 0 || initSeq == 0 {
num, seq, err := fc.accountRetriever.GetAccountNumberSequence(clientCtx, from)
if err != nil {
return fc, err
}

fc = fc.WithAccountNumber(num)
fc = fc.WithSequence(seq)
if initNum == 0 {
fc = fc.WithAccountNumber(num)
}

if initSeq == 0 {
fc = fc.WithSequence(seq)
}
}

return fc, nil
Expand Down

0 comments on commit be11aa4

Please sign in to comment.