fix: Show community token mint as Mint tx type (#4214)
This commit is contained in:
parent
a6d46756f5
commit
e5fbe40b9a
|
@ -492,10 +492,12 @@ func getActivityEntries(ctx context.Context, deps FilterDependencies, addresses
|
||||||
var tokenCode, fromTokenCode, toTokenCode sql.NullString
|
var tokenCode, fromTokenCode, toTokenCode sql.NullString
|
||||||
var methodHash sql.NullString
|
var methodHash sql.NullString
|
||||||
var transferType *TransferType
|
var transferType *TransferType
|
||||||
|
var communityMintEventDB sql.NullBool
|
||||||
|
var communityMintEvent bool
|
||||||
err := rows.Scan(&transferHash, &pendingHash, &chainID, &multiTxID, ×tamp, &dbMtType, &dbTrType, &fromAddress,
|
err := rows.Scan(&transferHash, &pendingHash, &chainID, &multiTxID, ×tamp, &dbMtType, &dbTrType, &fromAddress,
|
||||||
&toAddressDB, &ownerAddressDB, &dbTrAmount, &dbMtFromAmount, &dbMtToAmount, &aggregatedStatus, &aggregatedCount,
|
&toAddressDB, &ownerAddressDB, &dbTrAmount, &dbMtFromAmount, &dbMtToAmount, &aggregatedStatus, &aggregatedCount,
|
||||||
&tokenAddress, &dbTokenID, &tokenCode, &fromTokenCode, &toTokenCode, &outChainIDDB, &inChainIDDB, &contractType,
|
&tokenAddress, &dbTokenID, &tokenCode, &fromTokenCode, &toTokenCode, &outChainIDDB, &inChainIDDB, &contractType,
|
||||||
&contractAddressDB, &methodHash)
|
&contractAddressDB, &methodHash, &communityMintEventDB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -508,6 +510,10 @@ func getActivityEntries(ctx context.Context, deps FilterDependencies, addresses
|
||||||
transferType = contractTypeFromDBType(contractType.String)
|
transferType = contractTypeFromDBType(contractType.String)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if communityMintEventDB.Valid {
|
||||||
|
communityMintEvent = communityMintEventDB.Bool
|
||||||
|
}
|
||||||
|
|
||||||
if len(contractAddressDB) > 0 {
|
if len(contractAddressDB) > 0 {
|
||||||
contractAddress = new(eth.Address)
|
contractAddress = new(eth.Address)
|
||||||
*contractAddress = eth.BytesToAddress(contractAddressDB)
|
*contractAddress = eth.BytesToAddress(contractAddressDB)
|
||||||
|
@ -523,7 +529,7 @@ func getActivityEntries(ctx context.Context, deps FilterDependencies, addresses
|
||||||
} else if trType.Byte == toTrType {
|
} else if trType.Byte == toTrType {
|
||||||
at := ReceiveAT
|
at := ReceiveAT
|
||||||
if fromAddress == ZeroAddress && transferType != nil {
|
if fromAddress == ZeroAddress && transferType != nil {
|
||||||
if *transferType == TransferTypeErc721 || (*transferType == TransferTypeErc20 && methodHash.Valid && sliceContains(inputDataMethods, methodHash.String)) {
|
if *transferType == TransferTypeErc721 || (*transferType == TransferTypeErc20 && methodHash.Valid && (communityMintEvent || sliceContains(inputDataMethods, methodHash.String))) {
|
||||||
at = MintAT
|
at = MintAT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ WITH filter_conditions AS (
|
||||||
? AS layer2FinalisationDuration,
|
? AS layer2FinalisationDuration,
|
||||||
? AS layer1FinalisationDuration,
|
? AS layer1FinalisationDuration,
|
||||||
X'0000000000000000000000000000000000000000' AS zeroAddress,
|
X'0000000000000000000000000000000000000000' AS zeroAddress,
|
||||||
'0x28c427b0611d99da5c4f7368abe57e86b045b483c4689ae93e90745802335b87' as statusMintEvent
|
'0x28c427b0611d99da5c4f7368abe57e86b045b483c4689ae93e90745802335b87' as communityMintEvent
|
||||||
),
|
),
|
||||||
-- This UNION between CTE and TEMP TABLE acts as an optimization. As soon as we drop one or use them interchangeably the performance drops significantly.
|
-- This UNION between CTE and TEMP TABLE acts as an optimization. As soon as we drop one or use them interchangeably the performance drops significantly.
|
||||||
filter_addresses(address) AS (
|
filter_addresses(address) AS (
|
||||||
|
@ -207,7 +207,11 @@ SELECT
|
||||||
CASE
|
CASE
|
||||||
WHEN transfers.tx_from_address = zeroAddress AND transfers.type = "erc20" THEN substr(json_extract(tx, '$.input'), 1, 10)
|
WHEN transfers.tx_from_address = zeroAddress AND transfers.type = "erc20" THEN substr(json_extract(tx, '$.input'), 1, 10)
|
||||||
ELSE NULL
|
ELSE NULL
|
||||||
END AS method_hash
|
END AS method_hash,
|
||||||
|
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
|
||||||
FROM
|
FROM
|
||||||
transfers
|
transfers
|
||||||
CROSS JOIN filter_conditions
|
CROSS JOIN filter_conditions
|
||||||
|
@ -253,11 +257,7 @@ WHERE
|
||||||
transfers.type = 'erc20'
|
transfers.type = 'erc20'
|
||||||
AND (
|
AND (
|
||||||
(method_hash IS NOT NULL AND method_hash IN mint_methods)
|
(method_hash IS NOT NULL AND method_hash IN mint_methods)
|
||||||
OR (
|
OR community_mint_event IS NOT NULL
|
||||||
(SELECT 1
|
|
||||||
FROM json_each(transfers.receipt, '$.logs' )
|
|
||||||
WHERE json_extract( value, '$.topics[0]' ) = statusMintEvent) IS NOT NULL
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -284,11 +284,7 @@ WHERE
|
||||||
transfers.type = 'erc20'
|
transfers.type = 'erc20'
|
||||||
AND (
|
AND (
|
||||||
(method_hash IS NOT NULL AND method_hash IN mint_methods)
|
(method_hash IS NOT NULL AND method_hash IN mint_methods)
|
||||||
OR (
|
OR community_mint_event IS NOT NULL
|
||||||
(SELECT 1
|
|
||||||
FROM json_each(transfers.receipt, '$.logs' )
|
|
||||||
WHERE json_extract( value, '$.topics[0]' ) = statusMintEvent) IS NOT NULL
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -386,7 +382,8 @@ SELECT
|
||||||
NULL AS in_network_id,
|
NULL AS in_network_id,
|
||||||
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
|
||||||
FROM
|
FROM
|
||||||
pending_transactions
|
pending_transactions
|
||||||
CROSS JOIN filter_conditions
|
CROSS JOIN filter_conditions
|
||||||
|
@ -476,7 +473,8 @@ SELECT
|
||||||
multi_transactions.to_network_id AS in_network_id,
|
multi_transactions.to_network_id AS in_network_id,
|
||||||
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
|
||||||
FROM
|
FROM
|
||||||
multi_transactions
|
multi_transactions
|
||||||
CROSS JOIN filter_conditions
|
CROSS JOIN filter_conditions
|
||||||
|
|
Loading…
Reference in New Issue