fix(Collectibles): Trigger transaction event when creating transaction
Issue #11565
This commit is contained in:
parent
71ca35bf34
commit
7d9092e295
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,10 +99,10 @@ const (
|
|||
SetPubKey PendingTrxType = "SetPubKey"
|
||||
BuyStickerPack PendingTrxType = "BuyStickerPack"
|
||||
WalletTransfer PendingTrxType = "WalletTransfer"
|
||||
CollectibleDeployment PendingTrxType = "CollectibleDeployment"
|
||||
CollectibleAirdrop PendingTrxType = "CollectibleAirdrop"
|
||||
CollectibleRemoteSelfDestruct PendingTrxType = "CollectibleRemoteSelfDestruct"
|
||||
CollectibleBurn PendingTrxType = "CollectibleBurn"
|
||||
DeployCommunityToken PendingTrxType = "DeployCommunityToken"
|
||||
AirdropCommunityToken PendingTrxType = "AirdropCommunityToken"
|
||||
RemoteDestructCollectible PendingTrxType = "RemoteDestructCollectible"
|
||||
BurnCommunityToken PendingTrxType = "BurnCommunityToken"
|
||||
)
|
||||
|
||||
type PendingTransaction struct {
|
||||
|
|
Loading…
Reference in New Issue