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 Dec 18, 2024
1 parent 5ae936f commit 51fb57d
Show file tree
Hide file tree
Showing 27 changed files with 1,607 additions and 1,316 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)
}
Loading

0 comments on commit 51fb57d

Please sign in to comment.