From 0034dc38af4867f90408afb60cd576b6bc966f4c Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 9 Jan 2023 12:37:31 +0100 Subject: [PATCH 1/2] moving authz protos to transfer.v1 --- go.mod | 2 +- modules/apps/transfer/types/authz.pb.go | 72 +++++++++---------- .../transfer/types/transfer_authz_test.go | 10 +-- .../transfer/{v2 => v1}/authz.proto | 2 +- 4 files changed, 43 insertions(+), 43 deletions(-) rename proto/ibc/applications/transfer/{v2 => v1}/authz.proto (96%) diff --git a/go.mod b/go.mod index caf7821c07e..94a97dc4cba 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( github.com/stretchr/testify v1.8.1 github.com/tendermint/tendermint v0.34.23 github.com/tendermint/tm-db v0.6.7 + golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e google.golang.org/grpc v1.51.0 google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 @@ -140,7 +141,6 @@ require ( go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.23.0 // indirect golang.org/x/crypto v0.2.0 // indirect - golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect golang.org/x/net v0.2.0 // indirect golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect golang.org/x/sys v0.2.0 // indirect diff --git a/modules/apps/transfer/types/authz.pb.go b/modules/apps/transfer/types/authz.pb.go index db9a9e3dbc3..403bd32352d 100644 --- a/modules/apps/transfer/types/authz.pb.go +++ b/modules/apps/transfer/types/authz.pb.go @@ -1,15 +1,15 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/applications/transfer/v2/authz.proto +// source: ibc/applications/transfer/v1/authz.proto package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - _ "github.com/regen-network/cosmos-proto" io "io" math "math" math_bits "math/bits" @@ -41,7 +41,7 @@ func (m *PortChannelAmount) Reset() { *m = PortChannelAmount{} } func (m *PortChannelAmount) String() string { return proto.CompactTextString(m) } func (*PortChannelAmount) ProtoMessage() {} func (*PortChannelAmount) Descriptor() ([]byte, []int) { - return fileDescriptor_c4c17169771443ae, []int{0} + return fileDescriptor_b1a28b55d17325aa, []int{0} } func (m *PortChannelAmount) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -109,7 +109,7 @@ func (m *TransferAuthorization) Reset() { *m = TransferAuthorization{} } func (m *TransferAuthorization) String() string { return proto.CompactTextString(m) } func (*TransferAuthorization) ProtoMessage() {} func (*TransferAuthorization) Descriptor() ([]byte, []int) { - return fileDescriptor_c4c17169771443ae, []int{1} + return fileDescriptor_b1a28b55d17325aa, []int{1} } func (m *TransferAuthorization) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -146,44 +146,44 @@ func (m *TransferAuthorization) GetAllocations() []PortChannelAmount { } func init() { - proto.RegisterType((*PortChannelAmount)(nil), "ibc.applications.transfer.v2.PortChannelAmount") - proto.RegisterType((*TransferAuthorization)(nil), "ibc.applications.transfer.v2.TransferAuthorization") + proto.RegisterType((*PortChannelAmount)(nil), "ibc.applications.transfer.v1.PortChannelAmount") + proto.RegisterType((*TransferAuthorization)(nil), "ibc.applications.transfer.v1.TransferAuthorization") } func init() { - proto.RegisterFile("ibc/applications/transfer/v2/authz.proto", fileDescriptor_c4c17169771443ae) + proto.RegisterFile("ibc/applications/transfer/v1/authz.proto", fileDescriptor_b1a28b55d17325aa) } -var fileDescriptor_c4c17169771443ae = []byte{ +var fileDescriptor_b1a28b55d17325aa = []byte{ // 442 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08,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d, 0xa5, - 0xb3, 0xfe, 0xef, 0x5f, 0xe3, 0xc3, 0x3b, 0x77, 0xcd, 0xde, 0x5f, 0x6d, 0xe2, 0xe0, 0x7a, 0x13, - 0x07, 0xff, 0x36, 0x71, 0xf0, 0x7d, 0x1b, 0x77, 0xae, 0xb7, 0x71, 0xe7, 0xcf, 0x36, 0xee, 0x7c, - 0x3a, 0xbd, 0x6f, 0x81, 0xc8, 0xd9, 0x78, 0x01, 0x64, 0xf5, 0x9a, 0x54, 0x50, 0x34, 0x25, 0xd7, - 0xed, 0x12, 0xee, 0x2c, 0x9f, 0xf5, 0x25, 0x7f, 0x64, 0x77, 0xe1, 0xd5, 0xff, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x1b, 0x30, 0xdf, 0x96, 0xa6, 0x02, 0x00, 0x00, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xc1, 0x8a, 0x13, 0x31, + 0x18, 0xee, 0x6c, 0x17, 0x61, 0x53, 0x56, 0xec, 0xe0, 0xca, 0x74, 0x91, 0x69, 0x99, 0xd3, 0x80, + 0x34, 0xb1, 0x0a, 0x2e, 0xec, 0xc9, 0x76, 0xaf, 0x1e, 0x74, 0x10, 0x04, 0x2f, 0x25, 0x93, 0x89, + 0x6d, 0x70, 0x26, 0xff, 0x90, 0x64, 0x2a, 0xbb, 0x57, 0x5f, 0xc0, 0xd7, 0xd0, 0xb3, 0x0f, 0xb1, + 0x78, 0xda, 0xa3, 0xa7, 0x2a, 0xed, 0x1b, 0xec, 0x13, 0xc8, 0x24, 0x59, 0xe8, 0x52, 0xf0, 0x34, + 0x93, 0xff, 0xfb, 0xfe, 0x2f, 0xf9, 0xbf, 0xef, 0x47, 0xa9, 0xc8, 0x19, 0xa1, 0x75, 0x5d, 0x0a, + 0x46, 0x8d, 0x00, 0xa9, 0x89, 0x51, 0x54, 0xea, 0x4f, 0x5c, 0x91, 0xd5, 0x84, 0xd0,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 0x73, 0x6d, 0x1b, 0x74, 0x86, 0xac, 0xfe, 0x9b, 0x56, 0x3e, 0x7c, + 0x86, 0xfa, 0xb4, 0x2c, 0xe1, 0x0b, 0x2f, 0xe6, 0xb4, 0x28, 0x14, 0xd7, 0x9a, 0xeb, 0xe8, 0x70, + 0xd4, 0x4d, 0x8f, 0xb2, 0x47, 0x1e, 0x98, 0xde, 0xd5, 0x93, 0xaf, 0x01, 0x3a, 0x79, 0xef, 0xc3, + 0x98, 0x36, 0x66, 0x09, 0x4a, 0x5c, 0xd9, 0x8c, 0xc2, 0x0f, 0xa8, 0xd7, 0xb2, 0x7d, 0x62, 0x51, + 0x60, 0x1f, 0x4d, 0xf0, 0xff, 0xa2, 0xc4, 0x7b, 0xae, 0xcf, 0x0e, 0xdb, 0x51, 0xb2, 0x5d, 0xa5, + 0xf3, 0xfe, 0xaf, 0x9f, 0xe3, 0xe3, 0x7b, 0x77, 0xcd, 0xde, 0x5d, 0x6f, 0xe2, 0xe0, 0x66, 0x13, + 0x07, 0x7f, 0x37, 0x71, 0xf0, 0x6d, 0x1b, 0x77, 0x6e, 0xb6, 0x71, 0xe7, 0xf7, 0x36, 0xee, 0x7c, + 0x3c, 0xdb, 0xb7, 0x40, 0xe4, 0x6c, 0xbc, 0x00, 0xb2, 0x7a, 0x45, 0x2a, 0x28, 0x9a, 0x92, 0xeb, + 0x76, 0x09, 0x77, 0x96, 0xcf, 0xfa, 0x92, 0x3f, 0xb0, 0xbb, 0xf0, 0xf2, 0x5f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x50, 0xcc, 0x73, 0x94, 0xa6, 0x02, 0x00, 0x00, } func (m *PortChannelAmount) Marshal() (dAtA []byte, err error) { diff --git a/modules/apps/transfer/types/transfer_authz_test.go b/modules/apps/transfer/types/transfer_authz_test.go index 022188e747c..873303d7e7a 100644 --- a/modules/apps/transfer/types/transfer_authz_test.go +++ b/modules/apps/transfer/types/transfer_authz_test.go @@ -31,7 +31,7 @@ func TestTransferAuthorization(t *testing.T) { t.Log("verify authorization returns valid method name") require.Equal(t, authorization.MsgTypeURL(), "/ibc.applications.transfer.v1.MsgTransfer") require.NoError(t, authorization.ValidateBasic()) - transfer := NewMsgTransfer(sourcePort, sourceChannel, coin1000, fromAddr.String(), toAddr.String(), timeoutHeight, 0) + transfer := NewMsgTransfer(sourcePort, sourceChannel, coin1000, fromAddr.String(), toAddr.String(), timeoutHeight, 0, "") require.NoError(t, authorization.ValidateBasic()) t.Log("verify updated authorization returns nil") @@ -44,7 +44,7 @@ func TestTransferAuthorization(t *testing.T) { authorization = NewTransferAuthorization([]string{sourcePort}, []string{sourceChannel}, []sdk.Coins{coins1000}, [][]string{{toAddr.String()}}) require.Equal(t, authorization.MsgTypeURL(), "/ibc.applications.transfer.v1.MsgTransfer") require.NoError(t, authorization.ValidateBasic()) - transfer = NewMsgTransfer(sourcePort, sourceChannel, coin500, fromAddr.String(), toAddr.String(), timeoutHeight, 0) + transfer = NewMsgTransfer(sourcePort, sourceChannel, coin500, fromAddr.String(), toAddr.String(), timeoutHeight, 0, "") require.NoError(t, authorization.ValidateBasic()) resp, err = authorization.Accept(ctx, transfer) require.NoError(t, err) @@ -61,7 +61,7 @@ func TestTransferAuthorization(t *testing.T) { t.Log("expect error when spend limit for specific port and channel is not set") authorization = NewTransferAuthorization([]string{sourcePort}, []string{sourceChannel}, []sdk.Coins{coins1000}, [][]string{{toAddr.String()}}) - transfer = NewMsgTransfer(sourcePort2, sourceChannel2, coin500, fromAddr.String(), toAddr.String(), timeoutHeight, 0) + transfer = NewMsgTransfer(sourcePort2, sourceChannel2, coin500, fromAddr.String(), toAddr.String(), timeoutHeight, 0, "") _, err = authorization.Accept(ctx, transfer) require.Error(t, err) @@ -71,7 +71,7 @@ func TestTransferAuthorization(t *testing.T) { []string{sourceChannel, sourceChannel2}, []sdk.Coins{coins1000, coins1000}, [][]string{{toAddr.String()}, {toAddr.String()}}) - transfer = NewMsgTransfer(sourcePort, sourceChannel, coin1000, fromAddr.String(), toAddr.String(), timeoutHeight, 0) + transfer = NewMsgTransfer(sourcePort, sourceChannel, coin1000, fromAddr.String(), toAddr.String(), timeoutHeight, 0, "") resp, err = authorization.Accept(ctx, transfer) require.NoError(t, err) require.NotNil(t, resp.Updated) @@ -80,7 +80,7 @@ func TestTransferAuthorization(t *testing.T) { t.Log("expect error when transferring to not allowed address") authorization = NewTransferAuthorization([]string{sourcePort}, []string{sourceChannel}, []sdk.Coins{coins1000}, [][]string{{fromAddr.String()}}) - transfer = NewMsgTransfer(sourcePort, sourceChannel, coin500, fromAddr.String(), toAddr.String(), timeoutHeight, 0) + transfer = NewMsgTransfer(sourcePort, sourceChannel, coin500, fromAddr.String(), toAddr.String(), timeoutHeight, 0, "") _, err = authorization.Accept(ctx, transfer) require.Error(t, err) } diff --git a/proto/ibc/applications/transfer/v2/authz.proto b/proto/ibc/applications/transfer/v1/authz.proto similarity index 96% rename from proto/ibc/applications/transfer/v2/authz.proto rename to proto/ibc/applications/transfer/v1/authz.proto index 53ee25fc1cb..b1aa9b2adb1 100644 --- a/proto/ibc/applications/transfer/v2/authz.proto +++ b/proto/ibc/applications/transfer/v1/authz.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package ibc.applications.transfer.v2; +package ibc.applications.transfer.v1; option go_package = "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"; From ac2f8f4197d0adde0e8edeea4b75d6fa755c0bc1 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 9 Jan 2023 12:47:21 +0100 Subject: [PATCH 2/2] running make format --- modules/apps/transfer/keeper/msg_server_test.go | 4 +--- modules/apps/transfer/types/transfer_authz.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index e457d3894cb..e11b2b1dfce 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -9,9 +9,7 @@ import ( ) func (suite *KeeperTestSuite) TestMsgTransfer() { - var ( - msg *types.MsgTransfer - ) + var msg *types.MsgTransfer testCases := []struct { name string diff --git a/modules/apps/transfer/types/transfer_authz.go b/modules/apps/transfer/types/transfer_authz.go index bcf6e3ebb27..585106e2e9c 100644 --- a/modules/apps/transfer/types/transfer_authz.go +++ b/modules/apps/transfer/types/transfer_authz.go @@ -11,9 +11,7 @@ import ( const gasCostPerIteration = uint64(10) -var ( - _ authz.Authorization = &TransferAuthorization{} -) +var _ authz.Authorization = &TransferAuthorization{} // NewTransferAuthorization creates a new TransferAuthorization object. func NewTransferAuthorization(sourcePorts, sourceChannels []string, spendLimits []sdk.Coins, allowedAddrs [][]string) *TransferAuthorization {