Migrate {x/auth, x/gov, x/staking} missing CLI queries to proto (#6994)

* Fix error code

* Fix decoder

* Fix typo

* Fix decode

* refactor

* Migrate SearchTxsResult to proto

* fix MarkEventsToIndex

* lint++

* Fix output

* Add QueryTxCmd cli test

* Add fmt

* Put txBuilder in types/tx

* Add GetAnyTx in TxBuilder

* Add new IsAnyTx

* Rename to IntoAny

* Fix bug

* fmt

Co-authored-by: Marie <marie.gauthier63@gmail.com>

* Fix ibc CLI to use proto

* Fix any MarshalJSON

* Fix test

* Make tx.Tx implement sdk.Tx

* Register sdk.Tx

* Fix lint

* Allow DefaultJSONTxEncoder to take tx.Tx

* refactor

* Rename variable

* remove fmt

Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Marie <marie.gauthier63@gmail.com>
This commit is contained in:
SaReN 2020-09-10 23:56:47 +05:30 committed by GitHub
parent d84296a5fc
commit b2348180b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 758 additions and 258 deletions

View File

@ -11,10 +11,12 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/simulate"
"github.com/cosmos/cosmos-sdk/client/tx"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@ -98,9 +100,14 @@ func (s IntegrationTestSuite) TestSimulateService() {
)
txBuilder.SetSignatures(sigV2)
any, ok := txBuilder.(codectypes.IntoAny)
s.Require().True(ok)
cached := any.AsAny().GetCachedValue()
txTx, ok := cached.(*txtypes.Tx)
s.Require().True(ok)
res, err := s.queryClient.Simulate(
context.Background(),
&simulate.SimulateRequest{Tx: txBuilder.GetProtoTx()},
&simulate.SimulateRequest{Tx: txTx},
)
s.Require().NoError(err)

View File

@ -12,7 +12,6 @@ import (
// ConvertTxToStdTx converts a transaction to the legacy StdTx format
func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (types.StdTx, error) {
if stdTx, ok := tx.(types.StdTx); ok {
return stdTx, nil
}

View File

@ -3,26 +3,21 @@ package tx_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/client"
tx2 "github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
types3 "github.com/cosmos/cosmos-sdk/x/auth/types"
signing2 "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/types"
signing2 "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
types3 "github.com/cosmos/cosmos-sdk/x/auth/types"
types2 "github.com/cosmos/cosmos-sdk/x/bank/types"
)

View File

@ -14,9 +14,11 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
sim "github.com/cosmos/cosmos-sdk/client/grpc/simulate"
"github.com/cosmos/cosmos-sdk/client/input"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
)
@ -265,7 +267,17 @@ func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error) {
return nil, err
}
simReq := sim.SimulateRequest{Tx: txb.GetProtoTx()}
any, ok := txb.(codectypes.IntoAny)
if !ok {
return nil, fmt.Errorf("cannot simulate tx that cannot be wrapped into any")
}
cached := any.AsAny().GetCachedValue()
protoTx, ok := cached.(*tx.Tx)
if !ok {
return nil, fmt.Errorf("cannot simulate amino tx")
}
simReq := sim.SimulateRequest{Tx: protoTx}
return simReq.Marshal()
}

View File

