Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(community)_: duplicated community tokens package #6293

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/geth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,10 @@ func (b *GethStatusBackend) injectAccountsIntoWakuService(w wakutypes.WakuKeyMan
}

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.CommunityTokensService(), b.statusNode.WakuV2Service(), logutils.ZapLogger(), b.statusNode.AccountsFeed()); 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(), b.statusNode.WakuV2Service(),
logutils.ZapLogger(), b.statusNode.AccountsFeed()); err != nil {
return err
}
// Set initial connection state
Expand Down
78 changes: 78 additions & 0 deletions contracts/community-tokens/contracts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package communitytokens

import (
"errors"

"github.com/ethereum/go-ethereum/common"
"github.com/status-im/status-go/contracts/community-tokens/assets"
"github.com/status-im/status-go/contracts/community-tokens/collectibles"
communitytokendeployer "github.com/status-im/status-go/contracts/community-tokens/deployer"
"github.com/status-im/status-go/contracts/community-tokens/mastertoken"
"github.com/status-im/status-go/contracts/community-tokens/ownertoken"
communityownertokenregistry "github.com/status-im/status-go/contracts/community-tokens/registry"
"github.com/status-im/status-go/rpc"
)

type CommunityTokensContractMaker struct {
RPCClient rpc.ClientInterface
}

func NewCommunityTokensContractMakerMaker(client rpc.ClientInterface) (*CommunityTokensContractMaker, error) {
if client == nil {
return nil, errors.New("rpc client is required")
}
return &CommunityTokensContractMaker{RPCClient: client}, nil
}

func (c *CommunityTokensContractMaker) NewOwnerTokenInstance(chainID uint64, contractAddress common.Address,
) (*ownertoken.OwnerToken, error) {
backend, err := c.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
}
return ownertoken.NewOwnerToken(contractAddress, backend)
}

func (c *CommunityTokensContractMaker) NewMasterTokenInstance(chainID uint64, contractAddress common.Address,
) (*mastertoken.MasterToken, error) {
backend, err := c.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
}
return mastertoken.NewMasterToken(contractAddress, backend)
}

func (c *CommunityTokensContractMaker) NewCollectiblesInstance(chainID uint64, contractAddress common.Address,
) (*collectibles.Collectibles, error) {
backend, err := c.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
}
return collectibles.NewCollectibles(contractAddress, backend)
}

func (c *CommunityTokensContractMaker) NewAssetsInstance(chainID uint64, contractAddress common.Address,
) (*assets.Assets, error) {
backend, err := c.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
}
return assets.NewAssets(contractAddress, backend)
}

func (c *CommunityTokensContractMaker) NewCommunityTokenDeployerInstance(chainID uint64, contractAddress common.Address,
) (*communitytokendeployer.CommunityTokenDeployer, error) {
backend, err := c.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
}
return communitytokendeployer.NewCommunityTokenDeployer(contractAddress, backend)
}

func (c *CommunityTokensContractMaker) NewCommunityOwnerTokenRegistryInstance(chainID uint64, contractAddress common.Address) (*communityownertokenregistry.CommunityOwnerTokenRegistry, error) {
backend, err := c.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
}
return communityownertokenregistry.NewCommunityOwnerTokenRegistry(contractAddress, backend)
}
2 changes: 1 addition & 1 deletion node/status_node_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func (b *StatusNode) pendingTrackerService(walletFeed *event.Feed) *transactions

func (b *StatusNode) CommunityTokensService() *communitytokens.Service {
if b.communityTokensSrvc == nil {
b.communityTokensSrvc = communitytokens.NewService(b.rpcClient, b.gethAccountManager, b.pendingTracker, b.config, b.appDB, &b.walletFeed, b.transactor)
b.communityTokensSrvc = communitytokens.NewService(b.rpcClient, b.gethAccountManager, b.config, b.appDB, &b.walletFeed, b.transactor)
}
return b.communityTokensSrvc
}
Expand Down
2 changes: 0 additions & 2 deletions protocol/communities/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
walletcommon "github.com/status-im/status-go/services/wallet/common"
"github.com/status-im/status-go/services/wallet/thirdparty"
"github.com/status-im/status-go/services/wallet/token"
"github.com/status-im/status-go/services/wallet/wallettypes"
"github.com/status-im/status-go/signal"

wakutypes "github.com/status-im/status-go/waku/types"
Expand Down Expand Up @@ -270,7 +269,6 @@ type AssetContractData struct {

type CommunityTokensServiceInterface interface {
GetCollectibleContractData(chainID uint64, contractAddress string) (*CollectibleContractData, error)
SetSignerPubKey(ctx context.Context, chainID uint64, contractAddress string, txArgs wallettypes.SendTxArgs, password string, newSignerPubKey string) (string, error)
GetAssetContractData(chainID uint64, contractAddress string) (*AssetContractData, error)
SafeGetSignerPubKey(ctx context.Context, chainID uint64, communityID string) (string, error)
DeploymentSignatureDigest(chainID uint64, addressFrom string, communityID string) ([]byte, error)
Expand Down
5 changes: 0 additions & 5 deletions protocol/communities_messenger_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
walletCommon "github.com/status-im/status-go/services/wallet/common"
"github.com/status-im/status-go/services/wallet/thirdparty"
walletToken "github.com/status-im/status-go/services/wallet/token"
"github.com/status-im/status-go/services/wallet/wallettypes"

wakutypes "github.com/status-im/status-go/waku/types"
)
Expand Down Expand Up @@ -203,10 +202,6 @@ func (c *CollectiblesServiceMock) SetSignerPubkeyForCommunity(communityID []byte
c.Signers[types.EncodeHex(communityID)] = signerPubKey
}

func (c *CollectiblesServiceMock) SetSignerPubKey(ctx context.Context, chainID uint64, contractAddress string, txArgs wallettypes.SendTxArgs, password string, newSignerPubKey string) (string, error) {
return "", nil
}

func (c *CollectiblesServiceMock) GetCollectibleContractData(chainID uint64, contractAddress string) (*communities.CollectibleContractData, error) {
collectibleContractData, dataExists := c.Collectibles[chainID][contractAddress]
if dataExists {
Expand Down
Loading