Skip to content

Commit

Permalink
chore(wallet-community)_: move community transactions to the wallet r…
Browse files Browse the repository at this point in the history
…outer

- new file `contracts/community-tokens/contracts.go` added to unify contracts creation

- the following community related path processors added:
- `CommunityBurnProcessor`
- `CommunityDeployAssetsProcessor`
- `CommunityDeployCollectiblesProcessor`
- `CommunityDeployOwnerTokenProcessor`
- `CommunityMintTokensProcessor`
- `CommunityRemoteBurnProcessor`
- `CommunitySetSignerPubKeyProcessor`

- `SendType` extended with appropriate options

- added endpoints to duplicated `communitytokens` api:
- `StoreDeployedCollectibles`
- `StoreDeployedOwnerToken`
- `StoreDeployedAssets`

- removed endpoints from duplicated `communitytokens` api:
- `DeployCollectibles`
- `DeployOwnerToken`
- `ReTrackOwnerTokenDeploymentTransaction`
- `DeployAssets`
- `DeployCollectiblesEstimate`
- `DeployAssetsEstimate`
- `DeployOwnerTokenEstimate`
- `EstimateMintTokens`
- `EstimateRemoteBurn`
- `EstimateBurn`
- `EstimateSetSignerPubKey`
- `NewOwnerTokenInstance`
- `NewCommunityTokenDeployerInstance`
- `NewCommunityOwnerTokenRegistryInstance`
- `NewCollectiblesInstance`
- `NewAssetsInstance`
- `MintTokens`
- `RemoteBurn`
- `GetCollectiblesContractInstance`
- `GetAssetContractInstance`
- `Burn`
- `SetSignerPubKey`

- `Path` type extended with new property:
- `UsedContractAddress` - an address of the contract that will be used for the transaction
  • Loading branch information
saledjenic committed Jan 23, 2025
1 parent 37aeb40 commit d442b09
Show file tree
Hide file tree
Showing 35 changed files with 2,047 additions and 1,513 deletions.
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("could not initialize CommunityTokensContractMaker with an rpc client")
}
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 @@ -513,7 +513,7 @@ func (b *StatusNode) CommunityTokensService() *communitytokens.Service {

func (b *StatusNode) CommunityTokensServiceV2() *communitytokensv2.Service {
if b.communityTokensSrvcV2 == nil {
b.communityTokensSrvcV2 = communitytokensv2.NewService(b.rpcClient, b.gethAccountManager, b.pendingTracker, b.config, b.appDB, &b.walletFeed, b.transactor)
b.communityTokensSrvcV2 = communitytokensv2.NewService(b.rpcClient, b.gethAccountManager, b.config, b.appDB, &b.walletFeed, b.transactor)
}
return b.communityTokensSrvcV2
}
Expand Down
8 changes: 4 additions & 4 deletions services/communitytokens/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func (api *API) DeployCollectibles(ctx context.Context, chainID uint64, deployme
address, tx, _, err := collectibles.DeployCollectibles(transactOpts, ethClient, deploymentParameters.Name,
deploymentParameters.Symbol, deploymentParameters.GetSupply(),
deploymentParameters.RemoteSelfDestruct, deploymentParameters.Transferable,
deploymentParameters.TokenURI, common.HexToAddress(deploymentParameters.OwnerTokenAddress),
common.HexToAddress(deploymentParameters.MasterTokenAddress))
deploymentParameters.TokenURI, deploymentParameters.OwnerTokenAddress,
deploymentParameters.MasterTokenAddress)
if err != nil {
logutils.ZapLogger().Error(err.Error())
return responses.DeploymentDetails{}, err
Expand Down Expand Up @@ -229,8 +229,8 @@ func (api *API) DeployAssets(ctx context.Context, chainID uint64, deploymentPara
address, tx, _, err := assets.DeployAssets(transactOpts, ethClient, deploymentParameters.Name,
deploymentParameters.Symbol, decimals, deploymentParameters.GetSupply(),
deploymentParameters.TokenURI,
common.HexToAddress(deploymentParameters.OwnerTokenAddress),
common.HexToAddress(deploymentParameters.MasterTokenAddress))
deploymentParameters.OwnerTokenAddress,
deploymentParameters.MasterTokenAddress)
if err != nil {
logutils.ZapLogger().Error(err.Error())
return responses.DeploymentDetails{}, err
Expand Down
2 changes: 1 addition & 1 deletion services/communitytokens/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (s *Service) handleWalletEvent(event walletevent.Event) {
errorStr = tokenErr.Error()
}

signal.SendCommunityTokenTransactionStatusSignal(string(pendingTransaction.Type), p.Status == transactions.Success, pendingTransaction.Hash,
signal.SendCommunityTokenTransactionStatusSignal(0, p.Status == transactions.Success, pendingTransaction.Hash,
communityToken, ownerToken, masterToken, errorStr)
}
}
Expand Down
Loading

0 comments on commit d442b09

Please sign in to comment.