diff --git a/node/status_node_services.go b/node/status_node_services.go index ad49c7382..92402b63b 100644 --- a/node/status_node_services.go +++ b/node/status_node_services.go @@ -419,7 +419,7 @@ func (b *StatusNode) ensService(timesource func() time.Time) *ens.Service { func (b *StatusNode) collectiblesService() *collectibles.Service { if b.collectiblesSrvc == nil { - b.collectiblesSrvc = collectibles.NewService(b.rpcClient, b.gethAccountManager, b.config, b.appDB) + b.collectiblesSrvc = collectibles.NewService(b.rpcClient, b.gethAccountManager, b.rpcFiltersSrvc, b.config, b.appDB) } return b.collectiblesSrvc } diff --git a/services/collectibles/api.go b/services/collectibles/api.go index 0fea47765..9294f8ce6 100644 --- a/services/collectibles/api.go +++ b/services/collectibles/api.go @@ -20,15 +20,17 @@ import ( "github.com/status-im/status-go/params" "github.com/status-im/status-go/protocol/protobuf" "github.com/status-im/status-go/rpc" + "github.com/status-im/status-go/services/rpcfilters" "github.com/status-im/status-go/services/utils" "github.com/status-im/status-go/services/wallet/bigint" "github.com/status-im/status-go/transactions" ) -func NewAPI(rpcClient *rpc.Client, accountsManager *account.GethManager, config *params.NodeConfig, appDb *sql.DB) *API { +func NewAPI(rpcClient *rpc.Client, accountsManager *account.GethManager, rpcFiltersSrvc *rpcfilters.Service, config *params.NodeConfig, appDb *sql.DB) *API { return &API{ RPCClient: rpcClient, accountsManager: accountsManager, + rpcFiltersSrvc: rpcFiltersSrvc, config: config, db: NewCommunityTokensDatabase(appDb), } @@ -37,6 +39,7 @@ func NewAPI(rpcClient *rpc.Client, accountsManager *account.GethManager, config type API struct { RPCClient *rpc.Client accountsManager *account.GethManager + rpcFiltersSrvc *rpcfilters.Service config *params.NodeConfig db *Database } @@ -114,6 +117,13 @@ func (api *API) DeployCollectibles(ctx context.Context, chainID uint64, deployme return DeploymentDetails{}, err } + go api.rpcFiltersSrvc.TriggerTransactionSentToUpstreamEvent(&rpcfilters.PendingTxInfo{ + Hash: tx.Hash(), + Type: string(transactions.DeployCommunityToken), + From: common.Address(txArgs.From), + ChainID: chainID, + }) + return DeploymentDetails{address.Hex(), tx.Hash().Hex()}, nil } @@ -139,6 +149,13 @@ func (api *API) DeployAssets(ctx context.Context, chainID uint64, deploymentPara return DeploymentDetails{}, err } + go api.rpcFiltersSrvc.TriggerTransactionSentToUpstreamEvent(&rpcfilters.PendingTxInfo{ + Hash: tx.Hash(), + Type: string(transactions.DeployCommunityToken), + From: common.Address(txArgs.From), + ChainID: chainID, + }) + return DeploymentDetails{address.Hex(), tx.Hash().Hex()}, nil } @@ -243,6 +260,13 @@ func (api *API) MintCollectibles(ctx context.Context, chainID uint64, contractAd return "", err } + go api.rpcFiltersSrvc.TriggerTransactionSentToUpstreamEvent(&rpcfilters.PendingTxInfo{ + Hash: tx.Hash(), + Type: string(transactions.AirdropCommunityToken), + From: common.Address(txArgs.From), + ChainID: chainID, + }) + return tx.Hash().Hex(), nil } @@ -288,6 +312,13 @@ func (api *API) MintAssets(ctx context.Context, chainID uint64, contractAddress return "", err } + go api.rpcFiltersSrvc.TriggerTransactionSentToUpstreamEvent(&rpcfilters.PendingTxInfo{ + Hash: tx.Hash(), + Type: string(transactions.AirdropCommunityToken), + From: common.Address(txArgs.From), + ChainID: chainID, + }) + return tx.Hash().Hex(), nil } @@ -325,6 +356,13 @@ func (api *API) RemoteBurn(ctx context.Context, chainID uint64, contractAddress return "", err } + go api.rpcFiltersSrvc.TriggerTransactionSentToUpstreamEvent(&rpcfilters.PendingTxInfo{ + Hash: tx.Hash(), + Type: string(transactions.RemoteDestructCollectible), + From: common.Address(txArgs.From), + ChainID: chainID, + }) + return tx.Hash().Hex(), nil } @@ -418,7 +456,6 @@ func (api *API) remainingCollectiblesSupply(ctx context.Context, chainID uint64, } var res = new(big.Int) res.Sub(maxSupply, mintedCount) - fmt.Printf("Remaining: %v for chain: %v and addr: %v", res, chainID, contractAddress) return &bigint.BigInt{Int: res}, nil } @@ -536,6 +573,13 @@ func (api *API) Burn(ctx context.Context, chainID uint64, contractAddress string return "", err } + go api.rpcFiltersSrvc.TriggerTransactionSentToUpstreamEvent(&rpcfilters.PendingTxInfo{ + Hash: tx.Hash(), + Type: string(transactions.BurnCommunityToken), + From: common.Address(txArgs.From), + ChainID: chainID, + }) + return tx.Hash().Hex(), nil } diff --git a/services/collectibles/service.go b/services/collectibles/service.go index 393721a51..918390308 100644 --- a/services/collectibles/service.go +++ b/services/collectibles/service.go @@ -8,6 +8,7 @@ import ( "github.com/status-im/status-go/account" "github.com/status-im/status-go/params" "github.com/status-im/status-go/rpc" + "github.com/status-im/status-go/services/rpcfilters" ) // Collectibles service @@ -16,9 +17,9 @@ type Service struct { } // Returns a new Collectibles Service. -func NewService(rpcClient *rpc.Client, accountsManager *account.GethManager, config *params.NodeConfig, appDb *sql.DB) *Service { +func NewService(rpcClient *rpc.Client, accountsManager *account.GethManager, rpcFiltersSrvc *rpcfilters.Service, config *params.NodeConfig, appDb *sql.DB) *Service { return &Service{ - NewAPI(rpcClient, accountsManager, config, appDb), + NewAPI(rpcClient, accountsManager, rpcFiltersSrvc, config, appDb), } } diff --git a/transactions/pending.go b/transactions/pending.go index 02b85420e..7a86fcf69 100644 --- a/transactions/pending.go +++ b/transactions/pending.go @@ -94,15 +94,15 @@ func (tm *TransactionManager) Stop() { type PendingTrxType string const ( - RegisterENS PendingTrxType = "RegisterENS" - ReleaseENS PendingTrxType = "ReleaseENS" - SetPubKey PendingTrxType = "SetPubKey" - BuyStickerPack PendingTrxType = "BuyStickerPack" - WalletTransfer PendingTrxType = "WalletTransfer" - CollectibleDeployment PendingTrxType = "CollectibleDeployment" - CollectibleAirdrop PendingTrxType = "CollectibleAirdrop" - CollectibleRemoteSelfDestruct PendingTrxType = "CollectibleRemoteSelfDestruct" - CollectibleBurn PendingTrxType = "CollectibleBurn" + RegisterENS PendingTrxType = "RegisterENS" + ReleaseENS PendingTrxType = "ReleaseENS" + SetPubKey PendingTrxType = "SetPubKey" + BuyStickerPack PendingTrxType = "BuyStickerPack" + WalletTransfer PendingTrxType = "WalletTransfer" + DeployCommunityToken PendingTrxType = "DeployCommunityToken" + AirdropCommunityToken PendingTrxType = "AirdropCommunityToken" + RemoteDestructCollectible PendingTrxType = "RemoteDestructCollectible" + BurnCommunityToken PendingTrxType = "BurnCommunityToken" ) type PendingTransaction struct {