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

View File

@ -216,7 +216,12 @@ SELECT
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)
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
transfers
CROSS JOIN filter_conditions
@ -385,7 +390,8 @@ SELECT
pending_transactions.type AS type,
NULL as contract_address,
NULL AS method_hash,
NULL AS community_mint_event
NULL AS community_mint_event,
NULL AS community_id
FROM
pending_transactions
CROSS JOIN filter_conditions
@ -477,7 +483,8 @@ SELECT
NULL AS type,
NULL as contract_address,
NULL AS method_hash,
NULL AS community_mint_event
NULL AS community_mint_event,
NULL AS community_id
FROM
multi_transactions
CROSS JOIN filter_conditions