From eb2380383306fa281926fbd2fea94f84ea62a7a9 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Tue, 13 Mar 2018 13:46:08 +0100 Subject: [PATCH] remove tx.GetFeePayer --- baseapp/baseapp_test.go | 1 - docs/guide.md | 13 +++---------- docs/sdk/overview.rst | 11 ----------- examples/kvstore/tx.go | 4 ---- mock/tx.go | 4 ---- types/tx_msg.go | 12 +++++++----- 6 files changed, 10 insertions(+), 35 deletions(-) diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 5cc20185d4..de9a0253c5 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -328,7 +328,6 @@ func (tx testUpdatePowerTx) GetMsg() sdk.Msg { return tx func (tx testUpdatePowerTx) GetSignBytes() []byte { return nil } func (tx testUpdatePowerTx) ValidateBasic() sdk.Error { return nil } func (tx testUpdatePowerTx) GetSigners() []sdk.Address { return nil } -func (tx testUpdatePowerTx) GetFeePayer() sdk.Address { return nil } func (tx testUpdatePowerTx) GetSignatures() []sdk.StdSignature { return nil } func TestValidatorChange(t *testing.T) { diff --git a/docs/guide.md b/docs/guide.md index 1a6d21c82a..5c31d2e271 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -105,14 +105,6 @@ type Tx interface { GetMsg() Msg - // The address that pays the base fee for this message. The fee is - // deducted before the Msg is processed. - GetFeePayer() Address - - // Get the canonical byte representation of the Tx. - // Includes any signatures (or empty slots). - GetTxBytes() []byte - // Signatures returns the signature of signers who signed the Msg. // CONTRACT: Length returned is same as length of // pubkeys returned from MsgKeySigners, and the order @@ -148,8 +140,9 @@ case of Basecoin, the public key only needs to be included in the first transaction send by a given account - after that, the public key is forever stored by the application and can be left out of transactions. -Transactions can also specify the address responsible for paying the -transaction's fees using the `tx.GetFeePayer()` method. +The address responsible for paying the transactions fee is the first address +returned by msg.GetSigners(). The convenience function `FeePayer(tx Tx)` is provided +to return this. The standard way to create a transaction from a message is to use the `StdTx`: diff --git a/docs/sdk/overview.rst b/docs/sdk/overview.rst index bf7b23a606..9e79dd04ff 100644 --- a/docs/sdk/overview.rst +++ b/docs/sdk/overview.rst @@ -219,14 +219,6 @@ A transaction is a message with additional information for authentication: GetMsg() Msg - // The address that pays the base fee for this message. The fee is - // deducted before the Msg is processed. - GetFeePayer() Address - - // Get the canonical byte representation of the Tx. - // Includes any signatures (or empty slots). - GetTxBytes() []byte - // Signatures returns the signature of signers who signed the Msg. // CONTRACT: Length returned is same as length of // pubkeys returned from MsgKeySigners, and the order @@ -261,9 +253,6 @@ case of Basecoin, the public key only needs to be included in the first transaction send by a given account - after that, the public key is forever stored by the application and can be left out of transactions. -Transactions can also specify the address responsible for paying the -transaction's fees using the ``tx.GetFeePayer()`` method. - The standard way to create a transaction from a message is to use the ``StdTx``: :: diff --git a/examples/kvstore/tx.go b/examples/kvstore/tx.go index fdecf63807..c9c30c885d 100644 --- a/examples/kvstore/tx.go +++ b/examples/kvstore/tx.go @@ -51,10 +51,6 @@ func (tx kvstoreTx) GetSignatures() []sdk.StdSignature { return nil } -func (tx kvstoreTx) GetFeePayer() sdk.Address { - return nil -} - // takes raw transaction bytes and decodes them into an sdk.Tx. An sdk.Tx has // all the signatures and can be used to authenticate. func decodeTx(txBytes []byte) (sdk.Tx, sdk.Error) { diff --git a/mock/tx.go b/mock/tx.go index efe60feb91..326946eaa5 100644 --- a/mock/tx.go +++ b/mock/tx.go @@ -64,10 +64,6 @@ func (tx kvstoreTx) GetSignatures() []sdk.StdSignature { return nil } -func (tx kvstoreTx) GetFeePayer() sdk.Address { - return nil -} - // takes raw transaction bytes and decodes them into an sdk.Tx. An sdk.Tx has // all the signatures and can be used to authenticate. func decodeTx(txBytes []byte) (sdk.Tx, sdk.Error) { diff --git a/types/tx_msg.go b/types/tx_msg.go index 141f9d050d..8510237487 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -33,10 +33,6 @@ type Tx interface { // Gets the Msg. GetMsg() Msg - // The address that pays the base fee for this message. The fee is - // deducted before the Msg is processed. - GetFeePayer() Address - // Signatures returns the signature of signers who signed the Msg. // CONTRACT: Length returned is same as length of // pubkeys returned from MsgKeySigners, and the order @@ -63,9 +59,15 @@ func NewStdTx(msg Msg, sigs []StdSignature) StdTx { } } +// FeePayer returns the address responsible for paying the fees +// for the transactions. It's the first address returned by msg.GetSigners(). +// If GetSigners() is empty, this panics. +func FeePayer(tx Tx) Address { + return tx.GetMsg().GetSigners()[0] +} + //nolint func (tx StdTx) GetMsg() Msg { return tx.Msg } -func (tx StdTx) GetFeePayer() Address { return tx.Signatures[0].PubKey.Address() } // XXX but PubKey is optional! func (tx StdTx) GetSignatures() []StdSignature { return tx.Signatures } // StdSignDoc is replay-prevention structure.