diff --git a/client/client.go b/client/client.go index cc2b37c..9f112f1 100644 --- a/client/client.go +++ b/client/client.go @@ -6,11 +6,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/tendermint/go-amino" "github.com/tendermint/tendermint/libs/log" rpcclient "github.com/tendermint/tendermint/rpc/client/http" ctypes "github.com/tendermint/tendermint/rpc/core/types" tmtypes "github.com/tendermint/tendermint/types" - "github.com/tendermint/go-amino" "github.com/kava-labs/go-sdk/keys" ) @@ -44,9 +44,16 @@ func NewKavaClient(cdc *amino.Codec, mnemonic string, coinID uint32, rpcAddr str } } -// Broadcast sends a message to the Kava blockchain as a transaction +// Broadcast sends a message to the Kava blockchain as a transaction. +// This pays no transaction fees. func (kc *KavaClient) Broadcast(m sdk.Msg, syncType SyncType) (*ctypes.ResultBroadcastTx, error) { - signBz, err := kc.sign(m) + fee := authtypes.NewStdFee(250000, nil) + return kc.BroadcastWithFee(m, fee, syncType) +} + +// BroadcastWithFee sends a message to the Kava blockchain as a transaction, paying the specified transaction fee. +func (kc *KavaClient) BroadcastWithFee(m sdk.Msg, fee authtypes.StdFee, syncType SyncType) (*ctypes.ResultBroadcastTx, error) { + signBz, err := kc.sign(m, fee) if err != nil { return nil, err } @@ -79,7 +86,7 @@ func (kc *KavaClient) Broadcast(m sdk.Msg, syncType SyncType) (*ctypes.ResultBro } } -func (kc *KavaClient) sign(m sdk.Msg) ([]byte, error) { +func (kc *KavaClient) sign(m sdk.Msg, fee authtypes.StdFee) ([]byte, error) { if kc.Keybase == nil { return nil, fmt.Errorf("Keys are missing, must to set key") } @@ -93,7 +100,7 @@ func (kc *KavaClient) sign(m sdk.Msg) ([]byte, error) { ChainID: chainID, AccountNumber: 0, Sequence: 0, - Fee: authtypes.NewStdFee(250000, nil), + Fee: fee, Msgs: []sdk.Msg{m}, Memo: "", } diff --git a/go.mod b/go.mod index b282df8..ada9385 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/btcsuite/btcd v0.20.1-beta github.com/cosmos/cosmos-sdk v0.39.1 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d - github.com/kava-labs/kava v0.11.0-rc1 + github.com/kava-labs/kava v0.12.0 github.com/stretchr/testify v1.6.1 github.com/tendermint/go-amino v0.15.1 github.com/tendermint/tendermint v0.33.7 diff --git a/go.sum b/go.sum index 485ddda..d5c4c41 100644 --- a/go.sum +++ b/go.sum @@ -237,10 +237,8 @@ github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kava-labs/kava v0.11.0-alpha.1.0.20200922214458-087b10d15ff2 h1:D2RyPYygQ7cr08ax3D03qC+c6gep7TTHf+NNucNKSu0= -github.com/kava-labs/kava v0.11.0-alpha.1.0.20200922214458-087b10d15ff2/go.mod h1:1AYBNxuelDdwzZzWFsgPUMVwZ9qfKSjgT6UEEhTe/ys= -github.com/kava-labs/kava v0.11.0-rc1 h1:2qV0SYgtzPxZ+oLJV5dzLweLNa0AXxM7X+n1zrnDOS0= -github.com/kava-labs/kava v0.11.0-rc1/go.mod h1:1AYBNxuelDdwzZzWFsgPUMVwZ9qfKSjgT6UEEhTe/ys= +github.com/kava-labs/kava v0.12.0 h1:ix/Ooq5HV9pIvUd2nbHjnDheGx65+x3Da5pecI0OXpQ= +github.com/kava-labs/kava v0.12.0/go.mod h1:1AYBNxuelDdwzZzWFsgPUMVwZ9qfKSjgT6UEEhTe/ys= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= diff --git a/keys/keys.go b/keys/keys.go index b6e0ede..786b974 100644 --- a/keys/keys.go +++ b/keys/keys.go @@ -12,13 +12,13 @@ import ( "strings" "github.com/btcsuite/btcd/btcec" - "github.com/cosmos/go-bip39" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/go-bip39" + "github.com/tendermint/go-amino" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/tendermint/go-amino" ) const (