diff --git a/app/app.go b/app/app.go index 95635c37..c6e383eb 100644 --- a/app/app.go +++ b/app/app.go @@ -126,6 +126,11 @@ import ( assetmodulekeeper "github.com/realiotech/realio-network/x/asset/keeper" assetmoduletypes "github.com/realiotech/realio-network/x/asset/types" + "github.com/realiotech/realio-network/x/asset/priviledges/clawback" + "github.com/realiotech/realio-network/x/asset/priviledges/freeze" + mintpriviledge "github.com/realiotech/realio-network/x/asset/priviledges/mint" + "github.com/realiotech/realio-network/x/asset/priviledges/transfer_auth" + realionetworktypes "github.com/realiotech/realio-network/types" // unnamed import of statik for swagger UI support @@ -309,6 +314,8 @@ func New( // multi-staking keys multistakingtypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey + freeze.StoreKey, + transfer_auth.StoreKey, ) // Add the EVM transient store key @@ -415,6 +422,25 @@ func New( app.AccountKeeper, ) + err := app.AssetKeeper.AddPrivilege(mintpriviledge.NewMintPriviledge(app.BankKeeper)) + if err != nil { + panic(err) + } + err = app.AssetKeeper.AddPrivilege(freeze.NewFreezePriviledge(keys[freeze.StoreKey])) + if err != nil { + panic(err) + } + err = app.AssetKeeper.AddPrivilege(transfer_auth.NewTransferAuthPriviledge(keys[transfer_auth.StoreKey])) + if err != nil { + panic(err) + } + err = app.AssetKeeper.AddPrivilege(clawback.NewClawbackPriviledge(app.BankKeeper)) + if err != nil { + panic(err) + } + + app.BankKeeper.AppendSendRestriction(app.AssetKeeper.AssetSendRestriction) + // IBC Keeper app.IBCKeeper = ibckeeper.NewKeeper( appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go new file mode 100644 index 00000000..6b0ee013 --- /dev/null +++ b/app/apptesting/test_suite.go @@ -0,0 +1,45 @@ +package apptesting + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" + "github.com/realiotech/realio-network/app" + "github.com/realiotech/realio-network/x/asset/keeper" + "github.com/realiotech/realio-network/x/asset/types" +) + +type KeeperTestSuite struct { + suite.Suite + app *app.RealioNetwork + ctx sdk.Context + + assetKeeper *keeper.Keeper + govkeeper govkeeper.Keeper + msgServer types.MsgServer + bankKeeper bankkeeper.Keeper +} + +func (suite *KeeperTestSuite) SetupTest() { + app := app.Setup(false, nil, 3) + + suite.app = app + suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: app.LastBlockHeight() + 1}) + suite.assetKeeper = keeper.NewKeeper( + app.AppCodec(), app.InterfaceRegistry(), app.GetKey(types.StoreKey), + app.GetMemKey(types.MemStoreKey), app.GetSubspace(types.ModuleName), app.BankKeeper, app.AccountKeeper, + ) + suite.govkeeper = app.GovKeeper + suite.bankKeeper = app.BankKeeper +} + +func (suite *KeeperTestSuite) + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} diff --git a/proto/realionetwork/asset/priviledges/clawback/messages.proto b/proto/realionetwork/asset/priviledges/clawback/messages.proto new file mode 100644 index 00000000..b63172fa --- /dev/null +++ b/proto/realionetwork/asset/priviledges/clawback/messages.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package realionetwork.asset.v1; + +option go_package = "github.com/realiotech/realio-network/x/asset/priviledges/clawback"; + +import "cosmos_proto/cosmos.proto"; + +message MsgClawbackToken { + string account = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + uint64 amount = 2; +} \ No newline at end of file diff --git a/proto/realionetwork/asset/priviledges/freeze/messages.proto b/proto/realionetwork/asset/priviledges/freeze/messages.proto new file mode 100644 index 00000000..57d78519 --- /dev/null +++ b/proto/realionetwork/asset/priviledges/freeze/messages.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package realionetwork.asset.v1; + +option go_package = "github.com/realiotech/realio-network/x/asset/priviledges/freeze"; + +import "cosmos_proto/cosmos.proto"; + +message MsgFreezeToken { + repeated string accounts = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} + +message MsgUnfreezeToken { + repeated string accounts = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} \ No newline at end of file diff --git a/proto/realionetwork/asset/priviledges/mint/messages.proto b/proto/realionetwork/asset/priviledges/mint/messages.proto index 4ed6b9d6..30d868e2 100644 --- a/proto/realionetwork/asset/priviledges/mint/messages.proto +++ b/proto/realionetwork/asset/priviledges/mint/messages.proto @@ -10,8 +10,6 @@ import "realionetwork/asset/v1/token.proto"; message MsgMintToken { - string account = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - string token_id = 2; - string to_account = 3; - uint64 amount = 4; + string to_account = 1; + uint64 amount = 2; } \ No newline at end of file diff --git a/proto/realionetwork/asset/priviledges/transfer_auth/messages.proto b/proto/realionetwork/asset/priviledges/transfer_auth/messages.proto new file mode 100644 index 00000000..056c3121 --- /dev/null +++ b/proto/realionetwork/asset/priviledges/transfer_auth/messages.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package realionetwork.asset.v1; + +option go_package = "github.com/realiotech/realio-network/x/asset/priviledges/transfer_auth"; + +import "cosmos_proto/cosmos.proto"; + +message MsgUpdateAllowList { + repeated string allowed_addresses = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + repeated string disallowed_addresses = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString"]; +} diff --git a/proto/realionetwork/asset/priviledges/transfer_auth/query.proto b/proto/realionetwork/asset/priviledges/transfer_auth/query.proto new file mode 100644 index 00000000..b36a5797 --- /dev/null +++ b/proto/realionetwork/asset/priviledges/transfer_auth/query.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package realionetwork.asset.v1; + +option go_package = "github.com/realiotech/realio-network/x/asset/priviledges/transfer_auth"; + +import "cosmos_proto/cosmos.proto"; + +message QueryWhitelistedAddressesRequest { + string token_id = 1; +} + +message QueryWhitelistedAddressesResponse { + repeated string whitelisted_addrs = 1; +} + +message QueryIsAddressWhitelistedRequest { + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} + +message QueryIsAddressWhitelistedRespones { + bool is_whitelisted = 1; +} \ No newline at end of file diff --git a/proto/realionetwork/asset/v1/token.proto b/proto/realionetwork/asset/v1/token.proto index 009923ee..9af888c2 100644 --- a/proto/realionetwork/asset/v1/token.proto +++ b/proto/realionetwork/asset/v1/token.proto @@ -21,6 +21,7 @@ message TokenManagement { string manager = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; bool add_new_privilege = 2; repeated string excluded_privileges = 3; + repeated string enabled_privileges = 4; } message Balance { diff --git a/proto/realionetwork/asset/v1/tx.proto b/proto/realionetwork/asset/v1/tx.proto index 326d800f..b96cb988 100644 --- a/proto/realionetwork/asset/v1/tx.proto +++ b/proto/realionetwork/asset/v1/tx.proto @@ -31,6 +31,7 @@ message MsgCreateToken { string description = 6; repeated string excluded_privileges = 7; bool add_new_privilege = 8; + repeated string enabled_privileges = 9; } message MsgCreateTokenResponse {} diff --git a/x/asset/keeper/keeper.go b/x/asset/keeper/keeper.go index 0e40c134..56328785 100644 --- a/x/asset/keeper/keeper.go +++ b/x/asset/keeper/keeper.go @@ -18,13 +18,14 @@ type ( Keeper struct { cdc codec.BinaryCodec // registry is used to register privilege interface and implementation. - registry cdctypes.InterfaceRegistry - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace - bankKeeper types.BankKeeper - ak types.AccountKeeper - PrivilegeManager map[string]types.PrivilegeI + registry cdctypes.InterfaceRegistry + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + bankKeeper types.BankKeeper + ak types.AccountKeeper + PrivilegeManager map[string]types.PrivilegeI + RestrictionChecker map[string]RestrictionChecker } ) @@ -68,6 +69,12 @@ func (k *Keeper) AddPrivilege(priv types.PrivilegeI) error { // regiester the privilege's interfaces priv.RegisterInterfaces(k.registry) + checker, ok := priv.(RestrictionChecker) + // currently we should only support one restriction checker at a time + if ok { + k.RestrictionChecker[priv.Name()] = checker + } + return nil } diff --git a/x/asset/keeper/keeper_test.go b/x/asset/keeper/keeper_test.go index 0fcea79f..84a09e7f 100644 --- a/x/asset/keeper/keeper_test.go +++ b/x/asset/keeper/keeper_test.go @@ -106,8 +106,8 @@ func (m MockPrivilegeI) RegisterInterfaces(registry cdctypes.InterfaceRegistry) } func (m MockPrivilegeI) MsgHandler() types.MsgHandler { - return func(context context.Context, privMsg sdk.Msg, tokenID string, privAcc sdk.AccAddress) (proto.Message, error) { - typeUrl := sdk.MsgTypeURL(privMsg) + return func(context context.Context, privMsg proto.Message, tokenID string, privAcc sdk.AccAddress) (proto.Message, error) { + typeUrl := "/" + proto.MessageName(privMsg) if typeUrl != sdk.MsgTypeURL(&types.MsgMock{}) { return nil, errors.New("unsupport msg type") } @@ -124,7 +124,7 @@ func (m MockPrivilegeI) MsgHandler() types.MsgHandler { } func (m MockPrivilegeI) QueryHandler() types.QueryHandler { - return func(context context.Context, privQuery sdk.Msg) (proto.Message, error) { + return func(context context.Context, privQuery proto.Message, tokenID string) (proto.Message, error) { return nil, nil } } diff --git a/x/asset/keeper/msg_server.go b/x/asset/keeper/msg_server.go index 1398e94e..b648be01 100644 --- a/x/asset/keeper/msg_server.go +++ b/x/asset/keeper/msg_server.go @@ -47,10 +47,10 @@ func (k msgServer) CreateToken(goCtx context.Context, msg *types.MsgCreateToken) k.SetToken(ctx, tokenId, token) k.bankKeeper.SetDenomMetaData(ctx, bank.Metadata{ Base: tokenId, Symbol: lowerCaseSymbol, Name: lowerCaseName, - DenomUnits: []*bank.DenomUnit{{Denom: lowerCaseSymbol, Exponent: msg.Decimal}, {Denom: tokenId, Exponent: 0}}, + DenomUnits: []*bank.DenomUnit{{Denom: tokenId, Exponent: msg.Decimal}}, }) - tokenManage := types.NewTokenManagement(msg.Manager, msg.AddNewPrivilege, msg.ExcludedPrivileges) + tokenManage := types.NewTokenManagement(msg.Manager, msg.AddNewPrivilege, msg.ExcludedPrivileges, msg.EnabledPrivileges) k.SetTokenManagement(ctx, tokenId, tokenManage) ctx.EventManager().EmitEvent( @@ -135,8 +135,13 @@ func (k msgServer) AssignPrivilege(goCtx context.Context, msg *types.MsgAssignPr if tm.Manager != msg.Manager { return nil, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "sender is not token manager") } - if slices.Contains(tm.ExcludedPrivileges, msg.Privilege) { - return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "privilege %s is excluded", msg.Privilege) + if !slices.Contains(tm.EnabledPrivileges, msg.GetPrivilege()) { + if !tm.AddNewPrivilege { + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "can't add new privilege") + } else if slices.Contains(tm.ExcludedPrivileges, msg.Privilege) { + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "privilege %s is excluded", msg.Privilege) + } + tm.EnabledPrivileges = append(tm.EnabledPrivileges, msg.Privilege) } for _, user := range msg.AssignedTo { @@ -145,6 +150,7 @@ func (k msgServer) AssignPrivilege(goCtx context.Context, msg *types.MsgAssignPr return nil, err } k.SetTokenPrivilegeAccount(ctx, msg.TokenId, msg.Privilege, userAcc) + k.SetTokenManagement(ctx, msg.TokenId, tm) } return &types.MsgAssignPrivilegeResponse{}, nil diff --git a/x/asset/keeper/msg_server_test.go b/x/asset/keeper/msg_server_test.go index 6a793c15..58251aae 100644 --- a/x/asset/keeper/msg_server_test.go +++ b/x/asset/keeper/msg_server_test.go @@ -87,7 +87,7 @@ func (s *KeeperTestSuite) TestUpdateToken() { token := types.NewToken(tokenId, strings.ToLower(name), lowerCaseSymbol, 2, description) k.SetToken(ctx, tokenId, token) - tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}) + tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}, []string{}) k.SetTokenManagement(ctx, tokenId, tokenManage) return &types.MsgUpdateToken{ @@ -162,7 +162,7 @@ func (s *KeeperTestSuite) TestAllocateToken() { token := types.NewToken(tokenId, strings.ToLower(name), lowerCaseSymbol, 2, description) k.SetToken(ctx, tokenId, token) - tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}) + tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}, []string{}) k.SetTokenManagement(ctx, tokenId, tokenManage) return &types.MsgAllocateToken{ @@ -235,7 +235,7 @@ func (s *KeeperTestSuite) TestAssignPrivilege() { token := types.NewToken(tokenId, strings.ToLower(name), lowerCaseSymbol, 2, description) k.SetToken(ctx, tokenId, token) - tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}) + tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}, []string{}) k.SetTokenManagement(ctx, tokenId, tokenManage) return &types.MsgAssignPrivilege{ @@ -307,7 +307,7 @@ func (s *KeeperTestSuite) TestUnassignPrivilege() { token := types.NewToken(tokenId, strings.ToLower(name), lowerCaseSymbol, 2, description) k.SetToken(ctx, tokenId, token) - tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}) + tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}, []string{}) k.SetTokenManagement(ctx, tokenId, tokenManage) k.SetTokenPrivilegeAccount(ctx, tokenId, creatorAddr.String(), userAddr1) @@ -382,7 +382,7 @@ func (s *KeeperTestSuite) TestDisablePrivilege() { token := types.NewToken(tokenId, strings.ToLower(name), lowerCaseSymbol, 2, description) k.SetToken(ctx, tokenId, token) - tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}) + tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}, []string{}) k.SetTokenManagement(ctx, tokenId, tokenManage) return &types.MsgDisablePrivilege{ @@ -447,7 +447,7 @@ func (s *KeeperTestSuite) TestExecutePrivilege() { token := types.NewToken(tokenId, strings.ToLower(name), lowerCaseSymbol, 2, description) k.SetToken(ctx, tokenId, token) - tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}) + tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}, []string{}) k.SetTokenManagement(ctx, tokenId, tokenManage) k.SetTokenPrivilegeAccount(ctx, tokenId, "test", userAddr1) @@ -483,7 +483,7 @@ func (s *KeeperTestSuite) TestExecutePrivilege() { token := types.NewToken(tokenId, strings.ToLower(name), lowerCaseSymbol, 2, description) k.SetToken(ctx, tokenId, token) - tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}) + tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}, []string{}) k.SetTokenManagement(ctx, tokenId, tokenManage) k.SetTokenPrivilegeAccount(ctx, tokenId, "test", userAddr1) @@ -543,7 +543,7 @@ func (s *KeeperTestSuite) TestExecutePrivilege() { token := types.NewToken(tokenId, strings.ToLower(name), lowerCaseSymbol, 2, description) k.SetToken(ctx, tokenId, token) - tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}) + tokenManage := types.NewTokenManagement(managerAddr.String(), true, []string{}, []string{}) k.SetTokenManagement(ctx, tokenId, tokenManage) k.SetTokenPrivilegeAccount(ctx, tokenId, creatorAddr.String(), userAddr1) diff --git a/x/asset/keeper/restriction.go b/x/asset/keeper/restriction.go new file mode 100644 index 00000000..3cd5afbb --- /dev/null +++ b/x/asset/keeper/restriction.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "slices" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/realiotech/realio-network/x/asset/types" +) + +type RestrictionChecker interface { + IsAllow(ctx sdk.Context, tokenId string, sender string) (bool, error) +} + +func (k Keeper) AssetSendRestriction(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) (newToAddr sdk.AccAddress, err error) { + newToAddr = toAddr + err = nil + + // if no checker exist allow all sender + if len(k.RestrictionChecker) == 0 { + return newToAddr, nil + } + + for _, coin := range amt { + // Check if the value already exists + // fetch bank metadata to get symbol from denom + tokenID := coin.Denom + tm, isFound := k.GetTokenManagement( + ctx, + tokenID, + ) + if !isFound { + continue + } + enabledPrivileges := tm.EnabledPrivileges + for priv, restrictionChecker := range k.RestrictionChecker { + if slices.Contains(enabledPrivileges, priv) { + isAllow, err := restrictionChecker.IsAllow(ctx, tokenID, fromAddr.String()) + if err != nil { + return newToAddr, err + } + if isAllow { + continue + } else { //nolint:revive // superfluous else, could fix, but not worth it? + err = errorsmod.Wrapf(types.ErrNotAuthorized, "%s is not authorized to transact with %s", fromAddr, coin.Denom) + return newToAddr, err + } + } + } + } + return newToAddr, nil +} diff --git a/x/asset/priviledges/clawback/messages.pb.go b/x/asset/priviledges/clawback/messages.pb.go new file mode 100644 index 00000000..f775c67e --- /dev/null +++ b/x/asset/priviledges/clawback/messages.pb.go @@ -0,0 +1,357 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: realionetwork/asset/priviledges/clawback/messages.proto + +package clawback + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgClawbackToken struct { + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgClawbackToken) Reset() { *m = MsgClawbackToken{} } +func (m *MsgClawbackToken) String() string { return proto.CompactTextString(m) } +func (*MsgClawbackToken) ProtoMessage() {} +func (*MsgClawbackToken) Descriptor() ([]byte, []int) { + return fileDescriptor_9bcb01db0400574f, []int{0} +} +func (m *MsgClawbackToken) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClawbackToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClawbackToken.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 *MsgClawbackToken) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClawbackToken.Merge(m, src) +} +func (m *MsgClawbackToken) XXX_Size() int { + return m.Size() +} +func (m *MsgClawbackToken) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClawbackToken.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClawbackToken proto.InternalMessageInfo + +func (m *MsgClawbackToken) GetAccount() string { + if m != nil { + return m.Account + } + return "" +} + +func (m *MsgClawbackToken) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +func init() { + proto.RegisterType((*MsgClawbackToken)(nil), "realionetwork.asset.v1.MsgClawbackToken") +} + +func init() { + proto.RegisterFile("realionetwork/asset/priviledges/clawback/messages.proto", fileDescriptor_9bcb01db0400574f) +} + +var fileDescriptor_9bcb01db0400574f = []byte{ + // 240 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x2f, 0x4a, 0x4d, 0xcc, + 0xc9, 0xcc, 0xcf, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0xd1, + 0x2f, 0x28, 0xca, 0x2c, 0xcb, 0xcc, 0x49, 0x4d, 0x49, 0x4f, 0x2d, 0xd6, 0x4f, 0xce, 0x49, 0x2c, + 0x4f, 0x4a, 0x4c, 0xce, 0xd6, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0x2d, 0xd6, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x43, 0xd1, 0xa8, 0x07, 0xd6, 0xa8, 0x57, 0x66, 0x28, 0x25, 0x99, + 0x9c, 0x5f, 0x9c, 0x9b, 0x5f, 0x1c, 0x0f, 0x56, 0xa5, 0x0f, 0xe1, 0x40, 0xb4, 0x28, 0xc5, 0x71, + 0x09, 0xf8, 0x16, 0xa7, 0x3b, 0x43, 0x0d, 0x0c, 0xc9, 0xcf, 0x4e, 0xcd, 0x13, 0x32, 0xe2, 0x62, + 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0x92, 0xb8, + 0xb4, 0x45, 0x57, 0x04, 0xaa, 0xcd, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x38, 0xb8, 0xa4, 0x28, + 0x33, 0x2f, 0x3d, 0x08, 0xa6, 0x50, 0x48, 0x8c, 0x8b, 0x2d, 0x31, 0x17, 0xac, 0x85, 0x49, 0x81, + 0x51, 0x83, 0x25, 0x08, 0xca, 0x73, 0x8a, 0x3e, 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, 0xc7, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x88, 0xbb, + 0x4b, 0x52, 0x93, 0x33, 0xa0, 0x4c, 0x5d, 0x98, 0xe7, 0x2b, 0xf0, 0x78, 0x3f, 0x89, 0x0d, 0xec, + 0x07, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x9e, 0x5e, 0x26, 0x31, 0x01, 0x00, 0x00, +} + +func (m *MsgClawbackToken) 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 *MsgClawbackToken) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClawbackToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Amount != 0 { + i = encodeVarintMessages(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x10 + } + if len(m.Account) > 0 { + i -= len(m.Account) + copy(dAtA[i:], m.Account) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Account))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { + offset -= sovMessages(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgClawbackToken) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Account) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + if m.Amount != 0 { + n += 1 + sovMessages(uint64(m.Amount)) + } + return n +} + +func sovMessages(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMessages(x uint64) (n int) { + return sovMessages(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgClawbackToken) 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 ErrIntOverflowMessages + } + 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: MsgClawbackToken: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClawbackToken: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Account = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipMessages(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMessages + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMessages(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMessages + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMessages + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMessages + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMessages = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMessages = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMessages = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/asset/priviledges/clawback/msg_handler.go b/x/asset/priviledges/clawback/msg_handler.go new file mode 100644 index 00000000..16d0b6a1 --- /dev/null +++ b/x/asset/priviledges/clawback/msg_handler.go @@ -0,0 +1,49 @@ +package clawback + +import ( + "context" + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" + "github.com/pkg/errors" + assettypes "github.com/realiotech/realio-network/x/asset/types" + // "github.com/cosmos/cosmos-sdk/store/types" +) + +func (cp ClawbackPriviledge) clawbackToken(ctx sdk.Context, msg *MsgClawbackToken, tokenID string, privAcc sdk.AccAddress) error { + + clawbackCoin := sdk.NewCoin(tokenID, sdk.NewIntFromUint64(msg.Amount)) + + senderAddr, err := sdk.AccAddressFromBech32(msg.Account) + if err != nil { + return fmt.Errorf("invalid bech 32 address: %v", err) + } + + spendable := cp.bk.SpendableCoins(ctx, senderAddr) + + if spendable.IsAllLT(sdk.NewCoins(sdk.NewCoin(tokenID, sdk.NewIntFromUint64(msg.Amount)))) { + return fmt.Errorf("insufficient funds want %s have %s", clawbackCoin.String(), spendable.String()) + } + + err = cp.bk.SendCoins(ctx, senderAddr, privAcc, sdk.NewCoins(clawbackCoin)) + if err != nil { + return err + } + + return err +} + +func (cp ClawbackPriviledge) MsgHandler() assettypes.MsgHandler { + return func(context context.Context, msg proto.Message, tokenID string, privAcc sdk.AccAddress) (proto.Message, error) { + ctx := sdk.UnwrapSDKContext(context) + + switch msg := msg.(type) { + case *MsgClawbackToken: + return nil, cp.clawbackToken(ctx, msg, tokenID, privAcc) + default: + errMsg := fmt.Sprintf("unrecognized message type: %T for Clawback priviledge", msg) + return nil, errors.Errorf(errMsg) + } + } +} diff --git a/x/asset/priviledges/clawback/priv.go b/x/asset/priviledges/clawback/priv.go new file mode 100644 index 00000000..e65f640f --- /dev/null +++ b/x/asset/priviledges/clawback/priv.go @@ -0,0 +1,37 @@ +package clawback + +import ( + "context" + + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + proto "github.com/gogo/protobuf/proto" + assettypes "github.com/realiotech/realio-network/x/asset/types" +) + +const priv_name = "clawback" + +type ClawbackPriviledge struct { + bk BankKeeper +} + +func NewClawbackPriviledge(bk BankKeeper) ClawbackPriviledge { + return ClawbackPriviledge{ + bk: bk, + } +} + +func (cp ClawbackPriviledge) Name() string { + return priv_name +} + +func (cp ClawbackPriviledge) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*assettypes.PrivilegeMsgI)(nil), + &MsgClawbackToken{}, + ) +} + +func (cb ClawbackPriviledge) QueryHandler() assettypes.QueryHandler { + return func(context context.Context, privQuery proto.Message, tokenID string) (proto.Message, error) { + return nil, nil + } +} diff --git a/x/asset/priviledges/clawback/priv_test.go b/x/asset/priviledges/clawback/priv_test.go new file mode 100644 index 00000000..b2bc94ac --- /dev/null +++ b/x/asset/priviledges/clawback/priv_test.go @@ -0,0 +1,5 @@ +package clawback_test + +// import ( +// assettest "github.com/realiotech/realio-network/x/asset/keeper" +// ) diff --git a/x/asset/priviledges/clawback/types.go b/x/asset/priviledges/clawback/types.go new file mode 100644 index 00000000..53fdcca7 --- /dev/null +++ b/x/asset/priviledges/clawback/types.go @@ -0,0 +1,10 @@ +package clawback + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type BankKeeper interface { + SendCoins(ctx sdk.Context, senderAddr, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins +} diff --git a/x/asset/priviledges/freeze/messages.pb.go b/x/asset/priviledges/freeze/messages.pb.go new file mode 100644 index 00000000..55ab943e --- /dev/null +++ b/x/asset/priviledges/freeze/messages.pb.go @@ -0,0 +1,500 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: realionetwork/asset/priviledges/freeze/messages.proto + +package freeze + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgFreezeToken struct { + Accounts []string `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts,omitempty"` +} + +func (m *MsgFreezeToken) Reset() { *m = MsgFreezeToken{} } +func (m *MsgFreezeToken) String() string { return proto.CompactTextString(m) } +func (*MsgFreezeToken) ProtoMessage() {} +func (*MsgFreezeToken) Descriptor() ([]byte, []int) { + return fileDescriptor_537c9a40c5210f44, []int{0} +} +func (m *MsgFreezeToken) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgFreezeToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgFreezeToken.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 *MsgFreezeToken) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgFreezeToken.Merge(m, src) +} +func (m *MsgFreezeToken) XXX_Size() int { + return m.Size() +} +func (m *MsgFreezeToken) XXX_DiscardUnknown() { + xxx_messageInfo_MsgFreezeToken.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgFreezeToken proto.InternalMessageInfo + +func (m *MsgFreezeToken) GetAccounts() []string { + if m != nil { + return m.Accounts + } + return nil +} + +type MsgUnfreezeToken struct { + Accounts []string `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts,omitempty"` +} + +func (m *MsgUnfreezeToken) Reset() { *m = MsgUnfreezeToken{} } +func (m *MsgUnfreezeToken) String() string { return proto.CompactTextString(m) } +func (*MsgUnfreezeToken) ProtoMessage() {} +func (*MsgUnfreezeToken) Descriptor() ([]byte, []int) { + return fileDescriptor_537c9a40c5210f44, []int{1} +} +func (m *MsgUnfreezeToken) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnfreezeToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnfreezeToken.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 *MsgUnfreezeToken) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnfreezeToken.Merge(m, src) +} +func (m *MsgUnfreezeToken) XXX_Size() int { + return m.Size() +} +func (m *MsgUnfreezeToken) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnfreezeToken.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnfreezeToken proto.InternalMessageInfo + +func (m *MsgUnfreezeToken) GetAccounts() []string { + if m != nil { + return m.Accounts + } + return nil +} + +func init() { + proto.RegisterType((*MsgFreezeToken)(nil), "realionetwork.asset.v1.MsgFreezeToken") + proto.RegisterType((*MsgUnfreezeToken)(nil), "realionetwork.asset.v1.MsgUnfreezeToken") +} + +func init() { + proto.RegisterFile("realionetwork/asset/priviledges/freeze/messages.proto", fileDescriptor_537c9a40c5210f44) +} + +var fileDescriptor_537c9a40c5210f44 = []byte{ + // 236 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x2d, 0x4a, 0x4d, 0xcc, + 0xc9, 0xcc, 0xcf, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0xd1, + 0x2f, 0x28, 0xca, 0x2c, 0xcb, 0xcc, 0x49, 0x4d, 0x49, 0x4f, 0x2d, 0xd6, 0x4f, 0x2b, 0x4a, 0x4d, + 0xad, 0x4a, 0xd5, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x12, 0x43, 0xd1, 0xa6, 0x07, 0xd6, 0xa6, 0x57, 0x66, 0x28, 0x25, 0x99, 0x9c, 0x5f, + 0x9c, 0x9b, 0x5f, 0x1c, 0x0f, 0x56, 0xa5, 0x0f, 0xe1, 0x40, 0xb4, 0x28, 0xb9, 0x71, 0xf1, 0xf9, + 0x16, 0xa7, 0xbb, 0x81, 0x8d, 0x0b, 0xc9, 0xcf, 0x4e, 0xcd, 0x13, 0x32, 0xe1, 0xe2, 0x48, 0x4c, + 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0x96, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x74, 0x92, 0xb8, 0xb4, + 0x45, 0x57, 0x04, 0xaa, 0xcb, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x38, 0xb8, 0xa4, 0x28, 0x33, + 0x2f, 0x3d, 0x08, 0xae, 0x52, 0xc9, 0x83, 0x4b, 0xc0, 0xb7, 0x38, 0x3d, 0x34, 0x2f, 0x8d, 0x52, + 0x93, 0x9c, 0x22, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, + 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x3e, 0x3d, + 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xe2, 0xd3, 0x92, 0xd4, 0xe4, 0x0c, + 0x28, 0x53, 0x17, 0x16, 0x58, 0x15, 0x38, 0x83, 0x2b, 0x89, 0x0d, 0xec, 0x67, 0x63, 0x40, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xef, 0xa6, 0x54, 0x2b, 0x5f, 0x01, 0x00, 0x00, +} + +func (m *MsgFreezeToken) 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 *MsgFreezeToken) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgFreezeToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Accounts) > 0 { + for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Accounts[iNdEx]) + copy(dAtA[i:], m.Accounts[iNdEx]) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Accounts[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MsgUnfreezeToken) 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 *MsgUnfreezeToken) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnfreezeToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Accounts) > 0 { + for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Accounts[iNdEx]) + copy(dAtA[i:], m.Accounts[iNdEx]) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Accounts[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { + offset -= sovMessages(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgFreezeToken) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Accounts) > 0 { + for _, s := range m.Accounts { + l = len(s) + n += 1 + l + sovMessages(uint64(l)) + } + } + return n +} + +func (m *MsgUnfreezeToken) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Accounts) > 0 { + for _, s := range m.Accounts { + l = len(s) + n += 1 + l + sovMessages(uint64(l)) + } + } + return n +} + +func sovMessages(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMessages(x uint64) (n int) { + return sovMessages(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgFreezeToken) 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 ErrIntOverflowMessages + } + 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: MsgFreezeToken: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgFreezeToken: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Accounts", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Accounts = append(m.Accounts, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMessages(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMessages + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUnfreezeToken) 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 ErrIntOverflowMessages + } + 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: MsgUnfreezeToken: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnfreezeToken: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Accounts", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Accounts = append(m.Accounts, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMessages(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMessages + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMessages(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMessages + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMessages + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMessages + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMessages = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMessages = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMessages = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/asset/priviledges/freeze/msg_server.go b/x/asset/priviledges/freeze/msg_server.go index f9a3c5ff..6a9886ea 100644 --- a/x/asset/priviledges/freeze/msg_server.go +++ b/x/asset/priviledges/freeze/msg_server.go @@ -1 +1,42 @@ package freeze + +import ( + "context" + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" + "github.com/pkg/errors" + assettypes "github.com/realiotech/realio-network/x/asset/types" + // "github.com/cosmos/cosmos-sdk/store/types" +) + +func (mp FreezePriviledge) FreezeToken(ctx sdk.Context, msg *MsgFreezeToken, tokenID string) error { + for _, addr := range msg.Accounts { + mp.SetFreezeAddress(ctx, tokenID, addr) + } + return nil +} + +func (mp FreezePriviledge) UnfreezeToken(ctx sdk.Context, msg *MsgUnfreezeToken, tokenID string) error { + for _, addr := range msg.Accounts { + mp.RemoveFreezeAddress(ctx, tokenID, addr) + } + return nil +} + +func (mp FreezePriviledge) MsgHandler() assettypes.MsgHandler { + return func(context context.Context, msg proto.Message, tokenID string, privAcc sdk.AccAddress) (proto.Message, error) { + ctx := sdk.UnwrapSDKContext(context) + + switch msg := msg.(type) { + case *MsgFreezeToken: + return nil, mp.FreezeToken(ctx, msg, tokenID) + case *MsgUnfreezeToken: + return nil, mp.UnfreezeToken(ctx, msg, tokenID) + default: + errMsg := fmt.Sprintf("unrecognized message type: %T for Transfer auth priviledge", msg) + return nil, errors.Errorf(errMsg) + } + } +} diff --git a/x/asset/priviledges/freeze/priv.go b/x/asset/priviledges/freeze/priv.go new file mode 100644 index 00000000..cc090328 --- /dev/null +++ b/x/asset/priviledges/freeze/priv.go @@ -0,0 +1,42 @@ +package freeze + +import ( + "github.com/realiotech/realio-network/x/asset/keeper" + + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + assettypes "github.com/realiotech/realio-network/x/asset/types" +) + +var ( + _ keeper.RestrictionChecker = (*FreezePriviledge)(nil) + StoreKey = "freezepriv" +) + +const priv_name = "transfer_auth" + +type FreezePriviledge struct { + storeKey storetypes.StoreKey +} + +func NewFreezePriviledge(sk storetypes.StoreKey) FreezePriviledge { + return FreezePriviledge{ + storeKey: sk, + } +} + +func (tp FreezePriviledge) Name() string { + return priv_name +} + +func (tp FreezePriviledge) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*assettypes.PrivilegeMsgI)(nil), + &MsgFreezeToken{}, + &MsgUnfreezeToken{}, + ) +} + +func (tp FreezePriviledge) IsAllow(ctx sdk.Context, tokenID string, sender string) (bool, error) { + return tp.CheckAddressIsFreezed(ctx, tokenID, sender), nil +} diff --git a/x/asset/priviledges/freeze/store.go b/x/asset/priviledges/freeze/store.go new file mode 100644 index 00000000..59d9deb1 --- /dev/null +++ b/x/asset/priviledges/freeze/store.go @@ -0,0 +1,48 @@ +package freeze + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + FreezePrefix = []byte{0x2} + TokenPrefix = []byte{0x1} +) + +func tokenPrefix(tokenID string) []byte { + return append(TokenPrefix, tokenID...) +} + +func (tp FreezePriviledge) FreezeStore(ctx sdk.Context, tokenID string) storetypes.KVStore { + tokenStore := prefix.NewStore(ctx.KVStore(tp.storeKey), tokenPrefix(tokenID)) + return prefix.NewStore(tokenStore, FreezePrefix) +} + +func (tp FreezePriviledge) SetFreezeAddress(ctx sdk.Context, tokenID string, address string) { + store := tp.FreezeStore(ctx, tokenID) + store.Set([]byte(address), []byte{0x01}) +} + +func (tp FreezePriviledge) RemoveFreezeAddress(ctx sdk.Context, tokenID string, address string) { + store := tp.FreezeStore(ctx, tokenID) + store.Delete([]byte(address)) +} + +func (tp FreezePriviledge) CheckAddressIsFreezed(ctx sdk.Context, tokenID string, address string) bool { + store := tp.FreezeStore(ctx, tokenID) + return store.Has([]byte(address)) +} + +func (tp FreezePriviledge) GetFreezeedAddrs(ctx sdk.Context, tokenID string) (whitelistedAddrs []string) { + store := tp.FreezeStore(ctx, tokenID) + + iterator := store.Iterator(nil, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + whitelistedAddrs = append(whitelistedAddrs, string(iterator.Value())) + } + return +} diff --git a/x/asset/priviledges/mint/messages.pb.go b/x/asset/priviledges/mint/messages.pb.go index d8f013ba..a6e45e31 100644 --- a/x/asset/priviledges/mint/messages.pb.go +++ b/x/asset/priviledges/mint/messages.pb.go @@ -27,10 +27,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgMintToken struct { - Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` - TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` - ToAccount string `protobuf:"bytes,3,opt,name=to_account,json=toAccount,proto3" json:"to_account,omitempty"` - Amount uint64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"` + ToAccount string `protobuf:"bytes,1,opt,name=to_account,json=toAccount,proto3" json:"to_account,omitempty"` + Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` } func (m *MsgMintToken) Reset() { *m = MsgMintToken{} } @@ -66,20 +64,6 @@ func (m *MsgMintToken) XXX_DiscardUnknown() { var xxx_messageInfo_MsgMintToken proto.InternalMessageInfo -func (m *MsgMintToken) GetAccount() string { - if m != nil { - return m.Account - } - return "" -} - -func (m *MsgMintToken) GetTokenId() string { - if m != nil { - return m.TokenId - } - return "" -} - func (m *MsgMintToken) GetToAccount() string { if m != nil { return m.ToAccount @@ -103,27 +87,24 @@ func init() { } var fileDescriptor_815603282167548b = []byte{ - // 309 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xb1, 0x6e, 0xf2, 0x30, - 0x14, 0x85, 0xf1, 0xff, 0x23, 0x28, 0x56, 0xa7, 0x08, 0x21, 0x40, 0xaa, 0x85, 0x98, 0x58, 0x88, - 0x45, 0x99, 0x3b, 0xc0, 0xd6, 0x81, 0x85, 0x56, 0xaa, 0xd4, 0x05, 0x99, 0xc4, 0x35, 0x16, 0xc4, - 0x17, 0xd9, 0x17, 0xda, 0xbe, 0x45, 0x87, 0x3e, 0x4a, 0x1f, 0xa2, 0x23, 0xea, 0xd4, 0xb1, 0x4a, - 0x5e, 0xa4, 0x8a, 0x93, 0x0c, 0x95, 0xda, 0xed, 0x1e, 0x7f, 0xe7, 0x5c, 0xfb, 0xc8, 0x74, 0x6a, - 0xa5, 0xd8, 0x69, 0x30, 0x12, 0x1f, 0xc1, 0x6e, 0xb9, 0x70, 0x4e, 0x22, 0xdf, 0x5b, 0x7d, 0xd4, - 0x3b, 0x19, 0x2b, 0xe9, 0x78, 0xa2, 0x0d, 0xf2, 0x44, 0x3a, 0x27, 0x94, 0x74, 0xe1, 0xde, 0x02, - 0x42, 0xd0, 0xf9, 0x11, 0x0a, 0x7d, 0x28, 0x3c, 0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x8d, - 0xa0, 0xb5, 0x01, 0x00, 0x00, + // 259 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xb1, 0x4a, 0x03, 0x41, + 0x10, 0x86, 0x6f, 0x45, 0x02, 0x39, 0xac, 0x0e, 0x09, 0x1a, 0x70, 0x09, 0xa9, 0xd2, 0x78, 0x4b, + 0x48, 0x6d, 0xa1, 0x60, 0x99, 0x26, 0x08, 0x82, 0x4d, 0xd8, 0x5b, 0xc7, 0xcd, 0x92, 0xdb, 0x9d, + 0x70, 0x3b, 0x77, 0xea, 0x5b, 0xf8, 0x58, 0x96, 0x29, 0x2d, 0xe5, 0xee, 0x45, 0x24, 0xbb, 0x97, + 0x42, 0xd0, 0x6e, 0xfe, 0xf9, 0xfe, 0x81, 0x8f, 0x49, 0x17, 0x15, 0xc8, 0xd2, 0xa0, 0x03, 0x7a, + 0xc5, 0x6a, 0x2b, 0xa4, 0xf7, 0x40, 0x62, 0x57, 0x99, 0xc6, 0x94, 0xf0, 0xac, 0xc1, 0x0b, 0x6b, + 0x1c, 0x09, 0x0b, 0xde, 0x4b, 0x0d, 0x3e, 0xdf, 0x55, 0x48, 0x98, 0x8d, 0x7e, 0x1d, 0xe5, 0xe1, + 0x28, 0x6f, 0xe6, 0xe3, 0x73, 0x8d, 0x1a, 0x43, 0x45, 0x1c, 0xa6, 0xd8, 0x1e, 0x5f, 0x2a, 0xf4, + 0x16, 0xfd, 0x3a, 0x82, 0x18, 0x8e, 0x48, 0x23, 0xea, 0x12, 0x44, 0x48, 0x45, 0xfd, 0x22, 0xa4, + 0x7b, 0xef, 0xd1, 0xf4, 0x2f, 0xb1, 0x66, 0x2e, 0x08, 0xb7, 0xe0, 0x62, 0x67, 0x7a, 0x9f, 0x9e, + 0x2d, 0xbd, 0x5e, 0x1a, 0x47, 0x0f, 0x87, 0x6d, 0x76, 0x95, 0xa6, 0x84, 0x6b, 0xa9, 0x14, 0xd6, + 0x8e, 0x2e, 0xd8, 0x84, 0xcd, 0x86, 0xab, 0x21, 0xe1, 0x6d, 0x5c, 0x64, 0xa3, 0x74, 0x20, 0x6d, + 0x40, 0x27, 0x13, 0x36, 0x3b, 0x5d, 0xf5, 0xe9, 0xee, 0xf1, 0xb3, 0xe5, 0x6c, 0xdf, 0x72, 0xf6, + 0xdd, 0x72, 0xf6, 0xd1, 0xf1, 0x64, 0xdf, 0xf1, 0xe4, 0xab, 0xe3, 0xc9, 0xd3, 0x8d, 0x36, 0xb4, + 0xa9, 0x8b, 0x5c, 0xa1, 0x15, 0xd1, 0x87, 0x40, 0x6d, 0xfa, 0xf1, 0xfa, 0xe8, 0xf6, 0xf6, 0xcf, + 0xdb, 0x8a, 0x41, 0xd0, 0x5c, 0xfc, 0x04, 0x00, 0x00, 0xff, 0xff, 0x79, 0xf2, 0xf6, 0x03, 0x65, + 0x01, 0x00, 0x00, } func (m *MsgMintToken) Marshal() (dAtA []byte, err error) { @@ -149,27 +130,13 @@ func (m *MsgMintToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.Amount != 0 { i = encodeVarintMessages(dAtA, i, uint64(m.Amount)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x10 } if len(m.ToAccount) > 0 { i -= len(m.ToAccount) copy(dAtA[i:], m.ToAccount) i = encodeVarintMessages(dAtA, i, uint64(len(m.ToAccount))) i-- - dAtA[i] = 0x1a - } - if len(m.TokenId) > 0 { - i -= len(m.TokenId) - copy(dAtA[i:], m.TokenId) - i = encodeVarintMessages(dAtA, i, uint64(len(m.TokenId))) - i-- - dAtA[i] = 0x12 - } - if len(m.Account) > 0 { - i -= len(m.Account) - copy(dAtA[i:], m.Account) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Account))) - i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -192,14 +159,6 @@ func (m *MsgMintToken) Size() (n int) { } var l int _ = l - l = len(m.Account) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - l = len(m.TokenId) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } l = len(m.ToAccount) if l > 0 { n += 1 + l + sovMessages(uint64(l)) @@ -246,70 +205,6 @@ func (m *MsgMintToken) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Account = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TokenId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ToAccount", wireType) } @@ -341,7 +236,7 @@ func (m *MsgMintToken) Unmarshal(dAtA []byte) error { } m.ToAccount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } diff --git a/x/asset/priviledges/mint/msg_server.go b/x/asset/priviledges/mint/msg_server.go index d1391f81..b50b0137 100644 --- a/x/asset/priviledges/mint/msg_server.go +++ b/x/asset/priviledges/mint/msg_server.go @@ -25,14 +25,16 @@ func (mp MintPriviledge) MintToken(ctx sdk.Context, msg *MsgMintToken, tokenID s return err } -func (mp MintPriviledge) MsgHandler(context context.Context, msg proto.Message, tokenID string, privAcc sdk.AccAddress) (proto.Message, error) { - ctx := sdk.UnwrapSDKContext(context) - - switch msg := msg.(type) { - case *MsgMintToken: - return nil, mp.MintToken(ctx, msg, tokenID) - default: - errMsg := fmt.Sprintf("unrecognized message type: %T for Mint priviledge", msg) - return nil, errors.Errorf(errMsg) +func (mp MintPriviledge) MsgHandler() assettypes.MsgHandler { + return func(context context.Context, msg proto.Message, tokenID string, privAcc sdk.AccAddress) (proto.Message, error) { + ctx := sdk.UnwrapSDKContext(context) + + switch msg := msg.(type) { + case *MsgMintToken: + return nil, mp.MintToken(ctx, msg, tokenID) + default: + errMsg := fmt.Sprintf("unrecognized message type: %T for Mint priviledge", msg) + return nil, errors.Errorf(errMsg) + } } } diff --git a/x/asset/priviledges/mint/priv.go b/x/asset/priviledges/mint/priv.go index e0b6ecfc..1ab1a46f 100644 --- a/x/asset/priviledges/mint/priv.go +++ b/x/asset/priviledges/mint/priv.go @@ -1,5 +1,15 @@ package mint +import ( + "context" + + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + proto "github.com/gogo/protobuf/proto" + assettypes "github.com/realiotech/realio-network/x/asset/types" +) + +const priv_name = "mint" + type MintPriviledge struct { bk BankKeeper } @@ -9,3 +19,19 @@ func NewMintPriviledge(bk BankKeeper) MintPriviledge { bk: bk, } } + +func (mp MintPriviledge) Name() string { + return priv_name +} + +func (mp MintPriviledge) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*assettypes.PrivilegeMsgI)(nil), + &MsgMintToken{}, + ) +} + +func (mp MintPriviledge) QueryHandler() assettypes.QueryHandler { + return func(context context.Context, privQuery proto.Message, tokenID string) (proto.Message, error) { + return nil, nil + } +} diff --git a/x/asset/priviledges/transfer_auth/messages.pb.go b/x/asset/priviledges/transfer_auth/messages.pb.go new file mode 100644 index 00000000..ac50bd46 --- /dev/null +++ b/x/asset/priviledges/transfer_auth/messages.pb.go @@ -0,0 +1,383 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: realionetwork/asset/priviledges/transfer_auth/messages.proto + +package transfer_auth + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgUpdateAllowList struct { + AllowedAddresses []string `protobuf:"bytes,1,rep,name=allowed_addresses,json=allowedAddresses,proto3" json:"allowed_addresses,omitempty"` + DisallowedAddresses []string `protobuf:"bytes,2,rep,name=disallowed_addresses,json=disallowedAddresses,proto3" json:"disallowed_addresses,omitempty"` +} + +func (m *MsgUpdateAllowList) Reset() { *m = MsgUpdateAllowList{} } +func (m *MsgUpdateAllowList) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAllowList) ProtoMessage() {} +func (*MsgUpdateAllowList) Descriptor() ([]byte, []int) { + return fileDescriptor_815f42c56d94596e, []int{0} +} +func (m *MsgUpdateAllowList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateAllowList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateAllowList.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 *MsgUpdateAllowList) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAllowList.Merge(m, src) +} +func (m *MsgUpdateAllowList) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateAllowList) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAllowList.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateAllowList proto.InternalMessageInfo + +func (m *MsgUpdateAllowList) GetAllowedAddresses() []string { + if m != nil { + return m.AllowedAddresses + } + return nil +} + +func (m *MsgUpdateAllowList) GetDisallowedAddresses() []string { + if m != nil { + return m.DisallowedAddresses + } + return nil +} + +func init() { + proto.RegisterType((*MsgUpdateAllowList)(nil), "realionetwork.asset.v1.MsgUpdateAllowList") +} + +func init() { + proto.RegisterFile("realionetwork/asset/priviledges/transfer_auth/messages.proto", fileDescriptor_815f42c56d94596e) +} + +var fileDescriptor_815f42c56d94596e = []byte{ + // 263 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x29, 0x4a, 0x4d, 0xcc, + 0xc9, 0xcc, 0xcf, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0xd1, + 0x2f, 0x28, 0xca, 0x2c, 0xcb, 0xcc, 0x49, 0x4d, 0x49, 0x4f, 0x2d, 0xd6, 0x2f, 0x29, 0x4a, 0xcc, + 0x2b, 0x4e, 0x4b, 0x2d, 0x8a, 0x4f, 0x2c, 0x2d, 0xc9, 0xd0, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, + 0x4f, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x43, 0xd1, 0xad, 0x07, 0xd6, 0xad, + 0x57, 0x66, 0x28, 0x25, 0x99, 0x9c, 0x5f, 0x9c, 0x9b, 0x5f, 0x1c, 0x0f, 0x56, 0xa5, 0x0f, 0xe1, + 0x40, 0xb4, 0x28, 0xad, 0x60, 0xe4, 0x12, 0xf2, 0x2d, 0x4e, 0x0f, 0x2d, 0x48, 0x49, 0x2c, 0x49, + 0x75, 0xcc, 0xc9, 0xc9, 0x2f, 0xf7, 0xc9, 0x2c, 0x2e, 0x11, 0x72, 0xe5, 0x12, 0x4c, 0x04, 0x71, + 0x52, 0x53, 0xe2, 0x13, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x53, 0x8b, 0x25, 0x18, 0x15, 0x98, + 0x35, 0x38, 0x9d, 0x24, 0x2e, 0x6d, 0xd1, 0x15, 0x81, 0x9a, 0xe1, 0x08, 0x91, 0x0b, 0x2e, 0x29, + 0xca, 0xcc, 0x4b, 0x0f, 0x12, 0x80, 0x6a, 0x71, 0x84, 0xe9, 0x10, 0xf2, 0xe6, 0x12, 0x49, 0xc9, + 0x2c, 0xc6, 0x34, 0x89, 0x89, 0x80, 0x49, 0xc2, 0x08, 0x5d, 0x70, 0xc3, 0x9c, 0x12, 0x4e, 0x3c, + 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, + 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x2d, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, + 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x12, 0x04, 0x25, 0xa9, 0xc9, 0x19, 0x50, 0xa6, 0x2e, 0x2c, 0x30, + 0x2b, 0x08, 0x05, 0x67, 0x12, 0x1b, 0x38, 0x4c, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8a, + 0xb4, 0x4e, 0xe8, 0x86, 0x01, 0x00, 0x00, +} + +func (m *MsgUpdateAllowList) 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 *MsgUpdateAllowList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateAllowList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DisallowedAddresses) > 0 { + for iNdEx := len(m.DisallowedAddresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.DisallowedAddresses[iNdEx]) + copy(dAtA[i:], m.DisallowedAddresses[iNdEx]) + i = encodeVarintMessages(dAtA, i, uint64(len(m.DisallowedAddresses[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.AllowedAddresses) > 0 { + for iNdEx := len(m.AllowedAddresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowedAddresses[iNdEx]) + copy(dAtA[i:], m.AllowedAddresses[iNdEx]) + i = encodeVarintMessages(dAtA, i, uint64(len(m.AllowedAddresses[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { + offset -= sovMessages(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateAllowList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AllowedAddresses) > 0 { + for _, s := range m.AllowedAddresses { + l = len(s) + n += 1 + l + sovMessages(uint64(l)) + } + } + if len(m.DisallowedAddresses) > 0 { + for _, s := range m.DisallowedAddresses { + l = len(s) + n += 1 + l + sovMessages(uint64(l)) + } + } + return n +} + +func sovMessages(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMessages(x uint64) (n int) { + return sovMessages(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateAllowList) 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 ErrIntOverflowMessages + } + 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: MsgUpdateAllowList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateAllowList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowedAddresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowedAddresses = append(m.AllowedAddresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DisallowedAddresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DisallowedAddresses = append(m.DisallowedAddresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMessages(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMessages + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMessages(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMessages + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMessages + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMessages + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMessages = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMessages = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMessages = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/asset/priviledges/transfer_auth/msg_server.go b/x/asset/priviledges/transfer_auth/msg_server.go new file mode 100644 index 00000000..adf6bda9 --- /dev/null +++ b/x/asset/priviledges/transfer_auth/msg_server.go @@ -0,0 +1,37 @@ +package transfer_auth + +import ( + "context" + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" + "github.com/pkg/errors" + assettypes "github.com/realiotech/realio-network/x/asset/types" + // "github.com/cosmos/cosmos-sdk/store/types" +) + +func (mp TransferAuthPriviledge) UpdateAllowList(ctx sdk.Context, msg *MsgUpdateAllowList, tokenID string) error { + + for _, addr := range msg.AllowedAddresses { + mp.AddAddressToWhiteList(ctx, tokenID, addr) + } + for _, addr := range msg.DisallowedAddresses { + mp.RemoveAddressFromWhiteList(ctx, tokenID, addr) + } + return nil +} + +func (mp TransferAuthPriviledge) MsgHandler() assettypes.MsgHandler { + return func(context context.Context, msg proto.Message, tokenID string, privAcc sdk.AccAddress) (proto.Message, error) { + ctx := sdk.UnwrapSDKContext(context) + + switch msg := msg.(type) { + case *MsgUpdateAllowList: + return nil, mp.UpdateAllowList(ctx, msg, tokenID) + default: + errMsg := fmt.Sprintf("unrecognized message type: %T for Transfer auth priviledge", msg) + return nil, errors.Errorf(errMsg) + } + } +} diff --git a/x/asset/priviledges/transfer_auth/priv.go b/x/asset/priviledges/transfer_auth/priv.go new file mode 100644 index 00000000..a5ab806d --- /dev/null +++ b/x/asset/priviledges/transfer_auth/priv.go @@ -0,0 +1,41 @@ +package transfer_auth + +import ( + assetkeeper "github.com/realiotech/realio-network/x/asset/keeper" + + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + assettypes "github.com/realiotech/realio-network/x/asset/types" +) + +var ( + _ assetkeeper.RestrictionChecker = (*TransferAuthPriviledge)(nil) + StoreKey = "transferauthpriv" +) + +const priv_name = "transfer_auth" + +type TransferAuthPriviledge struct { + storeKey storetypes.StoreKey +} + +func NewTransferAuthPriviledge(sk storetypes.StoreKey) TransferAuthPriviledge { + return TransferAuthPriviledge{ + storeKey: sk, + } +} + +func (tp TransferAuthPriviledge) Name() string { + return priv_name +} + +func (tp TransferAuthPriviledge) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*assettypes.PrivilegeMsgI)(nil), + &MsgUpdateAllowList{}, + ) +} + +func (tp TransferAuthPriviledge) IsAllow(ctx sdk.Context, tokenID string, sender string) (bool, error) { + return tp.CheckAddressIsWhitelisted(ctx, tokenID, sender), nil +} diff --git a/x/asset/priviledges/transfer_auth/priv.pb.go b/x/asset/priviledges/transfer_auth/priv.pb.go new file mode 100644 index 00000000..7fa95d96 --- /dev/null +++ b/x/asset/priviledges/transfer_auth/priv.pb.go @@ -0,0 +1,424 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: realionetwork/asset/priviledges/transfer_auth/priv.proto + +package transfer_auth + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type AllowAddrs struct { + Addrs map[string]bool `protobuf:"bytes,1,rep,name=addrs,proto3" json:"addrs,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` +} + +func (m *AllowAddrs) Reset() { *m = AllowAddrs{} } +func (m *AllowAddrs) String() string { return proto.CompactTextString(m) } +func (*AllowAddrs) ProtoMessage() {} +func (*AllowAddrs) Descriptor() ([]byte, []int) { + return fileDescriptor_f16378177ffba5d1, []int{0} +} +func (m *AllowAddrs) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AllowAddrs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AllowAddrs.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 *AllowAddrs) XXX_Merge(src proto.Message) { + xxx_messageInfo_AllowAddrs.Merge(m, src) +} +func (m *AllowAddrs) XXX_Size() int { + return m.Size() +} +func (m *AllowAddrs) XXX_DiscardUnknown() { + xxx_messageInfo_AllowAddrs.DiscardUnknown(m) +} + +var xxx_messageInfo_AllowAddrs proto.InternalMessageInfo + +func (m *AllowAddrs) GetAddrs() map[string]bool { + if m != nil { + return m.Addrs + } + return nil +} + +func init() { + proto.RegisterType((*AllowAddrs)(nil), "realionetwork.asset.v1.AllowAddrs") + proto.RegisterMapType((map[string]bool)(nil), "realionetwork.asset.v1.AllowAddrs.AddrsEntry") +} + +func init() { + proto.RegisterFile("realionetwork/asset/priviledges/transfer_auth/priv.proto", fileDescriptor_f16378177ffba5d1) +} + +var fileDescriptor_f16378177ffba5d1 = []byte{ + // 240 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x28, 0x4a, 0x4d, 0xcc, + 0xc9, 0xcc, 0xcf, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0xd1, + 0x2f, 0x28, 0xca, 0x2c, 0xcb, 0xcc, 0x49, 0x4d, 0x49, 0x4f, 0x2d, 0xd6, 0x2f, 0x29, 0x4a, 0xcc, + 0x2b, 0x4e, 0x4b, 0x2d, 0x8a, 0x4f, 0x2c, 0x2d, 0xc9, 0x00, 0xcb, 0xe8, 0x15, 0x14, 0xe5, 0x97, + 0xe4, 0x0b, 0x89, 0xa1, 0xe8, 0xd4, 0x03, 0xeb, 0xd4, 0x2b, 0x33, 0x54, 0xea, 0x66, 0xe4, 0xe2, + 0x72, 0xcc, 0xc9, 0xc9, 0x2f, 0x77, 0x4c, 0x49, 0x29, 0x2a, 0x16, 0x72, 0xe6, 0x62, 0x4d, 0x04, + 0x31, 0x24, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x74, 0xf5, 0xb0, 0x6b, 0xd3, 0x43, 0x68, 0xd1, + 0x03, 0x93, 0xae, 0x79, 0x25, 0x45, 0x95, 0x41, 0x10, 0xbd, 0x52, 0x16, 0x5c, 0x5c, 0x08, 0x41, + 0x21, 0x01, 0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x10, 0x53, + 0x48, 0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x49, 0x81, 0x51, 0x83, 0x23, 0x08, + 0xc2, 0xb1, 0x62, 0xb2, 0x60, 0x74, 0x4a, 0x38, 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, 0xb7, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x88, 0x9b, + 0x4a, 0x52, 0x93, 0x33, 0xa0, 0x4c, 0x5d, 0x58, 0x80, 0x54, 0x10, 0x0a, 0x92, 0x24, 0x36, 0x70, + 0x70, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x62, 0xbe, 0x22, 0x6a, 0x4a, 0x01, 0x00, 0x00, +} + +func (m *AllowAddrs) 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 *AllowAddrs) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AllowAddrs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Addrs) > 0 { + for k := range m.Addrs { + v := m.Addrs[k] + baseI := i + i-- + if v { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintPriv(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintPriv(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintPriv(dAtA []byte, offset int, v uint64) int { + offset -= sovPriv(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AllowAddrs) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Addrs) > 0 { + for k, v := range m.Addrs { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovPriv(uint64(len(k))) + 1 + 1 + n += mapEntrySize + 1 + sovPriv(uint64(mapEntrySize)) + } + } + return n +} + +func sovPriv(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPriv(x uint64) (n int) { + return sovPriv(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AllowAddrs) 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 ErrIntOverflowPriv + } + 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: AllowAddrs: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllowAddrs: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addrs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPriv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPriv + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPriv + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Addrs == nil { + m.Addrs = make(map[string]bool) + } + var mapkey string + var mapvalue bool + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPriv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPriv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthPriv + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthPriv + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapvaluetemp int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPriv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapvaluetemp |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + mapvalue = bool(mapvaluetemp != 0) + } else { + iNdEx = entryPreIndex + skippy, err := skipPriv(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPriv + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Addrs[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPriv(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPriv + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPriv(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPriv + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPriv + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPriv + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPriv + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPriv + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPriv + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPriv = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPriv = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPriv = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/asset/priviledges/transfer_auth/query.pb.go b/x/asset/priviledges/transfer_auth/query.pb.go new file mode 100644 index 00000000..b36d2e5a --- /dev/null +++ b/x/asset/priviledges/transfer_auth/query.pb.go @@ -0,0 +1,832 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: realionetwork/asset/priviledges/transfer_auth/query.proto + +package transfer_auth + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryWhitelistedAddressesRequest struct { + TokenId string `protobuf:"bytes,1,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` +} + +func (m *QueryWhitelistedAddressesRequest) Reset() { *m = QueryWhitelistedAddressesRequest{} } +func (m *QueryWhitelistedAddressesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryWhitelistedAddressesRequest) ProtoMessage() {} +func (*QueryWhitelistedAddressesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a20f3df665e91f36, []int{0} +} +func (m *QueryWhitelistedAddressesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryWhitelistedAddressesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryWhitelistedAddressesRequest.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 *QueryWhitelistedAddressesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryWhitelistedAddressesRequest.Merge(m, src) +} +func (m *QueryWhitelistedAddressesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryWhitelistedAddressesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryWhitelistedAddressesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryWhitelistedAddressesRequest proto.InternalMessageInfo + +func (m *QueryWhitelistedAddressesRequest) GetTokenId() string { + if m != nil { + return m.TokenId + } + return "" +} + +type QueryWhitelistedAddressesResponse struct { + WhitelistedAddrs []string `protobuf:"bytes,1,rep,name=whitelisted_addrs,json=whitelistedAddrs,proto3" json:"whitelisted_addrs,omitempty"` +} + +func (m *QueryWhitelistedAddressesResponse) Reset() { *m = QueryWhitelistedAddressesResponse{} } +func (m *QueryWhitelistedAddressesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryWhitelistedAddressesResponse) ProtoMessage() {} +func (*QueryWhitelistedAddressesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a20f3df665e91f36, []int{1} +} +func (m *QueryWhitelistedAddressesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryWhitelistedAddressesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryWhitelistedAddressesResponse.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 *QueryWhitelistedAddressesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryWhitelistedAddressesResponse.Merge(m, src) +} +func (m *QueryWhitelistedAddressesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryWhitelistedAddressesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryWhitelistedAddressesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryWhitelistedAddressesResponse proto.InternalMessageInfo + +func (m *QueryWhitelistedAddressesResponse) GetWhitelistedAddrs() []string { + if m != nil { + return m.WhitelistedAddrs + } + return nil +} + +type QueryIsAddressWhitelistedRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryIsAddressWhitelistedRequest) Reset() { *m = QueryIsAddressWhitelistedRequest{} } +func (m *QueryIsAddressWhitelistedRequest) String() string { return proto.CompactTextString(m) } +func (*QueryIsAddressWhitelistedRequest) ProtoMessage() {} +func (*QueryIsAddressWhitelistedRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a20f3df665e91f36, []int{2} +} +func (m *QueryIsAddressWhitelistedRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIsAddressWhitelistedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIsAddressWhitelistedRequest.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 *QueryIsAddressWhitelistedRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIsAddressWhitelistedRequest.Merge(m, src) +} +func (m *QueryIsAddressWhitelistedRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryIsAddressWhitelistedRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIsAddressWhitelistedRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIsAddressWhitelistedRequest proto.InternalMessageInfo + +func (m *QueryIsAddressWhitelistedRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type QueryIsAddressWhitelistedRespones struct { + IsWhitelisted bool `protobuf:"varint,1,opt,name=is_whitelisted,json=isWhitelisted,proto3" json:"is_whitelisted,omitempty"` +} + +func (m *QueryIsAddressWhitelistedRespones) Reset() { *m = QueryIsAddressWhitelistedRespones{} } +func (m *QueryIsAddressWhitelistedRespones) String() string { return proto.CompactTextString(m) } +func (*QueryIsAddressWhitelistedRespones) ProtoMessage() {} +func (*QueryIsAddressWhitelistedRespones) Descriptor() ([]byte, []int) { + return fileDescriptor_a20f3df665e91f36, []int{3} +} +func (m *QueryIsAddressWhitelistedRespones) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIsAddressWhitelistedRespones) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIsAddressWhitelistedRespones.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 *QueryIsAddressWhitelistedRespones) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIsAddressWhitelistedRespones.Merge(m, src) +} +func (m *QueryIsAddressWhitelistedRespones) XXX_Size() int { + return m.Size() +} +func (m *QueryIsAddressWhitelistedRespones) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIsAddressWhitelistedRespones.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIsAddressWhitelistedRespones proto.InternalMessageInfo + +func (m *QueryIsAddressWhitelistedRespones) GetIsWhitelisted() bool { + if m != nil { + return m.IsWhitelisted + } + return false +} + +func init() { + proto.RegisterType((*QueryWhitelistedAddressesRequest)(nil), "realionetwork.asset.v1.QueryWhitelistedAddressesRequest") + proto.RegisterType((*QueryWhitelistedAddressesResponse)(nil), "realionetwork.asset.v1.QueryWhitelistedAddressesResponse") + proto.RegisterType((*QueryIsAddressWhitelistedRequest)(nil), "realionetwork.asset.v1.QueryIsAddressWhitelistedRequest") + proto.RegisterType((*QueryIsAddressWhitelistedRespones)(nil), "realionetwork.asset.v1.QueryIsAddressWhitelistedRespones") +} + +func init() { + proto.RegisterFile("realionetwork/asset/priviledges/transfer_auth/query.proto", fileDescriptor_a20f3df665e91f36) +} + +var fileDescriptor_a20f3df665e91f36 = []byte{ + // 329 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x4b, 0x3a, 0x41, + 0x14, 0xc7, 0x5d, 0x7e, 0xf0, 0x53, 0x07, 0x8a, 0x5a, 0x22, 0xb4, 0xc3, 0x62, 0x0b, 0x81, 0x10, + 0xee, 0x50, 0x9d, 0x3a, 0x74, 0xc8, 0x43, 0x60, 0xa7, 0xda, 0xa0, 0xa0, 0xcb, 0x36, 0x3a, 0x2f, + 0x77, 0x50, 0x77, 0x74, 0xde, 0x5b, 0xad, 0xff, 0xa2, 0x3f, 0xa6, 0x3f, 0xa2, 0xa3, 0x74, 0xea, + 0x18, 0xfa, 0x8f, 0x84, 0xbb, 0x23, 0x29, 0x44, 0xdd, 0xe6, 0xf1, 0xde, 0xe7, 0xcb, 0x67, 0xf8, + 0xb2, 0x53, 0x03, 0xa2, 0xaf, 0x74, 0x02, 0x34, 0xd1, 0xa6, 0xc7, 0x05, 0x22, 0x10, 0x1f, 0x1a, + 0x35, 0x56, 0x7d, 0x90, 0x5d, 0x40, 0x4e, 0x46, 0x24, 0xf8, 0x08, 0x26, 0x12, 0x29, 0xc5, 0x7c, + 0x94, 0x82, 0x79, 0x0e, 0x86, 0x46, 0x93, 0x76, 0x77, 0xd7, 0xd0, 0x20, 0x43, 0x83, 0xf1, 0xd1, + 0x5e, 0xb5, 0xa3, 0x71, 0xa0, 0x31, 0x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 0xf9, 0x0a, 0x00, 0x00, 0xff, + 0xff, 0xb2, 0x87, 0x2d, 0x1a, 0x0d, 0x02, 0x00, 0x00, +} + +func (m *QueryWhitelistedAddressesRequest) 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 *QueryWhitelistedAddressesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryWhitelistedAddressesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryWhitelistedAddressesResponse) 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 *QueryWhitelistedAddressesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryWhitelistedAddressesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WhitelistedAddrs) > 0 { + for iNdEx := len(m.WhitelistedAddrs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.WhitelistedAddrs[iNdEx]) + copy(dAtA[i:], m.WhitelistedAddrs[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.WhitelistedAddrs[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryIsAddressWhitelistedRequest) 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 *QueryIsAddressWhitelistedRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIsAddressWhitelistedRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryIsAddressWhitelistedRespones) 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 *QueryIsAddressWhitelistedRespones) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIsAddressWhitelistedRespones) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsWhitelisted { + i-- + if m.IsWhitelisted { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryWhitelistedAddressesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryWhitelistedAddressesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.WhitelistedAddrs) > 0 { + for _, s := range m.WhitelistedAddrs { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryIsAddressWhitelistedRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryIsAddressWhitelistedRespones) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IsWhitelisted { + n += 2 + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryWhitelistedAddressesRequest) 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 ErrIntOverflowQuery + } + 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: QueryWhitelistedAddressesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryWhitelistedAddressesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryWhitelistedAddressesResponse) 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 ErrIntOverflowQuery + } + 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: QueryWhitelistedAddressesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryWhitelistedAddressesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedAddrs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WhitelistedAddrs = append(m.WhitelistedAddrs, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryIsAddressWhitelistedRequest) 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 ErrIntOverflowQuery + } + 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: QueryIsAddressWhitelistedRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIsAddressWhitelistedRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryIsAddressWhitelistedRespones) 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 ErrIntOverflowQuery + } + 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: QueryIsAddressWhitelistedRespones: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIsAddressWhitelistedRespones: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsWhitelisted", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsWhitelisted = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/asset/priviledges/transfer_auth/query_server.go b/x/asset/priviledges/transfer_auth/query_server.go new file mode 100644 index 00000000..cee4c702 --- /dev/null +++ b/x/asset/priviledges/transfer_auth/query_server.go @@ -0,0 +1,41 @@ +package transfer_auth + +import ( + "context" + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/gogo/protobuf/proto" + "github.com/pkg/errors" + assettypes "github.com/realiotech/realio-network/x/asset/types" +) + +func (tp TransferAuthPriviledge) QueryWhitelistedAddresses(ctx sdk.Context, req *QueryWhitelistedAddressesRequest, tokenID string) (*QueryWhitelistedAddressesResponse, error) { + return &QueryWhitelistedAddressesResponse{ + WhitelistedAddrs: tp.GetWhitelistedAddrs(ctx, req.TokenId), + }, nil +} + +func (mp TransferAuthPriviledge) QueryIsAddressWhitelisted(ctx sdk.Context, req *QueryIsAddressWhitelistedRequest, tokenID string) (*QueryIsAddressWhitelistedRespones, error) { + isWhitelisted := mp.CheckAddressIsWhitelisted(ctx, tokenID, req.Address) + + return &QueryIsAddressWhitelistedRespones{ + IsWhitelisted: isWhitelisted, + }, nil +} + +func (mp TransferAuthPriviledge) QueryHandler() assettypes.QueryHandler { + return func(context context.Context, req proto.Message, tokenID string) (proto.Message, error) { + ctx := sdk.UnwrapSDKContext(context) + + switch req := req.(type) { + case *QueryWhitelistedAddressesRequest: + return mp.QueryWhitelistedAddresses(ctx, req, tokenID) + case *QueryIsAddressWhitelistedRequest: + return mp.QueryIsAddressWhitelisted(ctx, req, tokenID) + default: + errMsg := fmt.Sprintf("unrecognized query request type: %T for Transfer auth priviledge", req) + return nil, errors.Errorf(errMsg) + } + } +} diff --git a/x/asset/priviledges/transfer_auth/store.go b/x/asset/priviledges/transfer_auth/store.go new file mode 100644 index 00000000..949900ad --- /dev/null +++ b/x/asset/priviledges/transfer_auth/store.go @@ -0,0 +1,48 @@ +package transfer_auth + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + WhitelistPrefix = []byte{0x2} + TokenPrefix = []byte{0x1} +) + +func tokenPrefix(tokenID string) []byte { + return append(TokenPrefix, tokenID...) +} + +func (tp TransferAuthPriviledge) WhitelistStore(ctx sdk.Context, tokenID string) storetypes.KVStore { + tokenStore := prefix.NewStore(ctx.KVStore(tp.storeKey), tokenPrefix(tokenID)) + return prefix.NewStore(tokenStore, WhitelistPrefix) +} + +func (tp TransferAuthPriviledge) AddAddressToWhiteList(ctx sdk.Context, tokenID string, address string) { + store := tp.WhitelistStore(ctx, tokenID) + store.Set([]byte(address), []byte{0x01}) +} + +func (tp TransferAuthPriviledge) RemoveAddressFromWhiteList(ctx sdk.Context, tokenID string, address string) { + store := tp.WhitelistStore(ctx, tokenID) + store.Delete([]byte(address)) +} + +func (tp TransferAuthPriviledge) CheckAddressIsWhitelisted(ctx sdk.Context, tokenID string, address string) bool { + store := tp.WhitelistStore(ctx, tokenID) + return store.Has([]byte(address)) +} + +func (tp TransferAuthPriviledge) GetWhitelistedAddrs(ctx sdk.Context, tokenID string) (whitelistedAddrs []string) { + store := tp.WhitelistStore(ctx, tokenID) + + iterator := store.Iterator(nil, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + whitelistedAddrs = append(whitelistedAddrs, string(iterator.Value())) + } + return +} diff --git a/x/asset/priviledges/transfer_auth/types.go b/x/asset/priviledges/transfer_auth/types.go new file mode 100644 index 00000000..b2f984e0 --- /dev/null +++ b/x/asset/priviledges/transfer_auth/types.go @@ -0,0 +1,11 @@ +package transfer_auth + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +type BankKeeper interface { + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool) +} diff --git a/x/asset/spec/06_logic.md b/x/asset/spec/06_logic.md index 86dfb6a8..7564108c 100644 --- a/x/asset/spec/06_logic.md +++ b/x/asset/spec/06_logic.md @@ -32,12 +32,11 @@ type Privilege interface { RegisterInterfaces() MsgHandler() MsgHandler QueryHandler() QueryHandler - CLI() *cobra.Command } -type MsgHandler func(context Context, privMsg PrivilegeMsg) error +type MsgHandler func(context Context, privMsg PrivilegeMsg, tokenID string, privAcc sdk.AccAddress) error -type QueryHandler func(context Context, privQuery PrivilegeQuery) error +type QueryHandler func(context Context, privQuery PrivilegeQuery, tokenID string) error ``` This interface provides all the functionality necessary for a privilege, including a message handler, query handler and cli @@ -46,6 +45,12 @@ All the `PrivilegeMsg` of a privilege should return the name of that privilege w When adding a `Privilege`, we calls `PrivilegeManager.AddPrivilege()` in `app.go` which inturn maps all the `PrivilegeMsg` of that privilege to its `MsgHandler`. This mapping logic will later be used when running a `MsgExecutePrivilege` +## Privilege send restriction + +In case when a privilege wants to enforce a specific send restriction logic, it can define the restriction logic and register that logic by implementing `RestrictionChecker` interface. + +The restriction logic will be triggered for an token transfer only if the token has enabled the privilege with such restriction logic. For example, any transfer of the token RIO (with transfer auth privilege enabled) will trigger `transfer auth privilege`'s send restriction logic. + ## Flow of MsgExecutePrivilege This process is triggered by the `MsgExecutePrivilege`. @@ -58,6 +63,5 @@ Validation: Flow: -- Prepare store for the privilege of the token via `MakePrivilegeStore(privilege name, token denom)`. That store is the only store accessable by the privilege's `MsgHandler`. - `PrivilegeManager` routes the `PrivilegeMsg` to the its `MsgHandler`. - `MsgHandler` now handles the `PrivilegeMsg`. diff --git a/x/asset/types/messages.pb.go b/x/asset/types/messages.pb.go new file mode 100644 index 00000000..1c7da4c7 --- /dev/null +++ b/x/asset/types/messages.pb.go @@ -0,0 +1,447 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: realionetwork/asset/priviledges/transfer_auth/messages.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ActionType int32 + +const ( + ActionType_ACTION_TYPE_UNSPECIFIED ActionType = 0 + // ACTION_TYPE_ADD defines the type for adding addresses. + ActionType_ACTION_TYPE_ADD ActionType = 1 + // ACTION_TYPE_REMOVE defines the type for remove addresses. + ActionType_ACTION_TYPE_REMOVE ActionType = 2 +) + +var ActionType_name = map[int32]string{ + 0: "ACTION_TYPE_UNSPECIFIED", + 1: "ACTION_TYPE_ADD", + 2: "ACTION_TYPE_REMOVE", +} + +var ActionType_value = map[string]int32{ + "ACTION_TYPE_UNSPECIFIED": 0, + "ACTION_TYPE_ADD": 1, + "ACTION_TYPE_REMOVE": 2, +} + +func (x ActionType) String() string { + return proto.EnumName(ActionType_name, int32(x)) +} + +func (ActionType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_815f42c56d94596e, []int{0} +} + +type MsgUpdateAllowList struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` + ActionType ActionType `protobuf:"varint,3,opt,name=action_type,json=actionType,proto3,enum=realionetwork.asset.v1.ActionType" json:"action_type,omitempty"` +} + +func (m *MsgUpdateAllowList) Reset() { *m = MsgUpdateAllowList{} } +func (m *MsgUpdateAllowList) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAllowList) ProtoMessage() {} +func (*MsgUpdateAllowList) Descriptor() ([]byte, []int) { + return fileDescriptor_815f42c56d94596e, []int{0} +} +func (m *MsgUpdateAllowList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateAllowList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateAllowList.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 *MsgUpdateAllowList) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAllowList.Merge(m, src) +} +func (m *MsgUpdateAllowList) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateAllowList) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAllowList.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateAllowList proto.InternalMessageInfo + +func (m *MsgUpdateAllowList) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgUpdateAllowList) GetTokenId() string { + if m != nil { + return m.TokenId + } + return "" +} + +func (m *MsgUpdateAllowList) GetActionType() ActionType { + if m != nil { + return m.ActionType + } + return ActionType_ACTION_TYPE_UNSPECIFIED +} + +func init() { + proto.RegisterEnum("realionetwork.asset.v1.ActionType", ActionType_name, ActionType_value) + proto.RegisterType((*MsgUpdateAllowList)(nil), "realionetwork.asset.v1.MsgUpdateAllowList") +} + +func init() { + proto.RegisterFile("realionetwork/asset/priviledges/transfer_auth/messages.proto", fileDescriptor_815f42c56d94596e) +} + +var fileDescriptor_815f42c56d94596e = []byte{ + // 354 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcf, 0x6a, 0xea, 0x40, + 0x18, 0xc5, 0x33, 0x5e, 0xb8, 0xde, 0x3b, 0x17, 0x6e, 0x65, 0x5a, 0x6c, 0x6c, 0x21, 0x88, 0x2b, + 0x29, 0x98, 0x50, 0xbb, 0xed, 0x26, 0x6a, 0x0a, 0x01, 0xff, 0x11, 0xff, 0x40, 0xbb, 0x09, 0x63, + 0x32, 0x8d, 0x83, 0x31, 0x13, 0x66, 0x46, 0xad, 0x6f, 0xd1, 0xc7, 0xe8, 0x03, 0xf4, 0x21, 0xba, + 0x94, 0xae, 0xba, 0x2c, 0xfa, 0x22, 0xc5, 0x44, 0x5b, 0x0b, 0xdd, 0x7d, 0xdf, 0x9c, 0xf3, 0x83, + 0x33, 0xdf, 0x81, 0xd7, 0x9c, 0xe0, 0x90, 0xb2, 0x88, 0xc8, 0x05, 0xe3, 0x13, 0x03, 0x0b, 0x41, + 0xa4, 0x11, 0x73, 0x3a, 0xa7, 0x21, 0xf1, 0x03, 0x22, 0x0c, 0xc9, 0x71, 0x24, 0xee, 0x09, 0x77, + 0xf1, 0x4c, 0x8e, 0x8d, 0x29, 0x11, 0x02, 0x07, 0x44, 0xe8, 0x31, 0x67, 0x92, 0xa1, 0xfc, 0x37, + 0x5a, 0x4f, 0x68, 0x7d,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, 0x9e, 0x8d, 0x74, 0x8f, 0x4d, 0x8d, + 0x34, 0xab, 0x24, 0xde, 0x78, 0x37, 0x56, 0xf6, 0x25, 0x3d, 0xec, 0x6a, 0xda, 0x7e, 0x4d, 0x8c, + 0x7e, 0x27, 0x77, 0xbd, 0xfa, 0x08, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x19, 0x3a, 0x40, 0xca, 0x01, + 0x00, 0x00, +} + +func (m *MsgUpdateAllowList) 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 *MsgUpdateAllowList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateAllowList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ActionType != 0 { + i = encodeVarintMessages(dAtA, i, uint64(m.ActionType)) + i-- + dAtA[i] = 0x18 + } + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintMessages(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { + offset -= sovMessages(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateAllowList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + if m.ActionType != 0 { + n += 1 + sovMessages(uint64(m.ActionType)) + } + return n +} + +func sovMessages(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMessages(x uint64) (n int) { + return sovMessages(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateAllowList) 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 ErrIntOverflowMessages + } + 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: MsgUpdateAllowList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateAllowList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ActionType", wireType) + } + m.ActionType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ActionType |= ActionType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipMessages(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMessages + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMessages(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMessages + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMessages + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMessages + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMessages + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMessages = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMessages = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMessages = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/asset/types/privilege.go b/x/asset/types/privilege.go index 08387b38..4bcd784a 100644 --- a/x/asset/types/privilege.go +++ b/x/asset/types/privilege.go @@ -6,7 +6,6 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gogo/protobuf/proto" - "github.com/spf13/cobra" // "github.com/cosmos/cosmos-sdk/store/types" ) @@ -19,7 +18,6 @@ type PrivilegeI interface { RegisterInterfaces(registry cdctypes.InterfaceRegistry) MsgHandler() MsgHandler QueryHandler() QueryHandler - CLI() *cobra.Command } type MsgHandler func(context context.Context, msg proto.Message, tokenID string, privAcc sdk.AccAddress) (proto.Message, error) diff --git a/x/asset/types/restriction.pb.go b/x/asset/types/restriction.pb.go new file mode 100644 index 00000000..d0c7fe4d --- /dev/null +++ b/x/asset/types/restriction.pb.go @@ -0,0 +1,424 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: realionetwork/asset/v1/restriction.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type AllowAddrs struct { + Addrs map[string]bool `protobuf:"bytes,1,rep,name=addrs,proto3" json:"addrs,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` +} + +func (m *AllowAddrs) Reset() { *m = AllowAddrs{} } +func (m *AllowAddrs) String() string { return proto.CompactTextString(m) } +func (*AllowAddrs) ProtoMessage() {} +func (*AllowAddrs) Descriptor() ([]byte, []int) { + return fileDescriptor_9ab4ced91c503b9f, []int{0} +} +func (m *AllowAddrs) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AllowAddrs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AllowAddrs.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 *AllowAddrs) XXX_Merge(src proto.Message) { + xxx_messageInfo_AllowAddrs.Merge(m, src) +} +func (m *AllowAddrs) XXX_Size() int { + return m.Size() +} +func (m *AllowAddrs) XXX_DiscardUnknown() { + xxx_messageInfo_AllowAddrs.DiscardUnknown(m) +} + +var xxx_messageInfo_AllowAddrs proto.InternalMessageInfo + +func (m *AllowAddrs) GetAddrs() map[string]bool { + if m != nil { + return m.Addrs + } + return nil +} + +func init() { + proto.RegisterType((*AllowAddrs)(nil), "realionetwork.asset.v1.AllowAddrs") + proto.RegisterMapType((map[string]bool)(nil), "realionetwork.asset.v1.AllowAddrs.AddrsEntry") +} + +func init() { + proto.RegisterFile("realionetwork/asset/v1/restriction.proto", fileDescriptor_9ab4ced91c503b9f) +} + +var fileDescriptor_9ab4ced91c503b9f = []byte{ + // 232 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00,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, 0xc9, 0xf9, 0xb9, + 0xfa, 0x10, 0x37, 0x95, 0xa4, 0x26, 0x67, 0x40, 0x99, 0xba, 0xb0, 0x00, 0xa8, 0x80, 0x06, 0x41, + 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xeb, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xb5, 0x4b, 0x99, 0xa0, 0x26, 0x01, 0x00, 0x00, +} + +func (m *AllowAddrs) 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 *AllowAddrs) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AllowAddrs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Addrs) > 0 { + for k := range m.Addrs { + v := m.Addrs[k] + baseI := i + i-- + if v { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintRestriction(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintRestriction(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintRestriction(dAtA []byte, offset int, v uint64) int { + offset -= sovRestriction(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AllowAddrs) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Addrs) > 0 { + for k, v := range m.Addrs { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovRestriction(uint64(len(k))) + 1 + 1 + n += mapEntrySize + 1 + sovRestriction(uint64(mapEntrySize)) + } + } + return n +} + +func sovRestriction(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozRestriction(x uint64) (n int) { + return sovRestriction(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AllowAddrs) 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 ErrIntOverflowRestriction + } + 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: AllowAddrs: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllowAddrs: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addrs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRestriction + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRestriction + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRestriction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Addrs == nil { + m.Addrs = make(map[string]bool) + } + var mapkey string + var mapvalue bool + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRestriction + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRestriction + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthRestriction + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthRestriction + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapvaluetemp int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRestriction + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapvaluetemp |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + mapvalue = bool(mapvaluetemp != 0) + } else { + iNdEx = entryPreIndex + skippy, err := skipRestriction(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRestriction + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Addrs[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRestriction(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRestriction + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipRestriction(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRestriction + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRestriction + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRestriction + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthRestriction + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupRestriction + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthRestriction + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthRestriction = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowRestriction = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupRestriction = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/asset/types/token.go b/x/asset/types/token.go index d22161d1..411162b9 100644 --- a/x/asset/types/token.go +++ b/x/asset/types/token.go @@ -10,10 +10,11 @@ func NewToken(tokenId string, name string, symbol string, decimal uint32, descri } } -func NewTokenManagement(manager string, addNewPrivilege bool, excludedPrivileges []string) TokenManagement { +func NewTokenManagement(manager string, addNewPrivilege bool, excludedPrivileges []string, enabledPrivileges []string) TokenManagement { return TokenManagement{ Manager: manager, AddNewPrivilege: addNewPrivilege, ExcludedPrivileges: excludedPrivileges, + EnabledPrivileges: enabledPrivileges, } } diff --git a/x/asset/types/token.pb.go b/x/asset/types/token.pb.go index 81d35e4f..bf6d2012 100644 --- a/x/asset/types/token.pb.go +++ b/x/asset/types/token.pb.go @@ -105,6 +105,7 @@ type TokenManagement struct { Manager string `protobuf:"bytes,1,opt,name=manager,proto3" json:"manager,omitempty"` AddNewPrivilege bool `protobuf:"varint,2,opt,name=add_new_privilege,json=addNewPrivilege,proto3" json:"add_new_privilege,omitempty"` ExcludedPrivileges []string `protobuf:"bytes,3,rep,name=excluded_privileges,json=excludedPrivileges,proto3" json:"excluded_privileges,omitempty"` + EnabledPrivileges []string `protobuf:"bytes,4,rep,name=enabled_privileges,json=enabledPrivileges,proto3" json:"enabled_privileges,omitempty"` } func (m *TokenManagement) Reset() { *m = TokenManagement{} } @@ -161,6 +162,13 @@ func (m *TokenManagement) GetExcludedPrivileges() []string { return nil } +func (m *TokenManagement) GetEnabledPrivileges() []string { + if m != nil { + return m.EnabledPrivileges + } + return nil +} + type Balance struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` @@ -269,34 +277,35 @@ func init() { } var fileDescriptor_2f83138fc60a3176 = []byte{ - // 418 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xb1, 0x6e, 0xd4, 0x30, - 0x1c, 0xc6, 0xcf, 0xdc, 0xb5, 0x69, 0x8d, 0xaa, 0x0a, 0x53, 0x55, 0x6e, 0x87, 0x10, 0x65, 0x3a, - 0x21, 0x35, 0x51, 0xcb, 0xc6, 0xc6, 0x6d, 0x48, 0x05, 0xa1, 0x00, 0x0b, 0x4b, 0xe4, 0x8b, 0xff, - 0x4a, 0xad, 0xc6, 0x76, 0x64, 0xfb, 0xee, 0xda, 0xb7, 0xe8, 0x23, 0x20, 0x9e, 0x81, 0x87, 0x60, - 0xac, 0x98, 0x18, 0xd1, 0xdd, 0xc2, 0x63, 0xa0, 0xd8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 0xd5, - 0xc5, 0x10, 0x24, 0x2f, 0xf1, 0x33, 0xc6, 0x79, 0xa9, 0x60, 0x55, 0xb6, 0x46, 0x2c, 0x45, 0x03, - 0x75, 0xb8, 0xc2, 0x5e, 0x71, 0xc8, 0x38, 0x7f, 0x0f, 0xab, 0x0f, 0x83, 0x4d, 0x72, 0xfc, 0x1c, - 0x6e, 0xaa, 0x66, 0xc1, 0x81, 0xff, 0x0b, 0x5b, 0x3a, 0x4e, 0xc6, 0xd3, 0xfd, 0x82, 0x0c, 0xab, - 0x87, 0xbc, 0x4d, 0x3f, 0xe3, 0x68, 0xc6, 0x1a, 0xa6, 0x2a, 0xe8, 0xd8, 0x58, 0x20, 0x78, 0x9c, - 0xad, 0x0f, 0x76, 0xaf, 0xc7, 0xa4, 0x5e, 0x28, 0xe7, 0x81, 0x26, 0x45, 0xaf, 0xd2, 0x1c, 0x1f, - 0x3c, 0x1c, 0x72, 0x29, 0xac, 0x23, 0x31, 0xc6, 0x5b, 0x3c, 0xc8, 0xf3, 0x6c, 0x39, 0xb3, 0xcb, - 0x1f, 0xeb, 0x18, 0xdd, 0xaf, 0x63, 0xf4, 0x7b, 0x1d, 0xa3, 0xbb, 0x4d, 0x3c, 0xba, 0xdf, 0xc4, - 0xa3, 0x5f, 0x9b, 0x78, 0xf4, 0xe5, 0xa2, 0x16, 0xee, 0x6a, 0x31, 0xcf, 0x2a, 0x2d, 0xf3, 0xd0, - 0x16, 0x07, 0xd5, 0x55, 0x3f, 0x9e, 0x0d, 0xed, 0xba, 0xe9, 0xfb, 0xe5, 0x6e, 0x5b, 0xb0, 0xf3, - 0x5d, 0x5f, 0x8a, 0x57, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xff, 0x10, 0x32, 0xba, 0x83, 0x02, - 0x00, 0x00, + // 433 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x6e,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73, 0xbf, 0x4e, 0x3b, 0xbf, + 0xd7, 0x69, 0xe7, 0xeb, 0x45, 0x25, 0xfd, 0xd5, 0x7c, 0x3a, 0x2a, 0x8d, 0xca, 0xe3, 0x71, 0x79, + 0x2c, 0xaf, 0x9a, 0x72, 0xd8, 0x1e, 0xe3, 0x4d, 0x73, 0x8e, 0xfe, 0x76, 0x86, 0x6e, 0xba, 0x1b, + 0x6e, 0xe8, 0xf5, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xab, 0x34, 0xbc, 0x64, 0xb2, 0x02, 0x00, + 0x00, } func (m *Token) Marshal() (dAtA []byte, err error) { @@ -375,6 +384,15 @@ func (m *TokenManagement) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.EnabledPrivileges) > 0 { + for iNdEx := len(m.EnabledPrivileges) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.EnabledPrivileges[iNdEx]) + copy(dAtA[i:], m.EnabledPrivileges[iNdEx]) + i = encodeVarintToken(dAtA, i, uint64(len(m.EnabledPrivileges[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } if len(m.ExcludedPrivileges) > 0 { for iNdEx := len(m.ExcludedPrivileges) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.ExcludedPrivileges[iNdEx]) @@ -529,6 +547,12 @@ func (m *TokenManagement) Size() (n int) { n += 1 + l + sovToken(uint64(l)) } } + if len(m.EnabledPrivileges) > 0 { + for _, s := range m.EnabledPrivileges { + l = len(s) + n += 1 + l + sovToken(uint64(l)) + } + } return n } @@ -879,6 +903,38 @@ func (m *TokenManagement) Unmarshal(dAtA []byte) error { } m.ExcludedPrivileges = append(m.ExcludedPrivileges, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EnabledPrivileges", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowToken + } + 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 ErrInvalidLengthToken + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthToken + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EnabledPrivileges = append(m.EnabledPrivileges, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipToken(dAtA[iNdEx:]) diff --git a/x/asset/types/tx.pb.go b/x/asset/types/tx.pb.go index 2636eda2..c3009d0a 100644 --- a/x/asset/types/tx.pb.go +++ b/x/asset/types/tx.pb.go @@ -39,6 +39,7 @@ type MsgCreateToken struct { Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` ExcludedPrivileges []string `protobuf:"bytes,7,rep,name=excluded_privileges,json=excludedPrivileges,proto3" json:"excluded_privileges,omitempty"` AddNewPrivilege bool `protobuf:"varint,8,opt,name=add_new_privilege,json=addNewPrivilege,proto3" json:"add_new_privilege,omitempty"` + EnabledPrivileges []string `protobuf:"bytes,9,rep,name=enabled_privileges,json=enabledPrivileges,proto3" json:"enabled_privileges,omitempty"` } func (m *MsgCreateToken) Reset() { *m = MsgCreateToken{} } @@ -130,6 +131,13 @@ func (m *MsgCreateToken) GetAddNewPrivilege() bool { return false } +func (m *MsgCreateToken) GetEnabledPrivileges() []string { + if m != nil { + return m.EnabledPrivileges + } + return nil +} + type MsgCreateTokenResponse struct { } @@ -802,58 +810,59 @@ func init() { func init() { proto.RegisterFile("realionetwork/asset/v1/tx.proto", fileDescriptor_1cfda60866e68e13) } var fileDescriptor_1cfda60866e68e13 = []byte{ - // 810 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcd, 0x6e, 0xda, 0x58, - 0x14, 0xc6,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, 0xa6, 0xc8, 0x7d, 0xbf, 0x29, 0x72, 0xaf, - 0x6f, 0x8b, 0xa9, 0xeb, 0xdb, 0x62, 0xea, 0xcb, 0x6d, 0x31, 0xf5, 0xa2, 0xa6, 0x1b, 0xee, 0x59, - 0xb7, 0x2d, 0xa9, 0xc4, 0x92, 0x83, 0xc2, 0x2e, 0x56, 0xcf, 0xc2, 0xc7, 0x6a, 0xf4, 0x97, 0xd7, - 0x0f, 0xff, 0xf3, 0xdc, 0x41, 0x07, 0xd3, 0x76, 0xc6, 0x1f, 0xe5, 0xa3, 0x1f, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x70, 0x5d, 0x8a, 0x67, 0x90, 0x0a, 0x00, 0x00, + // 829 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4b, 0x6f, 0xe2, 0x56, + 0x14, 0xc6, 0x21, 0xe1, 0x71, 0x68, 0x1e, 0xdc, 0xa0, 0xc8, 0x71, 0x53, 0x42, 0x91, 0x5a, 0xa1, + 0xb4, 0xd8, 0x0d, 0xe9, 0xa6, 0x4b, 0xe8, 0x43, 0x8a, 0x54, 0xaa, 0xca, 0x4d, 0x37, 0xdd, 0xd0, + 0x8b, 0x7d, 0xe3, 0x58, 0xb1, 0x7d, 0xa9, 0xaf, 0x09, 0xf0, 0x2f, 0x2a, 0x75, 0xd3, 0x1f, 0xd0, + 0x9f, 0x90, 0x65, 0xd7, 0xa3, 0x68, 0x56, 0xd1, 0xac, 0x66, 0x36, 0xa3, 0x51, 0xb2, 0x9d, 0x1f, + 0x31, 0xf2, 0x13, 0x9b, 0x87, 0x21, 0xd2, 0x64, 0xe7, 0xeb, 0xf3, 0xdd, 0xf3, 0x7d, 0xdf, 0x39, + 0x9c, 0x63, 0xe0, 0xd8, 0x26, 0xd8, 0xd0, 0xa9, 0x45, 0x9c, 0x11, 0xb5, 0xaf, 0x25, 0xcc, 0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be, 0x5c, 0x36, 0xc6, 0xc9, 0x15, 0x2b, 0x88, 0xeb, 0xe1, 0x42, 0x3a, 0x97, 0x26, 0xbe, + 0x86, 0xd3, 0x68, 0x62, 0xb8, 0x54, 0x9a, 0x05, 0xbb, 0x0f, 0x5d, 0xc3, 0x76, 0x72, 0xef, 0x35, + 0x52, 0x12, 0x24, 0x90, 0xc2, 0x37, 0xeb, 0x22, 0x23, 0xb2, 0xbf, 0x60, 0x77, 0x76, 0x43, 0x9d, + 0xa4, 0x25, 0x49, 0x62, 0x85, 0xd6, 0xfa, 0xd8, 0x88, 0x72, 0x04, 0xe5, 0xf9, 0xbd, 0xf1, 0x75, + 0x5a, 0x91, 0x66, 0xd1, 0xc2, 0xb7, 0x4f, 0x41, 0x47, 0xc4, 0x0e, 0xec, 0xcd, 0xcd, 0xf1, 0x57, + 0x29, 0x99, 0x66, 0xc1, 0xc2, 0xd9, 0x13, 0xc0, 0x71, 0xd6, 0xb9, 0x41, 0x4c, 0x63, 0x9d, 0x05, + 0xa7, 0xb2, 0x2e, 0x1b, 0x8d, 0xce, 0xcf, 0x77, 0x0f, 0x55, 0xee, 0xfe, 0xa1, 0xca, 0xbd, 0x7b, + 0xa8, 0x72, 0x7f, 0x3f, 0x56, 0x33, 0xf7, 0x8f, 0xd5, 0xcc, 0xeb, 0xc7, 0x6a, 0xe6, 0x8f, 0x96, + 0xa6, 0x3b, 0x57, 0xc3, 0xbe, 0xa8, 0x50, 0x53, 0xf2, 0x13, 0x3b, 0x44, 0xb9, 0x0a, 0x1e, 0x9b, + 0xe1, 0x9f, 0xc2, 0x71, 0xf0, 0xb7, 0xd0, 0x99, 0x0c, 0x08, 0xeb, 0xe7, 0xbc, 0x51, 0x3e, 0xfb, + 0x10, 0x00, 0x00, 0xff, 0xff, 0x57, 0xec, 0x1e, 0x0b, 0xbf, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1172,6 +1181,15 @@ func (m *MsgCreateToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.EnabledPrivileges) > 0 { + for iNdEx := len(m.EnabledPrivileges) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.EnabledPrivileges[iNdEx]) + copy(dAtA[i:], m.EnabledPrivileges[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.EnabledPrivileges[iNdEx]))) + i-- + dAtA[i] = 0x4a + } + } if m.AddNewPrivilege { i-- if m.AddNewPrivilege { @@ -1762,6 +1780,12 @@ func (m *MsgCreateToken) Size() (n int) { if m.AddNewPrivilege { n += 2 } + if len(m.EnabledPrivileges) > 0 { + for _, s := range m.EnabledPrivileges { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } return n } @@ -2245,6 +2269,38 @@ func (m *MsgCreateToken) Unmarshal(dAtA []byte) error { } } m.AddNewPrivilege = bool(v != 0) + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EnabledPrivileges", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EnabledPrivileges = append(m.EnabledPrivileges, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:])