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:
co-authored by
Marie
Anil Kumar Kammari
Alexander Bezobchuk
Aleksandr Bezobchuk
Amaury Martiny
parent
d84296a5fc
commit
b2348180b8
+445
-51
@@ -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, 0xe5, 0x9c, 0x5f, 0xe2, 0xa3, 0x8f, 0x3e, 0x04, 0x4a, 0x22, 0xff, 0x03,
|
||||
0xff, 0x82, 0x60, 0x97, 0xd4, 0xc3, 0x09, 0xe4, 0x13, 0xe7, 0xf1, 0xed, 0xec, 0xcc, 0xf7, 0xcd,
|
||||
0x12, 0xb6, 0xdb, 0x8c, 0x07, 0x8c, 0xd7, 0x5a, 0x98, 0x93, 0x1a, 0x6e, 0xb5, 0xfd, 0xda, 0xe5,
|
||||
0x4e, 0x8b, 0x08, 0xbc, 0xa3, 0x1c, 0xbb, 0x17, 0x31, 0xc1, 0x90, 0x19, 0x83, 0x6c, 0x09, 0xb2,
|
||||
0x55, 0x3c, 0x01, 0x6d, 0x16, 0x29, 0xa3, 0x4c, 0x81, 0x6a, 0xd2, 0x8a, 0xf1, 0x9b, 0x5b, 0x82,
|
||||
0x84, 0x1e, 0x89, 0x02, 0x3f, 0x14, 0x71, 0x4d, 0x31, 0xec, 0x11, 0x9e, 0x24, 0x37, 0x28, 0x63,
|
||||
0xb4, 0x4b, 0x6a, 0xca, 0x6b, 0xf5, 0xcf, 0x6b, 0x38, 0x1c, 0xc6, 0x29, 0xeb, 0x3a, 0x03, 0xd0,
|
||||
0x18, 0xb8, 0x84, 0xf7, 0x58, 0xc8, 0x09, 0x5a, 0x03, 0xbd, 0x43, 0x7c, 0xda, 0x11, 0xa6, 0x56,
|
||||
0xd1, 0xaa, 0x19, 0x37, 0xf1, 0x90, 0x05, 0xba, 0x18, 0x74, 0x30, 0xef, 0x98, 0xe9, 0x8a, 0x56,
|
||||
0x35, 0x1c, 0x18, 0x8f, 0xca, 0x7a, 0x63, 0x70, 0x84, 0x79, 0xc7, 0x4d, 0x32, 0xe8, 0x47, 0x30,
|
||||
0xda, 0xcc, 0x23, 0xbc, 0x87, 0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 0x8d, 0x06, 0xdf, 0x3c, 0xee, 0x18, 0x6d, 0x81, 0x11, 0x70, 0xda, 0xf4,
|
||||
0x43, 0x8f, 0x0c, 0x94, 0x3e, 0x2b, 0x6e, 0x3e, 0xe0, 0xb4, 0x2e, 0x7d, 0xf4, 0x2d, 0x64, 0x24,
|
||||
0x67, 0x4a, 0x1e, 0x57, 0x9a, 0xe8, 0x14, 0x74, 0x72, 0x49, 0x42, 0xc1, 0xcd, 0x8c, 0xa2, 0xec,
|
||||
0xd7, 0xc5, 0x94, 0x9d, 0x8a, 0xc8, 0x0f, 0xe9, 0xbf, 0x12, 0xed, 0x14, 0x13, 0xbe, 0x96, 0xe7,
|
||||
0x82, 0xdc, 0x4d, 0x4a, 0x1d, 0x64, 0x5f, 0xbe, 0xaf, 0x68, 0x56, 0x04, 0x85, 0xb9, 0xac, 0xe4,
|
||||
0x50, 0xae, 0x9b, 0xea, 0xc9, 0x70, 0x95, 0x8d, 0xea, 0x00, 0x58, 0x88, 0xc8, 0x6f, 0xf5, 0x05,
|
||||
0xe1, 0x66, 0x5a, 0x75, 0xb0, 0xfd, 0x84, 0x68, 0x13, 0xac, 0x93, 0x95, 0xf7, 0xbb, 0x73, 0x87,
|
||||
0x93, 0x3b, 0xf7, 0xc0, 0x98, 0x82, 0xe4, 0xb4, 0x17, 0x64, 0x98, 0x5c, 0x28, 0x4d, 0x54, 0x84,
|
||||
0xa5, 0x4b, 0xdc, 0xed, 0x93, 0x84, 0x81, 0xd8, 0xb1, 0x18, 0xe4, 0xfe, 0xc7, 0xbc, 0x2e, 0x45,
|
||||
0xdd, 0x7f, 0x24, 0xaa, 0x3c, 0x99, 0x75, 0x7e, 0x78, 0x18, 0x95, 0xbf, 0x1b, 0xe2, 0xa0, 0x7b,
|
||||
0x60, 0xcd, 0x72, 0xd6, 0xbc, 0xd6, 0xf6, 0x9c, 0xd6, 0x69, 0x75, 0xe6, 0xfb, 0x87, 0x51, 0x79,
|
||||
0x75, 0x76, 0x46, 0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 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, 0xca, 0xc9, 0x7a, 0x72, 0x30, 0x2c, 0x26, 0x39, 0x27, 0xa0, 0x13, 0xe7, 0x64,
|
||||
0x46, 0x05, 0x9c, 0x26, 0x4e, 0xc2, 0x30, 0x2e, 0x18, 0xa2, 0x40, 0x88, 0x67, 0x12, 0x8a, 0xb5,
|
||||
0x32, 0xcc, 0xd0, 0x68, 0x56, 0xd2, 0x66, 0x75, 0x89, 0xee, 0x56, 0x73, 0xbb, 0xb2, 0xe5, 0x8e,
|
||||
0x92, 0x92, 0x2a, 0x05, 0x15, 0x35, 0xbf, 0x24, 0xa5, 0xcb, 0x14, 0xcc, 0x41, 0xec, 0x2e, 0xa5,
|
||||
0x7f, 0x01, 0xb3, 0x6f, 0xcf, 0xd2, 0x09, 0x46, 0xa9, 0xb4, 0xdf, 0xf7, 0xde, 0xbe, 0x7d, 0xfb,
|
||||
0x7d, 0x4f, 0x7b, 0xb0, 0x3b, 0x94, 0x2a, 0x96, 0xaa, 0x33, 0x60, 0x8a, 0x77, 0xd8, 0x60, 0x18,
|
||||
0x75, 0x8e, 0xee, 0x0c, 0xb8, 0x66, 0x77, 0x10, 0x84, 0xd3, 0x54, 0x6a, 0x49, 0x3c, 0x9b, 0x14,
|
||||
0x9a, 0xa4, 0x10, 0xf9, 0x3c, 0xe9, 0xc6, 0xb6, 0x90, 0x42, 0x62, 0x52, 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, 0x91, 0xc6, 0x27, 0xb7, 0x4a, 0x2d, 0x20, 0x5f, 0x41, 0x45, 0xcf,
|
||||
0x95, 0xe7, 0xa2, 0xc2, 0xb7, 0xd6, 0x2b, 0xbc, 0xfc, 0x50, 0x50, 0xb3, 0xc1, 0x6a, 0xdc, 0xfd,
|
||||
0xf6, 0xcd, 0xdb, 0x66, 0xe9, 0xf5, 0x59, 0xd3, 0x39, 0x3d, 0x6b, 0x3a, 0xff, 0x9c, 0x35, 0x9d,
|
||||
0xdf, 0xce, 0x9b, 0xa5, 0xd3, 0xf3, 0x66, 0xe9, 0xcd, 0x79, 0xb3, 0xf4, 0x73, 0x20, 0x22, 0x3d,
|
||||
0x9e, 0x0d, 0xc2, 0xa1, 0x8c, 0x3b, 0xf9, 0x87, 0xcf, 0xfe, 0x7c, 0xa9, 0x46, 0x2f, 0xed, 0x57,
|
||||
0x6a, 0xe0, 0xe2, 0x0b, 0x79, 0xf7, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x3e, 0xa1, 0x0e,
|
||||
0x1a, 0x07, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *TxResponse) Marshal() (dAtA []byte, err error) {
|
||||
@@ -1012,6 +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
|
||||
|
||||
+1
-2
@@ -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.
|
||||
|
||||
+10
-20
@@ -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)
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||
+99
-3
@@ -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{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user