From 33c090ee179a0e3ce6f5c83b33bcd7cc9832f7b3 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 24 Mar 2020 18:56:20 -0400 Subject: [PATCH] Use auth instead of func interface --- client/tx/factory.go | 15 --------------- client/tx/tx.go | 7 ++++--- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/client/tx/factory.go b/client/tx/factory.go index 1bd4fd9752..55a4982cb8 100644 --- a/client/tx/factory.go +++ b/client/tx/factory.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/spf13/viper" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keys" @@ -26,8 +25,6 @@ type Factory struct { keybase keys.Keybase txGenerator Generator accountRetriever AccountRetriever - feeFn func(gas uint64, amount sdk.Coins) sdk.Fee - sigFn func(pk crypto.PubKey, sig []byte) sdk.Signature accountNumber uint64 sequence uint64 gas uint64 @@ -107,18 +104,6 @@ func (f Factory) WithGas(gas uint64) Factory { return f } -// WithSigFn returns a copy of the Builder with an updated tx signature constructor. -func (f Factory) WithSigFn(sigFn func(pk crypto.PubKey, sig []byte) sdk.Signature) Factory { - f.sigFn = sigFn - return f -} - -// WithFeeFn returns a copy of the Builder with an updated fee constructor. -func (f Factory) WithFeeFn(feeFn func(gas uint64, amount sdk.Coins) sdk.Fee) Factory { - f.feeFn = feeFn - return f -} - // WithFees returns a copy of the Builder with an updated fee. func (f Factory) WithFees(fees string) Factory { parsedFees, err := sdk.ParseCoins(fees) diff --git a/client/tx/tx.go b/client/tx/tx.go index cb90d3aef0..dca9787c2a 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -16,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth" ) type ( @@ -187,7 +188,7 @@ func BuildUnsignedTx(txf Factory, msgs ...sdk.Msg) (ClientTx, error) { } tx := txf.txGenerator.NewTx() - tx.SetFee(txf.feeFn(txf.gas, fees)) + tx.SetFee(auth.NewStdFee(txf.gas, fees)) tx.SetMsgs(msgs...) tx.SetMemo(txf.memo) tx.SetSignatures(nil) @@ -206,7 +207,7 @@ func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error) { // Create an empty signature literal as the ante handler will populate with a // sentinel pubkey. - tx.SetSignatures(txf.sigFn(nil, nil)) + tx.SetSignatures(auth.NewStdSignature(nil, nil)) return tx.Marshal() } @@ -292,7 +293,7 @@ func Sign(txf Factory, name, passphrase string, tx ClientTx) ([]byte, error) { return nil, err } - tx.SetSignatures(txf.sigFn(pubkey, sigBytes)) + tx.SetSignatures(auth.NewStdSignature(pubkey, sigBytes)) return tx.Marshal() }