feat: Pass community id for wallet activity (#4757)

This commit is contained in:
Cuteivist 2024-02-29 11:22:14 +01:00 committed by GitHub
parent bb3006d747
commit 03b903fd64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 5 deletions

View File

@ -68,6 +68,7 @@ type Entry struct {
chainIDIn *common.ChainID chainIDIn *common.ChainID
transferType *TransferType transferType *TransferType
contractAddress *eth.Address contractAddress *eth.Address
communityID *string
isNew bool // isNew is used to indicate if the entry is newer than session start (changed state also) isNew bool // isNew is used to indicate if the entry is newer than session start (changed state also)
} }
@ -92,6 +93,7 @@ type EntryData struct {
ChainIDIn *common.ChainID `json:"chainIdIn,omitempty"` ChainIDIn *common.ChainID `json:"chainIdIn,omitempty"`
TransferType *TransferType `json:"transferType,omitempty"` TransferType *TransferType `json:"transferType,omitempty"`
ContractAddress *eth.Address `json:"contractAddress,omitempty"` ContractAddress *eth.Address `json:"contractAddress,omitempty"`
CommunityID *string `json:"communityId,omitempty"`
IsNew *bool `json:"isNew,omitempty"` IsNew *bool `json:"isNew,omitempty"`
@ -116,6 +118,7 @@ func (e *Entry) MarshalJSON() ([]byte, error) {
ChainIDIn: e.chainIDIn, ChainIDIn: e.chainIDIn,
TransferType: e.transferType, TransferType: e.transferType,
ContractAddress: e.contractAddress, ContractAddress: e.contractAddress,
CommunityID: e.communityID,
} }
if e.payloadType == MultiTransactionPT { if e.payloadType == MultiTransactionPT {
@ -162,6 +165,7 @@ func (e *Entry) UnmarshalJSON(data []byte) error {
e.chainIDOut = aux.ChainIDOut e.chainIDOut = aux.ChainIDOut
e.chainIDIn = aux.ChainIDIn e.chainIDIn = aux.ChainIDIn
e.transferType = aux.TransferType e.transferType = aux.TransferType
e.communityID = aux.CommunityID
e.isNew = aux.IsNew != nil && *aux.IsNew e.isNew = aux.IsNew != nil && *aux.IsNew
@ -510,14 +514,14 @@ func getActivityEntries(ctx context.Context, deps FilterDependencies, addresses
dbPTrAmount := new(big.Int) dbPTrAmount := new(big.Int)
var dbMtFromAmount, dbMtToAmount, contractType sql.NullString var dbMtFromAmount, dbMtToAmount, contractType sql.NullString
var tokenCode, fromTokenCode, toTokenCode sql.NullString var tokenCode, fromTokenCode, toTokenCode sql.NullString
var methodHash sql.NullString var methodHash, communityID sql.NullString
var transferType *TransferType var transferType *TransferType
var communityMintEventDB sql.NullBool var communityMintEventDB sql.NullBool
var communityMintEvent bool var communityMintEvent bool
err := rows.Scan(&transferHash, &pendingHash, &chainID, &multiTxID, &timestamp, &dbMtType, &dbTrType, &fromAddress, err := rows.Scan(&transferHash, &pendingHash, &chainID, &multiTxID, &timestamp, &dbMtType, &dbTrType, &fromAddress,
&toAddressDB, &ownerAddressDB, &dbTrAmount, (*bigint.SQLBigIntBytes)(dbPTrAmount), &dbMtFromAmount, &dbMtToAmount, &aggregatedStatus, &aggregatedCount, &toAddressDB, &ownerAddressDB, &dbTrAmount, (*bigint.SQLBigIntBytes)(dbPTrAmount), &dbMtFromAmount, &dbMtToAmount, &aggregatedStatus, &aggregatedCount,
&tokenAddress, &dbTokenID, &tokenCode, &fromTokenCode, &toTokenCode, &outChainIDDB, &inChainIDDB, &contractType, &tokenAddress, &dbTokenID, &tokenCode, &fromTokenCode, &toTokenCode, &outChainIDDB, &inChainIDDB, &contractType,
&contractAddressDB, &methodHash, &communityMintEventDB) &contractAddressDB, &methodHash, &communityMintEventDB, &communityID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -676,6 +680,10 @@ func getActivityEntries(ctx context.Context, deps FilterDependencies, addresses
return nil, errors.New("invalid row data") return nil, errors.New("invalid row data")
} }
if communityID.Valid {
entry.communityID = common.NewAndSet(communityID.String)
}
// Complete common data // Complete common data
entry.recipient = &toAddress entry.recipient = &toAddress
entry.sender = &fromAddress entry.sender = &fromAddress

View File

@ -216,7 +216,12 @@ SELECT
CASE CASE
WHEN transfers.tx_from_address = zeroAddress AND transfers.type = "erc20" THEN (SELECT 1 FROM json_each(transfers.receipt, '$.logs' ) WHERE json_extract( value, '$.topics[0]' ) = communityMintEvent) WHEN transfers.tx_from_address = zeroAddress AND transfers.type = "erc20" THEN (SELECT 1 FROM json_each(transfers.receipt, '$.logs' ) WHERE json_extract( value, '$.topics[0]' ) = communityMintEvent)
ELSE NULL ELSE NULL
END AS community_mint_event END AS community_mint_event,
CASE
WHEN transfers.type = 'erc20' THEN (SELECT community_id FROM tokens WHERE transfers.token_address = tokens.address AND transfers.network_id = tokens.network_id)
WHEN transfers.type = 'erc721' OR transfers.type = 'erc1155' THEN (SELECT community_id FROM collectible_data_cache WHERE transfers.token_address = collectible_data_cache.contract_address AND transfers.network_id = collectible_data_cache.chain_id)
ELSE NULL
END AS community_id
FROM FROM
transfers transfers
CROSS JOIN filter_conditions CROSS JOIN filter_conditions
@ -385,7 +390,8 @@ SELECT
pending_transactions.type AS type, pending_transactions.type AS type,
NULL as contract_address, NULL as contract_address,
NULL AS method_hash, NULL AS method_hash,
NULL AS community_mint_event NULL AS community_mint_event,
NULL AS community_id
FROM FROM
pending_transactions pending_transactions
CROSS JOIN filter_conditions CROSS JOIN filter_conditions
@ -477,7 +483,8 @@ SELECT
NULL AS type, NULL AS type,
NULL as contract_address, NULL as contract_address,
NULL AS method_hash, NULL AS method_hash,
NULL AS community_mint_event NULL AS community_mint_event,
NULL AS community_id
FROM FROM
multi_transactions multi_transactions
CROSS JOIN filter_conditions CROSS JOIN filter_conditions