Skip to content

Commit

Permalink
Merge pull request cosmos#1032 from elvin-du/develop
Browse files Browse the repository at this point in the history
Autosequence IBC relay account nonces
  • Loading branch information
cwgoes authored May 23, 2018
2 parents 1d17526 + 53e0b3b commit 6e92c8f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.18.1

BUG FIXES
* auto-sequencing transactions correctly
* query sequence via account store

## 0.18.0

*TBD*
Expand Down
47 changes: 46 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions x/ibc/client/cli/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type relayCommander struct {
decoder sdk.AccountDecoder
mainStore string
ibcStore string
accStore string

logger log.Logger
}
Expand All @@ -41,6 +42,7 @@ func IBCRelayCmd(cdc *wire.Codec) *cobra.Command {
decoder: authcmd.GetAccountDecoder(cdc),
ibcStore: "ibc",
mainStore: "main",
accStore: "acc",

logger: log.NewTMLogger(log.NewSyncWriter(os.Stdout)),
}
Expand Down Expand Up @@ -157,17 +159,20 @@ func (c relayCommander) broadcastTx(seq int64, node string, tx []byte) error {
}

func (c relayCommander) getSequence(node string) int64 {
res, err := query(node, c.address, c.mainStore)
res, err := query(node, c.address, c.accStore)
if err != nil {
panic(err)
}
if nil != res {
account, err := c.decoder(res)
if err != nil {
panic(err)
}

account, err := c.decoder(res)
if err != nil {
panic(err)
return account.GetSequence()
}

return account.GetSequence()
return 0
}

func (c relayCommander) refine(bz []byte, sequence int64, passphrase string) []byte {
Expand All @@ -182,7 +187,7 @@ func (c relayCommander) refine(bz []byte, sequence int64, passphrase string) []b
Sequence: sequence,
}

ctx := context.NewCoreContextFromViper()
ctx := context.NewCoreContextFromViper().WithSequence(sequence)
res, err := ctx.SignAndBuild(ctx.FromAddressName, passphrase, msg, c.cdc)
if err != nil {
panic(err)
Expand Down

0 comments on commit 6e92c8f

Please sign in to comment.