@ -15,13 +15,12 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)
func NewTestTxConfig() client.TxConfig {
_, cdc := simapp.MakeCodecs()
return types.StdTxConfig{Cdc: cdc}
cfg := simapp.MakeEncodingConfig()
return cfg.TxConfig
}
func TestCalculateGas(t *testing.T) {

View File

@ -2,7 +2,6 @@ package client
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
)
@ -36,8 +35,6 @@ type (
// also know how to encode itself.
TxBuilder interface {
GetTx() signing.Tx
// GetProtoTx returns the tx as a proto.Message.
GetProtoTx() *tx.Tx
SetMsgs(msgs ...sdk.Msg) error
SetSignatures(signatures ...signingtypes.SignatureV2) error

View File

@ -91,7 +91,7 @@ func (any *Any) Pack(x proto.Message) error {
func UnsafePackAny(x interface{}) *Any {
if msg, ok := x.(proto.Message); ok {
any, err := NewAnyWithValue(msg)
if err != nil {
if err == nil {
return any
}
}
@ -107,3 +107,8 @@ func (any *Any) GetCachedValue() interface{} {
func (any *Any) ClearCachedValue() {
any.cachedValue = nil
}
// IntoAny represents a type that can be wrapped into an Any.
type IntoAny interface {
AsAny() *Any
}

View File

@ -50,7 +50,7 @@ func (any *Any) UnmarshalAmino(bz []byte) error {
return nil
}
func (any Any) MarshalJSON() ([]byte, error) {
func (any *Any) MarshalJSON() ([]byte, error) {
ac := any.compat
if ac == nil {
return nil, anyCompatError("JSON marshal", any)

View File

@ -114,3 +114,30 @@ message TxMsgData {
repeated MsgData data = 1;
}
// SearchTxsResult defines a structure for querying txs pageable
message SearchTxsResult {
option (gogoproto.stringer) = true;
// Count of all txs
uint64 total_count = 1 [
(gogoproto.moretags) = "yaml:\"total_count\"",
(gogoproto.jsontag) = "total_count"
];
// Count of txs in current page
uint64 count = 2;
// Index of current page, start from 1
uint64 page_number = 3 [
(gogoproto.moretags) = "yaml:\"page_number\"",
(gogoproto.jsontag) = "page_number"
];
// Count of total pages
uint64 page_total = 4 [
(gogoproto.moretags) = "yaml:\"page_total\"",
(gogoproto.jsontag) = "page_total"
];
// Max count txs per page
uint64 limit = 5;
// List of txs in current page
repeated TxResponse txs = 6;
}

View File

@ -5,6 +5,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
)
@ -17,5 +18,6 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
// RegisterInterfaces registers Interfaces from sdk/types and vesting
func RegisterInterfaces(interfaceRegistry types.InterfaceRegistry) {
sdk.RegisterInterfaces(interfaceRegistry)
txtypes.RegisterInterfaces(interfaceRegistry)
vesting.RegisterInterfaces(interfaceRegistry)
}

View File

@ -498,6 +498,96 @@ func (m *TxMsgData) GetData() []*MsgData {
return nil
}
// SearchTxsResult defines a structure for querying txs pageable
type SearchTxsResult struct {
// Count of all txs
TotalCount uint64 `protobuf:"varint,1,opt,name=total_count,json=totalCount,proto3" json:"total_count" yaml:"total_count"`
// Count of txs in current page
Count uint64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
// Index of current page, start from 1
PageNumber uint64 `protobuf:"varint,3,opt,name=page_number,json=pageNumber,proto3" json:"page_number" yaml:"page_number"`
// Count of total pages
PageTotal uint64 `protobuf:"varint,4,opt,name=page_total,json=pageTotal,proto3" json:"page_total" yaml:"page_total",json:"page_total"`
// Max count txs per page
Limit uint64 `protobuf:"varint,5,opt,name=limit,proto3" json:"limit,omitempty"`
// List of txs in current page
Txs []*TxResponse `protobuf:"bytes,6,rep,name=txs,proto3" json:"txs,omitempty"`
}
func (m *SearchTxsResult) Reset() { *m = SearchTxsResult{} }
func (*SearchTxsResult) ProtoMessage() {}
func (*SearchTxsResult) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37629bc7eb0df8, []int{9}
}
func (m *SearchTxsResult) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SearchTxsResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SearchTxsResult.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *SearchTxsResult) XXX_Merge(src proto.Message) {
xxx_messageInfo_SearchTxsResult.Merge(m, src)
}
func (m *SearchTxsResult) XXX_Size() int {
return m.Size()
}
func (m *SearchTxsResult) XXX_DiscardUnknown() {
xxx_messageInfo_SearchTxsResult.DiscardUnknown(m)
}
var xxx_messageInfo_SearchTxsResult proto.InternalMessageInfo
func (m *SearchTxsResult) GetTotalCount() uint64 {
if m != nil {
return m.TotalCount
}
return 0
}
func (m *SearchTxsResult) GetCount() uint64 {
if m != nil {
return m.Count
}
return 0
}
func (m *SearchTxsResult) GetPageNumber() uint64 {
if m != nil {
return m.PageNumber
}
return 0
}
func (m *SearchTxsResult) GetPageTotal() uint64 {
if m != nil {
return m.PageTotal
}
return 0
}
func (m *SearchTxsResult) GetLimit() uint64 {
if m != nil {
return m.Limit
}
return 0
}
func (m *SearchTxsResult) GetTxs() []*TxResponse {
if m != nil {
return m.Txs
}
return nil
}
func init() {
proto.RegisterType((*TxResponse)(nil), "cosmos.base.abci.v1beta1.TxResponse")
proto.RegisterType((*ABCIMessageLog)(nil), "cosmos.base.abci.v1beta1.ABCIMessageLog")
@ -508,6 +598,7 @@ func init() {
proto.RegisterType((*SimulationResponse)(nil), "cosmos.base.abci.v1beta1.SimulationResponse")
proto.RegisterType((*MsgData)(nil), "cosmos.base.abci.v1beta1.MsgData")
proto.RegisterType((*TxMsgData)(nil), "cosmos.base.abci.v1beta1.TxMsgData")
proto.RegisterType((*SearchTxsResult)(nil), "cosmos.base.abci.v1beta1.SearchTxsResult")
}
func init() {
@ -515,57 +606,66 @@ func init() {
}
var fileDescriptor_4e37629bc7eb0df8 = []byte{
// 786 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x4b, 0x6f, 0xdb, 0x46,
0x10, 0x16, 0x25, 0x99, 0x12, 0x47, 0x76, 0xdd, 0x6e, 0x55, 0x9b, 0xb6, 0x5b, 0x49, 0xa5, 0x5b,
0x40, 0x97, 0x52, 0xf0, 0xa3, 0x40, 0xe1, 0x43, 0x51, 0xb3, 0x2f, 0x0b, 0xb0, 0x2f, 0xb4, 0x8c,
0x00, 0xb9, 0x08, 0x2b, 0x71, 0xbd, 0x62, 0x2c, 0x72, 0x05, 0xee, 0xca, 0x96, 0x6e, 0x39, 0xe6,
0x98, 0x93, 0x0f, 0x39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
0xfa, 0x5d, 0x2c, 0x7c, 0x16, 0x4e, 0xdf, 0xf0, 0x7f, 0x71, 0xcb, 0x6a, 0xab, 0x35, 0xb5, 0x89,
0x3f, 0x2f, 0xe6, 0x3d, 0x61, 0xc7, 0xc9, 0xcb, 0xfa, 0xb7, 0xa3, 0xb2, 0xa6, 0x46, 0x51, 0x84,
0xfd, 0x01, 0x7a, 0xa4, 0x46, 0x51, 0xfd, 0x16, 0x76, 0x2b, 0x8b, 0xab, 0xc4, 0x23, 0xbb, 0x09,
0xde, 0xfa, 0x13, 0x72, 0x27, 0x9c, 0xfe, 0x23, 0x27, 0xde, 0x00, 0xb9, 0xa2, 0xcd, 0xb9, 0xf5,
0xc8, 0x05, 0x9c, 0x36, 0xe4, 0x86, 0x4c, 0x08, 0x4a, 0xcf, 0x08, 0x4a, 0xa4, 0x3e, 0x02, 0xa3,
0x31, 0x98, 0x54, 0xf8, 0x7d, 0xca, 0x63, 0xe6, 0xe9, 0x51, 0x92, 0x03, 0xf3, 0x95, 0x9c, 0xbf,
0xee, 0x3e, 0x95, 0x52, 0x37, 0xe3, 0x92, 0x76, 0x3b, 0x2e, 0x69, 0x1f, 0xc7, 0x25, 0xed, 0xf5,
0x7d, 0x29, 0x75, 0x7b, 0x5f, 0x4a, 0xdd, 0xdd, 0x97, 0x52, 0xcf, 0x2d, 0xea, 0x8b, 0x4e, 0xbf,
0x65, 0xb7, 0x59, 0x50, 0x4b, 0x7e, 0xca, 0xf1, 0xe7, 0x37, 0xee, 0x5d, 0xc4, 0x7f, 0xd0, 0x96,
0xae, 0x5e, 0xef, 0xde, 0xe7, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x2c, 0x53, 0x4a, 0xb6, 0x05,
0x00, 0x00,
// 932 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x55, 0x31, 0x73, 0x1b, 0x45,
0x14, 0xd6, 0x49, 0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+1112,68 @@ func (m *TxMsgData) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *SearchTxsResult) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SearchTxsResult) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *SearchTxsResult) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Txs) > 0 {
for iNdEx := len(m.Txs) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Txs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintAbci(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x32
}
}
if m.Limit != 0 {
i = encodeVarintAbci(dAtA, i, uint64(m.Limit))
i--
dAtA[i] = 0x28
}
if m.PageTotal != 0 {
i = encodeVarintAbci(dAtA, i, uint64(m.PageTotal))
i--
dAtA[i] = 0x20
}
if m.PageNumber != 0 {
i = encodeVarintAbci(dAtA, i, uint64(m.PageNumber))
i--
dAtA[i] = 0x18
}
if m.Count != 0 {
i = encodeVarintAbci(dAtA, i, uint64(m.Count))
i--
dAtA[i] = 0x10
}
if m.TotalCount != 0 {
i = encodeVarintAbci(dAtA, i, uint64(m.TotalCount))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func encodeVarintAbci(dAtA []byte, offset int, v uint64) int {
offset -= sovAbci(v)
base := offset
@ -1221,6 +1383,36 @@ func (m *TxMsgData) Size() (n int) {
return n
}
func (m *SearchTxsResult) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.TotalCount != 0 {
n += 1 + sovAbci(uint64(m.TotalCount))
}
if m.Count != 0 {
n += 1 + sovAbci(uint64(m.Count))
}
if m.PageNumber != 0 {
n += 1 + sovAbci(uint64(m.PageNumber))
}
if m.PageTotal != 0 {
n += 1 + sovAbci(uint64(m.PageTotal))
}
if m.Limit != 0 {
n += 1 + sovAbci(uint64(m.Limit))
}
if len(m.Txs) > 0 {
for _, e := range m.Txs {
l = e.Size()
n += 1 + l + sovAbci(uint64(l))
}
}
return n
}
func sovAbci(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@ -1286,6 +1478,26 @@ func (this *TxMsgData) String() string {
}, "")
return s
}
func (this *SearchTxsResult) String() string {
if this == nil {
return "nil"
}
repeatedStringForTxs := "[]*TxResponse{"
for _, f := range this.Txs {
repeatedStringForTxs += strings.Replace(fmt.Sprintf("%v", f), "TxResponse", "TxResponse", 1) + ","
}
repeatedStringForTxs += "}"
s := strings.Join([]string{`&SearchTxsResult{`,
`TotalCount:` + fmt.Sprintf("%v", this.TotalCount) + `,`,
`Count:` + fmt.Sprintf("%v", this.Count) + `,`,
`PageNumber:` + fmt.Sprintf("%v", this.PageNumber) + `,`,
`PageTotal:` + fmt.Sprintf("%v", this.PageTotal) + `,`,
`Limit:` + fmt.Sprintf("%v", this.Limit) + `,`,
`Txs:` + repeatedStringForTxs + `,`,
`}`,
}, "")
return s
}
func valueToStringAbci(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
@ -2631,6 +2843,188 @@ func (m *TxMsgData) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *SearchTxsResult) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAbci
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: SearchTxsResult: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SearchTxsResult: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field TotalCount", wireType)
}
m.TotalCount = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAbci
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.TotalCount |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType)
}
m.Count = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAbci
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Count |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field PageNumber", wireType)
}
m.PageNumber = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAbci
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.PageNumber |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field PageTotal", wireType)
}
m.PageTotal = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAbci
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.PageTotal |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 5:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType)
}
m.Limit = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAbci
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Limit |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Txs", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAbci
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthAbci
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthAbci
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Txs = append(m.Txs, &TxResponse{})
if err := m.Txs[len(m.Txs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipAbci(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthAbci
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthAbci
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipAbci(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0

View File

@ -1,9 +1,8 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
)
// RegisterLegacyAminoCodec registers the sdk message type.

View File

@ -12,7 +12,7 @@ import (
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
)
var cdc = codec.NewLegacyAmino()
@ -60,7 +60,7 @@ func (logs ABCIMessageLogs) String() (str string) {
}
// NewResponseResultTx returns a TxResponse given a ResultTx from tendermint
func NewResponseResultTx(res *ctypes.ResultTx, tx Tx, timestamp string) *TxResponse {
func NewResponseResultTx(res *ctypes.ResultTx, anyTx *codectypes.Any, timestamp string) *TxResponse {
if res == nil {
return nil
}
@ -78,7 +78,7 @@ func NewResponseResultTx(res *ctypes.ResultTx, tx Tx, timestamp string) *TxRespo
Info: res.TxResult.Info,
GasWanted: res.TxResult.GasWanted,
GasUsed: res.TxResult.GasUsed,
Tx: types.UnsafePackAny(tx),
Tx: anyTx,
Timestamp: timestamp,
}
}
@ -213,22 +213,12 @@ func (r TxResponse) Empty() bool {
return r.TxHash == "" && r.Logs == nil
}
// SearchTxsResult defines a structure for querying txs pageable
type SearchTxsResult struct {
TotalCount int `json:"total_count"` // Count of all txs
Count int `json:"count"` // Count of txs in current page
PageNumber int `json:"page_number"` // Index of current page, start from 1
PageTotal int `json:"page_total"` // Count of total pages
Limit int `json:"limit"` // Max count txs per page
Txs []*TxResponse `json:"txs"` // List of txs in current page
}
func NewSearchTxsResult(totalCount, count, page, limit int, txs []*TxResponse) SearchTxsResult {
return SearchTxsResult{
func NewSearchTxsResult(totalCount, count, page, limit uint64, txs []*TxResponse) *SearchTxsResult {
return &SearchTxsResult{
TotalCount: totalCount,
Count: count,
PageNumber: page,
PageTotal: int(math.Ceil(float64(totalCount) / float64(limit))),
PageTotal: uint64(math.Ceil(float64(totalCount) / float64(limit))),
Limit: limit,
Txs: txs,
}
@ -241,15 +231,15 @@ func ParseABCILogs(logs string) (res ABCIMessageLogs, err error) {
return res, err
}
var _, _ types.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{}
var _, _ codectypes.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
//
// types.UnpackInterfaces needs to be called for each nested Tx because
// there are generally interfaces to unpack in Tx's
func (s SearchTxsResult) UnpackInterfaces(unpacker types.AnyUnpacker) error {
func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
for _, tx := range s.Txs {
err := types.UnpackInterfaces(tx, unpacker)
err := codectypes.UnpackInterfaces(tx, unpacker)
if err != nil {
return err
}
@ -258,7 +248,7 @@ func (s SearchTxsResult) UnpackInterfaces(unpacker types.AnyUnpacker) error {
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (r TxResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error {
func (r TxResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
if r.Tx != nil {
var tx Tx
return unpacker.UnpackAny(r.Tx, &tx)

View File

@ -11,7 +11,6 @@ import (
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -41,7 +40,7 @@ func TestABCIMessageLog(t *testing.T) {
func TestNewSearchTxsResult(t *testing.T) {
t.Parallel()
got := sdk.NewSearchTxsResult(150, 20, 2, 20, []*sdk.TxResponse{})
require.Equal(t, sdk.SearchTxsResult{
require.Equal(t, &sdk.SearchTxsResult{
TotalCount: 150,
Count: 20,
PageNumber: 2,
@ -93,12 +92,12 @@ func TestResponseResultTx(t *testing.T) {
Info: "info",
GasWanted: 100,
GasUsed: 90,
Tx: &types.Any{},
Tx: nil,
Timestamp: "timestamp",
}
require.Equal(t, want, sdk.NewResponseResultTx(resultTx, sdk.Tx(nil), "timestamp"))
require.Equal(t, (*sdk.TxResponse)(nil), sdk.NewResponseResultTx(nil, sdk.Tx(nil), "timestamp"))
require.Equal(t, want, sdk.NewResponseResultTx(resultTx, nil, "timestamp"))
require.Equal(t, (*sdk.TxResponse)(nil), sdk.NewResponseResultTx(nil, nil, "timestamp"))
require.Equal(t, `Response:
Height: 10
TxHash: 74657374
@ -110,7 +109,7 @@ func TestResponseResultTx(t *testing.T) {
GasWanted: 100
GasUsed: 90
Codespace: codespace
Timestamp: timestamp`, sdk.NewResponseResultTx(resultTx, sdk.Tx(nil), "timestamp").String())
Timestamp: timestamp`, sdk.NewResponseResultTx(resultTx, nil, "timestamp").String())
require.True(t, sdk.TxResponse{}.Empty())
require.False(t, want.Empty())

View File

@ -1,16 +1,106 @@
package tx
import (
fmt "fmt"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// MaxGasWanted defines the max gas allowed.
const MaxGasWanted = uint64((1 << 63) - 1)
var _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}
var _ sdk.Tx = &Tx{}
// GetMsgs implements the GetMsgs method on sdk.Tx.
func (t *Tx) GetMsgs() []sdk.Msg {
if t == nil || t.Body == nil {
return nil
}
anys := t.Body.Messages
res := make([]sdk.Msg, len(anys))
for i, any := range anys {
msg := any.GetCachedValue().(sdk.Msg)
res[i] = msg
}
return res
}
// ValidateBasic implements the ValidateBasic method on sdk.Tx.
func (t *Tx) ValidateBasic() error {
if t == nil {
return fmt.Errorf("bad Tx")
}
body := t.Body
if body == nil {
return fmt.Errorf("missing TxBody")
}
authInfo := t.AuthInfo
if authInfo == nil {
return fmt.Errorf("missing AuthInfo")
}
fee := authInfo.Fee
if fee == nil {
return fmt.Errorf("missing fee")
}
if fee.GasLimit > MaxGasWanted {
return sdkerrors.Wrapf(
sdkerrors.ErrInvalidRequest,
"invalid gas supplied; %d > %d", fee.GasLimit, MaxGasWanted,
)
}
if fee.Amount.IsAnyNegative() {
return sdkerrors.Wrapf(
sdkerrors.ErrInsufficientFee,
"invalid fee provided: %s", fee.Amount,
)
}
sigs := t.Signatures
if len(sigs) == 0 {
return sdkerrors.ErrNoSignatures
}
if len(sigs) != len(t.GetSigners()) {
return sdkerrors.Wrapf(
sdkerrors.ErrUnauthorized,
"wrong number of signers; expected %d, got %d", t.GetSigners(), len(sigs),
)
}
return nil
}
// GetSigners retrieves all the signers of a tx.
func (t *Tx) GetSigners() []sdk.AccAddress {
var signers []sdk.AccAddress
seen := map[string]bool{}
for _, msg := range t.GetMsgs() {
for _, addr := range msg.GetSigners() {
if !seen[addr.String()] {
signers = append(signers, addr)
seen[addr.String()] = true
}
}
}
return signers
}
// UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method
func (m *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
if m.Body != nil {
return m.Body.UnpackInterfaces(unpacker)
func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
if t.Body != nil {
return t.Body.UnpackInterfaces(unpacker)
}
return nil
}
@ -26,3 +116,9 @@ func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
}
return nil
}
// RegisterInterfaces registers the sdk.Tx interface.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterInterface("cosmos.tx.v1beta1.Tx", (*sdk.Tx)(nil))
registry.RegisterImplementations((*sdk.Tx)(nil), &Tx{})
}

View File

@ -8,8 +8,6 @@ import (
"strings"
"testing"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
tmcrypto "github.com/tendermint/tendermint/crypto"
@ -18,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codec2 "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
@ -165,6 +164,46 @@ func (s *IntegrationTestSuite) TestCLISignBatch() {
s.Require().Error(err)
}
func (s *IntegrationTestSuite) TestCLITxQueryCmd() {
val := s.network.Validators[0]
var txHash string
s.Run("bank send tx", func() {
clientCtx := val.ClientCtx
bz, err := bankcli.MsgSendExec(clientCtx, val.Address, val.Address, sdk.NewCoins(
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)),
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)),
), []string{
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
}...)
var txRes sdk.TxResponse
s.Require().NoError(err)
s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(bz.Bytes(), &txRes), bz.String())
txHash = txRes.TxHash
s.Require().Equal(uint32(0), txRes.Code)
})
s.network.WaitForNextBlock()
s.Run("test QueryTxCmd", func() {
cmd := authcli.QueryTxCmd()
args := []string{
txHash,
}
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
s.Require().NoError(err)
var tx sdk.TxResponse
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &tx))
})
}
func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
val1 := s.network.Validators[0]

View File

@ -167,13 +167,7 @@ $ %s query txs --%s 'message.sender=cosmos1...&message.action=withdraw_delegator
return err
}
output, err := clientCtx.LegacyAmino.MarshalJSON(txs)
if err != nil {
return err
}
fmt.Println(string(output))
return nil
return clientCtx.PrintOutput(txs)
},
}

View File

@ -3,15 +3,15 @@ package client
import (
"encoding/hex"
"errors"
"fmt"
"strings"
"time"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
// QueryTxsByEvents performs a search for transactions for a given set of events
@ -53,14 +53,14 @@ func QueryTxsByEvents(clientCtx client.Context, events []string, page, limit int
return nil, err
}
txs, err := formatTxResults(clientCtx.LegacyAmino, resTxs.Txs, resBlocks)
txs, err := formatTxResults(clientCtx.TxConfig, resTxs.Txs, resBlocks)
if err != nil {
return nil, err
}
result := sdk.NewSearchTxsResult(resTxs.TotalCount, len(txs), page, limit, txs)
result := sdk.NewSearchTxsResult(uint64(resTxs.TotalCount), uint64(len(txs)), uint64(page), uint64(limit), txs)
return &result, nil
return result, nil
}
// QueryTx queries for a single transaction by a hash string in hex format. An
@ -88,7 +88,7 @@ func QueryTx(clientCtx client.Context, hashHexStr string) (*sdk.TxResponse, erro
return nil, err
}
out, err := formatTxResult(clientCtx.LegacyAmino, resTx, resBlocks[resTx.Height])
out, err := formatTxResult(clientCtx.TxConfig, resTx, resBlocks[resTx.Height])
if err != nil {
return out, err
}
@ -97,11 +97,11 @@ func QueryTx(clientCtx client.Context, hashHexStr string) (*sdk.TxResponse, erro
}
// formatTxResults parses the indexed txs into a slice of TxResponse objects.
func formatTxResults(cdc *codec.LegacyAmino, resTxs []*ctypes.ResultTx, resBlocks map[int64]*ctypes.ResultBlock) ([]*sdk.TxResponse, error) {
func formatTxResults(txConfig client.TxConfig, resTxs []*ctypes.ResultTx, resBlocks map[int64]*ctypes.ResultBlock) ([]*sdk.TxResponse, error) {
var err error
out := make([]*sdk.TxResponse, len(resTxs))
for i := range resTxs {
out[i], err = formatTxResult(cdc, resTxs[i], resBlocks[resTxs[i].Height])
out[i], err = formatTxResult(txConfig, resTxs[i], resBlocks[resTxs[i].Height])
if err != nil {
return nil, err
}
@ -132,22 +132,27 @@ func getBlocksForTxResults(clientCtx client.Context, resTxs []*ctypes.ResultTx)
return resBlocks, nil
}
func formatTxResult(cdc *codec.LegacyAmino, resTx *ctypes.ResultTx, resBlock *ctypes.ResultBlock) (*sdk.TxResponse, error) {
tx, err := parseTx(cdc, resTx.Tx)
func formatTxResult(txConfig client.TxConfig, resTx *ctypes.ResultTx, resBlock *ctypes.ResultBlock) (*sdk.TxResponse, error) {
anyTx, err := parseTx(txConfig, resTx.Tx)
if err != nil {
return nil, err
}
return sdk.NewResponseResultTx(resTx, tx, resBlock.Block.Time.Format(time.RFC3339)), nil
return sdk.NewResponseResultTx(resTx, anyTx.AsAny(), resBlock.Block.Time.Format(time.RFC3339)), nil
}
func parseTx(cdc *codec.LegacyAmino, txBytes []byte) (sdk.Tx, error) {
var tx types.StdTx
func parseTx(txConfig client.TxConfig, txBytes []byte) (codectypes.IntoAny, error) {
var tx sdk.Tx
err := cdc.UnmarshalBinaryBare(txBytes, &tx)
tx, err := txConfig.TxDecoder()(txBytes)
if err != nil {
return nil, err
}
return tx, nil
anyTx, ok := tx.(codectypes.IntoAny)
if !ok {
return nil, fmt.Errorf("tx cannot be packed into Any")
}
return anyTx, nil
}

View File

@ -1,8 +1,6 @@
package tx
import (
"fmt"
"github.com/gogo/protobuf/proto"
"github.com/tendermint/tendermint/crypto"
@ -10,7 +8,6 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
@ -44,6 +41,7 @@ var (
_ client.TxBuilder = &wrapper{}
_ ante.HasExtensionOptionsTx = &wrapper{}
_ ExtensionOptionsTxBuilder = &wrapper{}
_ codectypes.IntoAny = &wrapper{}
)
// ExtensionOptionsTxBuilder defines a TxBuilder that can also set extensions.
@ -67,71 +65,11 @@ func newBuilder(pubkeyCodec types.PublicKeyCodec) *wrapper {
}
func (w *wrapper) GetMsgs() []sdk.Msg {
if w.tx == nil || w.tx.Body == nil {
return nil
}
anys := w.tx.Body.Messages
res := make([]sdk.Msg, len(anys))
for i, any := range anys {
msg := any.GetCachedValue().(sdk.Msg)
res[i] = msg
}
return res
return w.tx.GetMsgs()
}
// MaxGasWanted defines the max gas allowed.
const MaxGasWanted = uint64((1 << 63) - 1)
func (w *wrapper) ValidateBasic() error {
theTx := w.tx
if theTx == nil {
return fmt.Errorf("bad Tx")
}
body := w.tx.Body
if body == nil {
return fmt.Errorf("missing TxBody")
}
authInfo := w.tx.AuthInfo
if authInfo == nil {
return fmt.Errorf("missing AuthInfo")
}
fee := authInfo.Fee
if fee == nil {
return fmt.Errorf("missing fee")
}
if fee.GasLimit > MaxGasWanted {
return sdkerrors.Wrapf(
sdkerrors.ErrInvalidRequest,
"invalid gas supplied; %d > %d", fee.GasLimit, MaxGasWanted,
)
}
if fee.Amount.IsAnyNegative() {
return sdkerrors.Wrapf(
sdkerrors.ErrInsufficientFee,
"invalid fee provided: %s", fee.Amount,
)
}
sigs := theTx.Signatures
if len(sigs) == 0 {
return sdkerrors.ErrNoSignatures
}
if len(sigs) != len(w.GetSigners()) {
return sdkerrors.Wrapf(
sdkerrors.ErrUnauthorized,
"wrong number of signers; expected %d, got %d", w.GetSigners(), len(sigs),
)
}
return nil
return w.tx.ValidateBasic()
}
func (w *wrapper) getBodyBytes() []byte {
@ -167,19 +105,7 @@ func (w *wrapper) getAuthInfoBytes() []byte {
}
func (w *wrapper) GetSigners() []sdk.AccAddress {
var signers []sdk.AccAddress
seen := map[string]bool{}
for _, msg := range w.GetMsgs() {
for _, addr := range msg.GetSigners() {
if !seen[addr.String()] {
signers = append(signers, addr)
seen[addr.String()] = true
}
}
}
return signers
return w.tx.GetSigners()
}
func (w *wrapper) GetPubKeys() []crypto.PubKey {
@ -358,8 +284,10 @@ func (w *wrapper) GetTx() authsigning.Tx {
}
// GetProtoTx returns the tx as a proto.Message.
func (w *wrapper) GetProtoTx() *tx.Tx {
return w.tx
func (w *wrapper) AsAny() *codectypes.Any {
// We're sure here that w.tx is a proto.Message, so this will call
// codectypes.NewAnyWithValue under the hood.
return codectypes.UnsafePackAny(w.tx)
}
// WrapTx creates a TxBuilder wrapper around a tx.Tx proto message.

View File

@ -201,10 +201,10 @@ func TestBuilderValidateBasic(t *testing.T) {
require.NoError(t, err)
// gas limit too high
txBuilder.SetGasLimit(MaxGasWanted + 1)
txBuilder.SetGasLimit(txtypes.MaxGasWanted + 1)
err = txBuilder.ValidateBasic()
require.Error(t, err)
txBuilder.SetGasLimit(MaxGasWanted - 1)
txBuilder.SetGasLimit(txtypes.MaxGasWanted - 1)
err = txBuilder.ValidateBasic()
require.NoError(t, err)

View File

@ -6,13 +6,13 @@ import (
"github.com/gogo/protobuf/proto"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
)
// DefaultTxEncoder returns a default protobuf TxEncoder using the provided Marshaler
func DefaultTxEncoder() types.TxEncoder {
return func(tx types.Tx) ([]byte, error) {
func DefaultTxEncoder() sdk.TxEncoder {
return func(tx sdk.Tx) ([]byte, error) {
txWrapper, ok := tx.(*wrapper)
if !ok {
return nil, fmt.Errorf("expected %T, got %T", &wrapper{}, tx)
@ -28,14 +28,20 @@ func DefaultTxEncoder() types.TxEncoder {
}
}
// DefaultTxEncoder returns a default protobuf JSON TxEncoder using the provided Marshaler
func DefaultJSONTxEncoder() types.TxEncoder {
return func(tx types.Tx) ([]byte, error) {
// DefaultJSONTxEncoder returns a default protobuf JSON TxEncoder using the provided Marshaler.
func DefaultJSONTxEncoder() sdk.TxEncoder {
return func(tx sdk.Tx) ([]byte, error) {
txWrapper, ok := tx.(*wrapper)
if !ok {
return nil, fmt.Errorf("expected %T, got %T", &wrapper{}, tx)
if ok {
return codec.ProtoMarshalJSON(txWrapper.tx)
}
return codec.ProtoMarshalJSON(txWrapper.tx)
protoTx, ok := tx.(*txtypes.Tx)
if ok {
return codec.ProtoMarshalJSON(protoTx)
}
return nil, fmt.Errorf("expected %T, got %T", &wrapper{}, tx)
}
}

View File

@ -6,7 +6,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
)
@ -26,12 +25,6 @@ func (s *StdTxBuilder) GetTx() authsigning.Tx {
return s.StdTx
}
// GetProtoTx implements TxBuilder.GetProtoTx
func (s *StdTxBuilder) GetProtoTx() *txtypes.Tx {
// Stdtx isn't a proto.Message
return nil
}
// SetMsgs implements TxBuilder.SetMsgs
func (s *StdTxBuilder) SetMsgs(msgs ...sdk.Msg) error {
s.Msgs = msgs

View File

@ -133,7 +133,10 @@ func CountSubKeys(pub crypto.PubKey) int {
// DEPRECATED
// ---------------------------------------------------------------------------
var _ sdk.Tx = (*StdTx)(nil)
var (
_ sdk.Tx = (*StdTx)(nil)
_ codectypes.IntoAny = (*StdTx)(nil)
)
// StdTx is the legacy transaction format for wrapping a Msg with Fee and Signatures.
// It only works with Amino, please prefer the new protobuf Tx in types/tx.
@ -189,6 +192,11 @@ func (tx StdTx) ValidateBasic() error {
return nil
}
// AsAny implements IntoAny.AsAny.
func (tx *StdTx) AsAny() *codectypes.Any {
return codectypes.UnsafePackAny(tx)
}
// GetSigners returns the addresses that must sign the transaction.
// Addresses are returned in a deterministic order.
// They are accumulated from the GetSigners method for each Msg

View File

@ -1,6 +1,8 @@
package utils
package utils_test
import (
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/x/gov/client/utils"
"testing"
"github.com/stretchr/testify/require"
@ -59,7 +61,7 @@ func TestGetPaginatedVotes(t *testing.T) {
type testCase struct {
description string
page, limit int
txs []authtypes.StdTx
msgs [][]sdk.Msg
votes []types.Vote
}
acc1 := make(sdk.AccAddress, 20)
@ -79,22 +81,21 @@ func TestGetPaginatedVotes(t *testing.T) {
description: "1MsgPerTxAll",
page: 1,
limit: 2,
txs: []authtypes.StdTx{
{Msgs: acc1Msgs[:1]},
{Msgs: acc2Msgs[:1]},
msgs: [][]sdk.Msg{
acc1Msgs[:1],
acc2Msgs[:1],
},
votes: []types.Vote{
types.NewVote(0, acc1, types.OptionYes),
types.NewVote(0, acc2, types.OptionYes)},
},
{
description: "2MsgPerTx1Chunk",
page: 1,
limit: 2,
txs: []authtypes.StdTx{
{Msgs: acc1Msgs},
{Msgs: acc2Msgs},
msgs: [][]sdk.Msg{
acc1Msgs,
acc2Msgs,
},
votes: []types.Vote{
types.NewVote(0, acc1, types.OptionYes),
@ -104,9 +105,9 @@ func TestGetPaginatedVotes(t *testing.T) {
description: "2MsgPerTx2Chunk",
page: 2,
limit: 2,
txs: []authtypes.StdTx{
{Msgs: acc1Msgs},
{Msgs: acc2Msgs},
msgs: [][]sdk.Msg{
acc1Msgs,
acc2Msgs,
},
votes: []types.Vote{
types.NewVote(0, acc2, types.OptionYes),
@ -116,49 +117,54 @@ func TestGetPaginatedVotes(t *testing.T) {
description: "IncompleteSearchTx",
page: 1,
limit: 2,
txs: []authtypes.StdTx{
{Msgs: acc1Msgs[:1]},
msgs: [][]sdk.Msg{
acc1Msgs[:1],
},
votes: []types.Vote{types.NewVote(0, acc1, types.OptionYes)},
},
{
description: "InvalidPage",
page: -1,
txs: []authtypes.StdTx{
{Msgs: acc1Msgs[:1]},
msgs: [][]sdk.Msg{
acc1Msgs[:1],
},
},
{
description: "OutOfBounds",
page: 2,
limit: 10,
txs: []authtypes.StdTx{
{Msgs: acc1Msgs[:1]},
msgs: [][]sdk.Msg{
acc1Msgs[:1],
},
},
} {
tc := tc
t.Run(tc.description, func(t *testing.T) {
var (
marshalled = make([]tmtypes.Tx, len(tc.txs))
marshalled = make([]tmtypes.Tx, len(tc.msgs))
cdc = newTestCodec()
)
for i := range tc.txs {
tx, err := cdc.MarshalBinaryBare(&tc.txs[i])
encodingConfig := simapp.MakeEncodingConfig()
cli := TxSearchMock{txs: marshalled}
clientCtx := client.Context{}.
WithLegacyAmino(cdc).
WithClient(cli).
WithTxConfig(encodingConfig.TxConfig)
for i := range tc.msgs {
txBuilder := clientCtx.TxConfig.NewTxBuilder()
err := txBuilder.SetMsgs(tc.msgs[i]...)
require.NoError(t, err)
tx, err := clientCtx.TxConfig.TxEncoder()(txBuilder.GetTx())
require.NoError(t, err)
marshalled[i] = tx
}
cli := TxSearchMock{txs: marshalled}
clientCtx := client.Context{}.
WithLegacyAmino(cdc).
WithClient(cli)
params := types.NewQueryProposalVotesParams(0, tc.page, tc.limit)
votesData, err := QueryVotesByTxQuery(clientCtx, params)
votesData, err := utils.QueryVotesByTxQuery(clientCtx, params)
require.NoError(t, err)
votes := []types.Vote{}
require.NoError(t, clientCtx.LegacyAmino.UnmarshalJSON(votesData, &votes))

View File

@ -211,7 +211,7 @@ func GetCmdQueryHeader() *cobra.Command {
}
clientCtx = clientCtx.WithHeight(height)
return clientCtx.PrintOutputLegacy(header)
return clientCtx.PrintOutput(&header)
},
}

View File

@ -161,7 +161,7 @@ func GetCmdQueryChannelClientState() *cobra.Command {
return err
}
return clientCtx.PrintOutputLegacy(res.IdentifiedClientState)
return clientCtx.PrintOutput(res.IdentifiedClientState)
},
}