From e387fa1050d8865e3d84bbdfe50639bcc47a239c Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Sun, 22 Mar 2020 17:52:19 -0700 Subject: [PATCH] Merge PR #46: Continued account prefix fixes * Add address check in only other places where we fetch key * Try setting config right above failure --- relayer/chain.go | 3 +++ relayer/faucet.go | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/relayer/chain.go b/relayer/chain.go index 21b7f5f5e34..528f4c78741 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -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 diff --git a/relayer/faucet.go b/relayer/faucet.go index af7c3eece5b..269efddf795 100644 --- a/relayer/faucet.go +++ b/relayer/faucet.go @@ -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 { @@ -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