diff --git a/VERSION b/VERSION index f1c514333..ce66bc27e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.149.2 +0.150.0 diff --git a/protocol/communities/manager.go b/protocol/communities/manager.go index fd32500f2..ed32bc425 100644 --- a/protocol/communities/manager.go +++ b/protocol/communities/manager.go @@ -3251,6 +3251,10 @@ func (m *Manager) GetCommunityTokens(communityID string) ([]*CommunityToken, err return m.persistence.GetCommunityTokens(communityID) } +func (m *Manager) GetAllCommunityTokens() ([]*CommunityToken, error) { + return m.persistence.GetAllCommunityTokens() +} + func (m *Manager) ImageToBase64(uri string) string { file, err := os.Open(uri) if err != nil { diff --git a/protocol/communities/persistence.go b/protocol/communities/persistence.go index ff1cd1085..b623be857 100644 --- a/protocol/communities/persistence.go +++ b/protocol/communities/persistence.go @@ -909,6 +909,18 @@ func (p *Persistence) GetCommunityChatIDs(communityID types.HexBytes) ([]string, return ids, nil } +func (p *Persistence) GetAllCommunityTokens() ([]*CommunityToken, error) { + rows, err := p.db.Query(`SELECT community_id, address, type, name, symbol, description, supply, + infinite_supply, transferable, remote_self_destruct, chain_id, deploy_state, image_base64 + FROM community_tokens`) + if err != nil { + return nil, err + } + defer rows.Close() + + return p.getCommunityTokensInternal(rows) +} + func (p *Persistence) GetCommunityTokens(communityID string) ([]*CommunityToken, error) { rows, err := p.db.Query(`SELECT community_id, address, type, name, symbol, description, supply, infinite_supply, transferable, remote_self_destruct, chain_id, deploy_state, image_base64 @@ -918,6 +930,10 @@ func (p *Persistence) GetCommunityTokens(communityID string) ([]*CommunityToken, } defer rows.Close() + return p.getCommunityTokensInternal(rows) +} + +func (p *Persistence) getCommunityTokensInternal(rows *sql.Rows) ([]*CommunityToken, error) { tokens := []*CommunityToken{} for rows.Next() { diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index 934c7c965..6828d0c00 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -3540,6 +3540,10 @@ func (m *Messenger) GetCommunityTokens(communityID string) ([]*communities.Commu return m.communitiesManager.GetCommunityTokens(communityID) } +func (m *Messenger) GetAllCommunityTokens() ([]*communities.CommunityToken, error) { + return m.communitiesManager.GetAllCommunityTokens() +} + func (m *Messenger) AddCommunityToken(token *communities.CommunityToken) (*communities.CommunityToken, error) { return m.communitiesManager.AddCommunityToken(token) } diff --git a/services/ext/api.go b/services/ext/api.go index b124376a7..90a1b72b3 100644 --- a/services/ext/api.go +++ b/services/ext/api.go @@ -1278,6 +1278,10 @@ func (api *PublicAPI) GetCommunityTokens(communityID string) ([]*communities.Com return api.service.messenger.GetCommunityTokens(communityID) } +func (api *PublicAPI) GetAllCommunityTokens() ([]*communities.CommunityToken, error) { + return api.service.messenger.GetAllCommunityTokens() +} + func (api *PublicAPI) AddCommunityToken(token *communities.CommunityToken) (*communities.CommunityToken, error) { return api.service.messenger.AddCommunityToken(token) }