-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fetch account number/sequence when not in offline mode #16075
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
be11aa4
fix: partly revert #15123
julienrbrt f5431de
updates
julienrbrt a6c45c4
update comment
julienrbrt e6a5535
add changelog
julienrbrt fc52282
Merge branch 'main' into julien/factory
julienrbrt 0f09b3d
skip when offline mode
julienrbrt 5e067c1
comments
julienrbrt 52a91f3
add test
julienrbrt 3ecd7f6
add test case
julienrbrt 3ca21e7
Merge branch 'main' into julien/factory
julienrbrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,8 +460,8 @@ func (f Factory) getSimPK() (cryptotypes.PubKey, error) { | |
|
||
// Prepare ensures the account defined by ctx.GetFromAddress() exists and | ||
// if the account number and/or the account sequence number are zero (not set), | ||
// they will be queried for and set on the provided Factory. A new Factory with | ||
// the updated fields will be returned. | ||
// they will be queried (when not in offline mode) for and set on the provided Factory. | ||
// A new Factory with the updated fields will be returned. | ||
func (f Factory) Prepare(clientCtx client.Context) (Factory, error) { | ||
fc := f | ||
from := clientCtx.GetFromAddress() | ||
|
@@ -471,14 +471,19 @@ func (f Factory) Prepare(clientCtx client.Context) (Factory, error) { | |
} | ||
|
||
initNum, initSeq := fc.accountNumber, fc.sequence | ||
if initNum == 0 && initSeq == 0 { | ||
if !clientCtx.Offline && (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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Partly reverts #15123 |
||
fc = fc.WithAccountNumber(num) | ||
} | ||
|
||
if initSeq == 0 { | ||
fc = fc.WithSequence(seq) | ||
} | ||
} | ||
|
||
return fc, nil | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From an offline standpoint, I think, we should not even try the above right?
So, if in offline mode, we simply return the factory early? and keep the
||
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, doing that then.