feat(Collectibles): Change Collectibles service name to CommunityTokens.

Issue #12011
This commit is contained in:
Michal Iskierko 2023-08-25 17:36:39 +02:00 committed by Michał Iskierko
parent 9a1443d716
commit 8425e6d238
19 changed files with 79 additions and 83 deletions

View File

@ -1 +1 @@
0.165.4
0.166.0

View File

@ -2228,7 +2228,7 @@ func (b *GethStatusBackend) injectAccountsIntoWakuService(w types.WakuKeyManager
}
if st != nil {
if err := st.InitProtocol(b.statusNode.GethNode().Config().Name, identity, b.appDB, b.walletDB, b.statusNode.HTTPServer(), b.multiaccountsDB, acc, b.accountManager, b.statusNode.RPCClient(), b.statusNode.WalletService(), b.statusNode.CollectiblesService(), logutils.ZapLogger()); err != nil {
if err := st.InitProtocol(b.statusNode.GethNode().Config().Name, identity, b.appDB, b.walletDB, b.statusNode.HTTPServer(), b.multiaccountsDB, acc, b.accountManager, b.statusNode.RPCClient(), b.statusNode.WalletService(), b.statusNode.CommunityTokensService(), logutils.ZapLogger()); err != nil {
return err
}
// Set initial connection state

View File

@ -36,7 +36,7 @@ import (
appmetricsservice "github.com/status-im/status-go/services/appmetrics"
"github.com/status-im/status-go/services/browsers"
"github.com/status-im/status-go/services/chat"
"github.com/status-im/status-go/services/collectibles"
"github.com/status-im/status-go/services/communitytokens"
"github.com/status-im/status-go/services/ens"
"github.com/status-im/status-go/services/gif"
localnotifications "github.com/status-im/status-go/services/local-notifications"
@ -123,7 +123,7 @@ type StatusNode struct {
wakuV2Srvc *wakuv2.Waku
wakuV2ExtSrvc *wakuv2ext.Service
ensSrvc *ens.Service
collectiblesSrvc *collectibles.Service
communityTokensSrvc *communitytokens.Service
gifSrvc *gif.Service
stickersSrvc *stickers.Service
chatSrvc *chat.Service
@ -503,7 +503,7 @@ func (n *StatusNode) stop() error {
n.wakuV2Srvc = nil
n.wakuV2ExtSrvc = nil
n.ensSrvc = nil
n.collectiblesSrvc = nil
n.communityTokensSrvc = nil
n.stickersSrvc = nil
n.publicMethods = make(map[string]bool)
n.pendingTracker = nil

View File

@ -28,7 +28,7 @@ import (
appmetricsservice "github.com/status-im/status-go/services/appmetrics"
"github.com/status-im/status-go/services/browsers"
"github.com/status-im/status-go/services/chat"
"github.com/status-im/status-go/services/collectibles"
"github.com/status-im/status-go/services/communitytokens"
"github.com/status-im/status-go/services/ens"
"github.com/status-im/status-go/services/ext"
"github.com/status-im/status-go/services/gif"
@ -80,7 +80,7 @@ func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *server
services = append(services, b.statusPublicService())
services = append(services, b.pendingTrackerService(&b.walletFeed))
services = append(services, b.ensService(b.timeSourceNow()))
services = append(services, b.collectiblesService())
services = append(services, b.CommunityTokensService())
services = append(services, b.stickersService(accDB))
services = append(services, b.updatesService())
services = appendIf(b.appDB != nil && b.multiaccountsDB != nil, services, b.accountsService(accountsFeed, accDB, mediaServer))
@ -427,11 +427,11 @@ func (b *StatusNode) pendingTrackerService(walletFeed *event.Feed) *transactions
return b.pendingTracker
}
func (b *StatusNode) collectiblesService() *collectibles.Service {
if b.collectiblesSrvc == nil {
b.collectiblesSrvc = collectibles.NewService(b.rpcClient, b.gethAccountManager, b.pendingTracker, b.config, b.appDB)
func (b *StatusNode) CommunityTokensService() *communitytokens.Service {
if b.communityTokensSrvc == nil {
b.communityTokensSrvc = communitytokens.NewService(b.rpcClient, b.gethAccountManager, b.pendingTracker, b.config, b.appDB)
}
return b.collectiblesSrvc
return b.communityTokensSrvc
}
func (b *StatusNode) stickersService(accountDB *accounts.Database) *stickers.Service {
@ -503,10 +503,6 @@ func (b *StatusNode) SetWalletCollectibleMetadataProvider(provider thirdparty.Co
}
}
func (b *StatusNode) CollectiblesService() *collectibles.Service {
return b.collectiblesSrvc
}
func (b *StatusNode) walletService(accountsDB *accounts.Database, accountsFeed *event.Feed, walletFeed *event.Feed) *wallet.Service {
if b.walletSrvc == nil {
b.walletSrvc = wallet.NewService(

View File

@ -39,7 +39,7 @@ import (
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/transport"
"github.com/status-im/status-go/services/collectibles"
"github.com/status-im/status-go/services/communitytokens"
"github.com/status-im/status-go/services/wallet/bigint"
walletcommon "github.com/status-im/status-go/services/wallet/common"
"github.com/status-im/status-go/services/wallet/thirdparty"
@ -80,7 +80,7 @@ type Manager struct {
torrentConfig *params.TorrentConfig
torrentClient *torrent.Client
walletConfig *params.WalletConfig
collectiblesService collectibles.ServiceInterface
communityTokensService communitytokens.ServiceInterface
historyArchiveTasksWaitGroup sync.WaitGroup
historyArchiveTasks sync.Map // stores `chan struct{}`
periodicMembersReevaluationTasks sync.Map // stores `chan struct{}`
@ -115,7 +115,7 @@ type managerOptions struct {
tokenManager TokenManager
collectiblesManager CollectiblesManager
walletConfig *params.WalletConfig
collectiblesService collectibles.ServiceInterface
communityTokensService communitytokens.ServiceInterface
}
type TokenManager interface {
@ -191,9 +191,9 @@ func WithWalletConfig(walletConfig *params.WalletConfig) ManagerOption {
}
}
func WithCollectiblesService(collectiblesService collectibles.ServiceInterface) ManagerOption {
func WithCommunityTokensService(communityTokensService communitytokens.ServiceInterface) ManagerOption {
return func(opts *managerOptions) {
opts.collectiblesService = collectiblesService
opts.communityTokensService = communityTokensService
}
}
@ -251,8 +251,8 @@ func NewManager(identity *ecdsa.PrivateKey, db *sql.DB, encryptor *encryption.Pr
manager.walletConfig = managerConfig.walletConfig
}
if managerConfig.collectiblesService != nil {
manager.collectiblesService = managerConfig.collectiblesService
if managerConfig.communityTokensService != nil {
manager.communityTokensService = managerConfig.communityTokensService
}
if verifier != nil {
@ -4607,7 +4607,7 @@ func (m *Manager) HandleCommunityTokensMetadata(community *Community) error {
switch tokenMetadata.TokenType {
case protobuf.CommunityTokenType_ERC721:
contractData, err := m.collectiblesService.GetCollectibleContractData(chainID, address)
contractData, err := m.communityTokensService.GetCollectibleContractData(chainID, address)
if err != nil {
return err
}
@ -4618,7 +4618,7 @@ func (m *Manager) HandleCommunityTokensMetadata(community *Community) error {
communityToken.InfiniteSupply = contractData.InfiniteSupply
case protobuf.CommunityTokenType_ERC20:
contractData, err := m.collectiblesService.GetAssetContractData(chainID, address)
contractData, err := m.communityTokensService.GetAssetContractData(chainID, address)
if err != nil {
return err
}

View File

@ -16,7 +16,7 @@ import (
"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/services/collectibles"
"github.com/status-im/status-go/services/communitytokens"
"github.com/status-im/status-go/services/wallet/bigint"
)
@ -1674,7 +1674,7 @@ func testEventSenderCannotEditPrivilegedCommunityPermission(base CommunityEvents
func testAddAndSyncTokenFromControlNode(base CommunityEventsTestsInterface, community *communities.Community,
privilegesLvl token.PrivilegesLevel) {
tokenERC721 := createCommunityToken(community.IDString(), privilegesLvl)
addCommunityTokenToCollectiblesService(base, tokenERC721)
addCommunityTokenToCommunityTokensService(base, tokenERC721)
s := base.GetSuite()
@ -1754,7 +1754,7 @@ func createCommunityToken(communityID string, privilegesLevel token.PrivilegesLe
func testAddAndSyncTokenFromEventSenderByControlNode(base CommunityEventsTestsInterface, community *communities.Community,
privilegesLvl token.PrivilegesLevel) {
tokenERC721 := createCommunityToken(community.IDString(), privilegesLvl)
addCommunityTokenToCollectiblesService(base, tokenERC721)
addCommunityTokenToCommunityTokensService(base, tokenERC721)
s := base.GetSuite()
@ -1812,7 +1812,7 @@ func testAddAndSyncTokenFromEventSenderByControlNode(base CommunityEventsTestsIn
func testEventSenderAddTokenMasterAndOwnerToken(base CommunityEventsTestsInterface, community *communities.Community) {
ownerToken := createCommunityToken(community.IDString(), token.OwnerLevel)
addCommunityTokenToCollectiblesService(base, ownerToken)
addCommunityTokenToCommunityTokensService(base, ownerToken)
s := base.GetSuite()
@ -1833,8 +1833,8 @@ func testEventSenderAddTokenMasterAndOwnerToken(base CommunityEventsTestsInterfa
s.Require().Error(err, communities.ErrInvalidManageTokensPermission)
}
func addCommunityTokenToCollectiblesService(base CommunityEventsTestsInterface, token *token.CommunityToken) {
data := &collectibles.CollectibleContractData{
func addCommunityTokenToCommunityTokensService(base CommunityEventsTestsInterface, token *token.CommunityToken) {
data := &communitytokens.CollectibleContractData{
TotalSupply: token.Supply,
Transferable: token.Transferable,
RemoteBurnable: token.RemoteSelfDestruct,

View File

@ -30,7 +30,7 @@ import (
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/services/collectibles"
"github.com/status-im/status-go/services/communitytokens"
walletToken "github.com/status-im/status-go/services/wallet/token"
"github.com/status-im/status-go/t/helpers"
"github.com/status-im/status-go/walletdatabase"
@ -81,11 +81,11 @@ func (m *TokenManagerMock) UpsertCustom(token walletToken.Token) error {
}
type CollectiblesServiceMock struct {
Collectibles map[uint64]map[string]*collectibles.CollectibleContractData
Assets map[uint64]map[string]*collectibles.AssetContractData
Collectibles map[uint64]map[string]*communitytokens.CollectibleContractData
Assets map[uint64]map[string]*communitytokens.AssetContractData
}
func (c *CollectiblesServiceMock) GetCollectibleContractData(chainID uint64, contractAddress string) (*collectibles.CollectibleContractData, error) {
func (c *CollectiblesServiceMock) GetCollectibleContractData(chainID uint64, contractAddress string) (*communitytokens.CollectibleContractData, error) {
collectibleContractData, dataExists := c.Collectibles[chainID][contractAddress]
if dataExists {
return collectibleContractData, nil
@ -93,7 +93,7 @@ func (c *CollectiblesServiceMock) GetCollectibleContractData(chainID uint64, con
return nil, nil
}
func (c *CollectiblesServiceMock) GetAssetContractData(chainID uint64, contractAddress string) (*collectibles.AssetContractData, error) {
func (c *CollectiblesServiceMock) GetAssetContractData(chainID uint64, contractAddress string) (*communitytokens.AssetContractData, error) {
assetsContractData, dataExists := c.Assets[chainID][contractAddress]
if dataExists {
return assetsContractData, nil
@ -101,24 +101,24 @@ func (c *CollectiblesServiceMock) GetAssetContractData(chainID uint64, contractA
return nil, nil
}
func (c *CollectiblesServiceMock) SetMockCollectibleContractData(chainID uint64, contractAddress string, collectible *collectibles.CollectibleContractData) {
func (c *CollectiblesServiceMock) SetMockCollectibleContractData(chainID uint64, contractAddress string, collectible *communitytokens.CollectibleContractData) {
if c.Collectibles == nil {
c.Collectibles = make(map[uint64]map[string]*collectibles.CollectibleContractData)
c.Collectibles = make(map[uint64]map[string]*communitytokens.CollectibleContractData)
}
c.Collectibles[chainID] = make(map[string]*collectibles.CollectibleContractData)
c.Collectibles[chainID] = make(map[string]*communitytokens.CollectibleContractData)
c.Collectibles[chainID][contractAddress] = collectible
}
func (c *CollectiblesServiceMock) SetMockAssetContractData(chainID uint64, contractAddress string, assetData *collectibles.AssetContractData) {
func (c *CollectiblesServiceMock) SetMockAssetContractData(chainID uint64, contractAddress string, assetData *communitytokens.AssetContractData) {
if c.Assets == nil {
c.Assets = make(map[uint64]map[string]*collectibles.AssetContractData)
c.Assets = make(map[uint64]map[string]*communitytokens.AssetContractData)
}
c.Assets[chainID] = make(map[string]*collectibles.AssetContractData)
c.Assets[chainID] = make(map[string]*communitytokens.AssetContractData)
c.Assets[chainID][contractAddress] = assetData
}
func newMessenger(s *suite.Suite, shh types.Waku, logger *zap.Logger, password string, walletAddresses []string,
mockedBalances *map[uint64]map[gethcommon.Address]map[gethcommon.Address]*hexutil.Big, collectiblesService collectibles.ServiceInterface) *Messenger {
mockedBalances *map[uint64]map[gethcommon.Address]map[gethcommon.Address]*hexutil.Big, collectiblesService communitytokens.ServiceInterface) *Messenger {
accountsManagerMock := &AccountManagerMock{}
accountsManagerMock.AccountsMap = make(map[string]string)
for _, walletAddress := range walletAddresses {
@ -161,7 +161,7 @@ func newMessenger(s *suite.Suite, shh types.Waku, logger *zap.Logger, password s
}
func newCommunitiesTestMessenger(shh types.Waku, privateKey *ecdsa.PrivateKey, logger *zap.Logger, accountsManager account.Manager,
tokenManager communities.TokenManager, collectiblesService collectibles.ServiceInterface) (*Messenger, error) {
tokenManager communities.TokenManager, collectiblesService communitytokens.ServiceInterface) (*Messenger, error) {
tmpfile, err := ioutil.TempFile("", "accounts-tests-")
if err != nil {
return nil, err
@ -195,7 +195,7 @@ func newCommunitiesTestMessenger(shh types.Waku, privateKey *ecdsa.PrivateKey, l
}
if collectiblesService != nil {
options = append(options, WithCollectiblesService(collectiblesService))
options = append(options, WithCommunityTokensService(collectiblesService))
}
m, err := NewMessenger(

View File

@ -434,8 +434,8 @@ func NewMessenger(
managerOptions = append(managerOptions, communities.WithWalletConfig(c.walletConfig))
}
if c.collectiblesService != nil {
managerOptions = append(managerOptions, communities.WithCollectiblesService(c.collectiblesService))
if c.communityTokensService != nil {
managerOptions = append(managerOptions, communities.WithCommunityTokensService(c.communityTokensService))
}
communitiesManager, err := communities.NewManager(identity, database, encryptionProtocol, logger, ensVerifier, transp, c.torrentConfig, managerOptions...)

View File

@ -7,6 +7,7 @@ import (
"github.com/status-im/status-go/rpc"
"github.com/status-im/status-go/server"
"github.com/status-im/status-go/services/browsers"
"github.com/status-im/status-go/services/communitytokens"
"go.uber.org/zap"
@ -24,7 +25,6 @@ import (
"github.com/status-im/status-go/protocol/pushnotificationserver"
"github.com/status-im/status-go/protocol/transport"
"github.com/status-im/status-go/protocol/wakusync"
"github.com/status-im/status-go/services/collectibles"
"github.com/status-im/status-go/services/mailservers"
"github.com/status-im/status-go/services/wallet"
)
@ -87,7 +87,7 @@ type config struct {
torrentConfig *params.TorrentConfig
walletConfig *params.WalletConfig
walletService *wallet.Service
collectiblesService collectibles.ServiceInterface
communityTokensService communitytokens.ServiceInterface
httpServer *server.MediaServer
rpcClient *rpc.Client
tokenManager communities.TokenManager
@ -336,9 +336,9 @@ func WithWalletService(s *wallet.Service) Option {
}
}
func WithCollectiblesService(s collectibles.ServiceInterface) Option {
func WithCommunityTokensService(s communitytokens.ServiceInterface) Option {
return func(c *config) error {
c.collectiblesService = s
c.communityTokensService = s
return nil
}
}

View File

@ -1,4 +1,4 @@
package collectibles
package communitytokens
import (
"context"

View File

@ -1,4 +1,4 @@
package collectibles
package communitytokens
import (
"math/big"

View File

@ -1,4 +1,4 @@
package collectibles
package communitytokens
import "github.com/status-im/status-go/services/wallet/bigint"

View File

@ -1,4 +1,4 @@
package collectibles
package communitytokens
import "github.com/status-im/status-go/services/wallet/bigint"

View File

@ -1,4 +1,4 @@
package collectibles
package communitytokens
import (
"database/sql"

View File

@ -1,4 +1,4 @@
package collectibles
package communitytokens
import (
"database/sql"

View File

@ -1,4 +1,4 @@
package collectibles
package communitytokens
import (
"context"

View File

@ -1,4 +1,4 @@
package collectibles
package communitytokens
import (
"database/sql"
@ -45,7 +45,7 @@ func (s *Service) Protocols() []p2p.Protocol {
func (s *Service) APIs() []ethRpc.API {
return []ethRpc.API{
{
Namespace: "collectibles",
Namespace: "communitytokens",
Version: "0.1.0",
Service: NewAPI(s),
Public: true,

View File

@ -1,4 +1,4 @@
package collectibles
package communitytokens
import (
"context"

View File

@ -44,7 +44,7 @@ import (
"github.com/status-im/status-go/rpc"
"github.com/status-im/status-go/server"
"github.com/status-im/status-go/services/browsers"
"github.com/status-im/status-go/services/collectibles"
"github.com/status-im/status-go/services/communitytokens"
"github.com/status-im/status-go/services/ext/mailservers"
localnotifications "github.com/status-im/status-go/services/local-notifications"
mailserversDB "github.com/status-im/status-go/services/mailservers"
@ -116,7 +116,7 @@ func (s *Service) GetPeer(rawURL string) (*enode.Node, error) {
return enode.ParseV4(rawURL)
}
func (s *Service) InitProtocol(nodeName string, identity *ecdsa.PrivateKey, appDb, walletDb *sql.DB, httpServer *server.MediaServer, multiAccountDb *multiaccounts.Database, acc *multiaccounts.Account, accountManager *account.GethManager, rpcClient *rpc.Client, walletService *wallet.Service, collectiblesService *collectibles.Service, logger *zap.Logger) error {
func (s *Service) InitProtocol(nodeName string, identity *ecdsa.PrivateKey, appDb, walletDb *sql.DB, httpServer *server.MediaServer, multiAccountDb *multiaccounts.Database, acc *multiaccounts.Account, accountManager *account.GethManager, rpcClient *rpc.Client, walletService *wallet.Service, communityTokensService *communitytokens.Service, logger *zap.Logger) error {
var err error
if !s.config.ShhextConfig.PFSEnabled {
return nil
@ -155,7 +155,7 @@ func (s *Service) InitProtocol(nodeName string, identity *ecdsa.PrivateKey, appD
s.multiAccountsDB = multiAccountDb
s.account = acc
options, err := buildMessengerOptions(s.config, identity, appDb, walletDb, httpServer, s.rpcClient, s.multiAccountsDB, acc, envelopesMonitorConfig, s.accountsDB, walletService, collectiblesService, logger, &MessengerSignalsHandler{})
options, err := buildMessengerOptions(s.config, identity, appDb, walletDb, httpServer, s.rpcClient, s.multiAccountsDB, acc, envelopesMonitorConfig, s.accountsDB, walletService, communityTokensService, logger, &MessengerSignalsHandler{})
if err != nil {
return err
}
@ -413,7 +413,7 @@ func buildMessengerOptions(
envelopesMonitorConfig *transport.EnvelopesMonitorConfig,
accountsDB *accounts.Database,
walletService *wallet.Service,
collectiblesService *collectibles.Service,
communityTokensService *communitytokens.Service,
logger *zap.Logger,
messengerSignalsHandler protocol.MessengerSignalsHandler,
) ([]protocol.Option, error) {
@ -436,7 +436,7 @@ func buildMessengerOptions(
protocol.WithMessageCSV(config.OutputMessageCSVEnabled),
protocol.WithWalletConfig(&config.WalletConfig),
protocol.WithWalletService(walletService),
protocol.WithCollectiblesService(collectiblesService),
protocol.WithCommunityTokensService(communityTokensService),
}
if config.ShhextConfig.DataSyncEnabled {