diff --git a/proto/realionetwork/asset/priviledges/transfer_auth/priv.proto b/proto/realionetwork/asset/priviledges/transfer_auth/priv.proto deleted file mode 100644 index 781ebc9f..00000000 --- a/proto/realionetwork/asset/priviledges/transfer_auth/priv.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto3"; -package realionetwork.asset.v1; - -option go_package = "github.com/realiotech/realio-network/x/asset/priviledges/transfer_auth"; - -message AllowAddrs { - map addrs = 1; -} \ No newline at end of file diff --git a/proto/realionetwork/asset/priviledges/transfer_auth/query.proto b/proto/realionetwork/asset/priviledges/transfer_auth/query.proto index ca20ff57..b36a5797 100644 --- a/proto/realionetwork/asset/priviledges/transfer_auth/query.proto +++ b/proto/realionetwork/asset/priviledges/transfer_auth/query.proto @@ -4,22 +4,19 @@ package realionetwork.asset.v1; option go_package = "github.com/realiotech/realio-network/x/asset/priviledges/transfer_auth"; import "cosmos_proto/cosmos.proto"; -import "realionetwork/asset/priviledges/transfer_auth/priv.proto"; -message QueryAllowAddressRequest { +message QueryWhitelistedAddressesRequest { string token_id = 1; } -message QueryAllowAddressRespones { - AllowAddrs allow_addrs = 1; +message QueryWhitelistedAddressesResponse { + repeated string whitelisted_addrs = 1; } -message QueryIsAllowedRequest { +message QueryIsAddressWhitelistedRequest { string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - string token_id = 2; - } -message QueryIsAllowedRespones { - bool is_allow = 1; +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 6a91d3e0..56328785 100644 --- a/x/asset/keeper/keeper.go +++ b/x/asset/keeper/keeper.go @@ -25,7 +25,7 @@ type ( bankKeeper types.BankKeeper ak types.AccountKeeper PrivilegeManager map[string]types.PrivilegeI - RestrictionChecker []RestrictionChecker + RestrictionChecker map[string]RestrictionChecker } ) @@ -71,8 +71,8 @@ func (k *Keeper) AddPrivilege(priv types.PrivilegeI) error { checker, ok := priv.(RestrictionChecker) // currently we should only support one restriction checker at a time - if ok && len(k.RestrictionChecker) == 0 { - k.RestrictionChecker = append(k.RestrictionChecker, checker) + if ok { + k.RestrictionChecker[priv.Name()] = checker } return 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/restriction.go b/x/asset/keeper/restriction.go index 1a2993de..3cd5afbb 100644 --- a/x/asset/keeper/restriction.go +++ b/x/asset/keeper/restriction.go @@ -1,10 +1,11 @@ package keeper import ( - errorsmod "cosmossdk.io/errors" - "github.com/realiotech/realio-network/x/asset/types" + "slices" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/realiotech/realio-network/x/asset/types" ) type RestrictionChecker interface { @@ -20,34 +21,31 @@ func (k Keeper) AssetSendRestriction(ctx sdk.Context, fromAddr, toAddr sdk.AccAd return newToAddr, nil } - checker := k.RestrictionChecker[0] - for _, coin := range amt { // Check if the value already exists // fetch bank metadata to get symbol from denom - symbol := coin.Denom - tokenMetadata, found := k.bankKeeper.GetDenomMetaData(ctx, coin.Denom) - if found { - symbol = tokenMetadata.Symbol - } - _, isFound := k.GetToken( + tokenID := coin.Denom + tm, isFound := k.GetTokenManagement( ctx, - symbol, + tokenID, ) if !isFound { continue } - - isAllow, err := checker.IsAllow(ctx, symbol, 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 + 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/transfer_auth/msg_server.go b/x/asset/priviledges/transfer_auth/msg_server.go index f51a5025..9f31c827 100644 --- a/x/asset/priviledges/transfer_auth/msg_server.go +++ b/x/asset/priviledges/transfer_auth/msg_server.go @@ -13,16 +13,10 @@ import ( func (mp TransferAuthPriviledge) UpdateAllowList(ctx sdk.Context, msg *MsgUpdateAllowList, tokenID string) error { for _, addr := range msg.AllowedAddresses { - err := mp.AddAddr(ctx, addr, tokenID) - if err != nil { - return err - } + mp.AddAddressToWhiteList(ctx, tokenID, addr) } for _, addr := range msg.DisallowedAddresses { - err := mp.RemoveAddr(ctx, addr, tokenID) - if err != nil { - return err - } + mp.RemoveAddressFromWhiteList(ctx, tokenID, addr) } return nil } diff --git a/x/asset/priviledges/transfer_auth/priv.go b/x/asset/priviledges/transfer_auth/priv.go index 2c5a8e9a..8b6c2d28 100644 --- a/x/asset/priviledges/transfer_auth/priv.go +++ b/x/asset/priviledges/transfer_auth/priv.go @@ -1,14 +1,10 @@ package transfer_auth import ( - "fmt" - "github.com/realiotech/realio-network/x/asset/keeper" - "github.com/realiotech/realio-network/x/asset/types" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -35,124 +31,8 @@ func (tp TransferAuthPriviledge) Name() string { return priv_name } -func tokenPrefix(tokenID string) []byte { - return append([]byte{0x01}, tokenID...) -} - -func (tp TransferAuthPriviledge) SetupAllowListForToken(ctx sdk.Context, tokenId string, list map[string]bool) error { - store := prefix.NewStore(ctx.KVStore(tp.storeKey), tokenPrefix(tokenId)) - key := []byte(tokenId) - bz := store.Get(key) - - if bz != nil { - return fmt.Errorf("token ID %s already have an allow list", tokenId) - } - - allowAddrs := AllowAddrs{ - Addrs: list, - } - - bz, err := tp.cdc.Marshal(&allowAddrs) - if err != nil { - return err - } - store.Set(key, bz) - - return nil -} - -func (tp TransferAuthPriviledge) GetAddrList(ctx sdk.Context, tokenId string) (AllowAddrs, error) { - store := prefix.NewStore(ctx.KVStore(tp.storeKey), types.TokenKey) - key := []byte(tokenId) - bz := store.Get(key) - - if bz == nil { - return AllowAddrs{ - Addrs: map[string]bool{}, - }, nil - } - - var allowAddrs AllowAddrs - err := tp.cdc.Unmarshal(bz, &allowAddrs) - if err != nil { - return AllowAddrs{ - Addrs: map[string]bool{}, - }, err - } - - return allowAddrs, nil -} - -func (tp TransferAuthPriviledge) AddAddr(ctx sdk.Context, addr, tokenId string) error { - store := prefix.NewStore(ctx.KVStore(tp.storeKey), types.TokenKey) - key := []byte(tokenId) - bz := store.Get(key) - var allowAddrs *AllowAddrs - - if bz == nil { - allowAddrs = &AllowAddrs{ - Addrs: map[string]bool{}, - } - } - - err := tp.cdc.Unmarshal(bz, allowAddrs) - if err != nil { - return err - } - - allowAddrs.Addrs[addr] = true - - bz, err = tp.cdc.Marshal(allowAddrs) - if err != nil { - return err - } - store.Set(key, bz) - - return nil -} - -func (tp TransferAuthPriviledge) RemoveAddr(ctx sdk.Context, addr, tokenId string) error { - store := prefix.NewStore(ctx.KVStore(tp.storeKey), types.TokenKey) - key := []byte(tokenId) - bz := store.Get(key) - var allowAddrs *AllowAddrs - - if bz == nil { - allowAddrs = &AllowAddrs{ - Addrs: map[string]bool{}, - } - } - - err := tp.cdc.Unmarshal(bz, allowAddrs) - if err != nil { - return err - } - - allowAddrs.Addrs[addr] = false - - bz, err = tp.cdc.Marshal(allowAddrs) - if err != nil { - return err - } - store.Set(key, bz) - - return nil -} - func (tp TransferAuthPriviledge) RegisterInterfaces(registry cdctypes.InterfaceRegistry) {} func (tp TransferAuthPriviledge) IsAllow(ctx sdk.Context, tokenID string, sender string) (bool, error) { - allowAddrs, err := tp.GetAddrList(ctx, tokenID) - if err != nil { - return false, err - } - - var isAllow bool - isAllow, has := allowAddrs.Addrs[sender] - if !has { - isAllow = false - } - - return isAllow, nil - + return tp.CheckAddressIsWhitelisted(ctx, tokenID, sender), nil } diff --git a/x/asset/priviledges/transfer_auth/query.pb.go b/x/asset/priviledges/transfer_auth/query.pb.go index a4c4d65a..b36d2e5a 100644 --- a/x/asset/priviledges/transfer_auth/query.pb.go +++ b/x/asset/priviledges/transfer_auth/query.pb.go @@ -23,22 +23,22 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type QueryAllowAddressRequest struct { +type QueryWhitelistedAddressesRequest struct { TokenId string `protobuf:"bytes,1,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` } -func (m *QueryAllowAddressRequest) Reset() { *m = QueryAllowAddressRequest{} } -func (m *QueryAllowAddressRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllowAddressRequest) ProtoMessage() {} -func (*QueryAllowAddressRequest) Descriptor() ([]byte, []int) { +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 *QueryAllowAddressRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryWhitelistedAddressesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllowAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryWhitelistedAddressesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllowAddressRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryWhitelistedAddressesRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -48,41 +48,41 @@ func (m *QueryAllowAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *QueryAllowAddressRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllowAddressRequest.Merge(m, src) +func (m *QueryWhitelistedAddressesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryWhitelistedAddressesRequest.Merge(m, src) } -func (m *QueryAllowAddressRequest) XXX_Size() int { +func (m *QueryWhitelistedAddressesRequest) XXX_Size() int { return m.Size() } -func (m *QueryAllowAddressRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllowAddressRequest.DiscardUnknown(m) +func (m *QueryWhitelistedAddressesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryWhitelistedAddressesRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllowAddressRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryWhitelistedAddressesRequest proto.InternalMessageInfo -func (m *QueryAllowAddressRequest) GetTokenId() string { +func (m *QueryWhitelistedAddressesRequest) GetTokenId() string { if m != nil { return m.TokenId } return "" } -type QueryAllowAddressRespones struct { - AllowAddrs *AllowAddrs `protobuf:"bytes,1,opt,name=allow_addrs,json=allowAddrs,proto3" json:"allow_addrs,omitempty"` +type QueryWhitelistedAddressesResponse struct { + WhitelistedAddrs []string `protobuf:"bytes,1,rep,name=whitelisted_addrs,json=whitelistedAddrs,proto3" json:"whitelisted_addrs,omitempty"` } -func (m *QueryAllowAddressRespones) Reset() { *m = QueryAllowAddressRespones{} } -func (m *QueryAllowAddressRespones) String() string { return proto.CompactTextString(m) } -func (*QueryAllowAddressRespones) ProtoMessage() {} -func (*QueryAllowAddressRespones) Descriptor() ([]byte, []int) { +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 *QueryAllowAddressRespones) XXX_Unmarshal(b []byte) error { +func (m *QueryWhitelistedAddressesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllowAddressRespones) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryWhitelistedAddressesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllowAddressRespones.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryWhitelistedAddressesResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -92,42 +92,41 @@ func (m *QueryAllowAddressRespones) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *QueryAllowAddressRespones) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllowAddressRespones.Merge(m, src) +func (m *QueryWhitelistedAddressesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryWhitelistedAddressesResponse.Merge(m, src) } -func (m *QueryAllowAddressRespones) XXX_Size() int { +func (m *QueryWhitelistedAddressesResponse) XXX_Size() int { return m.Size() } -func (m *QueryAllowAddressRespones) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllowAddressRespones.DiscardUnknown(m) +func (m *QueryWhitelistedAddressesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryWhitelistedAddressesResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllowAddressRespones proto.InternalMessageInfo +var xxx_messageInfo_QueryWhitelistedAddressesResponse proto.InternalMessageInfo -func (m *QueryAllowAddressRespones) GetAllowAddrs() *AllowAddrs { +func (m *QueryWhitelistedAddressesResponse) GetWhitelistedAddrs() []string { if m != nil { - return m.AllowAddrs + return m.WhitelistedAddrs } return nil } -type QueryIsAllowedRequest struct { +type QueryIsAddressWhitelistedRequest 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"` } -func (m *QueryIsAllowedRequest) Reset() { *m = QueryIsAllowedRequest{} } -func (m *QueryIsAllowedRequest) String() string { return proto.CompactTextString(m) } -func (*QueryIsAllowedRequest) ProtoMessage() {} -func (*QueryIsAllowedRequest) Descriptor() ([]byte, []int) { +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 *QueryIsAllowedRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryIsAddressWhitelistedRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryIsAllowedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryIsAddressWhitelistedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryIsAllowedRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryIsAddressWhitelistedRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -137,48 +136,41 @@ func (m *QueryIsAllowedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *QueryIsAllowedRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryIsAllowedRequest.Merge(m, src) +func (m *QueryIsAddressWhitelistedRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIsAddressWhitelistedRequest.Merge(m, src) } -func (m *QueryIsAllowedRequest) XXX_Size() int { +func (m *QueryIsAddressWhitelistedRequest) XXX_Size() int { return m.Size() } -func (m *QueryIsAllowedRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryIsAllowedRequest.DiscardUnknown(m) +func (m *QueryIsAddressWhitelistedRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIsAddressWhitelistedRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryIsAllowedRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryIsAddressWhitelistedRequest proto.InternalMessageInfo -func (m *QueryIsAllowedRequest) GetAddress() string { +func (m *QueryIsAddressWhitelistedRequest) GetAddress() string { if m != nil { return m.Address } return "" } -func (m *QueryIsAllowedRequest) GetTokenId() string { - if m != nil { - return m.TokenId - } - return "" +type QueryIsAddressWhitelistedRespones struct { + IsWhitelisted bool `protobuf:"varint,1,opt,name=is_whitelisted,json=isWhitelisted,proto3" json:"is_whitelisted,omitempty"` } -type QueryIsAllowedRespones struct { - IsAllow bool `protobuf:"varint,1,opt,name=is_allow,json=isAllow,proto3" json:"is_allow,omitempty"` -} - -func (m *QueryIsAllowedRespones) Reset() { *m = QueryIsAllowedRespones{} } -func (m *QueryIsAllowedRespones) String() string { return proto.CompactTextString(m) } -func (*QueryIsAllowedRespones) ProtoMessage() {} -func (*QueryIsAllowedRespones) Descriptor() ([]byte, []int) { +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 *QueryIsAllowedRespones) XXX_Unmarshal(b []byte) error { +func (m *QueryIsAddressWhitelistedRespones) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryIsAllowedRespones) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryIsAddressWhitelistedRespones) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryIsAllowedRespones.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryIsAddressWhitelistedRespones.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -188,30 +180,30 @@ func (m *QueryIsAllowedRespones) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *QueryIsAllowedRespones) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryIsAllowedRespones.Merge(m, src) +func (m *QueryIsAddressWhitelistedRespones) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIsAddressWhitelistedRespones.Merge(m, src) } -func (m *QueryIsAllowedRespones) XXX_Size() int { +func (m *QueryIsAddressWhitelistedRespones) XXX_Size() int { return m.Size() } -func (m *QueryIsAllowedRespones) XXX_DiscardUnknown() { - xxx_messageInfo_QueryIsAllowedRespones.DiscardUnknown(m) +func (m *QueryIsAddressWhitelistedRespones) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIsAddressWhitelistedRespones.DiscardUnknown(m) } -var xxx_messageInfo_QueryIsAllowedRespones proto.InternalMessageInfo +var xxx_messageInfo_QueryIsAddressWhitelistedRespones proto.InternalMessageInfo -func (m *QueryIsAllowedRespones) GetIsAllow() bool { +func (m *QueryIsAddressWhitelistedRespones) GetIsWhitelisted() bool { if m != nil { - return m.IsAllow + return m.IsWhitelisted } return false } func init() { - proto.RegisterType((*QueryAllowAddressRequest)(nil), "realionetwork.asset.v1.QueryAllowAddressRequest") - proto.RegisterType((*QueryAllowAddressRespones)(nil), "realionetwork.asset.v1.QueryAllowAddressRespones") - proto.RegisterType((*QueryIsAllowedRequest)(nil), "realionetwork.asset.v1.QueryIsAllowedRequest") - proto.RegisterType((*QueryIsAllowedRespones)(nil), "realionetwork.asset.v1.QueryIsAllowedRespones") + 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() { @@ -219,31 +211,31 @@ func init() { } var fileDescriptor_a20f3df665e91f36 = []byte{ - // 332 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x51, 0xc1, 0x4e, 0x02, 0x31, - 0x14, 0x64, 0x3d, 0x08, 0x96, 0x1b, 0x51, 0xc2, 0x72, 0xd8, 0x98, 0x3d, 0x79, 0xa1, 0x8d, 0x10, - 0x13, 0x3d, 0x82, 0x89, 0x09, 0x47, 0xd7, 0x9b, 0x97, 0xa5, 0xd0, 0x07, 0x34, 0x2c, 0x5b, 0xe8, - 0xeb, 0x82, 0xfe, 0x85, 0x1f, 0xe3, 0x47, 0x78, 0x24, 0x9e, 0x3c, 0x1a, 0xf8, 0x11, 0x43, 0xbb, - 0x90, 0x60, 0x48, 0x8c, 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x8b, 0x54, 0x7f, 0xeb, 0xe4, 0x31, - 0x7c, 0x52, 0x92, 0x18, 0x5b, 0x4b, 0x56, 0xa9, 0x14, 0x15, 0xa5, 0x03, 0x75, 0x7a, 0x1f, 0xeb, - 0xc0, 0x5b, 0xad, 0x03, 0xef, 0x7b, 0x1d, 0x78, 0x6f, 0x9b, 0xa0, 0xb0, 0xda, 0x04, 0x85, 0xaf, - 0x4d, 0x50, 0x78, 0x7e, 0x18, 0x49, 0x33, 0xce, 0xfa, 0x74, 0xa0, 0xa6, 0xcc, 0x05, 0x36, 0x30, - 0x18, 0xe7, 0x63, 0x63, 0x57, 0xd0, 0xcb, 0x5f, 0x15, 0xf5, 0x4f, 0x6d, 0x3d, 0xad, 0x9f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x82, 0xea, 0x67, 0x0d, 0x48, 0x02, 0x00, 0x00, -} - -func (m *QueryAllowAddressRequest) Marshal() (dAtA []byte, err error) { + // 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, 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0xcf, 0x99, 0xe7, 0xbc, 0xcc, 0xbd, 0xc2, 0x74, 0xee, 0x15, 0x3e, 0xe6, 0x5e, 0xe1, + 0xfe, 0xa2, 0xab, 0x28, 0x4e, 0xdb, 0x41, 0x47, 0x0f, 0x78, 0x5e, 0x06, 0x41, 0x27, 0xb6, 0xcf, + 0xc6, 0xb2, 0xd3, 0xa7, 0xbf, 0x5a, 0x6d, 0xff, 0xcf, 0xda, 0x39, 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]) @@ -253,12 +245,12 @@ func (m *QueryAllowAddressRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAllowAddressRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryWhitelistedAddressesRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllowAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryWhitelistedAddressesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -273,7 +265,7 @@ func (m *QueryAllowAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *QueryAllowAddressRespones) Marshal() (dAtA []byte, err error) { +func (m *QueryWhitelistedAddressesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -283,32 +275,29 @@ func (m *QueryAllowAddressRespones) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAllowAddressRespones) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryWhitelistedAddressesResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllowAddressRespones) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryWhitelistedAddressesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.AllowAddrs != nil { - { - size, err := m.AllowAddrs.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + 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 } - i-- - dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryIsAllowedRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryIsAddressWhitelistedRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -318,23 +307,16 @@ func (m *QueryIsAllowedRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryIsAllowedRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryIsAddressWhitelistedRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryIsAllowedRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryIsAddressWhitelistedRequest) 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] = 0x12 - } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) @@ -345,7 +327,7 @@ func (m *QueryIsAllowedRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryIsAllowedRespones) Marshal() (dAtA []byte, err error) { +func (m *QueryIsAddressWhitelistedRespones) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -355,19 +337,19 @@ func (m *QueryIsAllowedRespones) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryIsAllowedRespones) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryIsAddressWhitelistedRespones) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryIsAllowedRespones) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryIsAddressWhitelistedRespones) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.IsAllow { + if m.IsWhitelisted { i-- - if m.IsAllow { + if m.IsWhitelisted { dAtA[i] = 1 } else { dAtA[i] = 0 @@ -389,7 +371,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryAllowAddressRequest) Size() (n int) { +func (m *QueryWhitelistedAddressesRequest) Size() (n int) { if m == nil { return 0 } @@ -402,20 +384,22 @@ func (m *QueryAllowAddressRequest) Size() (n int) { return n } -func (m *QueryAllowAddressRespones) Size() (n int) { +func (m *QueryWhitelistedAddressesResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.AllowAddrs != nil { - l = m.AllowAddrs.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.WhitelistedAddrs) > 0 { + for _, s := range m.WhitelistedAddrs { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } } return n } -func (m *QueryIsAllowedRequest) Size() (n int) { +func (m *QueryIsAddressWhitelistedRequest) Size() (n int) { if m == nil { return 0 } @@ -425,20 +409,16 @@ func (m *QueryIsAllowedRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.TokenId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } return n } -func (m *QueryIsAllowedRespones) Size() (n int) { +func (m *QueryIsAddressWhitelistedRespones) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.IsAllow { + if m.IsWhitelisted { n += 2 } return n @@ -450,7 +430,7 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryAllowAddressRequest) Unmarshal(dAtA []byte) error { +func (m *QueryWhitelistedAddressesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -473,10 +453,10 @@ func (m *QueryAllowAddressRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllowAddressRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryWhitelistedAddressesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllowAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryWhitelistedAddressesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -532,7 +512,7 @@ func (m *QueryAllowAddressRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllowAddressRespones) Unmarshal(dAtA []byte) error { +func (m *QueryWhitelistedAddressesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -555,17 +535,17 @@ func (m *QueryAllowAddressRespones) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllowAddressRespones: wiretype end group for non-group") + return fmt.Errorf("proto: QueryWhitelistedAddressesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllowAddressRespones: illegal tag %d (wire type %d)", fieldNum, wire) + 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 AllowAddrs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedAddrs", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -575,27 +555,23 @@ func (m *QueryAllowAddressRespones) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.AllowAddrs == nil { - m.AllowAddrs = &AllowAddrs{} - } - if err := m.AllowAddrs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.WhitelistedAddrs = append(m.WhitelistedAddrs, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -618,7 +594,7 @@ func (m *QueryAllowAddressRespones) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryIsAllowedRequest) Unmarshal(dAtA []byte) error { +func (m *QueryIsAddressWhitelistedRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -641,10 +617,10 @@ func (m *QueryIsAllowedRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryIsAllowedRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryIsAddressWhitelistedRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryIsAllowedRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryIsAddressWhitelistedRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -679,38 +655,6 @@ func (m *QueryIsAllowedRequest) Unmarshal(dAtA []byte) error { } 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 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:]) @@ -732,7 +676,7 @@ func (m *QueryIsAllowedRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryIsAllowedRespones) Unmarshal(dAtA []byte) error { +func (m *QueryIsAddressWhitelistedRespones) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -755,15 +699,15 @@ func (m *QueryIsAllowedRespones) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryIsAllowedRespones: wiretype end group for non-group") + return fmt.Errorf("proto: QueryIsAddressWhitelistedRespones: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryIsAllowedRespones: illegal tag %d (wire type %d)", fieldNum, wire) + 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 IsAllow", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IsWhitelisted", wireType) } var v int for shift := uint(0); ; shift += 7 { @@ -780,7 +724,7 @@ func (m *QueryIsAllowedRespones) Unmarshal(dAtA []byte) error { break } } - m.IsAllow = bool(v != 0) + m.IsWhitelisted = bool(v != 0) default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/asset/priviledges/transfer_auth/query_server.go b/x/asset/priviledges/transfer_auth/query_server.go index f44f93a5..2e41f39a 100644 --- a/x/asset/priviledges/transfer_auth/query_server.go +++ b/x/asset/priviledges/transfer_auth/query_server.go @@ -9,31 +9,17 @@ import ( "github.com/pkg/errors" ) -func (mp TransferAuthPriviledge) QueryAllowAddresses(ctx sdk.Context, req *QueryAllowAddressRequest, tokenID string) (*QueryAllowAddressRespones, error) { - allowAddr, err := mp.GetAddrList(ctx, req.TokenId) - if err != nil { - return nil, err - } - - return &QueryAllowAddressRespones{ - AllowAddrs: &allowAddr, +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) QueryIsAllow(ctx sdk.Context, req *QueryIsAllowedRequest, tokenID string) (*QueryIsAllowedRespones, error) { - allowAddr, err := mp.GetAddrList(ctx, req.TokenId) - if err != nil { - return nil, err - } - - var isAllow bool - isAllow, has := allowAddr.Addrs[req.Address] - if !has { - isAllow = false - } +func (mp TransferAuthPriviledge) QueryIsAddressWhitelisted(ctx sdk.Context, req *QueryIsAddressWhitelistedRequest, tokenID string) (*QueryIsAddressWhitelistedRespones, error) { + isWhitelisted := mp.CheckAddressIsWhitelisted(ctx, tokenID, req.Address) - return &QueryIsAllowedRespones{ - IsAllow: isAllow, + return &QueryIsAddressWhitelistedRespones{ + IsWhitelisted: isWhitelisted, }, nil } @@ -41,10 +27,10 @@ func (mp TransferAuthPriviledge) QueryHandler(context context.Context, req proto ctx := sdk.UnwrapSDKContext(context) switch req := req.(type) { - case *QueryAllowAddressRequest: - return mp.QueryAllowAddresses(ctx, req, tokenID) - case *QueryIsAllowedRequest: - return mp.QueryIsAllow(ctx, req, tokenID) + 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/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, 0x49, 0x39, 0xa6, 0x6e, 0xff, 0xef, 0xfb, - 0x7f, 0x89, 0x7f, 0xb6, 0x3e, 0x9c, 0x1a, 0x60, 0x8d, 0xd0, 0x0a, 0xdc, 0x4a, 0x9b, 0xeb, 0x9c, - 0x59, 0x0b, 0x2e, 0x5f, 0x9e, 0xe7, 0x4e, 0x5f, 0x83, 0xca, 0x5a, 0xa3, 0x9d, 0x26, 0xc7, 0xff, - 0x65, 0x32, 0x9f, 0xc9, 0x96, 0xe7, 0xa7, 0x47, 0xb5, 0xae, 0xb5, 0x8f, 0xe4, 0xdd, 0x14, 0xd2, - 0xa7, 0x27, 0x95, 0xb6, 0x52, 0xdb, 0x32, 0x2c, 0x82, 0x08, 0xab, 0xf4, 0x0e, 0xe1, 0x9d, 0x4f, - 0xdd, 0x8f, 0xc9, 0x09, 0xde, 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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, 0x13, 0x31, + 0x10, 0x86, 0x63, 0xb2, 0x6d, 0xda, 0x41, 0x55, 0x55, 0x53, 0x55, 0x6e, 0x0f, 0x4b, 0xb4, 0xa7, + 0x08, 0x29, 0x59, 0xb5, 0xdc, 0xb8, 0x91, 0x1b, 0x52, 0x41, 0x68, 0x81, 0x0b, 0x97, 0xc8, 0x59, + 0x8f, 0xb6, 0x56, 0xd7, 0x76, 0x64, 0x3b, 0x49, 0xfb, 0x16, 0x7d, 0x04, 0x1e, 0x82, 0x87, 0xe0, + 0x58, 0x38, 0x71, 0x44, 0xc9, 0x85, 0xc7, 0x40, 0xb1, 0x77, 0xdb, 0xf4, 0xc4, 0x6d, 0xfe, 0x7f, + 0xbe, 0xdd, 0xf9, 0xc7, 0x1a, 0xc8, 0x2c, 0xf2, 0x5a, 0x1a, 0x8d, 0x7e,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ec, 0x15, 0x87, 0x5c, 0x88, 0x0f, 0xb8, 0xfc, 0xd8, 0xda, 0x34, 0x87, 0x17, 0x78, + 0x53, 0xd6, 0x73, 0x81, 0xe2, 0x11, 0x76, 0xac, 0xdb, 0xef, 0x0e, 0xf6, 0x0b, 0xda, 0xb6, 0x1e, + 0x78, 0x47, 0x87, 0x40, 0x51, 0xf3, 0x69, 0xfd, 0x94, 0x4f, 0x02, 0x7f, 0xd4, 0x74, 0x1e, 0xf1, + 0xec, 0x0b, 0xf4, 0xc6, 0xbc, 0xe6, 0xba, 0xc4, 0xcd, 0x2a, 0x3c, 0x06, 0xfe, 0xff, 0x2a, 0x0d, + 0xb8, 0x79, 0x6c, 0xae, 0xcc, 0x5c, 0xfb, 0x90, 0x3f, 0x29, 0x1a, 0x95, 0xe5, 0x70, 0xf0, 0x30, + 0xe4, 0x52, 0x3a, 0x4f, 0x53, 0x80, 0xad, 0x38, 0x24, 0xc4, 0xd9, 0x72, 0xc6, 0x97, 0x3f, 0x56, + 0x29, 0xb9, 0x5f, 0xa5, 0xe4, 0xcf, 0x2a, 0x25, 0x77, 0xeb, 0xb4, 0x73, 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, 0x21, 0x01, 0x72, 0x98, 0xfc, 0x39, 0x28, 0x72, 0x3c, 0x19, 0xc2, 0x20, 0xcd, 0x08, - 0x65, 0x06, 0x7b, 0x42, 0x66, 0x33, 0x4b, 0x98, 0xb6, 0x52, 0xa4, 0x52, 0x55, 0x6e, 0xba, 0xe9, - 0x86, 0x5e, 0xec, 0x1b, 0xc7, 0x8a, 0xed, 0x4b, 0x7d, 0x4d, 0x80, 0xb7, 0xa8, 0xd4, 0x4d, 0x1f, - 0xa0, 0x8f, 0x90, 0x65, 0xbb, 0xad, 0xa2, 0xae, 0xa2, 0xae, 0xda, 0x4d, 0x55, 0x25, 0x2f, 0x52, - 0xf9, 0xef, 0x62, 0xfe, 0x0c, 0x91, 0x9a, 0x9d, 0xaf, 0xcf, 0x77, 0xce, 0xf7, 0x7d, 0xe7, 0xea, - 0x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0x1a, 0xe3, 0xd1, 0x15, 0x2b, 0x4a, 0x8b, 0xe1, 0x22, 0x3a, 0x8f, 0x26, 0xbe, 0x86, 0x93, 0x68, - 0x62, 0xb8, 0x44, 0x9a, 0x29, 0xbb, 0x8f, 0x3f, 0x87, 0xb5, 0xd1, 0xbd, 0x57, 0x49, 0x28, 0x30, - 0x82, 0x14, 0xff, 0x59, 0x14, 0xc9, 0xc8, 0x5e, 0xc1, 0xc6, 0xf8, 0x86, 0x3a, 0x48, 0x2a, 0x32, - 0x8a, 0x15, 0x6b, 0x8b, 0x63, 0x19, 0x65, 0x0f, 0xb6, 0x26, 0xf7, 0xc6, 0xdf, 0x49, 0x4d, 0x1a, - 0x47, 0x8b, 0xff, 0xde, 0x05, 0xcd, 0x88, 0x5d, 0xd8, 0x9c, 0x98, 0xe3, 0xbf, 0x12, 0x2a, 0x8d, - 0x83, 0xc5, 0xa3, 0x3b, 0x80, 0xe3, 0xac, 0x13, 0x83, 0x98, 0xc4, 0x3a, 0x0e, 0x4e, 0x64, 0x9d, - 0x35, 0x1a, 0x8d, 0xc7, 0x57, 0x37, 0x45, 0xee, 0xfa, 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, 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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:])