fix(GetAllCommunityTokens): Add GetAllCommunityTokens function
Issue #10254
This commit is contained in:
parent
83998272dd
commit
4935848287
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue