diff --git a/go.mod b/go.mod index 34a45f600..8eeead5c0 100644 --- a/go.mod +++ b/go.mod @@ -43,9 +43,9 @@ require ( golang.org/x/sync v0.7.0 golang.org/x/text v0.15.0 golang.org/x/time v0.3.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe - google.golang.org/grpc v1.61.0 - google.golang.org/protobuf v1.33.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 + google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.34.1 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -125,6 +125,7 @@ require ( github.com/fzipp/gocyclo v0.5.1 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.3 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -172,6 +173,7 @@ require ( github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-bexpr v0.1.10 // indirect @@ -321,7 +323,7 @@ require ( golang.org/x/term v0.20.0 // indirect golang.org/x/tools v0.21.0 // indirect google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect honnef.co/go/tools v0.3.1 // indirect diff --git a/go.sum b/go.sum index 681eda8d4..350f42055 100644 --- a/go.sum +++ b/go.sum @@ -457,6 +457,7 @@ github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2Gihuqh github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -765,6 +766,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/guptarohit/asciigraph v0.5.5/go.mod h1:dYl5wwK4gNsnFf9Zp+l06rFiDZ5YtXM6x7SRWZ3KGag= @@ -2257,8 +2260,12 @@ google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac h1:ZL/Teoy/ZGnzyrq google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe h1:0poefMBYvYbs7g5UkjS6HcxBPaTRAmznle9jnxYoAI8= google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA= +google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 h1:W5Xj/70xIA4x60O/IFyXivR5MGqblAb8R3w26pnD6No= +google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas= google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o= google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -2278,6 +2285,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/proto/evm/gov.proto b/proto/evm/gov.proto index 0425df2de..55ec172d4 100644 --- a/proto/evm/gov.proto +++ b/proto/evm/gov.proto @@ -40,3 +40,27 @@ message AddERCCW721PointerProposal { string pointer = 4 [(gogoproto.moretags) = "yaml:\"pointer\""]; uint32 version = 5 [(gogoproto.moretags) = "yaml:\"version\""]; } + +message AddCWERC20PointerProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + string pointee = 3 [(gogoproto.moretags) = "yaml:\"pointee\""]; + string pointer = 4 [(gogoproto.moretags) = "yaml:\"pointer\""]; + uint32 version = 5 [(gogoproto.moretags) = "yaml:\"version\""]; +} + +message AddCWERC721PointerProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + string pointee = 3 [(gogoproto.moretags) = "yaml:\"pointee\""]; + string pointer = 4 [(gogoproto.moretags) = "yaml:\"pointer\""]; + uint32 version = 5 [(gogoproto.moretags) = "yaml:\"version\""]; +} diff --git a/x/evm/client/cli/gov_tx.go b/x/evm/client/cli/gov_tx.go index 40b475768..efc771b6d 100644 --- a/x/evm/client/cli/gov_tx.go +++ b/x/evm/client/cli/gov_tx.go @@ -173,3 +173,109 @@ func NewAddERCCW721PointerProposalTxCmd() *cobra.Command { return cmd } + +func NewAddCWERC20PointerProposalTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-cw-erc20-pointer title description erc20address version deposit [pointer address]", + Args: cobra.RangeArgs(5, 6), + Short: "Submit an add CW-ERC20 pointer proposal", + Long: strings.TrimSpace(` + Submit a proposal to register an CW pointer contract address for a ERC20 token. + Not specifying the pointer address means a proposal that deletes the existing pointer. + `), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + version, err := strconv.ParseUint(args[3], 10, 16) + if err != nil { + return err + } + deposit, err := sdk.ParseCoinsNormalized(args[4]) + if err != nil { + return err + } + var pointer string + if len(args) == 6 { + pointer = args[5] + } + + // Convert proposal to RegisterPairsProposal Type + from := clientCtx.GetFromAddress() + + content := types.AddCWERC20PointerProposal{ + Title: args[0], + Description: args[1], + Pointee: args[2], + Version: uint32(version), + Pointer: pointer, + } + + msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, from) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func NewAddCWERC721PointerProposalTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-cw-erc721-pointer title description erc721address version deposit [pointer address]", + Args: cobra.RangeArgs(5, 6), + Short: "Submit an add CW-ERC721 pointer proposal", + Long: strings.TrimSpace(` + Submit a proposal to register an CW pointer contract address for a ERC721 token. + Not specifying the pointer address means a proposal that deletes the existing pointer. + `), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + version, err := strconv.ParseUint(args[3], 10, 16) + if err != nil { + return err + } + deposit, err := sdk.ParseCoinsNormalized(args[4]) + if err != nil { + return err + } + var pointer string + if len(args) == 6 { + pointer = args[5] + } + + // Convert proposal to RegisterPairsProposal Type + from := clientCtx.GetFromAddress() + + content := types.AddCWERC721PointerProposal{ + Title: args[0], + Description: args[1], + Pointee: args[2], + Version: uint32(version), + Pointer: pointer, + } + + msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, from) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/evm/client/cli/tx.go b/x/evm/client/cli/tx.go index fd48a96f4..0ef58bf48 100644 --- a/x/evm/client/cli/tx.go +++ b/x/evm/client/cli/tx.go @@ -68,6 +68,8 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(NewAddERCNativePointerProposalTxCmd()) cmd.AddCommand(NewAddERCCW20PointerProposalTxCmd()) cmd.AddCommand(NewAddERCCW721PointerProposalTxCmd()) + cmd.AddCommand(NewAddCWERC20PointerProposalTxCmd()) + cmd.AddCommand(NewAddCWERC721PointerProposalTxCmd()) cmd.AddCommand(AssociateContractAddressCmd()) return cmd diff --git a/x/evm/gov.go b/x/evm/gov.go index 879f2fa5d..7d9229477 100644 --- a/x/evm/gov.go +++ b/x/evm/gov.go @@ -44,3 +44,27 @@ func HandleAddERCCW721PointerProposal(ctx sdk.Context, k *keeper.Keeper, p *type } return k.SetERC721CW721PointerWithVersion(ctx, p.Pointee, common.HexToAddress(p.Pointer), uint16(p.Version)) } + +func HandleAddCWERC20PointerProposal(ctx sdk.Context, k *keeper.Keeper, p *types.AddCWERC20PointerProposal) error { + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypePointerRegistered, sdk.NewAttribute(types.AttributeKeyPointerType, "erc20"), + sdk.NewAttribute(types.AttributeKeyPointerAddress, p.Pointer), sdk.NewAttribute(types.AttributeKeyPointee, p.Pointee), + sdk.NewAttribute(types.AttributeKeyPointerVersion, fmt.Sprintf("%d", p.Version)))) + if p.Pointer == "" { + k.DeleteCW20ERC20Pointer(ctx, common.HexToAddress(p.Pointee), uint16(p.Version)) + return nil + } + return k.SetCW20ERC20PointerWithVersion(ctx, common.HexToAddress(p.Pointee), p.Pointer, uint16(p.Version)) +} + +func HandleAddCWERC721PointerProposal(ctx sdk.Context, k *keeper.Keeper, p *types.AddCWERC721PointerProposal) error { + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypePointerRegistered, sdk.NewAttribute(types.AttributeKeyPointerType, "erc721"), + sdk.NewAttribute(types.AttributeKeyPointerAddress, p.Pointer), sdk.NewAttribute(types.AttributeKeyPointee, p.Pointee), + sdk.NewAttribute(types.AttributeKeyPointerVersion, fmt.Sprintf("%d", p.Version)))) + if p.Pointer == "" { + k.DeleteCW721ERC721Pointer(ctx, common.HexToAddress(p.Pointee), uint16(p.Version)) + return nil + } + return k.SetCW721ERC721PointerWithVersion(ctx, common.HexToAddress(p.Pointee), p.Pointer, uint16(p.Version)) +} diff --git a/x/evm/gov_test.go b/x/evm/gov_test.go index 355403742..70ab53517 100644 --- a/x/evm/gov_test.go +++ b/x/evm/gov_test.go @@ -104,3 +104,69 @@ func TestAddERCCW721PointerProposals(t *testing.T) { require.Equal(t, uint16(1), ver) require.Equal(t, addr, pointer1) } + +func TestAddCWERC20PointerProposals(t *testing.T) { + k, ctx := testkeeper.MockEVMKeeper() + _, pointee1 := testkeeper.MockAddressPair() + pointer1, _ := testkeeper.MockAddressPair() + pointer2, _ := testkeeper.MockAddressPair() + require.Nil(t, evm.HandleAddCWERC20PointerProposal(ctx, k, &types.AddCWERC20PointerProposal{ + Pointee: pointee1.Hex(), + Version: 1, + Pointer: pointer1.String(), + })) + addr, ver, exists := k.GetCW20ERC20Pointer(ctx, pointee1) + require.True(t, exists) + require.Equal(t, uint16(1), ver) + require.Equal(t, addr, pointer1) + require.Nil(t, evm.HandleAddCWERC20PointerProposal(ctx, k, &types.AddCWERC20PointerProposal{ + Pointee: pointee1.Hex(), + Version: 2, + Pointer: pointer2.String(), + })) + addr, ver, exists = k.GetCW20ERC20Pointer(ctx, pointee1) + require.True(t, exists) + require.Equal(t, uint16(2), ver) + require.Equal(t, addr, pointer2) + require.Nil(t, evm.HandleAddCWERC20PointerProposal(ctx, k, &types.AddCWERC20PointerProposal{ + Pointee: pointee1.Hex(), + Version: 2, + })) + addr, ver, exists = k.GetCW20ERC20Pointer(ctx, pointee1) + require.True(t, exists) + require.Equal(t, uint16(1), ver) + require.Equal(t, addr, pointer1) +} + +func TestAddCWERC721PointerProposals(t *testing.T) { + k, ctx := testkeeper.MockEVMKeeper() + _, pointee1 := testkeeper.MockAddressPair() + pointer1, _ := testkeeper.MockAddressPair() + pointer2, _ := testkeeper.MockAddressPair() + require.Nil(t, evm.HandleAddCWERC721PointerProposal(ctx, k, &types.AddCWERC721PointerProposal{ + Pointee: pointee1.Hex(), + Version: 1, + Pointer: pointer1.String(), + })) + addr, ver, exists := k.GetCW721ERC721Pointer(ctx, pointee1) + require.True(t, exists) + require.Equal(t, uint16(1), ver) + require.Equal(t, addr, pointer1) + require.Nil(t, evm.HandleAddCWERC721PointerProposal(ctx, k, &types.AddCWERC721PointerProposal{ + Pointee: pointee1.Hex(), + Version: 2, + Pointer: pointer2.String(), + })) + addr, ver, exists = k.GetCW721ERC721Pointer(ctx, pointee1) + require.True(t, exists) + require.Equal(t, uint16(2), ver) + require.Equal(t, addr, pointer2) + require.Nil(t, evm.HandleAddCWERC721PointerProposal(ctx, k, &types.AddCWERC721PointerProposal{ + Pointee: pointee1.Hex(), + Version: 2, + })) + addr, ver, exists = k.GetCW721ERC721Pointer(ctx, pointee1) + require.True(t, exists) + require.Equal(t, uint16(1), ver) + require.Equal(t, addr, pointer1) +} diff --git a/x/evm/handler.go b/x/evm/handler.go index 03e4eaca8..d75417883 100644 --- a/x/evm/handler.go +++ b/x/evm/handler.go @@ -46,6 +46,10 @@ func NewProposalHandler(k keeper.Keeper) govtypes.Handler { return HandleAddERCCW20PointerProposal(ctx, &k, c) case *types.AddERCCW721PointerProposal: return HandleAddERCCW721PointerProposal(ctx, &k, c) + case *types.AddCWERC20PointerProposal: + return HandleAddCWERC20PointerProposal(ctx, &k, c) + case *types.AddCWERC721PointerProposal: + return HandleAddCWERC721PointerProposal(ctx, &k, c) default: return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized evm proposal content type: %T", c) } diff --git a/x/evm/keeper/pointer.go b/x/evm/keeper/pointer.go index b3cf5372e..33e1a6fed 100644 --- a/x/evm/keeper/pointer.go +++ b/x/evm/keeper/pointer.go @@ -127,14 +127,19 @@ func (k *Keeper) DeleteERC721CW721Pointer(ctx sdk.Context, cw721Address string, // CW20 -> ERC20 func (k *Keeper) SetCW20ERC20Pointer(ctx sdk.Context, erc20Address common.Address, addr string) error { + return k.SetCW20ERC20PointerWithVersion(ctx, erc20Address, addr, erc20.CurrentVersion) +} + +// CW20 -> ERC20 +func (k *Keeper) SetCW20ERC20PointerWithVersion(ctx sdk.Context, erc20Address common.Address, addr string, version uint16) error { if k.evmAddressIsPointer(ctx, erc20Address) { return ErrorPointerToPointerNotAllowed } - err := k.setPointerInfo(ctx, types.PointerCW20ERC20Key(erc20Address), []byte(addr), erc20.CurrentVersion) + err := k.setPointerInfo(ctx, types.PointerCW20ERC20Key(erc20Address), []byte(addr), version) if err != nil { return err } - return k.setPointerInfo(ctx, types.PointerReverseRegistryKey(common.BytesToAddress([]byte(addr))), erc20Address[:], erc20.CurrentVersion) + return k.setPointerInfo(ctx, types.PointerReverseRegistryKey(common.BytesToAddress([]byte(addr))), erc20Address[:], version) } // CW20 -> ERC20 @@ -146,6 +151,15 @@ func (k *Keeper) GetCW20ERC20Pointer(ctx sdk.Context, erc20Address common.Addres return } +// CW20 -> ERC20 +func (k *Keeper) DeleteCW20ERC20Pointer(ctx sdk.Context, erc20Address common.Address, version uint16) { + addr, _, exists := k.GetCW20ERC20Pointer(ctx, erc20Address) + if exists { + k.deletePointerInfo(ctx, types.PointerCW20ERC20Key(erc20Address), version) + k.deletePointerInfo(ctx, types.PointerReverseRegistryKey(common.BytesToAddress([]byte(addr.String()))), version) + } +} + func (k *Keeper) evmAddressIsPointer(ctx sdk.Context, addr common.Address) bool { _, _, exists := k.GetPointerInfo(ctx, types.PointerReverseRegistryKey(addr)) return exists @@ -156,17 +170,24 @@ func (k *Keeper) cwAddressIsPointer(ctx sdk.Context, addr string) bool { return exists } +// CW721 -> ERC721 func (k *Keeper) SetCW721ERC721Pointer(ctx sdk.Context, erc721Address common.Address, addr string) error { + return k.SetCW721ERC721PointerWithVersion(ctx, erc721Address, addr, erc721.CurrentVersion) +} + +// CW721 -> ERC721 +func (k *Keeper) SetCW721ERC721PointerWithVersion(ctx sdk.Context, erc721Address common.Address, addr string, version uint16) error { if k.evmAddressIsPointer(ctx, erc721Address) { return ErrorPointerToPointerNotAllowed } - err := k.setPointerInfo(ctx, types.PointerCW721ERC721Key(erc721Address), []byte(addr), erc721.CurrentVersion) + err := k.setPointerInfo(ctx, types.PointerCW721ERC721Key(erc721Address), []byte(addr), version) if err != nil { return err } - return k.setPointerInfo(ctx, types.PointerReverseRegistryKey(common.BytesToAddress([]byte(addr))), erc721Address[:], erc721.CurrentVersion) + return k.setPointerInfo(ctx, types.PointerReverseRegistryKey(common.BytesToAddress([]byte(addr))), erc721Address[:], version) } +// CW721 -> ERC721 func (k *Keeper) GetCW721ERC721Pointer(ctx sdk.Context, erc721Address common.Address) (addr sdk.AccAddress, version uint16, exists bool) { addrBz, version, exists := k.GetPointerInfo(ctx, types.PointerCW721ERC721Key(erc721Address)) if exists { @@ -175,6 +196,15 @@ func (k *Keeper) GetCW721ERC721Pointer(ctx sdk.Context, erc721Address common.Add return } +// CW721 -> ERC721 +func (k *Keeper) DeleteCW721ERC721Pointer(ctx sdk.Context, erc721Address common.Address, version uint16) { + addr, _, exists := k.GetCW721ERC721Pointer(ctx, erc721Address) + if exists { + k.deletePointerInfo(ctx, types.PointerCW721ERC721Key(erc721Address), version) + k.deletePointerInfo(ctx, types.PointerReverseRegistryKey(common.BytesToAddress([]byte(addr.String()))), version) + } +} + func (k *Keeper) GetPointerInfo(ctx sdk.Context, pref []byte) (addr []byte, version uint16, exists bool) { store := prefix.NewStore(ctx.KVStore(k.GetStoreKey()), pref) iter := store.ReverseIterator(nil, nil) diff --git a/x/evm/types/codec.go b/x/evm/types/codec.go index bba5d881e..890b208ed 100644 --- a/x/evm/types/codec.go +++ b/x/evm/types/codec.go @@ -36,6 +36,8 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &AddERCNativePointerProposal{}, &AddERCCW20PointerProposal{}, &AddERCCW721PointerProposal{}, + &AddCWERC20PointerProposal{}, + &AddCWERC721PointerProposal{}, ) registry.RegisterImplementations( (*sdk.Msg)(nil), diff --git a/x/evm/types/gov.go b/x/evm/types/gov.go index 1ef47dddd..89eaa59f0 100644 --- a/x/evm/types/gov.go +++ b/x/evm/types/gov.go @@ -15,6 +15,8 @@ const ( ProposalTypeAddERCNativePointer = "AddERCNativePointer" ProposalTypeAddERCCW20Pointer = "AddERCCW20Pointer" ProposalTypeAddERCCW721Pointer = "AddERCCW721Pointer" + ProposalTypeAddCWERC20Pointer = "AddCWERC20Pointer" + ProposalTypeAddCWERC721Pointer = "AddCWERC721Pointer" ) func init() { @@ -26,6 +28,8 @@ func init() { govtypes.RegisterProposalTypeCodec(&AddERCNativePointerProposal{}, "evm/AddERCNativePointerProposal") govtypes.RegisterProposalTypeCodec(&AddERCCW20PointerProposal{}, "evm/AddERCCW20PointerProposal") govtypes.RegisterProposalTypeCodec(&AddERCCW721PointerProposal{}, "evm/AddERCCW721PointerProposal") + govtypes.RegisterProposalTypeCodec(&AddCWERC20PointerProposal{}, "evm/AddCWERC20PointerProposal") + govtypes.RegisterProposalTypeCodec(&AddCWERC721PointerProposal{}, "evm/AddCWERC721PointerProposal") } func (p *AddERCNativePointerProposal) GetTitle() string { return p.Title } @@ -137,3 +141,81 @@ func (p AddERCCW721PointerProposal) String() string { `, p.Title, p.Description, p.Pointee, p.Pointer, p.Version)) return b.String() } + +func (p *AddCWERC20PointerProposal) GetTitle() string { return p.Title } + +func (p *AddCWERC20PointerProposal) GetDescription() string { return p.Description } + +func (p *AddCWERC20PointerProposal) ProposalRoute() string { return RouterKey } + +func (p *AddCWERC20PointerProposal) ProposalType() string { + return ProposalTypeAddCWERC20Pointer +} + +func (p *AddCWERC20PointerProposal) ValidateBasic() error { + if p.Pointer != "" { + if _, err := sdk.AccAddressFromBech32(p.Pointer); err != nil { + return err + } + } + if !common.IsHexAddress(p.Pointee) { + return errors.New("pointee address must be either empty or a valid hex-encoded string") + } + + if p.Version > math.MaxUint16 { + return errors.New("pointer version must be <= 65535") + } + + return govtypes.ValidateAbstract(p) +} + +func (p AddCWERC20PointerProposal) String() string { + var b strings.Builder + b.WriteString(fmt.Sprintf(`Add CW ERC20 pointer Proposal: + Title: %s + Description: %s + Pointee: %s + Pointer: %s + Version: %d +`, p.Title, p.Description, p.Pointee, p.Pointer, p.Version)) + return b.String() +} + +func (p *AddCWERC721PointerProposal) GetTitle() string { return p.Title } + +func (p *AddCWERC721PointerProposal) GetDescription() string { return p.Description } + +func (p *AddCWERC721PointerProposal) ProposalRoute() string { return RouterKey } + +func (p *AddCWERC721PointerProposal) ProposalType() string { + return ProposalTypeAddCWERC721Pointer +} + +func (p *AddCWERC721PointerProposal) ValidateBasic() error { + if p.Pointer != "" { + if _, err := sdk.AccAddressFromBech32(p.Pointer); err != nil { + return err + } + } + if !common.IsHexAddress(p.Pointee) { + return errors.New("pointee address must be either empty or a valid hex-encoded string") + } + + if p.Version > math.MaxUint16 { + return errors.New("pointer version must be <= 65535") + } + + return govtypes.ValidateAbstract(p) +} + +func (p AddCWERC721PointerProposal) String() string { + var b strings.Builder + b.WriteString(fmt.Sprintf(`Add CW ERC721 pointer Proposal: + Title: %s + Description: %s + Pointee: %s + Pointer: %s + Version: %d +`, p.Title, p.Description, p.Pointee, p.Pointer, p.Version)) + return b.String() +} diff --git a/x/evm/types/gov.pb.go b/x/evm/types/gov.pb.go index 6e7ef58d2..ef6f6457e 100644 --- a/x/evm/types/gov.pb.go +++ b/x/evm/types/gov.pb.go @@ -143,16 +143,98 @@ func (m *AddERCCW721PointerProposal) XXX_DiscardUnknown() { var xxx_messageInfo_AddERCCW721PointerProposal proto.InternalMessageInfo +type AddCWERC20PointerProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + Pointee string `protobuf:"bytes,3,opt,name=pointee,proto3" json:"pointee,omitempty" yaml:"pointee"` + Pointer string `protobuf:"bytes,4,opt,name=pointer,proto3" json:"pointer,omitempty" yaml:"pointer"` + Version uint32 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty" yaml:"version"` +} + +func (m *AddCWERC20PointerProposal) Reset() { *m = AddCWERC20PointerProposal{} } +func (*AddCWERC20PointerProposal) ProtoMessage() {} +func (*AddCWERC20PointerProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_fb66eb1aab5c39af, []int{3} +} +func (m *AddCWERC20PointerProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AddCWERC20PointerProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AddCWERC20PointerProposal.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 *AddCWERC20PointerProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddCWERC20PointerProposal.Merge(m, src) +} +func (m *AddCWERC20PointerProposal) XXX_Size() int { + return m.Size() +} +func (m *AddCWERC20PointerProposal) XXX_DiscardUnknown() { + xxx_messageInfo_AddCWERC20PointerProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_AddCWERC20PointerProposal proto.InternalMessageInfo + +type AddCWERC721PointerProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + Pointee string `protobuf:"bytes,3,opt,name=pointee,proto3" json:"pointee,omitempty" yaml:"pointee"` + Pointer string `protobuf:"bytes,4,opt,name=pointer,proto3" json:"pointer,omitempty" yaml:"pointer"` + Version uint32 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty" yaml:"version"` +} + +func (m *AddCWERC721PointerProposal) Reset() { *m = AddCWERC721PointerProposal{} } +func (*AddCWERC721PointerProposal) ProtoMessage() {} +func (*AddCWERC721PointerProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_fb66eb1aab5c39af, []int{4} +} +func (m *AddCWERC721PointerProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AddCWERC721PointerProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AddCWERC721PointerProposal.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 *AddCWERC721PointerProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddCWERC721PointerProposal.Merge(m, src) +} +func (m *AddCWERC721PointerProposal) XXX_Size() int { + return m.Size() +} +func (m *AddCWERC721PointerProposal) XXX_DiscardUnknown() { + xxx_messageInfo_AddCWERC721PointerProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_AddCWERC721PointerProposal proto.InternalMessageInfo + func init() { proto.RegisterType((*AddERCNativePointerProposal)(nil), "seiprotocol.seichain.evm.AddERCNativePointerProposal") proto.RegisterType((*AddERCCW20PointerProposal)(nil), "seiprotocol.seichain.evm.AddERCCW20PointerProposal") proto.RegisterType((*AddERCCW721PointerProposal)(nil), "seiprotocol.seichain.evm.AddERCCW721PointerProposal") + proto.RegisterType((*AddCWERC20PointerProposal)(nil), "seiprotocol.seichain.evm.AddCWERC20PointerProposal") + proto.RegisterType((*AddCWERC721PointerProposal)(nil), "seiprotocol.seichain.evm.AddCWERC721PointerProposal") } func init() { proto.RegisterFile("evm/gov.proto", fileDescriptor_fb66eb1aab5c39af) } var fileDescriptor_fb66eb1aab5c39af = []byte{ - // 359 bytes of a gzipped FileDescriptorProto + // 377 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0x2d, 0xcb, 0xd5, 0x4f, 0xcf, 0x2f, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x28, 0x4e, 0xcd, 0x04, 0xb3, 0x92, 0xf3, 0x73, 0xf4, 0x8a, 0x53, 0x33, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0x52, 0xcb, 0x72, @@ -170,12 +252,13 @@ var fileDescriptor_fb66eb1aab5c39af = []byte{ 0xf2, 0x0c, 0x33, 0x16, 0xc8, 0x33, 0xbc, 0x58, 0x20, 0xcf, 0xa0, 0x34, 0x95, 0x89, 0x4b, 0x12, 0x12, 0x26, 0xce, 0xe1, 0x46, 0x06, 0xf4, 0x0f, 0x11, 0xb8, 0x4f, 0x53, 0xa1, 0x61, 0x82, 0xe1, 0xd3, 0x54, 0xb8, 0x4f, 0x53, 0xe9, 0x18, 0x2e, 0xd3, 0x98, 0xb8, 0xa4, 0x60, 0xe1, 0x62, 0x6e, - 0x64, 0x38, 0x1a, 0x30, 0xd0, 0x80, 0x71, 0x72, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, - 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, - 0x39, 0x86, 0x28, 0xdd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe2, - 0xd4, 0x4c, 0x5d, 0x58, 0xd6, 0x04, 0x73, 0xc0, 0x79, 0x53, 0xbf, 0x42, 0x1f, 0x94, 0x83, 0x4b, - 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xf2, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x08, - 0x8c, 0x8b, 0x94, 0xd5, 0x03, 0x00, 0x00, + 0x64, 0x38, 0x1a, 0x30, 0x68, 0x09, 0xc6, 0x39, 0xdc, 0x35, 0xc8, 0x79, 0x34, 0xc1, 0x60, 0x24, + 0x18, 0x70, 0xb8, 0x8c, 0x26, 0x18, 0x44, 0xc0, 0x38, 0xb9, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, + 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, + 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x6e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, + 0x7e, 0x71, 0x6a, 0xa6, 0x2e, 0xac, 0x2c, 0x07, 0x73, 0xc0, 0x85, 0xb9, 0x7e, 0x85, 0x3e, 0xa8, + 0xc8, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xcb, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, + 0xff, 0xb2, 0xe1, 0xcb, 0x45, 0x06, 0x06, 0x00, 0x00, } func (m *AddERCNativePointerProposal) Marshal() (dAtA []byte, err error) { @@ -346,6 +429,118 @@ func (m *AddERCCW721PointerProposal) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *AddCWERC20PointerProposal) 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 *AddCWERC20PointerProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AddCWERC20PointerProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Version != 0 { + i = encodeVarintGov(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x28 + } + if len(m.Pointer) > 0 { + i -= len(m.Pointer) + copy(dAtA[i:], m.Pointer) + i = encodeVarintGov(dAtA, i, uint64(len(m.Pointer))) + i-- + dAtA[i] = 0x22 + } + if len(m.Pointee) > 0 { + i -= len(m.Pointee) + copy(dAtA[i:], m.Pointee) + i = encodeVarintGov(dAtA, i, uint64(len(m.Pointee))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AddCWERC721PointerProposal) 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 *AddCWERC721PointerProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AddCWERC721PointerProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Version != 0 { + i = encodeVarintGov(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x28 + } + if len(m.Pointer) > 0 { + i -= len(m.Pointer) + copy(dAtA[i:], m.Pointer) + i = encodeVarintGov(dAtA, i, uint64(len(m.Pointer))) + i-- + dAtA[i] = 0x22 + } + if len(m.Pointee) > 0 { + i -= len(m.Pointee) + copy(dAtA[i:], m.Pointee) + i = encodeVarintGov(dAtA, i, uint64(len(m.Pointee))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintGov(dAtA []byte, offset int, v uint64) int { offset -= sovGov(v) base := offset @@ -441,6 +636,62 @@ func (m *AddERCCW721PointerProposal) Size() (n int) { return n } +func (m *AddCWERC20PointerProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Pointee) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Pointer) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + if m.Version != 0 { + n += 1 + sovGov(uint64(m.Version)) + } + return n +} + +func (m *AddCWERC721PointerProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Pointee) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Pointer) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + if m.Version != 0 { + n += 1 + sovGov(uint64(m.Version)) + } + return n +} + func sovGov(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1038,6 +1289,400 @@ func (m *AddERCCW721PointerProposal) Unmarshal(dAtA []byte) error { } return nil } +func (m *AddCWERC20PointerProposal) 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 ErrIntOverflowGov + } + 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: AddCWERC20PointerProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AddCWERC20PointerProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pointee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pointee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pointer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pointer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AddCWERC721PointerProposal) 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 ErrIntOverflowGov + } + 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: AddCWERC721PointerProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AddCWERC721PointerProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pointee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pointee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pointer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pointer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGov(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0