feat: synchronize community token between TokenMasters and Owners (#3893)
This commit is contained in:
parent
cd4ed51a25
commit
e7f5f32298
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/images"
|
||||
"github.com/status-im/status-go/protocol/common"
|
||||
community_token "github.com/status-im/status-go/protocol/communities/token"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
"github.com/status-im/status-go/protocol/requests"
|
||||
"github.com/status-im/status-go/protocol/v1"
|
||||
|
@ -2225,3 +2226,8 @@ func (o *Community) ValidateEvent(event *CommunityEvent, signer *ecdsa.PublicKey
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *Community) MemberCanManageToken(member *ecdsa.PublicKey, token *community_token.CommunityToken) bool {
|
||||
return o.IsMemberOwner(member) || (o.IsMemberTokenMaster(member) &&
|
||||
token.PrivilegesLevel != community_token.OwnerLevel && token.PrivilegesLevel != community_token.MasterLevel)
|
||||
}
|
||||
|
|
|
@ -1503,11 +1503,6 @@ func (m *Manager) HandleCommunityPrivilegedUserSyncMessage(signer *ecdsa.PublicK
|
|||
return errors.New("user has no permissions to process privileged sync message")
|
||||
}
|
||||
|
||||
isControlNodeMsg := common.IsPubKeyEqual(community.PublicKey(), signer)
|
||||
if !(isControlNodeMsg || community.IsPrivilegedMember(signer)) {
|
||||
return errors.New("user has no permissions to send privileged sync message")
|
||||
}
|
||||
|
||||
err = validateCommunityPrivilegedUserSyncMessage(message)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1517,7 +1512,7 @@ func (m *Manager) HandleCommunityPrivilegedUserSyncMessage(signer *ecdsa.PublicK
|
|||
case protobuf.CommunityPrivilegedUserSyncMessage_CONTROL_NODE_ACCEPT_REQUEST_TO_JOIN:
|
||||
fallthrough
|
||||
case protobuf.CommunityPrivilegedUserSyncMessage_CONTROL_NODE_REJECT_REQUEST_TO_JOIN:
|
||||
if !isControlNodeMsg {
|
||||
if !common.IsPubKeyEqual(community.PublicKey(), signer) {
|
||||
return errors.New("accepted/requested to join sync messages can be send only by the control node")
|
||||
}
|
||||
|
||||
|
@ -1543,6 +1538,23 @@ func (m *Manager) HandleCommunityPrivilegedUserSyncMessage(signer *ecdsa.PublicK
|
|||
return err
|
||||
}
|
||||
}
|
||||
case protobuf.CommunityPrivilegedUserSyncMessage_ADD_COMMUNITY_TOKENS:
|
||||
for _, token := range message.CommunityTokens {
|
||||
token := community_token.FromCommunityTokenProtobuf(token)
|
||||
if !community.MemberCanManageToken(community.MemberIdentity(), token) {
|
||||
return ErrInvalidManageTokensPermission
|
||||
}
|
||||
|
||||
exist, err := m.persistence.HasCommunityToken(token.CommunityID, token.Address, token.ChainID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !exist {
|
||||
return m.persistence.AddCommunityToken(token)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -4239,6 +4251,10 @@ func findIndexFile(files []*torrent.File) (index int, ok bool) {
|
|||
return 0, false
|
||||
}
|
||||
|
||||
func (m *Manager) GetCommunityToken(communityID string, chainID int, address string) (*community_token.CommunityToken, error) {
|
||||
return m.persistence.GetCommunityToken(communityID, chainID, address)
|
||||
}
|
||||
|
||||
func (m *Manager) GetCommunityTokens(communityID string) ([]*community_token.CommunityToken, error) {
|
||||
return m.persistence.GetCommunityTokens(communityID)
|
||||
}
|
||||
|
@ -4297,19 +4313,21 @@ func (m *Manager) SaveCommunityToken(token *community_token.CommunityToken, crop
|
|||
return token, m.persistence.AddCommunityToken(token)
|
||||
}
|
||||
|
||||
func (m *Manager) AddCommunityToken(communityID string, chainID int, address string) error {
|
||||
func (m *Manager) AddCommunityToken(token *community_token.CommunityToken) (*Community, error) {
|
||||
if token == nil {
|
||||
return nil, errors.New("Token is absent in database")
|
||||
}
|
||||
|
||||
community, err := m.GetByIDString(communityID)
|
||||
community, err := m.GetByIDString(token.CommunityID)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
if community == nil {
|
||||
return ErrOrgNotFound
|
||||
return nil, ErrOrgNotFound
|
||||
}
|
||||
|
||||
token, err := m.persistence.GetCommunityToken(communityID, chainID, address)
|
||||
if err != nil {
|
||||
return err
|
||||
if !community.MemberCanManageToken(&m.identity.PublicKey, token) {
|
||||
return nil, ErrInvalidManageTokensPermission
|
||||
}
|
||||
|
||||
tokenMetadata := &protobuf.CommunityTokenMetadata{
|
||||
|
@ -4323,10 +4341,10 @@ func (m *Manager) AddCommunityToken(communityID string, chainID int, address str
|
|||
}
|
||||
_, err = community.AddCommunityTokensMetadata(tokenMetadata)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return m.saveAndPublish(community)
|
||||
return community, m.saveAndPublish(community)
|
||||
}
|
||||
|
||||
func (m *Manager) UpdateCommunityTokenState(chainID int, contractAddress string, deployState community_token.DeployState) error {
|
||||
|
@ -4623,7 +4641,16 @@ func validateCommunityPrivilegedUserSyncMessage(message *protobuf.CommunityPrivi
|
|||
return errors.New("no communityId in request to join in CommunityPrivilegedUserSyncMessage message")
|
||||
}
|
||||
}
|
||||
case protobuf.CommunityPrivilegedUserSyncMessage_ADD_COMMUNITY_TOKENS:
|
||||
if message.CommunityTokens == nil {
|
||||
return errors.New("invalid add token CommunityPrivilegedUserSyncMessage message")
|
||||
}
|
||||
for _, token := range message.CommunityTokens {
|
||||
if token == nil || len(token.Address) == 0 || len(token.CommunityId) == 0 ||
|
||||
token.ChainId == 0 || len(token.Supply) == 0 {
|
||||
return errors.New("invalid token data in CommunityPrivilegedUserSyncMessage message")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package token
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
"github.com/status-im/status-go/services/wallet/bigint"
|
||||
)
|
||||
|
@ -39,3 +42,54 @@ type CommunityToken struct {
|
|||
Deployer string `json:"deployer"`
|
||||
PrivilegesLevel PrivilegesLevel `json:"privilegesLevel"`
|
||||
}
|
||||
|
||||
func ToCommunityTokenProtobuf(token *CommunityToken) *protobuf.CommunityToken {
|
||||
return &protobuf.CommunityToken{
|
||||
TokenType: token.TokenType,
|
||||
CommunityId: token.CommunityID,
|
||||
Address: token.Address,
|
||||
Name: token.Name,
|
||||
Symbol: token.Symbol,
|
||||
Description: token.Description,
|
||||
Supply: token.Supply.String(),
|
||||
InfiniteSupply: token.InfiniteSupply,
|
||||
Transferable: token.Transferable,
|
||||
RemoteSelfDestruct: token.RemoteSelfDestruct,
|
||||
ChainId: int32(token.ChainID),
|
||||
DeployState: protobuf.CommunityToken_DeployState(token.DeployState),
|
||||
Base64Image: token.Base64Image,
|
||||
Decimals: int32(token.Decimals),
|
||||
Deployer: token.Deployer,
|
||||
PrivilegesLevel: protobuf.CommunityToken_PrivilegesLevel(token.PrivilegesLevel),
|
||||
}
|
||||
}
|
||||
|
||||
func FromCommunityTokenProtobuf(pToken *protobuf.CommunityToken) *CommunityToken {
|
||||
token := &CommunityToken{
|
||||
TokenType: pToken.TokenType,
|
||||
CommunityID: pToken.CommunityId,
|
||||
Address: pToken.Address,
|
||||
Name: pToken.Name,
|
||||
Symbol: pToken.Symbol,
|
||||
Description: pToken.Description,
|
||||
InfiniteSupply: pToken.InfiniteSupply,
|
||||
Transferable: pToken.Transferable,
|
||||
RemoteSelfDestruct: pToken.RemoteSelfDestruct,
|
||||
ChainID: int(pToken.ChainId),
|
||||
DeployState: DeployState(pToken.DeployState),
|
||||
Base64Image: pToken.Base64Image,
|
||||
Decimals: int(pToken.Decimals),
|
||||
Deployer: pToken.Deployer,
|
||||
PrivilegesLevel: PrivilegesLevel(pToken.PrivilegesLevel),
|
||||
}
|
||||
|
||||
supplyBigInt, ok := new(big.Int).SetString(pToken.Supply, 10)
|
||||
if ok {
|
||||
token.Supply = &bigint.BigInt{Int: supplyBigInt}
|
||||
} else {
|
||||
token.Supply = &bigint.BigInt{Int: big.NewInt(0)}
|
||||
fmt.Println("can't create supply bigInt from string")
|
||||
}
|
||||
|
||||
return token
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/common"
|
||||
"github.com/status-im/status-go/protocol/communities/token"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
"github.com/status-im/status-go/protocol/tt"
|
||||
"github.com/status-im/status-go/waku"
|
||||
|
@ -210,7 +211,32 @@ func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerPinMessage() {
|
|||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerAddCommunityToken() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER)
|
||||
testEventSenderAddedCommunityToken(s, community)
|
||||
testAddAndSyncTokenFromEventSenderByControlNode(s, community, token.CommunityLevel)
|
||||
}
|
||||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerAddOwnerToken() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER)
|
||||
testAddAndSyncTokenFromEventSenderByControlNode(s, community, token.OwnerLevel)
|
||||
}
|
||||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerAddTokenMasterToken() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER)
|
||||
testAddAndSyncTokenFromEventSenderByControlNode(s, community, token.MasterLevel)
|
||||
}
|
||||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerSyncOwnerTokenFromControlNode() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER)
|
||||
testAddAndSyncTokenFromControlNode(s, community, token.OwnerLevel, true)
|
||||
}
|
||||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerSyncTokenMasterTokenFromControlNode() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER)
|
||||
testAddAndSyncTokenFromControlNode(s, community, token.MasterLevel, true)
|
||||
}
|
||||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerSyncCommunityTokenFromControlNode() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER)
|
||||
testAddAndSyncTokenFromControlNode(s, community, token.CommunityLevel, true)
|
||||
}
|
||||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestMemberReceiveOwnerEventsWhenControlNodeOffline() {
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/common"
|
||||
"github.com/status-im/status-go/protocol/communities/token"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
"github.com/status-im/status-go/protocol/tt"
|
||||
"github.com/status-im/status-go/waku"
|
||||
|
@ -231,7 +232,27 @@ func (s *TokenMasterCommunityEventsSuite) TestTokenMasterPinMessage() {
|
|||
|
||||
func (s *TokenMasterCommunityEventsSuite) TestTokenMasterAddCommunityToken() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_TOKEN_MASTER)
|
||||
testEventSenderAddedCommunityToken(s, community)
|
||||
testAddAndSyncTokenFromEventSenderByControlNode(s, community, token.CommunityLevel)
|
||||
}
|
||||
|
||||
func (s *TokenMasterCommunityEventsSuite) TestTokenMasterAddTokenMasterAndOwnerToken() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_TOKEN_MASTER)
|
||||
testEventSenderAddTokenMasterAndOwnerToken(s, community)
|
||||
}
|
||||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestTokenMasterSyncOwnerTokenFromControlNode() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_TOKEN_MASTER)
|
||||
testAddAndSyncTokenFromControlNode(s, community, token.OwnerLevel, false)
|
||||
}
|
||||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestTokenMasterSyncTokenMasterTokenFromControlNode() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_TOKEN_MASTER)
|
||||
testAddAndSyncTokenFromControlNode(s, community, token.MasterLevel, false)
|
||||
}
|
||||
|
||||
func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestTokenMasterSyncCommunityTokenFromControlNode() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_TOKEN_MASTER)
|
||||
testAddAndSyncTokenFromControlNode(s, community, token.CommunityLevel, true)
|
||||
}
|
||||
|
||||
func (s *TokenMasterCommunityEventsSuite) TestMemberReceiveTokenMasterEventsWhenControlNodeOffline() {
|
||||
|
|
|
@ -1634,9 +1634,81 @@ func testEventSenderCannotEditPrivilegedCommunityPermission(base CommunityEvents
|
|||
s.Require().Nil(response)
|
||||
}
|
||||
|
||||
func testEventSenderAddedCommunityToken(base CommunityEventsTestsInterface, community *communities.Community) {
|
||||
tokenERC721 := &token.CommunityToken{
|
||||
CommunityID: community.IDString(),
|
||||
func testAddAndSyncTokenFromControlNode(base CommunityEventsTestsInterface, community *communities.Community,
|
||||
privilegesLvl token.PrivilegesLevel, expectedSync bool) {
|
||||
tokenERC721 := createCommunityToken(community.IDString(), privilegesLvl)
|
||||
|
||||
s := base.GetSuite()
|
||||
|
||||
_, err := base.GetControlNode().SaveCommunityToken(tokenERC721, nil)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = base.GetControlNode().AddCommunityToken(tokenERC721.CommunityID, tokenERC721.ChainID, tokenERC721.Address)
|
||||
s.Require().NoError(err)
|
||||
|
||||
tokens, err := base.GetEventSender().communitiesManager.GetAllCommunityTokens()
|
||||
s.Require().NoError(err)
|
||||
s.Require().Len(tokens, 0)
|
||||
|
||||
checkTokenAdded := func(response *MessengerResponse) error {
|
||||
modifiedCommmunity, err := getModifiedCommunity(response, community.IDString())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, tokenMetadata := range modifiedCommmunity.CommunityTokensMetadata() {
|
||||
if tokenMetadata.Name == tokenERC721.Name {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return errors.New("Token was not found")
|
||||
}
|
||||
|
||||
waitOnMessengerResponse(s, WaitCommunityCondition, checkTokenAdded, base.GetMember())
|
||||
waitOnMessengerResponse(s, WaitCommunityCondition, checkTokenAdded, base.GetEventSender())
|
||||
|
||||
// check control node sent sync message to the event sender
|
||||
_, err = WaitOnMessengerResponse(
|
||||
base.GetEventSender(),
|
||||
func(r *MessengerResponse) bool {
|
||||
tokens, err := base.GetEventSender().communitiesManager.GetAllCommunityTokens()
|
||||
return err == nil && len(tokens) == 1
|
||||
},
|
||||
"no token sync message from control node",
|
||||
)
|
||||
|
||||
if expectedSync {
|
||||
s.Require().NoError(err)
|
||||
} else {
|
||||
s.Require().Error(err)
|
||||
}
|
||||
|
||||
// check member did not receive sync message with the token
|
||||
_, err = WaitOnMessengerResponse(
|
||||
base.GetMember(),
|
||||
func(r *MessengerResponse) bool {
|
||||
tokens, err := base.GetMember().communitiesManager.GetAllCommunityTokens()
|
||||
return err == nil && len(tokens) == 1
|
||||
},
|
||||
"no token sync message from control node",
|
||||
)
|
||||
|
||||
s.Require().Error(err)
|
||||
}
|
||||
|
||||
func testEventSenderCannotCreatePrivilegedCommunityPermission(base CommunityEventsTestsInterface, community *communities.Community, pType protobuf.CommunityTokenPermission_Type) {
|
||||
permissionRequest := createTestPermissionRequest(community, pType)
|
||||
|
||||
response, err := base.GetEventSender().CreateCommunityTokenPermission(permissionRequest)
|
||||
s := base.GetSuite()
|
||||
s.Require().Nil(response)
|
||||
s.Require().Error(err)
|
||||
}
|
||||
|
||||
func createCommunityToken(communityID string, privilegesLevel token.PrivilegesLevel) *token.CommunityToken {
|
||||
return &token.CommunityToken{
|
||||
CommunityID: communityID,
|
||||
TokenType: protobuf.CommunityTokenType_ERC721,
|
||||
Address: "0x123",
|
||||
Name: "StatusToken",
|
||||
|
@ -1649,7 +1721,13 @@ func testEventSenderAddedCommunityToken(base CommunityEventsTestsInterface, comm
|
|||
ChainID: 1,
|
||||
DeployState: token.Deployed,
|
||||
Base64Image: "ABCD",
|
||||
PrivilegesLevel: privilegesLevel,
|
||||
}
|
||||
}
|
||||
|
||||
func testAddAndSyncTokenFromEventSenderByControlNode(base CommunityEventsTestsInterface, community *communities.Community,
|
||||
privilegesLvl token.PrivilegesLevel) {
|
||||
tokenERC721 := createCommunityToken(community.IDString(), privilegesLvl)
|
||||
|
||||
s := base.GetSuite()
|
||||
|
||||
|
@ -1659,6 +1737,10 @@ func testEventSenderAddedCommunityToken(base CommunityEventsTestsInterface, comm
|
|||
err = base.GetEventSender().AddCommunityToken(tokenERC721.CommunityID, tokenERC721.ChainID, tokenERC721.Address)
|
||||
s.Require().NoError(err)
|
||||
|
||||
tokens, err := base.GetControlNode().communitiesManager.GetAllCommunityTokens()
|
||||
s.Require().NoError(err)
|
||||
s.Require().Len(tokens, 0)
|
||||
|
||||
checkTokenAdded := func(response *MessengerResponse) error {
|
||||
modifiedCommmunity, err := getModifiedCommunity(response, community.IDString())
|
||||
if err != nil {
|
||||
|
@ -1675,13 +1757,50 @@ func testEventSenderAddedCommunityToken(base CommunityEventsTestsInterface, comm
|
|||
}
|
||||
|
||||
checkClientsReceivedAdminEvent(base, WaitCommunityCondition, checkTokenAdded)
|
||||
}
|
||||
|
||||
func testEventSenderCannotCreatePrivilegedCommunityPermission(base CommunityEventsTestsInterface, community *communities.Community, pType protobuf.CommunityTokenPermission_Type) {
|
||||
permissionRequest := createTestPermissionRequest(community, pType)
|
||||
// check event sender sent sync message to the control node
|
||||
_, err = WaitOnMessengerResponse(
|
||||
base.GetControlNode(),
|
||||
func(r *MessengerResponse) bool {
|
||||
tokens, err := base.GetControlNode().communitiesManager.GetAllCommunityTokens()
|
||||
return err == nil && len(tokens) == 1
|
||||
},
|
||||
"no token sync message from event sender",
|
||||
)
|
||||
|
||||
s.Require().NoError(err)
|
||||
|
||||
// check member did not receive sync message with the token
|
||||
_, err = WaitOnMessengerResponse(
|
||||
base.GetMember(),
|
||||
func(r *MessengerResponse) bool {
|
||||
tokens, err := base.GetMember().communitiesManager.GetAllCommunityTokens()
|
||||
return err == nil && len(tokens) == 1
|
||||
},
|
||||
"no token sync message from event sender",
|
||||
)
|
||||
|
||||
response, err := base.GetEventSender().CreateCommunityTokenPermission(permissionRequest)
|
||||
s := base.GetSuite()
|
||||
s.Require().Nil(response)
|
||||
s.Require().Error(err)
|
||||
}
|
||||
|
||||
func testEventSenderAddTokenMasterAndOwnerToken(base CommunityEventsTestsInterface, community *communities.Community) {
|
||||
ownerToken := createCommunityToken(community.IDString(), token.OwnerLevel)
|
||||
|
||||
s := base.GetSuite()
|
||||
|
||||
_, err := base.GetEventSender().SaveCommunityToken(ownerToken, nil)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = base.GetEventSender().AddCommunityToken(ownerToken.CommunityID, ownerToken.ChainID, ownerToken.Address)
|
||||
s.Require().Error(err, communities.ErrInvalidManageTokensPermission)
|
||||
|
||||
tokenMasterToken := ownerToken
|
||||
tokenMasterToken.PrivilegesLevel = token.MasterLevel
|
||||
tokenMasterToken.Address = "0x124"
|
||||
|
||||
_, err = base.GetEventSender().SaveCommunityToken(tokenMasterToken, nil)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = base.GetEventSender().AddCommunityToken(ownerToken.CommunityID, ownerToken.ChainID, ownerToken.Address)
|
||||
s.Require().Error(err, communities.ErrInvalidManageTokensPermission)
|
||||
}
|
||||
|
|
|
@ -263,6 +263,11 @@ func (s *AdminCommunityEventsSuite) TestAdminAddCommunityToken() {
|
|||
s.Require().Error(err)
|
||||
}
|
||||
|
||||
func (s *TokenMasterCommunityEventsSuite) TestAdminAddTokenMasterAndOwnerToken() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
||||
testEventSenderAddTokenMasterAndOwnerToken(s, community)
|
||||
}
|
||||
|
||||
func (s *AdminCommunityEventsSuite) TestMemberReceiveAdminEventsWhenOwnerOffline() {
|
||||
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
||||
testMemberReceiveEventsWhenControlNodeOffline(s, community)
|
||||
|
|
|
@ -4234,7 +4234,47 @@ func (m *Messenger) SaveCommunityToken(token *token.CommunityToken, croppedImage
|
|||
}
|
||||
|
||||
func (m *Messenger) AddCommunityToken(communityID string, chainID int, address string) error {
|
||||
return m.communitiesManager.AddCommunityToken(communityID, chainID, address)
|
||||
communityToken, err := m.communitiesManager.GetCommunityToken(communityID, chainID, address)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
community, err := m.communitiesManager.AddCommunityToken(communityToken)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
syncMsg := &protobuf.CommunityPrivilegedUserSyncMessage{
|
||||
Type: protobuf.CommunityPrivilegedUserSyncMessage_ADD_COMMUNITY_TOKENS,
|
||||
CommunityId: community.ID(),
|
||||
CommunityTokens: []*protobuf.CommunityToken{token.ToCommunityTokenProtobuf(communityToken)},
|
||||
}
|
||||
|
||||
payloadSyncMsg, err := proto.Marshal(syncMsg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rawSyncMessage := &common.RawMessage{
|
||||
Payload: payloadSyncMsg,
|
||||
Sender: m.identity,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_PRIVILEGED_USER_SYNC_MESSAGE,
|
||||
}
|
||||
|
||||
for _, member := range community.GetMemberPubkeys() {
|
||||
if member.Equal(&m.identity.PublicKey) {
|
||||
continue
|
||||
}
|
||||
|
||||
if community.MemberCanManageToken(member, communityToken) {
|
||||
_, err := m.sender.SendPrivate(context.Background(), member, rawSyncMessage)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Messenger) UpdateCommunityTokenState(chainID int, contractAddress string, deployState token.DeployState) error {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,21 +26,21 @@ const (
|
|||
CommunityPrivilegedUserSyncMessage_UNKNOWN CommunityPrivilegedUserSyncMessage_EventType = 0
|
||||
CommunityPrivilegedUserSyncMessage_CONTROL_NODE_ACCEPT_REQUEST_TO_JOIN CommunityPrivilegedUserSyncMessage_EventType = 1
|
||||
CommunityPrivilegedUserSyncMessage_CONTROL_NODE_REJECT_REQUEST_TO_JOIN CommunityPrivilegedUserSyncMessage_EventType = 2
|
||||
CommunityPrivilegedUserSyncMessage_ADD_TOKEN CommunityPrivilegedUserSyncMessage_EventType = 3
|
||||
CommunityPrivilegedUserSyncMessage_ADD_COMMUNITY_TOKENS CommunityPrivilegedUserSyncMessage_EventType = 3
|
||||
)
|
||||
|
||||
var CommunityPrivilegedUserSyncMessage_EventType_name = map[int32]string{
|
||||
0: "UNKNOWN",
|
||||
1: "CONTROL_NODE_ACCEPT_REQUEST_TO_JOIN",
|
||||
2: "CONTROL_NODE_REJECT_REQUEST_TO_JOIN",
|
||||
3: "ADD_TOKEN",
|
||||
3: "ADD_COMMUNITY_TOKENS",
|
||||
}
|
||||
|
||||
var CommunityPrivilegedUserSyncMessage_EventType_value = map[string]int32{
|
||||
"UNKNOWN": 0,
|
||||
"CONTROL_NODE_ACCEPT_REQUEST_TO_JOIN": 1,
|
||||
"CONTROL_NODE_REJECT_REQUEST_TO_JOIN": 2,
|
||||
"ADD_TOKEN": 3,
|
||||
"ADD_COMMUNITY_TOKENS": 3,
|
||||
}
|
||||
|
||||
func (x CommunityPrivilegedUserSyncMessage_EventType) String() string {
|
||||
|
@ -56,6 +56,7 @@ type CommunityPrivilegedUserSyncMessage struct {
|
|||
Type CommunityPrivilegedUserSyncMessage_EventType `protobuf:"varint,2,opt,name=type,proto3,enum=protobuf.CommunityPrivilegedUserSyncMessage_EventType" json:"type,omitempty"`
|
||||
CommunityId []byte `protobuf:"bytes,3,opt,name=community_id,json=communityId,proto3" json:"community_id,omitempty"`
|
||||
RequestToJoin map[string]*CommunityRequestToJoin `protobuf:"bytes,4,rep,name=request_to_join,json=requestToJoin,proto3" json:"request_to_join,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
CommunityTokens []*CommunityToken `protobuf:"bytes,5,rep,name=community_tokens,json=communityTokens,proto3" json:"community_tokens,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
|
@ -114,6 +115,13 @@ func (m *CommunityPrivilegedUserSyncMessage) GetRequestToJoin() map[string]*Comm
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *CommunityPrivilegedUserSyncMessage) GetCommunityTokens() []*CommunityToken {
|
||||
if m != nil {
|
||||
return m.CommunityTokens
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("protobuf.CommunityPrivilegedUserSyncMessage_EventType", CommunityPrivilegedUserSyncMessage_EventType_name, CommunityPrivilegedUserSyncMessage_EventType_value)
|
||||
proto.RegisterType((*CommunityPrivilegedUserSyncMessage)(nil), "protobuf.CommunityPrivilegedUserSyncMessage")
|
||||
|
@ -125,28 +133,31 @@ func init() {
|
|||
}
|
||||
|
||||
var fileDescriptor_158595055b4cfee2 = []byte{
|
||||
// 362 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x90, 0xc1, 0x4f, 0xf2, 0x30,
|
||||
0x18, 0xc6, 0xbf, 0x31, 0xf8, 0xbe, 0x8f, 0x0e, 0x74, 0x36, 0x1e, 0x16, 0x4e, 0x13, 0x0f, 0xee,
|
||||
0x60, 0x66, 0x82, 0x09, 0x31, 0x7a, 0x30, 0x38, 0x7a, 0x60, 0xe8, 0x86, 0x65, 0xc4, 0xc4, 0x4b,
|
||||
0x03, 0xa3, 0x92, 0x09, 0xac, 0x73, 0xed, 0x48, 0xfa, 0x67, 0xfb, 0x1f, 0x18, 0xb7, 0x0c, 0x35,
|
||||
0x98, 0x18, 0x4f, 0x7d, 0xfb, 0xf6, 0xe9, 0xef, 0x7d, 0xde, 0x07, 0x9c, 0x86, 0x6c, 0xbd, 0xce,
|
||||
0xe2, 0x48, 0x48, 0x92, 0xa4, 0xd1, 0x26, 0x5a, 0xd1, 0x05, 0x9d, 0x93, 0x8c, 0xd3, 0x94, 0x70,
|
||||
0x19, 0x87, 0x64, 0x4d, 0x39, 0x9f, 0x2e, 0xa8, 0x9d, 0xa4, 0x4c, 0x30, 0xf8, 0x3f, 0x3f, 0x66,
|
||||
0xd9, 0x53, 0xeb, 0xa0, 0xfc, 0x17, 0x51, 0x5e, 0x3c, 0xb6, 0x5f, 0x55, 0xd0, 0x76, 0x4a, 0xda,
|
||||
0x68, 0x0b, 0x9b, 0x70, 0x9a, 0x8e, 0x65, 0x1c, 0xde, 0x15, 0x24, 0x78, 0x08, 0x6a, 0xe1, 0x8a,
|
||||
0x85, 0x4b, 0x43, 0x31, 0x15, 0xab, 0x8a, 0x8b, 0x0b, 0x74, 0x41, 0x55, 0xc8, 0x84, 0x1a, 0x15,
|
||||
0x53, 0xb1, 0xf6, 0x3a, 0x5d, 0xbb, 0x1c, 0x64, 0xff, 0x4c, 0xb4, 0xd1, 0x86, 0xc6, 0x22, 0x90,
|
||||
0x09, 0xc5, 0x39, 0x03, 0x1e, 0x81, 0xc6, 0xc7, 0x56, 0xd1, 0xdc, 0x50, 0x4d, 0xc5, 0x6a, 0x60,
|
||||
0x6d, 0xdb, 0x1b, 0xcc, 0xe1, 0x02, 0xec, 0xa7, 0xf4, 0x25, 0xa3, 0x5c, 0x10, 0xc1, 0xc8, 0x33,
|
||||
0x8b, 0x62, 0xa3, 0x6a, 0xaa, 0x96, 0xd6, 0xb9, 0xfe, 0xd5, 0x64, 0x5c, 0x30, 0x02, 0xe6, 0xb2,
|
||||
0x28, 0x46, 0xb1, 0x48, 0x25, 0x6e, 0xa6, 0x9f, 0x7b, 0xad, 0x19, 0x80, 0xbb, 0x22, 0xa8, 0x03,
|
||||
0x75, 0x49, 0x65, 0x9e, 0x40, 0x1d, 0xbf, 0x97, 0xb0, 0x0b, 0x6a, 0x9b, 0xe9, 0x2a, 0x2b, 0x02,
|
||||
0xd0, 0x3a, 0xe6, 0x37, 0x36, 0xbe, 0x70, 0x70, 0x21, 0xbf, 0xac, 0x5c, 0x28, 0x6d, 0x09, 0xea,
|
||||
0xdb, 0x08, 0xa0, 0x06, 0xfe, 0x4d, 0xbc, 0xa1, 0xe7, 0x3f, 0x78, 0xfa, 0x1f, 0x78, 0x02, 0x8e,
|
||||
0x1d, 0xdf, 0x0b, 0xb0, 0x7f, 0x4b, 0x3c, 0xbf, 0x8f, 0x48, 0xcf, 0x71, 0xd0, 0x28, 0x20, 0x18,
|
||||
0xdd, 0x4f, 0xd0, 0x38, 0x20, 0x81, 0x4f, 0x5c, 0x7f, 0xe0, 0xe9, 0xca, 0x8e, 0x10, 0x23, 0x17,
|
||||
0x39, 0xbb, 0xc2, 0x0a, 0x6c, 0x82, 0x7a, 0xaf, 0xdf, 0x27, 0x81, 0x3f, 0x44, 0x9e, 0xae, 0xde,
|
||||
0x34, 0x1f, 0x35, 0xfb, 0xec, 0xaa, 0xf4, 0x3a, 0xfb, 0x9b, 0x57, 0xe7, 0x6f, 0x01, 0x00, 0x00,
|
||||
0xff, 0xff, 0xcf, 0xca, 0x41, 0x8f, 0x56, 0x02, 0x00, 0x00,
|
||||
// 403 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x90, 0x4f, 0x6f, 0xd3, 0x30,
|
||||
0x18, 0xc6, 0x49, 0x93, 0x02, 0x73, 0x36, 0x16, 0xac, 0x21, 0x45, 0x3d, 0x85, 0x72, 0x20, 0x07,
|
||||
0x14, 0xa4, 0x22, 0x4d, 0x08, 0x0e, 0x68, 0xa4, 0x3e, 0x34, 0xa3, 0xf6, 0x70, 0x1d, 0x21, 0xb8,
|
||||
0x58, 0x6b, 0x6a, 0xaa, 0xd0, 0xd6, 0x0e, 0xb1, 0x53, 0x29, 0x77, 0x3e, 0x19, 0x9f, 0x0c, 0x2d,
|
||||
0x51, 0x3a, 0x46, 0x2b, 0xa1, 0x9d, 0xfc, 0xfe, 0x79, 0xfc, 0xfc, 0x5e, 0x3d, 0xe0, 0x55, 0xa6,
|
||||
0x36, 0x9b, 0x4a, 0xe6, 0xa6, 0xe6, 0x45, 0x99, 0x6f, 0xf3, 0xb5, 0x58, 0x8a, 0x05, 0xaf, 0xb4,
|
||||
0x28, 0xb9, 0xae, 0x65, 0xc6, 0x37, 0x42, 0xeb, 0xeb, 0xa5, 0x88, 0x8a, 0x52, 0x19, 0x05, 0x1f,
|
||||
0x37, 0xcf, 0xbc, 0xfa, 0x3e, 0x78, 0xda, 0xfd, 0xcb, 0x85, 0x6e, 0x97, 0x83, 0x67, 0xb7, 0x56,
|
||||
0x46, 0xad, 0x84, 0x6c, 0xc7, 0xc3, 0xdf, 0x0e, 0x18, 0xc6, 0xdd, 0xe6, 0x6a, 0xc7, 0x48, 0xb5,
|
||||
0x28, 0x67, 0xb5, 0xcc, 0xa6, 0x2d, 0x00, 0x9e, 0x81, 0x7e, 0xb6, 0x56, 0xd9, 0xca, 0xb7, 0x02,
|
||||
0x2b, 0x74, 0x68, 0xdb, 0xc0, 0x04, 0x38, 0xa6, 0x2e, 0x84, 0xdf, 0x0b, 0xac, 0xf0, 0xc9, 0xe8,
|
||||
0x3c, 0xea, 0xf8, 0xd1, 0xff, 0x1d, 0x23, 0xb4, 0x15, 0xd2, 0xb0, 0xba, 0x10, 0xb4, 0xf1, 0x80,
|
||||
0xcf, 0xc1, 0xf1, 0xed, 0x85, 0xf9, 0xc2, 0xb7, 0x03, 0x2b, 0x3c, 0xa6, 0xee, 0x6e, 0x36, 0x59,
|
||||
0xc0, 0x25, 0x38, 0x2d, 0xc5, 0xcf, 0x4a, 0x68, 0xc3, 0x8d, 0xe2, 0x3f, 0x54, 0x2e, 0x7d, 0x27,
|
||||
0xb0, 0x43, 0x77, 0xf4, 0xe1, 0x5e, 0x64, 0xda, 0x7a, 0x30, 0x95, 0xa8, 0x5c, 0x22, 0x69, 0xca,
|
||||
0x9a, 0x9e, 0x94, 0x7f, 0xcf, 0x60, 0x0c, 0xbc, 0x7f, 0xd2, 0xd2, 0x7e, 0xbf, 0x21, 0xf9, 0x07,
|
||||
0x48, 0xec, 0x46, 0x40, 0x4f, 0xb3, 0x3b, 0xbd, 0x1e, 0xcc, 0x01, 0xdc, 0x27, 0x41, 0x0f, 0xd8,
|
||||
0x2b, 0x51, 0x37, 0x31, 0x1e, 0xd1, 0x9b, 0x12, 0x9e, 0x83, 0xfe, 0xf6, 0x7a, 0x5d, 0xb5, 0x29,
|
||||
0xba, 0xa3, 0xe0, 0x00, 0xe1, 0x8e, 0x0f, 0x6d, 0xe5, 0xef, 0x7a, 0x6f, 0xad, 0xe1, 0x2f, 0x0b,
|
||||
0x1c, 0xed, 0x82, 0x84, 0x2e, 0x78, 0x94, 0xe2, 0x4b, 0x4c, 0xbe, 0x60, 0xef, 0x01, 0x7c, 0x09,
|
||||
0x5e, 0xc4, 0x04, 0x33, 0x4a, 0x3e, 0x71, 0x4c, 0xc6, 0x88, 0x5f, 0xc4, 0x31, 0xba, 0x62, 0x9c,
|
||||
0xa2, 0xcf, 0x29, 0x9a, 0x31, 0xce, 0x08, 0x4f, 0xc8, 0x04, 0x7b, 0xd6, 0x9e, 0x90, 0xa2, 0x04,
|
||||
0xc5, 0xfb, 0xc2, 0x1e, 0xf4, 0xc1, 0xd9, 0xc5, 0x78, 0xcc, 0x63, 0x32, 0x9d, 0xa6, 0x78, 0xc2,
|
||||
0xbe, 0x72, 0x46, 0x2e, 0x11, 0x9e, 0x79, 0xf6, 0xc7, 0x93, 0x6f, 0x6e, 0xf4, 0xfa, 0x7d, 0x77,
|
||||
0xf7, 0xfc, 0x61, 0x53, 0xbd, 0xf9, 0x13, 0x00, 0x00, 0xff, 0xff, 0x76, 0x02, 0x4a, 0xb3, 0xbe,
|
||||
0x02, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -4,17 +4,19 @@ option go_package = "./;protobuf";
|
|||
package protobuf;
|
||||
|
||||
import "communities.proto";
|
||||
import "community_token.proto";
|
||||
|
||||
message CommunityPrivilegedUserSyncMessage {
|
||||
uint64 clock = 1;
|
||||
EventType type = 2;
|
||||
bytes community_id = 3;
|
||||
map<string,CommunityRequestToJoin> request_to_join = 4;
|
||||
repeated CommunityToken community_tokens = 5;
|
||||
|
||||
enum EventType {
|
||||
UNKNOWN = 0;
|
||||
CONTROL_NODE_ACCEPT_REQUEST_TO_JOIN = 1;
|
||||
CONTROL_NODE_REJECT_REQUEST_TO_JOIN = 2;
|
||||
ADD_TOKEN = 3;
|
||||
ADD_COMMUNITY_TOKENS = 3;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,285 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: community_token.proto
|
||||
|
||||
package protobuf
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// 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.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type CommunityToken_DeployState int32
|
||||
|
||||
const (
|
||||
CommunityToken_UNKNOWN CommunityToken_DeployState = 0
|
||||
CommunityToken_FAILED CommunityToken_DeployState = 1
|
||||
CommunityToken_IN_PROGRESS CommunityToken_DeployState = 2
|
||||
CommunityToken_DEPLOYED CommunityToken_DeployState = 3
|
||||
)
|
||||
|
||||
var CommunityToken_DeployState_name = map[int32]string{
|
||||
0: "UNKNOWN",
|
||||
1: "FAILED",
|
||||
2: "IN_PROGRESS",
|
||||
3: "DEPLOYED",
|
||||
}
|
||||
|
||||
var CommunityToken_DeployState_value = map[string]int32{
|
||||
"UNKNOWN": 0,
|
||||
"FAILED": 1,
|
||||
"IN_PROGRESS": 2,
|
||||
"DEPLOYED": 3,
|
||||
}
|
||||
|
||||
func (x CommunityToken_DeployState) String() string {
|
||||
return proto.EnumName(CommunityToken_DeployState_name, int32(x))
|
||||
}
|
||||
|
||||
func (CommunityToken_DeployState) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_e2582028caf1a04a, []int{0, 0}
|
||||
}
|
||||
|
||||
type CommunityToken_PrivilegesLevel int32
|
||||
|
||||
const (
|
||||
CommunityToken_OWNER_LEVEL CommunityToken_PrivilegesLevel = 0
|
||||
CommunityToken_MASTER_LEVEL CommunityToken_PrivilegesLevel = 1
|
||||
CommunityToken_COMMUNITY_LEVEL CommunityToken_PrivilegesLevel = 2
|
||||
)
|
||||
|
||||
var CommunityToken_PrivilegesLevel_name = map[int32]string{
|
||||
0: "OWNER_LEVEL",
|
||||
1: "MASTER_LEVEL",
|
||||
2: "COMMUNITY_LEVEL",
|
||||
}
|
||||
|
||||
var CommunityToken_PrivilegesLevel_value = map[string]int32{
|
||||
"OWNER_LEVEL": 0,
|
||||
"MASTER_LEVEL": 1,
|
||||
"COMMUNITY_LEVEL": 2,
|
||||
}
|
||||
|
||||
func (x CommunityToken_PrivilegesLevel) String() string {
|
||||
return proto.EnumName(CommunityToken_PrivilegesLevel_name, int32(x))
|
||||
}
|
||||
|
||||
func (CommunityToken_PrivilegesLevel) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_e2582028caf1a04a, []int{0, 1}
|
||||
}
|
||||
|
||||
type CommunityToken struct {
|
||||
TokenType CommunityTokenType `protobuf:"varint,1,opt,name=token_type,json=tokenType,proto3,enum=protobuf.CommunityTokenType" json:"token_type,omitempty"`
|
||||
CommunityId string `protobuf:"bytes,2,opt,name=community_id,json=communityId,proto3" json:"community_id,omitempty"`
|
||||
Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
|
||||
Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Symbol string `protobuf:"bytes,5,opt,name=symbol,proto3" json:"symbol,omitempty"`
|
||||
Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"`
|
||||
Supply string `protobuf:"bytes,7,opt,name=supply,proto3" json:"supply,omitempty"`
|
||||
InfiniteSupply bool `protobuf:"varint,8,opt,name=infinite_supply,json=infiniteSupply,proto3" json:"infinite_supply,omitempty"`
|
||||
Transferable bool `protobuf:"varint,9,opt,name=transferable,proto3" json:"transferable,omitempty"`
|
||||
RemoteSelfDestruct bool `protobuf:"varint,10,opt,name=remote_self_destruct,json=remoteSelfDestruct,proto3" json:"remote_self_destruct,omitempty"`
|
||||
ChainId int32 `protobuf:"varint,11,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
|
||||
DeployState CommunityToken_DeployState `protobuf:"varint,12,opt,name=deploy_state,json=deployState,proto3,enum=protobuf.CommunityToken_DeployState" json:"deploy_state,omitempty"`
|
||||
Base64Image string `protobuf:"bytes,13,opt,name=base64_image,json=base64Image,proto3" json:"base64_image,omitempty"`
|
||||
Decimals int32 `protobuf:"varint,14,opt,name=decimals,proto3" json:"decimals,omitempty"`
|
||||
Deployer string `protobuf:"bytes,15,opt,name=deployer,proto3" json:"deployer,omitempty"`
|
||||
PrivilegesLevel CommunityToken_PrivilegesLevel `protobuf:"varint,16,opt,name=privileges_level,json=privilegesLevel,proto3,enum=protobuf.CommunityToken_PrivilegesLevel" json:"privileges_level,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *CommunityToken) Reset() { *m = CommunityToken{} }
|
||||
func (m *CommunityToken) String() string { return proto.CompactTextString(m) }
|
||||
func (*CommunityToken) ProtoMessage() {}
|
||||
func (*CommunityToken) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_e2582028caf1a04a, []int{0}
|
||||
}
|
||||
|
||||
func (m *CommunityToken) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_CommunityToken.Unmarshal(m, b)
|
||||
}
|
||||
func (m *CommunityToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_CommunityToken.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *CommunityToken) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_CommunityToken.Merge(m, src)
|
||||
}
|
||||
func (m *CommunityToken) XXX_Size() int {
|
||||
return xxx_messageInfo_CommunityToken.Size(m)
|
||||
}
|
||||
func (m *CommunityToken) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_CommunityToken.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_CommunityToken proto.InternalMessageInfo
|
||||
|
||||
func (m *CommunityToken) GetTokenType() CommunityTokenType {
|
||||
if m != nil {
|
||||
return m.TokenType
|
||||
}
|
||||
return CommunityTokenType_UNKNOWN_TOKEN_TYPE
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetCommunityId() string {
|
||||
if m != nil {
|
||||
return m.CommunityId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetAddress() string {
|
||||
if m != nil {
|
||||
return m.Address
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetSymbol() string {
|
||||
if m != nil {
|
||||
return m.Symbol
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetDescription() string {
|
||||
if m != nil {
|
||||
return m.Description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetSupply() string {
|
||||
if m != nil {
|
||||
return m.Supply
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetInfiniteSupply() bool {
|
||||
if m != nil {
|
||||
return m.InfiniteSupply
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetTransferable() bool {
|
||||
if m != nil {
|
||||
return m.Transferable
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetRemoteSelfDestruct() bool {
|
||||
if m != nil {
|
||||
return m.RemoteSelfDestruct
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetChainId() int32 {
|
||||
if m != nil {
|
||||
return m.ChainId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetDeployState() CommunityToken_DeployState {
|
||||
if m != nil {
|
||||
return m.DeployState
|
||||
}
|
||||
return CommunityToken_UNKNOWN
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetBase64Image() string {
|
||||
if m != nil {
|
||||
return m.Base64Image
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetDecimals() int32 {
|
||||
if m != nil {
|
||||
return m.Decimals
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetDeployer() string {
|
||||
if m != nil {
|
||||
return m.Deployer
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CommunityToken) GetPrivilegesLevel() CommunityToken_PrivilegesLevel {
|
||||
if m != nil {
|
||||
return m.PrivilegesLevel
|
||||
}
|
||||
return CommunityToken_OWNER_LEVEL
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("protobuf.CommunityToken_DeployState", CommunityToken_DeployState_name, CommunityToken_DeployState_value)
|
||||
proto.RegisterEnum("protobuf.CommunityToken_PrivilegesLevel", CommunityToken_PrivilegesLevel_name, CommunityToken_PrivilegesLevel_value)
|
||||
proto.RegisterType((*CommunityToken)(nil), "protobuf.CommunityToken")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("community_token.proto", fileDescriptor_e2582028caf1a04a)
|
||||
}
|
||||
|
||||
var fileDescriptor_e2582028caf1a04a = []byte{
|
||||
// 509 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x4f, 0x6f, 0x9b, 0x40,
|
||||
0x10, 0xc5, 0x83, 0x93, 0xd8, 0x78, 0x20, 0x06, 0x4d, 0xff, 0x68, 0x1b, 0xf5, 0xe0, 0x5a, 0x95,
|
||||
0xea, 0x93, 0x5b, 0xb5, 0x55, 0x2f, 0x39, 0xa5, 0x31, 0x8d, 0x50, 0x6d, 0x6c, 0x81, 0xd3, 0x28,
|
||||
0xbd, 0x20, 0x6c, 0xc6, 0xe9, 0xaa, 0xfc, 0x13, 0xac, 0x23, 0xf1, 0x41, 0xfa, 0x7d, 0x2b, 0x16,
|
||||
0x43, 0xe3, 0x4a, 0x39, 0xb1, 0xef, 0x37, 0xef, 0xed, 0xce, 0x0c, 0xf0, 0x62, 0x93, 0xc6, 0xf1,
|
||||
0x2e, 0xe1, 0xa2, 0xf4, 0x45, 0xfa, 0x9b, 0x92, 0x49, 0x96, 0xa7, 0x22, 0x45, 0x55, 0x7e, 0xd6,
|
||||
0xbb, 0xed, 0xb9, 0x46, 0xc9, 0x2e, 0x2e, 0x6a, 0x3c, 0xfa, 0xd3, 0x85, 0xc1, 0x55, 0x13, 0x58,
|
||||
0x55, 0x7e, 0xbc, 0x00, 0x90, 0x41, 0x5f, 0x94, 0x19, 0x31, 0x65, 0xa8, 0x8c, 0x07, 0x1f, 0x5f,
|
||||
0x4f, 0x9a, 0xf8, 0xe4, 0xd0, 0xbd, 0x2a, 0x33, 0x72, 0xfb, 0xa2, 0x39, 0xe2, 0x1b, 0xd0, 0xff,
|
||||
0xbd, 0xcf, 0x43, 0xd6, 0x19, 0x2a, 0xe3, 0xbe, 0xab, 0xb5, 0xcc, 0x0e, 0x91, 0x41, 0x2f, 0x08,
|
||||
0xc3, 0x9c, 0x8a, 0x82, 0x1d, 0xcb, 0x6a, 0x23, 0x11, 0xe1, 0x24, 0x09, 0x62, 0x62, 0x27, 0x12,
|
||||
0xcb, 0x33, 0xbe, 0x84, 0x6e, 0x51, 0xc6, 0xeb, 0x34, 0x62, 0xa7, 0x92, 0xee, 0x15, 0x0e, 0x41,
|
||||
0x0b, 0xa9, 0xd8, 0xe4, 0x3c, 0x13, 0x3c, 0x4d, 0x58, 0xb7, 0x7e, 0xe7, 0x11, 0x92, 0xc9, 0x5d,
|
||||
0x96, 0x45, 0x25, 0xeb, 0xed, 0x93, 0x52, 0xe1, 0x3b, 0x30, 0x78, 0xb2, 0xe5, 0x09, 0x17, 0xe4,
|
||||
0xef, 0x0d, 0xea, 0x50, 0x19, 0xab, 0xee, 0xa0, 0xc1, 0x5e, 0x6d, 0x1c, 0x81, 0x2e, 0xf2, 0x20,
|
||||
0x29, 0xb6, 0x94, 0x07, 0xeb, 0x88, 0x58, 0x5f, 0xba, 0x0e, 0x18, 0x7e, 0x80, 0xe7, 0x39, 0xc5,
|
||||
0x69, 0x75, 0x15, 0x45, 0x5b, 0x3f, 0xa4, 0x42, 0xe4, 0xbb, 0x8d, 0x60, 0x20, 0xbd, 0x58, 0xd7,
|
||||
0x3c, 0x8a, 0xb6, 0xd3, 0x7d, 0x05, 0x5f, 0x81, 0xba, 0xf9, 0x15, 0xf0, 0xa4, 0xda, 0x8e, 0x36,
|
||||
0x54, 0xc6, 0xa7, 0x6e, 0x4f, 0x6a, 0x3b, 0xc4, 0x6b, 0xd0, 0x43, 0xca, 0xa2, 0xb4, 0xf4, 0x0b,
|
||||
0x11, 0x08, 0x62, 0xba, 0xdc, 0xfd, 0xdb, 0xa7, 0x76, 0x3f, 0x99, 0x4a, 0xb3, 0x57, 0x79, 0xab,
|
||||
0xd1, 0x5b, 0x51, 0xfd, 0x85, 0x75, 0x50, 0xd0, 0x97, 0xcf, 0x3e, 0x8f, 0x83, 0x7b, 0x62, 0x67,
|
||||
0xf5, 0x76, 0x6a, 0x66, 0x57, 0x08, 0xcf, 0x41, 0x0d, 0x69, 0xc3, 0xe3, 0x20, 0x2a, 0xd8, 0x40,
|
||||
0xb6, 0xd1, 0xea, 0xba, 0x56, 0xdd, 0x46, 0x39, 0x33, 0x64, 0xb4, 0xd5, 0xe8, 0x81, 0x99, 0xe5,
|
||||
0xfc, 0x81, 0x47, 0x74, 0x4f, 0x85, 0x1f, 0xd1, 0x03, 0x45, 0xcc, 0x94, 0x7d, 0x8e, 0x9f, 0xec,
|
||||
0x73, 0xd9, 0x06, 0x66, 0x95, 0xdf, 0x35, 0xb2, 0x43, 0x30, 0xb2, 0x40, 0x7b, 0x34, 0x0b, 0x6a,
|
||||
0xd0, 0xbb, 0x71, 0xbe, 0x3b, 0x8b, 0x5b, 0xc7, 0x3c, 0x42, 0x80, 0xee, 0xb7, 0x4b, 0x7b, 0x66,
|
||||
0x4d, 0x4d, 0x05, 0x0d, 0xd0, 0x6c, 0xc7, 0x5f, 0xba, 0x8b, 0x6b, 0xd7, 0xf2, 0x3c, 0xb3, 0x83,
|
||||
0x3a, 0xa8, 0x53, 0x6b, 0x39, 0x5b, 0xdc, 0x59, 0x53, 0xf3, 0x78, 0x64, 0x83, 0xf1, 0xdf, 0x53,
|
||||
0x55, 0x62, 0x71, 0xeb, 0x58, 0xae, 0x3f, 0xb3, 0x7e, 0x58, 0x33, 0xf3, 0x08, 0x4d, 0xd0, 0xe7,
|
||||
0x97, 0xde, 0xaa, 0x25, 0x0a, 0x3e, 0x03, 0xe3, 0x6a, 0x31, 0x9f, 0xdf, 0x38, 0xf6, 0xea, 0x6e,
|
||||
0x0f, 0x3b, 0x5f, 0xcf, 0x7e, 0x6a, 0x93, 0xf7, 0x17, 0xcd, 0x40, 0xeb, 0xae, 0x3c, 0x7d, 0xfa,
|
||||
0x1b, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x8d, 0x9f, 0x59, 0x5d, 0x03, 0x00, 0x00,
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
syntax = "proto3";
|
||||
|
||||
option go_package = "./;protobuf";
|
||||
package protobuf;
|
||||
|
||||
import "enums.proto";
|
||||
|
||||
message CommunityToken {
|
||||
CommunityTokenType token_type = 1;
|
||||
string community_id = 2;
|
||||
string address = 3;
|
||||
string name = 4;
|
||||
string symbol = 5;
|
||||
string description = 6;
|
||||
string supply = 7;
|
||||
bool infinite_supply = 8;
|
||||
bool transferable = 9;
|
||||
bool remote_self_destruct = 10;
|
||||
int32 chain_id = 11;
|
||||
DeployState deploy_state = 12;
|
||||
string base64_image = 13;
|
||||
int32 decimals = 14;
|
||||
string deployer = 15;
|
||||
PrivilegesLevel privileges_level = 16;
|
||||
|
||||
enum DeployState {
|
||||
UNKNOWN = 0;
|
||||
FAILED = 1;
|
||||
IN_PROGRESS = 2;
|
||||
DEPLOYED = 3;
|
||||
}
|
||||
|
||||
enum PrivilegesLevel {
|
||||
OWNER_LEVEL = 0;
|
||||
MASTER_LEVEL = 1;
|
||||
COMMUNITY_LEVEL = 2;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
//go:generate protoc --go_out=. ./chat_message.proto ./application_metadata_message.proto ./membership_update_message.proto ./command.proto ./contact.proto ./pairing.proto ./push_notifications.proto ./emoji_reaction.proto ./enums.proto ./group_chat_invitation.proto ./chat_identity.proto ./communities.proto ./pin_message.proto ./anon_metrics.proto ./status_update.proto ./sync_settings.proto ./contact_verification.proto ./community_update.proto ./url_data.proto ./community_privileged_user_sync_message.proto
|
||||
//go:generate protoc --go_out=. ./chat_message.proto ./application_metadata_message.proto ./membership_update_message.proto ./command.proto ./contact.proto ./pairing.proto ./push_notifications.proto ./emoji_reaction.proto ./enums.proto ./group_chat_invitation.proto ./chat_identity.proto ./communities.proto ./pin_message.proto ./anon_metrics.proto ./status_update.proto ./sync_settings.proto ./contact_verification.proto ./community_update.proto ./url_data.proto ./community_privileged_user_sync_message.proto ./community_token.proto
|
||||
|
||||
func Unmarshal(payload []byte) (*ApplicationMetadataMessage, error) {
|
||||
var message ApplicationMetadataMessage
|
||||
|
|
Loading…
Reference in New Issue