2023-08-25 15:36:39 +00:00
|
|
|
package communitytokens
|
2023-01-12 15:17:21 +00:00
|
|
|
|
|
|
|
import (
|
2023-03-10 14:09:34 +00:00
|
|
|
"database/sql"
|
|
|
|
|
2023-01-12 15:17:21 +00:00
|
|
|
"github.com/ethereum/go-ethereum/p2p"
|
|
|
|
ethRpc "github.com/ethereum/go-ethereum/rpc"
|
|
|
|
"github.com/status-im/status-go/account"
|
|
|
|
"github.com/status-im/status-go/params"
|
|
|
|
"github.com/status-im/status-go/rpc"
|
2023-08-01 18:50:30 +00:00
|
|
|
"github.com/status-im/status-go/transactions"
|
2023-01-12 15:17:21 +00:00
|
|
|
)
|
|
|
|
|
2023-08-22 17:48:42 +00:00
|
|
|
type ServiceInterface interface {
|
|
|
|
GetCollectibleContractData(chainID uint64, contractAddress string) (*CollectibleContractData, error)
|
|
|
|
GetAssetContractData(chainID uint64, contractAddress string) (*AssetContractData, error)
|
2023-08-29 13:17:37 +00:00
|
|
|
DeploymentSignatureDigest(chainID uint64, addressFrom string, communityID string) ([]byte, error)
|
2023-08-22 17:48:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-12 15:17:21 +00:00
|
|
|
// Collectibles service
|
|
|
|
type Service struct {
|
2023-08-22 17:48:42 +00:00
|
|
|
manager *Manager
|
|
|
|
accountsManager *account.GethManager
|
|
|
|
pendingTracker *transactions.PendingTxTracker
|
|
|
|
config *params.NodeConfig
|
|
|
|
db *Database
|
2023-01-12 15:17:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns a new Collectibles Service.
|
2023-08-01 18:50:30 +00:00
|
|
|
func NewService(rpcClient *rpc.Client, accountsManager *account.GethManager, pendingTracker *transactions.PendingTxTracker, config *params.NodeConfig, appDb *sql.DB) *Service {
|
2023-01-12 15:17:21 +00:00
|
|
|
return &Service{
|
2023-08-22 17:48:42 +00:00
|
|
|
manager: &Manager{rpcClient: rpcClient},
|
|
|
|
accountsManager: accountsManager,
|
|
|
|
pendingTracker: pendingTracker,
|
|
|
|
config: config,
|
|
|
|
db: NewCommunityTokensDatabase(appDb),
|
2023-01-12 15:17:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Protocols returns a new protocols list. In this case, there are none.
|
|
|
|
func (s *Service) Protocols() []p2p.Protocol {
|
|
|
|
return []p2p.Protocol{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// APIs returns a list of new APIs.
|
|
|
|
func (s *Service) APIs() []ethRpc.API {
|
|
|
|
return []ethRpc.API{
|
|
|
|
{
|
2023-08-25 15:36:39 +00:00
|
|
|
Namespace: "communitytokens",
|
2023-01-12 15:17:21 +00:00
|
|
|
Version: "0.1.0",
|
2023-08-22 17:48:42 +00:00
|
|
|
Service: NewAPI(s),
|
2023-01-12 15:17:21 +00:00
|
|
|
Public: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start is run when a service is started.
|
|
|
|
func (s *Service) Start() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop is run when a service is stopped.
|
|
|
|
func (s *Service) Stop() error {
|
|
|
|
return nil
|
|
|
|
}
|
2023-08-22 17:48:42 +00:00
|
|
|
|
|
|
|
func (s *Service) GetCollectibleContractData(chainID uint64, contractAddress string) (*CollectibleContractData, error) {
|
|
|
|
return s.manager.GetCollectibleContractData(chainID, contractAddress)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Service) GetAssetContractData(chainID uint64, contractAddress string) (*AssetContractData, error) {
|
|
|
|
return s.manager.GetAssetContractData(chainID, contractAddress)
|
|
|
|
}
|
2023-08-29 13:17:37 +00:00
|
|
|
|
|
|
|
func (s *Service) DeploymentSignatureDigest(chainID uint64, addressFrom string, communityID string) ([]byte, error) {
|
|
|
|
return s.manager.DeploymentSignatureDigest(chainID, addressFrom, communityID)
|
|
|
|
}
|