Override auth module codec for all references to Ethermint codec (#103)

This commit is contained in:
Austin Abell
2019-09-18 14:50:06 -04:00
committed by GitHub
parent 6c72a79035
commit 69567e29d5
4 changed files with 11 additions and 112 deletions
+1 -1
View File
@@ -118,7 +118,7 @@ func GetCmdGenETHTx(cdc *codec.Codec) *cobra.Command {
payload := args[3]
txBldr, err = emintUtils.PrepareTxBuilder(txBldr, cliCtx)
txBldr, err = utils.PrepareTxBuilder(txBldr, cliCtx)
if err != nil {
return err
}
-31
View File
@@ -342,34 +342,3 @@ func getFromFields(from string, genOnly bool) (sdk.AccAddress, string, error) {
return info.GetAddress(), info.GetName(), nil
}
// * Overriden function from cosmos-sdk/auth/client/utils/tx.go
// PrepareTxBuilder populates a TxBuilder in preparation for the build of a Tx.
func PrepareTxBuilder(txBldr authtypes.TxBuilder, cliCtx context.CLIContext) (authtypes.TxBuilder, error) {
from := cliCtx.GetFromAddress()
// * Function is needed to override to use different account getter (to not use static codec)
accGetter := emint.NewAccountRetriever(cliCtx, cliCtx.Codec)
if err := accGetter.EnsureExists(from); err != nil {
return txBldr, err
}
txbldrAccNum, txbldrAccSeq := txBldr.AccountNumber(), txBldr.Sequence()
// TODO: (ref #1903) Allow for user supplied account number without
// automatically doing a manual lookup.
if txbldrAccNum == 0 || txbldrAccSeq == 0 {
num, seq, err := accGetter.GetAccountNumberSequence(from)
if err != nil {
return txBldr, err
}
if txbldrAccNum == 0 {
txBldr = txBldr.WithAccountNumber(num)
}
if txbldrAccSeq == 0 {
txBldr = txBldr.WithSequence(seq)
}
}
return txBldr, nil
}