Skip to content

Commit

Permalink
Merge PR #46: Continued account prefix fixes
Browse files Browse the repository at this point in the history
* Add address check in only other places where we fetch key

* Try setting config right above failure
  • Loading branch information
jackzampolin authored Mar 23, 2020
1 parent 3a6b12c commit e387fa1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions relayer/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ func (src *Chain) SendMsgs(datagrams []sdk.Msg) (res sdk.TxResponse, err error)
// BuildAndSignTx takes messages and builds, signs and marshals a sdk.Tx to prepare it for broadcast
func (src *Chain) BuildAndSignTx(datagram []sdk.Msg) ([]byte, error) {
// Fetch account and sequence numbers for the account
sdkConf := sdk.GetConfig()
sdkConf.SetBech32PrefixForAccount(src.AccountPrefix, src.AccountPrefix+"pub")

acc, err := auth.NewAccountRetriever(src.Cdc, src).GetAccount(src.MustGetAddress())
if err != nil {
return nil, err
Expand Down
8 changes: 8 additions & 0 deletions relayer/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func (src *Chain) SendMsgWithKey(datagram sdk.Msg, keyName string) (res sdk.TxRe

// BuildAndSignTxWithKey allows the user to specify which relayer key will sign the message
func (src *Chain) BuildAndSignTxWithKey(datagram []sdk.Msg, keyName string) ([]byte, error) {
// Set sdk config to use custom Bech32 account prefix
sdkConf := sdk.GetConfig()
sdkConf.SetBech32PrefixForAccount(src.AccountPrefix, src.AccountPrefix+"pub")

// Fetch account and sequence numbers for the account
info, err := src.Keybase.Get(keyName)
if err != nil {
Expand Down Expand Up @@ -71,6 +75,10 @@ func (src *Chain) FaucetHandler(fromKey sdk.AccAddress, amount sdk.Coin) func(w
}

func (src *Chain) faucetSend(fromAddr, toAddr sdk.AccAddress, amount sdk.Coin) error {
// Set sdk config to use custom Bech32 account prefix
sdkConf := sdk.GetConfig()
sdkConf.SetBech32PrefixForAccount(src.AccountPrefix, src.AccountPrefix+"pub")

info, err := src.Keybase.GetByAddress(fromAddr)
if err != nil {
return err
Expand Down

0 comments on commit e387fa1

Please sign in to comment.