From ab6b7ca69076993cc42f84c7b78777991276a9a3 Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:51:54 -0500 Subject: [PATCH 01/10] detect if file is encrypted --- .../components/Storage/Files/FilePreview.tsx | 17 ++++++++- explorer/src/utils/file.ts | 36 ++++++++++++------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/explorer/src/components/Storage/Files/FilePreview.tsx b/explorer/src/components/Storage/Files/FilePreview.tsx index 7b678bb9..0855e606 100644 --- a/explorer/src/components/Storage/Files/FilePreview.tsx +++ b/explorer/src/components/Storage/Files/FilePreview.tsx @@ -1,3 +1,4 @@ +import { LockClosedIcon } from '@heroicons/react/24/outline' import { Arguments } from 'components/common/Arguments' import { Spinner } from 'components/common/Spinner' import { GetCidQuery, GetCidQueryVariables } from 'gql/graphql' @@ -16,6 +17,9 @@ type Props = { type PreviewData = { type: string data: ArrayBuffer + isEncrypted: boolean + // eslint-disable-next-line @typescript-eslint/no-explicit-any + uploadOptions: any } export const FilePreview: FC = ({ cid }) => { @@ -31,11 +35,13 @@ export const FilePreview: FC = ({ cid }) => { const fetchData = useCallback(async () => { if (data) { - const { dataArrayBuffer } = extractFileData(data) + const { dataArrayBuffer, isEncrypted, uploadOptions } = extractFileData(data) const fileType = await detectFileType(dataArrayBuffer) setRawData({ type: fileType, data: dataArrayBuffer, + isEncrypted, + uploadOptions, }) } }, [data]) @@ -60,6 +66,15 @@ export const FilePreview: FC = ({ cid }) => { if (!imageSrc) return <> switch (true) { + case rawData?.isEncrypted: + return ( +
+ +

+ No preview available for encrypted files +

+
+ ) case rawData?.type.startsWith('image'): return ( Date: Mon, 16 Dec 2024 08:23:08 -0500 Subject: [PATCH 02/10] fix downloadFullData so when passing variables it does not override the query --- explorer/src/utils/downloadFullData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorer/src/utils/downloadFullData.ts b/explorer/src/utils/downloadFullData.ts index f5ad1498..5d12f572 100644 --- a/explorer/src/utils/downloadFullData.ts +++ b/explorer/src/utils/downloadFullData.ts @@ -18,7 +18,7 @@ export const downloadFullData = async ( } const { data } = await apolloClient.query({ query, - variables: variables ? { ..._variables, ...variables } : _variables, + variables: variables ? { ...variables, ..._variables } : _variables, }) if (data[path + '_aggregate']) { const totalCount = data[path + '_aggregate'].aggregate.count From 8461edb00a555f580a56f20008421b10e4c4c011 Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Tue, 17 Dec 2024 09:26:07 -0500 Subject: [PATCH 03/10] add Finalization events and account for all events in event id --- .../consensus/src/mappings/mappingHandlers.ts | 51 ++++++++++++++++--- .../consensus/src/mappings/mappingHandlers.ts | 51 ++++++++++++++++--- 2 files changed, 88 insertions(+), 14 deletions(-) diff --git a/indexers/mainnet/consensus/src/mappings/mappingHandlers.ts b/indexers/mainnet/consensus/src/mappings/mappingHandlers.ts index c6f1b4d9..70b43a6c 100644 --- a/indexers/mainnet/consensus/src/mappings/mappingHandlers.ts +++ b/indexers/mainnet/consensus/src/mappings/mappingHandlers.ts @@ -63,6 +63,7 @@ export async function handleBlock(_block: SubstrateBlock): Promise { const logKindsToUpdate: string[] = []; const addressToUpdate: string[] = []; + let eventIndex = 0; let totalBlockRewardsCount = 0; let totalVoteRewardsCount = 0; let totalTransferValue = BigInt(0); @@ -155,7 +156,7 @@ export async function handleBlock(_block: SubstrateBlock): Promise { addressToUpdate.push(extrinsicSigner); // Process extrinsic events - extrinsicEvents.forEach((event, eventIdx) => { + extrinsicEvents.forEach((event) => { const extrinsicId = extrinsic ? height + "-" + extrinsicIdx.toString() : ""; @@ -177,7 +178,7 @@ export async function handleBlock(_block: SubstrateBlock): Promise { createEvent( height, blockHash, - BigInt(eventIdx), + BigInt(eventIndex), extrinsicId, extrinsic.hash.toString(), event.event.section, @@ -206,7 +207,7 @@ export async function handleBlock(_block: SubstrateBlock): Promise { height, blockHash, extrinsicId, - height + "-" + eventIdx.toString(), + height + "-" + eventIndex, from, to, amount, @@ -218,6 +219,39 @@ export async function handleBlock(_block: SubstrateBlock): Promise { break; } + default: + break; + } + + // Increment event index + eventIndex++; + }); + + // Get finalization events + const finalizationEvents = events.filter((e) => e.phase.isFinalization); + + // Process finalization events + finalizationEvents.forEach(async (event) => { + newEvents.push( + createEvent( + height, + blockHash, + BigInt(eventIndex), + height + "-" + event.phase.type, + extrinsic.hash.toString(), + event.event.section, + event.event.method, + timestamp ? timestamp : new Date(0), + event.phase.type, + pos, + args, + cid + ) + ); + eventMethodsToUpdate.push([event.event.section, event.event.method]); + + // Process specific events + switch (`${event.event.section}.${event.event.method}`) { case "rewards.VoteReward": { const voter = event.event.data[0].toString(); const reward = BigInt(event.event.data[1].toString()); @@ -231,8 +265,8 @@ export async function handleBlock(_block: SubstrateBlock): Promise { const newReward = createReward( height, blockHash, - extrinsicId, - height + "-" + eventIdx.toString(), + height + "-" + event.phase.type, + height + "-" + eventIndex, voter, "rewards.VoteReward", reward, @@ -255,8 +289,8 @@ export async function handleBlock(_block: SubstrateBlock): Promise { const newReward = createReward( height, blockHash, - extrinsicId, - height + "-" + eventIdx.toString(), + height + "-" + event.phase.type, + height + "-" + eventIndex, blockAuthor, "rewards.BlockReward", reward, @@ -269,6 +303,9 @@ export async function handleBlock(_block: SubstrateBlock): Promise { default: break; } + + // Increment event index + eventIndex++; }); }); diff --git a/indexers/taurus/consensus/src/mappings/mappingHandlers.ts b/indexers/taurus/consensus/src/mappings/mappingHandlers.ts index c6f1b4d9..70b43a6c 100644 --- a/indexers/taurus/consensus/src/mappings/mappingHandlers.ts +++ b/indexers/taurus/consensus/src/mappings/mappingHandlers.ts @@ -63,6 +63,7 @@ export async function handleBlock(_block: SubstrateBlock): Promise { const logKindsToUpdate: string[] = []; const addressToUpdate: string[] = []; + let eventIndex = 0; let totalBlockRewardsCount = 0; let totalVoteRewardsCount = 0; let totalTransferValue = BigInt(0); @@ -155,7 +156,7 @@ export async function handleBlock(_block: SubstrateBlock): Promise { addressToUpdate.push(extrinsicSigner); // Process extrinsic events - extrinsicEvents.forEach((event, eventIdx) => { + extrinsicEvents.forEach((event) => { const extrinsicId = extrinsic ? height + "-" + extrinsicIdx.toString() : ""; @@ -177,7 +178,7 @@ export async function handleBlock(_block: SubstrateBlock): Promise { createEvent( height, blockHash, - BigInt(eventIdx), + BigInt(eventIndex), extrinsicId, extrinsic.hash.toString(), event.event.section, @@ -206,7 +207,7 @@ export async function handleBlock(_block: SubstrateBlock): Promise { height, blockHash, extrinsicId, - height + "-" + eventIdx.toString(), + height + "-" + eventIndex, from, to, amount, @@ -218,6 +219,39 @@ export async function handleBlock(_block: SubstrateBlock): Promise { break; } + default: + break; + } + + // Increment event index + eventIndex++; + }); + + // Get finalization events + const finalizationEvents = events.filter((e) => e.phase.isFinalization); + + // Process finalization events + finalizationEvents.forEach(async (event) => { + newEvents.push( + createEvent( + height, + blockHash, + BigInt(eventIndex), + height + "-" + event.phase.type, + extrinsic.hash.toString(), + event.event.section, + event.event.method, + timestamp ? timestamp : new Date(0), + event.phase.type, + pos, + args, + cid + ) + ); + eventMethodsToUpdate.push([event.event.section, event.event.method]); + + // Process specific events + switch (`${event.event.section}.${event.event.method}`) { case "rewards.VoteReward": { const voter = event.event.data[0].toString(); const reward = BigInt(event.event.data[1].toString()); @@ -231,8 +265,8 @@ export async function handleBlock(_block: SubstrateBlock): Promise { const newReward = createReward( height, blockHash, - extrinsicId, - height + "-" + eventIdx.toString(), + height + "-" + event.phase.type, + height + "-" + eventIndex, voter, "rewards.VoteReward", reward, @@ -255,8 +289,8 @@ export async function handleBlock(_block: SubstrateBlock): Promise { const newReward = createReward( height, blockHash, - extrinsicId, - height + "-" + eventIdx.toString(), + height + "-" + event.phase.type, + height + "-" + eventIndex, blockAuthor, "rewards.BlockReward", reward, @@ -269,6 +303,9 @@ export async function handleBlock(_block: SubstrateBlock): Promise { default: break; } + + // Increment event index + eventIndex++; }); }); From ee5448c1eed8240f586bf09fbea1cf95cf415de8 Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:51:44 -0500 Subject: [PATCH 04/10] change leaderboard schema --- indexers/mainnet/leaderboard/schema.graphql | 168 +++++++++++--------- 1 file changed, 96 insertions(+), 72 deletions(-) diff --git a/indexers/mainnet/leaderboard/schema.graphql b/indexers/mainnet/leaderboard/schema.graphql index ef119761..41789f17 100644 --- a/indexers/mainnet/leaderboard/schema.graphql +++ b/indexers/mainnet/leaderboard/schema.graphql @@ -5,219 +5,243 @@ # account type AccountTransferSenderTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountTransferSenderTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountTransferReceiverTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountTransferReceiverTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountRemarkCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountExtrinsicTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountExtrinsicSuccessTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountExtrinsicFailedTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountTransactionFeePaidTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } # farmer type FarmerVoteTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerVoteTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerBlockTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerBlockTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerVoteAndBlockTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerVoteAndBlockTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } # operator type OperatorTotalRewardsCollectedHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorTotalTaxCollectedHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorBundleTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorDepositsTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorDepositsTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorWithdrawalsTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } # nominator/account type NominatorDepositsTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type NominatorDepositsTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type NominatorWithdrawalsTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } From 1af9531b34cf1bcb1ecdfbbba485f03b39d01704 Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:52:26 -0500 Subject: [PATCH 05/10] change the logic to mimic consensus and use a single handler --- indexers/mainnet/leaderboard/project.ts | 109 +-- .../mainnet/leaderboard/src/mappings/db.ts | 679 +++++++++------ .../src/mappings/mappingHandlers.ts | 784 ++++++++++-------- 3 files changed, 836 insertions(+), 736 deletions(-) diff --git a/indexers/mainnet/leaderboard/project.ts b/indexers/mainnet/leaderboard/project.ts index 00f97c89..96fc7e3e 100644 --- a/indexers/mainnet/leaderboard/project.ts +++ b/indexers/mainnet/leaderboard/project.ts @@ -45,116 +45,13 @@ const project: SubstrateProject = { dataSources: [ { kind: SubstrateDatasourceKind.Runtime, - startBlock: 1, + startBlock: 562800, mapping: { file: "./dist/index.js", handlers: [ - // accounts { - kind: SubstrateHandlerKind.Event, - handler: "handleTransferEvent", - filter: { - module: "balances", - method: "Transfer", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleRemarkEvent", - filter: { - module: "system", - method: "Remarked", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleExtrinsicSuccessEvent", - filter: { - module: "system", - method: "ExtrinsicSuccess", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleExtrinsicFailedEvent", - filter: { - module: "system", - method: "ExtrinsicFailed", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleTransactionFeePaidEvent", - filter: { - module: "transactionPayment", - method: "TransactionFeePaid", - }, - }, - // farmers - { - kind: SubstrateHandlerKind.Event, - handler: "handleFarmerVoteRewardEvent", - filter: { - module: "rewards", - method: "VoteReward", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleFarmerBlockRewardEvent", - filter: { - module: "rewards", - method: "BlockReward", - }, - }, - // operators & nominators - { - kind: SubstrateHandlerKind.Event, - handler: "handleOperatorRewardedEvent", - filter: { - module: "domains", - method: "OperatorRewarded", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleOperatorTaxCollectedEvent", - filter: { - module: "domains", - method: "OperatorTaxCollected", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleBundleStoredEvent", - filter: { - module: "domains", - method: "BundleStored", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleOperatorRegisteredEvent", - filter: { - module: "domains", - method: "OperatorRegistered", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleOperatorNominatedEvent", - filter: { - module: "domains", - method: "OperatorNominated", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleWithdrewStakeEvent", - filter: { - module: "domains", - method: "WithdrewStake", - }, + kind: SubstrateHandlerKind.Block, + handler: "handleBlock", }, ], }, diff --git a/indexers/mainnet/leaderboard/src/mappings/db.ts b/indexers/mainnet/leaderboard/src/mappings/db.ts index 1cbdbd76..4b81d2e8 100644 --- a/indexers/mainnet/leaderboard/src/mappings/db.ts +++ b/indexers/mainnet/leaderboard/src/mappings/db.ts @@ -25,437 +25,588 @@ import { OperatorWithdrawalsTotalCountHistory, } from "../types"; -export async function checkAndGetAccountTransferSenderTotalCount( - id: string, +type Cache = { + accountExtrinsicFailedTotalCountHistory: AccountExtrinsicFailedTotalCountHistory[]; + accountExtrinsicSuccessTotalCountHistory: AccountExtrinsicSuccessTotalCountHistory[]; + accountExtrinsicTotalCountHistory: AccountExtrinsicTotalCountHistory[]; + accountRemarkCountHistory: AccountRemarkCountHistory[]; + accountTransactionFeePaidTotalValueHistory: AccountTransactionFeePaidTotalValueHistory[]; + accountTransferReceiverTotalCountHistory: AccountTransferReceiverTotalCountHistory[]; + accountTransferReceiverTotalValueHistory: AccountTransferReceiverTotalValueHistory[]; + accountTransferSenderTotalCountHistory: AccountTransferSenderTotalCountHistory[]; + accountTransferSenderTotalValueHistory: AccountTransferSenderTotalValueHistory[]; + farmerBlockTotalCountHistory: FarmerBlockTotalCountHistory[]; + farmerBlockTotalValueHistory: FarmerBlockTotalValueHistory[]; + farmerVoteAndBlockTotalCountHistory: FarmerVoteAndBlockTotalCountHistory[]; + farmerVoteAndBlockTotalValueHistory: FarmerVoteAndBlockTotalValueHistory[]; + farmerVoteTotalCountHistory: FarmerVoteTotalCountHistory[]; + farmerVoteTotalValueHistory: FarmerVoteTotalValueHistory[]; + nominatorDepositsTotalCountHistory: NominatorDepositsTotalCountHistory[]; + nominatorDepositsTotalValueHistory: NominatorDepositsTotalValueHistory[]; + nominatorWithdrawalsTotalCountHistory: NominatorWithdrawalsTotalCountHistory[]; + operatorBundleTotalCountHistory: OperatorBundleTotalCountHistory[]; + operatorDepositsTotalCountHistory: OperatorDepositsTotalCountHistory[]; + operatorDepositsTotalValueHistory: OperatorDepositsTotalValueHistory[]; + operatorTotalRewardsCollectedHistory: OperatorTotalRewardsCollectedHistory[]; + operatorTotalTaxCollectedHistory: OperatorTotalTaxCollectedHistory[]; + operatorWithdrawalsTotalCountHistory: OperatorWithdrawalsTotalCountHistory[]; +}; + +export const initializeCache = (): Cache => ({ + accountExtrinsicFailedTotalCountHistory: [], + accountExtrinsicSuccessTotalCountHistory: [], + accountExtrinsicTotalCountHistory: [], + accountRemarkCountHistory: [], + accountTransactionFeePaidTotalValueHistory: [], + accountTransferReceiverTotalCountHistory: [], + accountTransferReceiverTotalValueHistory: [], + accountTransferSenderTotalCountHistory: [], + accountTransferSenderTotalValueHistory: [], + farmerBlockTotalCountHistory: [], + farmerBlockTotalValueHistory: [], + farmerVoteAndBlockTotalCountHistory: [], + farmerVoteAndBlockTotalValueHistory: [], + farmerVoteTotalCountHistory: [], + farmerVoteTotalValueHistory: [], + nominatorDepositsTotalCountHistory: [], + nominatorDepositsTotalValueHistory: [], + nominatorWithdrawalsTotalCountHistory: [], + operatorBundleTotalCountHistory: [], + operatorDepositsTotalCountHistory: [], + operatorDepositsTotalValueHistory: [], + operatorTotalRewardsCollectedHistory: [], + operatorTotalTaxCollectedHistory: [], + operatorWithdrawalsTotalCountHistory: [], +}); + +export const saveCache = async (cache: Cache) => { + await Promise.all( + cache.accountTransferSenderTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountTransferReceiverTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountTransferSenderTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountTransferReceiverTotalValueHistory.map((item) => item.save()) + ); + await Promise.all(cache.accountRemarkCountHistory.map((item) => item.save())); + await Promise.all( + cache.accountExtrinsicTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountExtrinsicSuccessTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountExtrinsicFailedTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountTransactionFeePaidTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerVoteTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerVoteTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerBlockTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerBlockTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerVoteAndBlockTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerVoteAndBlockTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.nominatorDepositsTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.nominatorDepositsTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.nominatorWithdrawalsTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorBundleTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorDepositsTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorDepositsTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorTotalRewardsCollectedHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorTotalTaxCollectedHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorWithdrawalsTotalCountHistory.map((item) => item.save()) + ); +}; + +export function createAccountTransferSenderTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransferSenderTotalCountHistory.create({ - id, - rank: 0, +): AccountTransferSenderTotalCountHistory { + return AccountTransferSenderTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountTransferSenderTotalValue( - id: string, +export function createAccountTransferSenderTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransferSenderTotalValueHistory.create({ - id, - rank: 0, +): AccountTransferSenderTotalValueHistory { + return AccountTransferSenderTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountTransferReceiverTotalCount( - id: string, +export function createAccountTransferReceiverTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransferReceiverTotalCountHistory.create({ - id, - rank: 0, +): AccountTransferReceiverTotalCountHistory { + return AccountTransferReceiverTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountTransferReceiverTotalValue( - id: string, +export function createAccountTransferReceiverTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransferReceiverTotalValueHistory.create({ - id, - rank: 0, +): AccountTransferReceiverTotalValueHistory { + return AccountTransferReceiverTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountRemarkCount( - id: string, +export function createAccountRemarkCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountRemarkCountHistory.create({ - id, - rank: 0, +): AccountRemarkCountHistory { + return AccountRemarkCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountExtrinsicTotalCount( - id: string, +export function createAccountExtrinsicTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountExtrinsicTotalCountHistory.create({ - id, - rank: 0, +): AccountExtrinsicTotalCountHistory { + return AccountExtrinsicTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountExtrinsicSuccessTotalCount( - id: string, +export function createAccountExtrinsicSuccessTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountExtrinsicSuccessTotalCountHistory.create({ - id, - rank: 0, +): AccountExtrinsicSuccessTotalCountHistory { + return AccountExtrinsicSuccessTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountExtrinsicFailedTotalCount( - id: string, +export function createAccountExtrinsicFailedTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountExtrinsicFailedTotalCountHistory.create({ - id, - rank: 0, +): AccountExtrinsicFailedTotalCountHistory { + return AccountExtrinsicFailedTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountTransactionFeePaidTotalValue( - id: string, +export function createAccountTransactionFeePaidTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransactionFeePaidTotalValueHistory.create({ - id, - rank: 0, +): AccountTransactionFeePaidTotalValueHistory { + return AccountTransactionFeePaidTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } // Farmer entities -export async function checkAndGetFarmerVoteTotalCount( - id: string, +export function createFarmerVoteTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerVoteTotalCountHistory.create({ - id, - rank: 0, +): FarmerVoteTotalCountHistory { + return FarmerVoteTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerVoteTotalValue( - id: string, +export function createFarmerVoteTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerVoteTotalValueHistory.create({ - id, - rank: 0, +): FarmerVoteTotalValueHistory { + return FarmerVoteTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerBlockTotalCount( - id: string, +export function createFarmerBlockTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerBlockTotalCountHistory.create({ - id, - rank: 0, +): FarmerBlockTotalCountHistory { + return FarmerBlockTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerBlockTotalValue( - id: string, +export function createFarmerBlockTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerBlockTotalValueHistory.create({ - id, - rank: 0, +): FarmerBlockTotalValueHistory { + return FarmerBlockTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerVoteAndBlockTotalCount( - id: string, +export function createFarmerVoteAndBlockTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerVoteAndBlockTotalCountHistory.create({ - id, - rank: 0, +): FarmerVoteAndBlockTotalCountHistory { + return FarmerVoteAndBlockTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerVoteAndBlockTotalValue( - id: string, +export function createFarmerVoteAndBlockTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerVoteAndBlockTotalValueHistory.create({ - id, - rank: 0, +): FarmerVoteAndBlockTotalValueHistory { + return FarmerVoteAndBlockTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } // Operator entities -export async function checkAndGetOperatorTotalRewardsCollected( - id: string, +export function createOperatorTotalRewardsCollected( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorTotalRewardsCollectedHistory.create({ - id, - rank: 0, +): OperatorTotalRewardsCollectedHistory { + return OperatorTotalRewardsCollectedHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorTotalTaxCollected( - id: string, +export function createOperatorTotalTaxCollected( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorTotalTaxCollectedHistory.create({ - id, - rank: 0, +): OperatorTotalTaxCollectedHistory { + return OperatorTotalTaxCollectedHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorBundleTotalCount( - id: string, +export function createOperatorBundleTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorBundleTotalCountHistory.create({ - id, - rank: 0, +): OperatorBundleTotalCountHistory { + return OperatorBundleTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorDepositsTotalCount( - id: string, +export function createOperatorDepositsTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorDepositsTotalCountHistory.create({ - id, - rank: 0, +): OperatorDepositsTotalCountHistory { + return OperatorDepositsTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorDepositsTotalValue( - id: string, +export function createOperatorDepositsTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorDepositsTotalValueHistory.create({ - id, - rank: 0, +): OperatorDepositsTotalValueHistory { + return OperatorDepositsTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorWithdrawalsTotalCount( - id: string, +export function createOperatorWithdrawalsTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorWithdrawalsTotalCountHistory.create({ - id, - rank: 0, +): OperatorWithdrawalsTotalCountHistory { + return OperatorWithdrawalsTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } // Nominator entities -export async function checkAndGetNominatorDepositsTotalCount( - id: string, +export function createNominatorDepositsTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = NominatorDepositsTotalCountHistory.create({ - id, - rank: 0, +): NominatorDepositsTotalCountHistory { + return NominatorDepositsTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetNominatorDepositsTotalValue( - id: string, +export function createNominatorDepositsTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = NominatorDepositsTotalValueHistory.create({ - id, - rank: 0, +): NominatorDepositsTotalValueHistory { + return NominatorDepositsTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetNominatorWithdrawalsTotalCount( - id: string, +export function createNominatorWithdrawalsTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = NominatorWithdrawalsTotalCountHistory.create({ - id, - rank: 0, +): NominatorWithdrawalsTotalCountHistory { + return NominatorWithdrawalsTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } diff --git a/indexers/mainnet/leaderboard/src/mappings/mappingHandlers.ts b/indexers/mainnet/leaderboard/src/mappings/mappingHandlers.ts index 552384cc..14d9b6f6 100644 --- a/indexers/mainnet/leaderboard/src/mappings/mappingHandlers.ts +++ b/indexers/mainnet/leaderboard/src/mappings/mappingHandlers.ts @@ -1,371 +1,423 @@ -import { SubstrateEvent } from "@subql/types"; +import { SubstrateBlock } from "@subql/types"; import * as db from "./db"; -export async function handleTransferEvent( - event: SubstrateEvent -): Promise { +export async function handleBlock(_block: SubstrateBlock): Promise { const { - event: { - data: [_from, _to, _amount], + block: { + header: { number }, + extrinsics, }, - } = event; - const from = _from.toString(); - const to = _to.toString(); - const amount = BigInt(_amount.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountTransferSenderTotalCount( - from, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetAccountTransferSenderTotalValue( - from, - amount, - blockNumber, - timestamp - ); - - await db.checkAndGetAccountTransferReceiverTotalCount( - to, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetAccountTransferReceiverTotalValue( - to, - amount, - blockNumber, - timestamp - ); -} - -export async function handleRemarkEvent(event: SubstrateEvent): Promise { - const { - event: { index }, - } = event; - - const extrinsicIndex = Number(index); - const extrinsic = event.block.block.extrinsics[extrinsicIndex]; - const accountId = extrinsic.signer.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountRemarkCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); -} - -export async function handleExtrinsicSuccessEvent( - event: SubstrateEvent -): Promise { - const { - event: { index }, - } = event; - - const extrinsicIndex = Number(index); - const extrinsic = event.block.block.extrinsics[extrinsicIndex]; - const accountId = extrinsic.signer.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountExtrinsicTotalCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetAccountExtrinsicSuccessTotalCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); -} - -export async function handleExtrinsicFailedEvent( - event: SubstrateEvent -): Promise { - const { - event: { index }, - } = event; - const extrinsicIndex = Number(index); - const extrinsic = event.block.block.extrinsics[extrinsicIndex]; - const accountId = extrinsic.signer.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountExtrinsicTotalCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetAccountExtrinsicFailedTotalCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); -} - -export async function handleTransactionFeePaidEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_who, _actualFee, _tip], - }, - } = event; - const who = _who.toString(); - const actualFee = BigInt(_actualFee.toString()); - const tip = BigInt(_tip.toString()); - const totalFeePaid = actualFee + tip; - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountTransactionFeePaidTotalValue( - who, - totalFeePaid, - blockNumber, - timestamp - ); -} - -export async function handleFarmerVoteRewardEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_voter, _reward], - }, - } = event; - const voter = _voter.toString(); - const reward = BigInt(_reward.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetFarmerVoteTotalCount( - voter, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetFarmerVoteTotalValue( - voter, - reward, - blockNumber, - timestamp - ); - - await db.checkAndGetFarmerVoteAndBlockTotalCount( - voter, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetFarmerVoteAndBlockTotalValue( - voter, - reward, - blockNumber, - timestamp - ); -} - -export async function handleFarmerBlockRewardEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_blockAuthor, _reward], - }, - } = event; - const blockAuthor = _blockAuthor.toString(); - const reward = BigInt(_reward.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetFarmerBlockTotalCount( - blockAuthor, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetFarmerBlockTotalValue( - blockAuthor, - reward, - blockNumber, - timestamp - ); - - await db.checkAndGetFarmerVoteAndBlockTotalCount( - blockAuthor, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetFarmerVoteAndBlockTotalValue( - blockAuthor, - reward, - blockNumber, - timestamp - ); -} - -export async function handleOperatorRewardedEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _reward], - }, - } = event; - const operatorId = _operatorId.toString(); - const reward = BigInt(_reward.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - if (reward === BigInt(0)) return; - - await db.checkAndGetOperatorTotalRewardsCollected( - operatorId, - reward, - blockNumber, - timestamp - ); -} - -export async function handleOperatorTaxCollectedEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _tax], - }, - } = event; - const operatorId = _operatorId.toString(); - const tax = BigInt(_tax.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorTotalTaxCollected( - operatorId, - tax, - blockNumber, - timestamp - ); -} - -export async function handleBundleStoredEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_bundleAuthor], - }, - } = event; - const operatorId = _bundleAuthor.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorBundleTotalCount( - operatorId, - BigInt(1), - blockNumber, - timestamp - ); -} - -export async function handleOperatorRegisteredEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _reward], - }, - } = event; - const operatorId = _operatorId.toString(); - const reward = BigInt(_reward.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorTotalRewardsCollected( - operatorId, - reward, - blockNumber, - timestamp - ); -} - -export async function handleOperatorNominatedEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _nominatorId, _amount], - }, - } = event; - const operatorId = _operatorId.toString(); - const nominatorId = _nominatorId.toString(); - const amount = BigInt(_amount.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorDepositsTotalCount( - operatorId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetOperatorDepositsTotalValue( - operatorId, - amount, - blockNumber, - timestamp - ); - - await db.checkAndGetNominatorDepositsTotalCount( - nominatorId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetNominatorDepositsTotalValue( - nominatorId, - amount, - blockNumber, - timestamp - ); -} - -export async function handleWithdrewStakeEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _nominatorId], - }, - } = event; - const operatorId = _operatorId.toString(); - const nominatorId = _nominatorId.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorWithdrawalsTotalCount( - operatorId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetNominatorWithdrawalsTotalCount( - nominatorId, - BigInt(1), - blockNumber, - timestamp - ); + timestamp, + events, + } = _block; + const height = BigInt(number.toString()); + + let cache = db.initializeCache(); + let eventIndex = 0; + + // Process extrinsics + extrinsics.forEach((extrinsic, extrinsicIdx) => { + const extrinsicEvents = events.filter( + (e) => + e.phase.isApplyExtrinsic && + e.phase.asApplyExtrinsic.toNumber() === extrinsicIdx + ); + const successEvent = events.find( + (e) => + e.event.section === "system" && e.event.method === "ExtrinsicSuccess" + ); + const successEventId = events.findIndex( + (e) => + e.event.section === "system" && e.event.method === "ExtrinsicSuccess" + ); + const extrinsicId = extrinsic ? height + "-" + extrinsicIdx.toString() : ""; + const extrinsicSigner = extrinsic.signer.toString(); + + cache.accountExtrinsicTotalCountHistory.push( + db.createAccountExtrinsicTotalCount( + extrinsicSigner, + BigInt(1), + height, + extrinsicId, + height + "-" + successEventId.toString(), + timestamp + ) + ); + if (successEvent) { + cache.accountExtrinsicSuccessTotalCountHistory.push( + db.createAccountExtrinsicSuccessTotalCount( + extrinsicSigner, + BigInt(1), + height, + extrinsicId, + height + "-" + successEventId.toString(), + timestamp + ) + ); + + // Process specific extrinsic + switch (`${extrinsic.method.section}.${extrinsic.method.method}`) { + case "system.remark": + case "system.remarkWithEvent": { + cache.accountRemarkCountHistory.push( + db.createAccountRemarkCount( + extrinsicSigner, + BigInt(1), + height, + extrinsicId, + "", + timestamp + ) + ); + break; + } + } + + // Process extrinsic events + extrinsicEvents.forEach((event, eventIdx) => { + const eventId = height + "-" + eventIndex; + + // Process specific events + switch (`${event.event.section}.${event.event.method}`) { + case "balances.Transfer": { + const from = event.event.data[0].toString(); + const to = event.event.data[1].toString(); + const amount = BigInt(event.event.data[2].toString()); + + cache.accountTransferSenderTotalCountHistory.push( + db.createAccountTransferSenderTotalCount( + from, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.accountTransferSenderTotalValueHistory.push( + db.createAccountTransferSenderTotalValue( + from, + amount, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + cache.accountTransferReceiverTotalCountHistory.push( + db.createAccountTransferReceiverTotalCount( + to, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.accountTransferReceiverTotalValueHistory.push( + db.createAccountTransferReceiverTotalValue( + to, + amount, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "transactionPayment.TransactionFeePaid": { + const who = event.event.data[0].toString(); + const actualFee = BigInt(event.event.data[1].toString()); + const tip = BigInt(event.event.data[2].toString()); + + cache.accountTransactionFeePaidTotalValueHistory.push( + db.createAccountTransactionFeePaidTotalValue( + who, + actualFee + tip, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.OperatorRewarded": { + const operatorId = event.event.data[0].toString(); + const reward = BigInt(event.event.data[1].toString()); + if (reward === BigInt(0)) break; + + cache.operatorTotalRewardsCollectedHistory.push( + db.createOperatorTotalRewardsCollected( + operatorId, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.OperatorTaxCollected": { + const operatorId = event.event.data[0].toString(); + const tax = BigInt(event.event.data[1].toString()); + + cache.operatorTotalTaxCollectedHistory.push( + db.createOperatorTotalTaxCollected( + operatorId, + tax, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + break; + } + case "domains.BundleStored": { + const bundleAuthor = event.event.data[0].toString(); + + cache.operatorBundleTotalCountHistory.push( + db.createOperatorBundleTotalCount( + bundleAuthor, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.OperatorRegistered": { + const operatorId = event.event.data[0].toString(); + const reward = BigInt(event.event.data[1].toString()); + + cache.operatorTotalRewardsCollectedHistory.push( + db.createOperatorTotalRewardsCollected( + operatorId, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.OperatorNominated": { + const operatorId = event.event.data[0].toString(); + const nominatorId = event.event.data[1].toString(); + const amount = BigInt(event.event.data[2].toString()); + + cache.operatorDepositsTotalCountHistory.push( + db.createOperatorDepositsTotalCount( + operatorId, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.operatorDepositsTotalValueHistory.push( + db.createOperatorDepositsTotalValue( + operatorId, + amount, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + cache.nominatorDepositsTotalCountHistory.push( + db.createNominatorDepositsTotalCount( + nominatorId, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.nominatorDepositsTotalValueHistory.push( + db.createNominatorDepositsTotalValue( + nominatorId, + amount, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.WithdrewStake": { + const operatorId = event.event.data[0].toString(); + const nominatorId = event.event.data[1].toString(); + + cache.operatorWithdrawalsTotalCountHistory.push( + db.createOperatorWithdrawalsTotalCount( + operatorId, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.nominatorWithdrawalsTotalCountHistory.push( + db.createNominatorWithdrawalsTotalCount( + nominatorId, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + default: + break; + } + + // Increment event index + eventIndex++; + }); + } else { + // Process fail extrinsic + cache.accountExtrinsicFailedTotalCountHistory.push( + db.createAccountExtrinsicFailedTotalCount( + extrinsicSigner, + BigInt(1), + height, + extrinsicId, + height + "-" + successEventId.toString(), + timestamp + ) + ); + } + }); + + const finalizationEvents = events.filter((e) => e.phase.isFinalization); + + // Process finalization events + finalizationEvents.forEach((event) => { + const extrinsicId = height + "-" + event.phase.type; // AKA (blockHeight-Finalization) + const eventId = height + "-" + eventIndex; + + // Process specific events + switch (`${event.event.section}.${event.event.method}`) { + case "rewards.VoteReward": { + const voter = event.event.data[0].toString(); + const reward = BigInt(event.event.data[1].toString()); + + cache.farmerVoteTotalCountHistory.push( + db.createFarmerVoteTotalCount( + voter, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.farmerVoteTotalValueHistory.push( + db.createFarmerVoteTotalValue( + voter, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + cache.farmerVoteAndBlockTotalCountHistory.push( + db.createFarmerVoteAndBlockTotalCount( + voter, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.farmerVoteAndBlockTotalValueHistory.push( + db.createFarmerVoteAndBlockTotalValue( + voter, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + break; + } + case "rewards.BlockReward": { + const blockAuthor = event.event.data[0].toString(); + const reward = BigInt(event.event.data[1].toString()); + + cache.farmerBlockTotalCountHistory.push( + db.createFarmerBlockTotalCount( + blockAuthor, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.farmerBlockTotalValueHistory.push( + db.createFarmerBlockTotalValue( + blockAuthor, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + cache.farmerVoteAndBlockTotalCountHistory.push( + db.createFarmerVoteAndBlockTotalCount( + blockAuthor, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.farmerVoteAndBlockTotalValueHistory.push( + db.createFarmerVoteAndBlockTotalValue( + blockAuthor, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + break; + } + default: + break; + } + + // Increment event index + eventIndex++; + }); + + // Save cache + await db.saveCache(cache); } From c5acd40575c844b958b2492ab7331579af12cff1 Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:52:37 -0500 Subject: [PATCH 06/10] change init-db accordingly --- .../db/docker-entrypoint-initdb.d/init-db.sql | 290 +++++++++--------- 1 file changed, 145 insertions(+), 145 deletions(-) diff --git a/indexers/db/docker-entrypoint-initdb.d/init-db.sql b/indexers/db/docker-entrypoint-initdb.d/init-db.sql index ec8036dc..da6d5669 100644 --- a/indexers/db/docker-entrypoint-initdb.d/init-db.sql +++ b/indexers/db/docker-entrypoint-initdb.d/init-db.sql @@ -352,11 +352,12 @@ ALTER TABLE dictionary.spec_versions OWNER TO postgres; CREATE TABLE leaderboard.account_extrinsic_failed_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -374,11 +375,12 @@ ALTER TABLE leaderboard.account_extrinsic_failed_total_counts OWNER TO postgres; CREATE TABLE leaderboard.account_extrinsic_success_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -396,11 +398,12 @@ ALTER TABLE leaderboard.account_extrinsic_success_total_counts OWNER TO postgres CREATE TABLE leaderboard.account_extrinsic_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -418,11 +421,12 @@ ALTER TABLE leaderboard.account_extrinsic_total_counts OWNER TO postgres; CREATE TABLE leaderboard.account_remark_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -440,11 +444,12 @@ ALTER TABLE leaderboard.account_remark_counts OWNER TO postgres; CREATE TABLE leaderboard.account_transaction_fee_paid_total_value_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -462,11 +467,12 @@ ALTER TABLE leaderboard.account_transaction_fee_paid_total_values OWNER TO postg CREATE TABLE leaderboard.account_transfer_receiver_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -484,11 +490,12 @@ ALTER TABLE leaderboard.account_transfer_receiver_total_counts OWNER TO postgres CREATE TABLE leaderboard.account_transfer_receiver_total_value_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -506,11 +513,12 @@ ALTER TABLE leaderboard.account_transfer_receiver_total_values OWNER TO postgres CREATE TABLE leaderboard.account_transfer_sender_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -528,11 +536,12 @@ ALTER TABLE leaderboard.account_transfer_sender_total_counts OWNER TO postgres; CREATE TABLE leaderboard.account_transfer_sender_total_value_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -550,11 +559,12 @@ ALTER TABLE leaderboard.account_transfer_sender_total_values OWNER TO postgres; CREATE TABLE leaderboard.farmer_block_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -572,11 +582,12 @@ ALTER TABLE leaderboard.farmer_block_total_counts OWNER TO postgres; CREATE TABLE leaderboard.farmer_block_total_value_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -594,11 +605,12 @@ ALTER TABLE leaderboard.farmer_block_total_values OWNER TO postgres; CREATE TABLE leaderboard.farmer_vote_and_block_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -616,11 +628,12 @@ ALTER TABLE leaderboard.farmer_vote_and_block_total_counts OWNER TO postgres; CREATE TABLE leaderboard.farmer_vote_and_block_total_value_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -638,11 +651,12 @@ ALTER TABLE leaderboard.farmer_vote_and_block_total_values OWNER TO postgres; CREATE TABLE leaderboard.farmer_vote_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -660,11 +674,12 @@ ALTER TABLE leaderboard.farmer_vote_total_counts OWNER TO postgres; CREATE TABLE leaderboard.farmer_vote_total_value_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -682,11 +697,12 @@ ALTER TABLE leaderboard.farmer_vote_total_values OWNER TO postgres; CREATE TABLE leaderboard.nominator_deposits_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -704,11 +720,12 @@ ALTER TABLE leaderboard.nominator_deposits_total_counts OWNER TO postgres; CREATE TABLE leaderboard.nominator_deposits_total_value_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -726,11 +743,12 @@ ALTER TABLE leaderboard.nominator_deposits_total_values OWNER TO postgres; CREATE TABLE leaderboard.nominator_withdrawals_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -748,11 +766,12 @@ ALTER TABLE leaderboard.nominator_withdrawals_total_counts OWNER TO postgres; CREATE TABLE leaderboard.operator_bundle_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -770,11 +789,12 @@ ALTER TABLE leaderboard.operator_bundle_total_counts OWNER TO postgres; CREATE TABLE leaderboard.operator_deposits_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -792,11 +812,12 @@ ALTER TABLE leaderboard.operator_deposits_total_counts OWNER TO postgres; CREATE TABLE leaderboard.operator_deposits_total_value_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -814,11 +835,12 @@ ALTER TABLE leaderboard.operator_deposits_total_values OWNER TO postgres; CREATE TABLE leaderboard.operator_total_rewards_collected_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -836,11 +858,12 @@ ALTER TABLE leaderboard.operator_total_rewards_collecteds OWNER TO postgres; CREATE TABLE leaderboard.operator_total_tax_collected_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -858,11 +881,12 @@ ALTER TABLE leaderboard.operator_total_tax_collecteds OWNER TO postgres; CREATE TABLE leaderboard.operator_withdrawals_total_count_histories ( id text NOT NULL, - rank integer NOT NULL, + account_id text NOT NULL, value numeric NOT NULL, last_contribution_at timestamp without time zone NOT NULL, - created_at integer NOT NULL, - updated_at integer NOT NULL, + block_height numeric NOT NULL, + extrinsic_id text NOT NULL, + event_id text NOT NULL, _id uuid NOT NULL, _block_range int8range NOT NULL ); @@ -1181,185 +1205,169 @@ CREATE INDEX "0x5b57ecd94445ad2e" ON dictionary.extrinsics USING btree (call); CREATE INDEX "0x62b8f3181611d490" ON dictionary.events USING btree (module); CREATE INDEX "0xc0c9768d1987b60f" ON dictionary.events USING btree (block_height); + +CREATE INDEX "0x00a19bd16cefb56d" ON leaderboard.operator_total_rewards_collected_histories USING gist (block_height, _block_range); CREATE INDEX "0x0237b4bb45c8cd3d" ON leaderboard.farmer_vote_and_block_total_values USING btree (created_at); -CREATE INDEX "0x02f8da0e922b0056" ON leaderboard.account_transfer_sender_total_count_histories USING gist (created_at, _block_range); +CREATE INDEX "0x0244cc7c84316bf5" ON leaderboard.nominator_deposits_total_count_histories USING gist (block_height, _block_range); CREATE INDEX "0x03f87f972ff639fb" ON leaderboard.nominator_deposits_total_counts USING btree (rank); -CREATE INDEX "0x0438dd6e4a5f836c" ON leaderboard.account_extrinsic_total_count_histories USING gist (rank, _block_range); CREATE INDEX "0x04c74d64a2ca170d" ON leaderboard.operator_deposits_total_values USING btree (created_at); -CREATE INDEX "0x04dfb89b9e2af7a7" ON leaderboard.operator_total_rewards_collected_histories USING gist (created_at, _block_range); CREATE INDEX "0x0a50f1f460ef26ea" ON leaderboard.farmer_vote_and_block_total_counts USING btree (created_at); CREATE INDEX "0x0a89134e4a3de20e" ON leaderboard.account_transfer_receiver_total_values USING btree (updated_at); CREATE INDEX "0x0a914dd2bb308160" ON leaderboard.farmer_block_total_value_histories USING btree (id); +CREATE INDEX "0x0b56aa1915c7f363" ON leaderboard.account_transaction_fee_paid_total_value_histories USING gist (account_id, _block_range); CREATE INDEX "0x0b8b8b69754807d3" ON leaderboard.farmer_vote_and_block_total_count_histories USING gist (value, _block_range); -CREATE INDEX "0x0e0b83f71c1fa808" ON leaderboard.farmer_block_total_value_histories USING gist (updated_at, _block_range); -CREATE INDEX "0x0f8ff92ec1de897d" ON leaderboard.operator_deposits_total_count_histories USING gist (rank, _block_range); -CREATE INDEX "0x109ef24a7bb98d30" ON leaderboard.operator_withdrawals_total_counts USING btree (rank); -CREATE INDEX "0x11c7fbd504978be3" ON leaderboard.operator_deposits_total_value_histories USING gist (created_at, _block_range); -CREATE INDEX "0x1354e8ceab9831c9" ON leaderboard.operator_deposits_total_value_histories USING gist (updated_at, _block_range); -CREATE INDEX "0x141aea21e5105cd2" ON leaderboard.account_transfer_sender_total_value_histories USING gist (updated_at, _block_range); CREATE INDEX "0x15178b2615ecb334" ON leaderboard.farmer_vote_total_counts USING btree (value); -CREATE INDEX "0x174bea85db7e2379" ON leaderboard.account_extrinsic_failed_total_count_histories USING gist (rank, _block_range); CREATE INDEX "0x17aa9d3d762269fa" ON leaderboard.account_transfer_receiver_total_value_histories USING gist (value, _block_range); CREATE INDEX "0x19ecd7ecdee51bdc" ON leaderboard.account_transfer_sender_total_value_histories USING gist (value, _block_range); -CREATE INDEX "0x1a653356147e1a5c" ON leaderboard.farmer_block_total_count_histories USING gist (created_at, _block_range); -CREATE INDEX "0x1ab55399690fbf98" ON leaderboard.operator_withdrawals_total_count_histories USING gist (updated_at, _block_range); -CREATE INDEX "0x1bd9b5a195d85978" ON leaderboard.farmer_block_total_count_histories USING gist (rank, _block_range); -CREATE INDEX "0x1c3ef49edcc0984d" ON leaderboard.farmer_vote_and_block_total_count_histories USING gist (created_at, _block_range); CREATE INDEX "0x1dc9d229fc046a77" ON leaderboard.farmer_block_total_counts USING btree (value); CREATE INDEX "0x1ed6c532b99ee178" ON leaderboard.nominator_deposits_total_values USING btree (rank); +CREATE INDEX "0x1fcbfceab1d743dc" ON leaderboard.nominator_deposits_total_value_histories USING gist (block_height, _block_range); CREATE INDEX "0x1fd4ad1795e237a1" ON leaderboard.farmer_vote_total_value_histories USING btree (id); CREATE INDEX "0x203a197257ce12a5" ON leaderboard.farmer_vote_total_counts USING btree (rank); CREATE INDEX "0x206ce884fc1c5cd0" ON leaderboard.account_transfer_sender_total_count_histories USING gist (value, _block_range); CREATE INDEX "0x21d9f76ed37bd96e" ON leaderboard.account_transfer_receiver_total_counts USING btree (created_at); -CREATE INDEX "0x23e27116b9f0acfb" ON leaderboard.farmer_vote_total_value_histories USING gist (rank, _block_range); -CREATE INDEX "0x246b2da19131c0aa" ON leaderboard.farmer_vote_and_block_total_value_histories USING gist (created_at, _block_range); CREATE INDEX "0x2543cf3b9ae14ab8" ON leaderboard.operator_deposits_total_counts USING btree (created_at); CREATE INDEX "0x25d59bd5befefa21" ON leaderboard.farmer_vote_and_block_total_values USING btree (updated_at); CREATE INDEX "0x261402fc9f454bf4" ON leaderboard.nominator_deposits_total_values USING btree (updated_at); CREATE INDEX "0x274bfb55e0692363" ON leaderboard.account_transfer_sender_total_counts USING btree (updated_at); -CREATE INDEX "0x2a08ed126a9ec75f" ON leaderboard.operator_deposits_total_count_histories USING gist (updated_at, _block_range); +CREATE INDEX "0x283ae161d36cc261" ON leaderboard.farmer_block_total_value_histories USING gist (account_id, _block_range); +CREATE INDEX "0x2a19af3b66553514" ON leaderboard.farmer_vote_and_block_total_count_histories USING gist (account_id, _block_range); CREATE INDEX "0x2ab353d6f5476280" ON leaderboard.farmer_vote_and_block_total_value_histories USING gist (value, _block_range); -CREATE INDEX "0x2b0706c6c4786c0b" ON leaderboard.operator_total_tax_collected_histories USING gist (created_at, _block_range); CREATE INDEX "0x2e81c6470104e40a" ON leaderboard.account_transfer_receiver_total_counts USING btree (updated_at); CREATE INDEX "0x3082545cf9f8ade6" ON leaderboard.operator_total_rewards_collected_histories USING btree (id); -CREATE INDEX "0x31c5517209f3c88a" ON leaderboard.account_transfer_receiver_total_count_histories USING gist (rank, _block_range); CREATE INDEX "0x33208903dd1d791b" ON leaderboard.operator_deposits_total_value_histories USING gist (value, _block_range); +CREATE INDEX "0x3676ac6d2b32bc84" ON leaderboard.operator_total_rewards_collected_histories USING gist (account_id, _block_range); CREATE INDEX "0x36fad076b7b609c8" ON leaderboard.operator_total_tax_collecteds USING btree (rank); CREATE INDEX "0x37cd3b31685e6b8a" ON leaderboard.operator_deposits_total_count_histories USING btree (id); CREATE INDEX "0x3bb471ec1101b66a" ON leaderboard.account_transfer_receiver_total_values USING btree (created_at); CREATE INDEX "0x3c11ae5e03742fc1" ON leaderboard.farmer_vote_total_count_histories USING btree (id); CREATE INDEX "0x3c8d59be33cc30fd" ON leaderboard.account_transaction_fee_paid_total_values USING btree (value); CREATE INDEX "0x3fb3bf4c3648e89f" ON leaderboard.operator_bundle_total_counts USING btree (value); -CREATE INDEX "0x40908f6096f8aae1" ON leaderboard.operator_total_tax_collected_histories USING gist (rank, _block_range); CREATE INDEX "0x414cf5a248371b9e" ON leaderboard.operator_total_rewards_collecteds USING btree (value); -CREATE INDEX "0x453b4a7d0154c00e" ON leaderboard.account_extrinsic_failed_total_count_histories USING gist (updated_at, _block_range); +CREATE INDEX "0x421f161af0318c8b" ON leaderboard.nominator_withdrawals_total_count_histories USING gist (account_id, _block_range); CREATE INDEX "0x45b6baa60f76afe5" ON leaderboard.farmer_block_total_counts USING btree (rank); CREATE INDEX "0x45db7717e810fbed" ON leaderboard.account_extrinsic_failed_total_counts USING btree (created_at); -CREATE INDEX "0x477f46ee7c4e2806" ON leaderboard.operator_bundle_total_count_histories USING gist (updated_at, _block_range); +CREATE INDEX "0x4650f835071e0d71" ON leaderboard.farmer_vote_total_value_histories USING gist (account_id, _block_range); CREATE INDEX "0x48833908a7574703" ON leaderboard.account_transfer_sender_total_counts USING btree (created_at); CREATE INDEX "0x499757adbe68e426" ON leaderboard.operator_bundle_total_count_histories USING gist (value, _block_range); +CREATE INDEX "0x4ca9e9ee31b8c664" ON leaderboard.account_remark_count_histories USING gist (block_height, _block_range); CREATE INDEX "0x4d064ce423ead9f9" ON leaderboard.nominator_deposits_total_value_histories USING gist (value, _block_range); -CREATE INDEX "0x4e064e2070199ae3" ON leaderboard.account_extrinsic_success_total_count_histories USING gist (updated_at, _block_range); -CREATE INDEX "0x5009af847af1621d" ON leaderboard.account_remark_count_histories USING gist (updated_at, _block_range); +CREATE INDEX "0x4da777bb92510b22" ON leaderboard.farmer_vote_and_block_total_value_histories USING gist (block_height, _block_range); +CREATE INDEX "0x4e666b4c0682b5d9" ON leaderboard.account_transfer_receiver_total_count_histories USING gist (account_id, _block_range); +CREATE INDEX "0x4ebb0e134d2bbcde" ON leaderboard.operator_deposits_total_count_histories USING gist (block_height, _block_range); +CREATE INDEX "0x4ec7b66d408abb23" ON leaderboard.nominator_deposits_total_count_histories USING gist (account_id, _block_range); CREATE INDEX "0x5162c85596c9338e" ON leaderboard.operator_deposits_total_values USING btree (value); +CREATE INDEX "0x52bb11467ca64f9e" ON leaderboard.nominator_deposits_total_value_histories USING gist (account_id, _block_range); CREATE INDEX "0x52d6270f1cc3c4dd" ON leaderboard.operator_bundle_total_counts USING btree (rank); CREATE INDEX "0x547b123af6dcd32a" ON leaderboard.account_extrinsic_total_counts USING btree (updated_at); -CREATE INDEX "0x547bce6e924324b3" ON leaderboard.farmer_vote_and_block_total_count_histories USING gist (updated_at, _block_range); CREATE INDEX "0x554eb4e5ac77f3eb" ON leaderboard.operator_withdrawals_total_count_histories USING btree (id); -CREATE INDEX "0x571e7ad4adadc8ab" ON leaderboard.account_extrinsic_success_total_count_histories USING gist (created_at, _block_range); +CREATE INDEX "0x5691017160aa14de" ON leaderboard.account_transfer_sender_total_value_histories USING gist (block_height, _block_range); CREATE INDEX "0x5738b9b369347bf1" ON leaderboard.account_remark_counts USING btree (created_at); -CREATE INDEX "0x58a6a962f5dabf12" ON leaderboard.farmer_vote_total_count_histories USING gist (rank, _block_range); CREATE INDEX "0x594dec910ab418ad" ON leaderboard.operator_total_rewards_collected_histories USING gist (value, _block_range); CREATE INDEX "0x5b1a07a2eacad81c" ON leaderboard.operator_bundle_total_counts USING btree (updated_at); CREATE INDEX "0x5bd3b2299db13775" ON leaderboard.farmer_vote_and_block_total_counts USING btree (updated_at); CREATE INDEX "0x5cfd74ecb2e7596e" ON leaderboard.nominator_withdrawals_total_counts USING btree (created_at); -CREATE INDEX "0x5d789c4c98a92206" ON leaderboard.account_transfer_receiver_total_count_histories USING gist (updated_at, _block_range); +CREATE INDEX "0x5dc53a0b91bef6f5" ON leaderboard.account_transfer_receiver_total_value_histories USING gist (account_id, _block_range); CREATE INDEX "0x5ed08ec48c219622" ON leaderboard.farmer_vote_total_value_histories USING gist (value, _block_range); CREATE INDEX "0x6446d391095803fe" ON leaderboard.account_transfer_receiver_total_values USING btree (rank); CREATE INDEX "0x648d3308d6c4914f" ON leaderboard.operator_deposits_total_counts USING btree (value); -CREATE INDEX "0x6500d8534ebd4e12" ON leaderboard.operator_total_tax_collected_histories USING gist (updated_at, _block_range); CREATE INDEX "0x6625bd986dfdd912" ON leaderboard.farmer_vote_total_values USING btree (rank); -CREATE INDEX "0x66c003a28114773c" ON leaderboard.nominator_deposits_total_count_histories USING gist (rank, _block_range); -CREATE INDEX "0x66d778d3ec849bd8" ON leaderboard.nominator_deposits_total_value_histories USING gist (rank, _block_range); CREATE INDEX "0x67610203489d7569" ON leaderboard.operator_total_tax_collecteds USING btree (created_at); CREATE INDEX "0x67876d73c8d1484a" ON leaderboard.nominator_deposits_total_values USING btree (created_at); CREATE INDEX "0x6a80c339bc124d94" ON leaderboard.account_extrinsic_success_total_count_histories USING gist (value, _block_range); -CREATE INDEX "0x6b6077a1d8b8d586" ON leaderboard.operator_bundle_total_count_histories USING gist (created_at, _block_range); CREATE INDEX "0x6e3c8d300e206644" ON leaderboard.account_transfer_sender_total_values USING btree (value); CREATE INDEX "0x6e7ba35bab79dae5" ON leaderboard.account_remark_counts USING btree (value); -CREATE INDEX "0x6ede99acc34cc024" ON leaderboard.farmer_vote_and_block_total_value_histories USING gist (rank, _block_range); CREATE INDEX "0x6effab7bf55318c0" ON leaderboard.farmer_block_total_values USING btree (created_at); CREATE INDEX "0x719e87ef859d46f9" ON leaderboard.account_extrinsic_total_count_histories USING gist (value, _block_range); CREATE INDEX "0x73606d69a16a51ed" ON leaderboard.farmer_vote_and_block_total_counts USING btree (rank); CREATE INDEX "0x74444c6cbb827fed" ON leaderboard.account_extrinsic_failed_total_counts USING btree (rank); -CREATE INDEX "0x74e5dcda7b724127" ON leaderboard.account_transaction_fee_paid_total_value_histories USING gist (rank, _block_range); CREATE INDEX "0x759f7e295510308d" ON leaderboard.operator_deposits_total_count_histories USING gist (value, _block_range); CREATE INDEX "0x75d5f56abf048ee1" ON leaderboard.account_remark_count_histories USING gist (value, _block_range); CREATE INDEX "0x77f1b742d319402c" ON leaderboard.account_transaction_fee_paid_total_values USING btree (created_at); -CREATE INDEX "0x796003f4275de9f4" ON leaderboard.nominator_deposits_total_count_histories USING gist (created_at, _block_range); +CREATE INDEX "0x7aa3904a7d3a4563" ON leaderboard.farmer_block_total_count_histories USING gist (account_id, _block_range); CREATE INDEX "0x7c0e839f35282376" ON leaderboard.farmer_block_total_counts USING btree (created_at); CREATE INDEX "0x7c584a4083105781" ON leaderboard.farmer_block_total_values USING btree (value); CREATE INDEX "0x7cdbfa16661f71ee" ON leaderboard.nominator_withdrawals_total_counts USING btree (value); CREATE INDEX "0x7ef3b9aa555b5a05" ON leaderboard.account_transfer_receiver_total_values USING btree (value); -CREATE INDEX "0x7fcce6162fd86748" ON leaderboard.farmer_vote_and_block_total_count_histories USING gist (rank, _block_range); CREATE INDEX "0x804628cadf8ddb42" ON leaderboard.farmer_block_total_value_histories USING gist (value, _block_range); -CREATE INDEX "0x809dc846b29ce189" ON leaderboard.account_transfer_sender_total_count_histories USING gist (rank, _block_range); -CREATE INDEX "0x80bd9d9b56f42c8c" ON leaderboard.farmer_vote_and_block_total_value_histories USING gist (updated_at, _block_range); -CREATE INDEX "0x81f5dea1dc8bdbd9" ON leaderboard.account_transfer_sender_total_count_histories USING gist (updated_at, _block_range); +CREATE INDEX "0x809a1540a47b34f1" ON leaderboard.account_remark_count_histories USING gist (account_id, _block_range); CREATE INDEX "0x82f033a6c175eddd" ON leaderboard.farmer_vote_and_block_total_values USING btree (value); CREATE INDEX "0x82fe14c738066801" ON leaderboard.account_transfer_sender_total_values USING btree (created_at); +CREATE INDEX "0x83d0481ecdfe1e3c" ON leaderboard.operator_total_tax_collected_histories USING gist (account_id, _block_range); CREATE INDEX "0x8463b2f12b68a67c" ON leaderboard.operator_withdrawals_total_count_histories USING gist (value, _block_range); CREATE INDEX "0x84d750e3c36ee4ab" ON leaderboard.operator_total_tax_collecteds USING btree (updated_at); CREATE INDEX "0x865a7a78cd9957e1" ON leaderboard.account_transaction_fee_paid_total_value_histories USING btree (id); CREATE INDEX "0x87379ebd9abb3c9f" ON leaderboard.account_extrinsic_total_counts USING btree (created_at); -CREATE INDEX "0x882bd0f439486d4f" ON leaderboard.farmer_block_total_value_histories USING gist (created_at, _block_range); -CREATE INDEX "0x89a552b0035c9bac" ON leaderboard.operator_deposits_total_count_histories USING gist (created_at, _block_range); -CREATE INDEX "0x89e6563a1f910e74" ON leaderboard.operator_deposits_total_value_histories USING gist (rank, _block_range); -CREATE INDEX "0x8a9ec139a3b7547d" ON leaderboard.account_extrinsic_total_count_histories USING gist (updated_at, _block_range); +CREATE INDEX "0x878e2eb4c7464f91" ON leaderboard.farmer_block_total_value_histories USING gist (block_height, _block_range); +CREATE INDEX "0x882daca0abfba2b8" ON leaderboard.account_extrinsic_success_total_count_histories USING gist (block_height, _block_range); CREATE INDEX "0x8b7c68617ff4e62b" ON leaderboard.operator_deposits_total_value_histories USING btree (id); CREATE INDEX "0x8ba1fd011d0120e6" ON leaderboard.account_remark_counts USING btree (updated_at); CREATE INDEX "0x8c12fe09c9fbcd4f" ON leaderboard.farmer_block_total_count_histories USING btree (id); +CREATE INDEX "0x8c4adce4e421c71f" ON leaderboard.operator_withdrawals_total_count_histories USING gist (account_id, _block_range); CREATE INDEX "0x8d7008ea364cf94c" ON leaderboard.account_transfer_sender_total_count_histories USING btree (id); CREATE INDEX "0x8fa61e629a2dcd38" ON leaderboard.account_transfer_receiver_total_value_histories USING btree (id); CREATE INDEX "0x901aff3934f41bd9" ON leaderboard.farmer_vote_total_counts USING btree (updated_at); -CREATE INDEX "0x90d324df0a448bbe" ON leaderboard.nominator_withdrawals_total_count_histories USING gist (updated_at, _block_range); +CREATE INDEX "0x9100c4535abd1ba4" ON leaderboard.farmer_vote_and_block_total_count_histories USING gist (block_height, _block_range); +CREATE INDEX "0x94d8701298d99d82" ON leaderboard.account_extrinsic_total_count_histories USING gist (account_id, _block_range); CREATE INDEX "0x957df7861716b7e5" ON leaderboard.nominator_deposits_total_count_histories USING btree (id); CREATE INDEX "0x958866172e237c5c" ON leaderboard.operator_total_rewards_collecteds USING btree (updated_at); CREATE INDEX "0x964d1cdad7a5330f" ON leaderboard.farmer_vote_total_count_histories USING gist (value, _block_range); +CREATE INDEX "0x97633453dae86d22" ON leaderboard.account_transfer_receiver_total_value_histories USING gist (block_height, _block_range); CREATE INDEX "0x979a3db4e9e7c431" ON leaderboard.account_extrinsic_failed_total_count_histories USING gist (value, _block_range); CREATE INDEX "0x97d32cd19e3802db" ON leaderboard.farmer_block_total_values USING btree (rank); CREATE INDEX "0x99d0f21c8605c41c" ON leaderboard.account_transfer_sender_total_counts USING btree (value); CREATE INDEX "0x9b42c9f7087cc0dd" ON leaderboard.account_transfer_receiver_total_count_histories USING btree (id); CREATE INDEX "0x9cd9957f6e6b9cf4" ON leaderboard.account_extrinsic_total_count_histories USING btree (id); -CREATE INDEX "0x9d162fe9f8c06084" ON leaderboard.account_transfer_receiver_total_value_histories USING gist (created_at, _block_range); -CREATE INDEX "0x9d8ba3138d055469" ON leaderboard.farmer_vote_total_value_histories USING gist (updated_at, _block_range); -CREATE INDEX "0x9dee2d53a2eb345d" ON leaderboard.farmer_block_total_count_histories USING gist (updated_at, _block_range); CREATE INDEX "0x9f3af39f22aac290" ON leaderboard.farmer_vote_and_block_total_count_histories USING btree (id); CREATE INDEX "0x9fc7939319b88d37" ON leaderboard.nominator_deposits_total_counts USING btree (value); CREATE INDEX "0xa035d5be2ef2e7ff" ON leaderboard.nominator_deposits_total_values USING btree (value); CREATE INDEX "0xa0371f05d6ab705d" ON leaderboard.farmer_vote_total_values USING btree (created_at); CREATE INDEX "0xa03f24a9dfd38cdc" ON leaderboard.farmer_vote_total_values USING btree (value); -CREATE INDEX "0xa13419e05df57bc9" ON leaderboard.account_transfer_receiver_total_value_histories USING gist (rank, _block_range); +CREATE INDEX "0xa0e359a56914557a" ON leaderboard.account_extrinsic_failed_total_count_histories USING gist (block_height, _block_range); CREATE INDEX "0xa6e9645812acf3c5" ON leaderboard.operator_withdrawals_total_counts USING btree (updated_at); -CREATE INDEX "0xa7ec65297714a878" ON leaderboard.account_remark_count_histories USING gist (rank, _block_range); -CREATE INDEX "0xa84f9c2f9b56e910" ON leaderboard.account_remark_count_histories USING gist (created_at, _block_range); +CREATE INDEX "0xa8876002594fb3d9" ON leaderboard.account_transfer_sender_total_value_histories USING gist (account_id, _block_range); +CREATE INDEX "0xa8fab7e0a0c35981" ON leaderboard.account_transfer_receiver_total_count_histories USING gist (block_height, _block_range); CREATE INDEX "0xab244f4097d5b7de" ON leaderboard.account_transfer_receiver_total_counts USING btree (value); CREATE INDEX "0xab389403bd29540d" ON leaderboard.operator_total_rewards_collecteds USING btree (rank); CREATE INDEX "0xab879a58ac57bb2e" ON leaderboard.account_remark_count_histories USING btree (id); CREATE INDEX "0xac1bf85d692ba008" ON leaderboard.account_transfer_sender_total_values USING btree (rank); CREATE INDEX "0xac5a3d6fd52e2eba" ON leaderboard.farmer_vote_and_block_total_values USING btree (rank); CREATE INDEX "0xacea6ba8b4475b52" ON leaderboard.operator_total_tax_collected_histories USING gist (value, _block_range); +CREATE INDEX "0xb025aed07cf0497b" ON leaderboard.account_extrinsic_success_total_count_histories USING gist (account_id, _block_range); +CREATE INDEX "0xb06359b1f82d8bc4" ON leaderboard.farmer_block_total_count_histories USING gist (block_height, _block_range); +CREATE INDEX "0xb169b4f6e59a38fb" ON leaderboard.account_transfer_sender_total_count_histories USING gist (account_id, _block_range); +CREATE INDEX "0xb1b17d21f13d1630" ON leaderboard.account_extrinsic_failed_total_count_histories USING gist (account_id, _block_range); CREATE INDEX "0xb1d45dae81251f24" ON leaderboard.account_transfer_receiver_total_count_histories USING gist (value, _block_range); -CREATE INDEX "0xb3402699fe4397b8" ON leaderboard.account_transaction_fee_paid_total_value_histories USING gist (updated_at, _block_range); CREATE INDEX "0xb65383ff3975f7d0" ON leaderboard.nominator_withdrawals_total_counts USING btree (rank); +CREATE INDEX "0xb657787497a56866" ON leaderboard.operator_bundle_total_count_histories USING gist (account_id, _block_range); +CREATE INDEX "0xb685fea77550c4ba" ON leaderboard.account_transaction_fee_paid_total_value_histories USING gist (block_height, _block_range); CREATE INDEX "0xb8c311b80e4878cf" ON leaderboard.operator_total_tax_collecteds USING btree (value); -CREATE INDEX "0xb9b3589a500a4db1" ON leaderboard.operator_withdrawals_total_count_histories USING gist (created_at, _block_range); +CREATE INDEX "0xb8c3a00bbda58dd1" ON leaderboard.operator_deposits_total_count_histories USING gist (account_id, _block_range); CREATE INDEX "0xb9c1f66664e1525c" ON leaderboard.account_extrinsic_success_total_counts USING btree (rank); CREATE INDEX "0xba6d7a768cf0f48a" ON leaderboard.account_extrinsic_success_total_counts USING btree (value); +CREATE INDEX "0xba8274c63f512a6c" ON leaderboard.operator_withdrawals_total_count_histories USING gist (block_height, _block_range); CREATE INDEX "0xbb772bc16a6f55fa" ON leaderboard.account_extrinsic_total_counts USING btree (rank); +CREATE INDEX "0xbd7d3688774132d9" ON leaderboard.account_extrinsic_total_count_histories USING gist (block_height, _block_range); CREATE INDEX "0xbd9aadf5a0a985b6" ON leaderboard.farmer_block_total_count_histories USING gist (value, _block_range); -CREATE INDEX "0xbdd64bae0c93c9a6" ON leaderboard.farmer_vote_total_count_histories USING gist (updated_at, _block_range); -CREATE INDEX "0xbfc0515dbc24baa0" ON leaderboard.operator_bundle_total_count_histories USING gist (rank, _block_range); -CREATE INDEX "0xc032b3ad6fce379b" ON leaderboard.account_transfer_sender_total_value_histories USING gist (rank, _block_range); CREATE INDEX "0xc18397609d2e50fc" ON leaderboard.nominator_withdrawals_total_count_histories USING btree (id); CREATE INDEX "0xc26c8c9093762044" ON leaderboard.nominator_deposits_total_value_histories USING btree (id); +CREATE INDEX "0xc2d1db0e1993ab6d" ON leaderboard.farmer_vote_total_value_histories USING gist (block_height, _block_range); CREATE INDEX "0xc2d78cc1bc2d4d1d" ON leaderboard.operator_bundle_total_counts USING btree (created_at); +CREATE INDEX "0xc39dcd4a26cdd42d" ON leaderboard.operator_total_tax_collected_histories USING gist (block_height, _block_range); CREATE INDEX "0xc62ca597010fa42d" ON leaderboard.operator_deposits_total_counts USING btree (rank); -CREATE INDEX "0xc633abfc19104b3e" ON leaderboard.nominator_deposits_total_value_histories USING gist (updated_at, _block_range); CREATE INDEX "0xc660a8aa2ffa9c5a" ON leaderboard.farmer_vote_and_block_total_value_histories USING btree (id); -CREATE INDEX "0xc66251f1e0f605d2" ON leaderboard.account_transfer_receiver_total_count_histories USING gist (created_at, _block_range); -CREATE INDEX "0xc704c2e4e4bda11e" ON leaderboard.account_extrinsic_total_count_histories USING gist (created_at, _block_range); CREATE INDEX "0xc777a0fed62b8863" ON leaderboard.account_extrinsic_success_total_counts USING btree (updated_at); -CREATE INDEX "0xc81dade686cf3dcf" ON leaderboard.account_extrinsic_failed_total_count_histories USING gist (created_at, _block_range); CREATE INDEX "0xc859dbf1a9895777" ON leaderboard.nominator_deposits_total_counts USING btree (created_at); CREATE INDEX "0xc88f7e95a1a80085" ON leaderboard.farmer_vote_and_block_total_counts USING btree (value); CREATE INDEX "0xc9823b43f2d5fc8e" ON leaderboard.operator_bundle_total_count_histories USING btree (id); CREATE INDEX "0xc9ad4369f9204059" ON leaderboard.account_extrinsic_success_total_counts USING btree (created_at); +CREATE INDEX "0xcae5a2492334afca" ON leaderboard.farmer_vote_total_count_histories USING gist (block_height, _block_range); CREATE INDEX "0xcb0aa6b763df69f6" ON leaderboard.operator_deposits_total_values USING btree (updated_at); +CREATE INDEX "0xcb5285231d73e9cc" ON leaderboard.nominator_withdrawals_total_count_histories USING gist (block_height, _block_range); +CREATE INDEX "0xcc867b5b6030777d" ON leaderboard.account_transfer_sender_total_count_histories USING gist (block_height, _block_range); CREATE INDEX "0xd1ed11b719eccd00" ON leaderboard.farmer_vote_total_values USING btree (updated_at); -CREATE INDEX "0xd22511462ced1db7" ON leaderboard.farmer_vote_total_value_histories USING gist (created_at, _block_range); CREATE INDEX "0xd2beaf5abcec6d67" ON leaderboard.operator_deposits_total_values USING btree (rank); -CREATE INDEX "0xd39bc9f009b16698" ON leaderboard.operator_total_rewards_collected_histories USING gist (updated_at, _block_range); +CREATE INDEX "0xd33f0389b2788b66" ON leaderboard.farmer_vote_and_block_total_value_histories USING gist (account_id, _block_range); CREATE INDEX "0xd74476f68a157f82" ON leaderboard.account_transaction_fee_paid_total_values USING btree (rank); CREATE INDEX "0xd8e7a933c1384413" ON leaderboard.account_extrinsic_failed_total_counts USING btree (value); CREATE INDEX "0xda2d0c5abd8f415c" ON leaderboard.operator_total_tax_collected_histories USING btree (id); @@ -1368,34 +1376,26 @@ CREATE INDEX "0xdbb2243b8d9f31b1" ON leaderboard.account_extrinsic_failed_total_ CREATE INDEX "0xdc3838f306829259" ON leaderboard.account_extrinsic_success_total_count_histories USING btree (id); CREATE INDEX "0xde3fa7f872aada9f" ON leaderboard.account_transfer_sender_total_value_histories USING btree (id); CREATE INDEX "0xe15c940bb687f7d3" ON leaderboard.nominator_deposits_total_count_histories USING gist (value, _block_range); -CREATE INDEX "0xe332bf4f536fa749" ON leaderboard.nominator_withdrawals_total_count_histories USING gist (rank, _block_range); +CREATE INDEX "0xe1c823abc112d3fb" ON leaderboard.farmer_vote_total_count_histories USING gist (account_id, _block_range); CREATE INDEX "0xe3fc37f3b8d89c8d" ON leaderboard.operator_total_rewards_collecteds USING btree (created_at); -CREATE INDEX "0xe804db0947f40afe" ON leaderboard.farmer_vote_total_count_histories USING gist (created_at, _block_range); +CREATE INDEX "0xe7b4f365c3b44d42" ON leaderboard.operator_deposits_total_value_histories USING gist (account_id, _block_range); CREATE INDEX "0xe8f087b3187060f5" ON leaderboard.farmer_vote_total_counts USING btree (created_at); -CREATE INDEX "0xe965018817336f74" ON leaderboard.account_extrinsic_success_total_count_histories USING gist (rank, _block_range); CREATE INDEX "0xea4fb11415169d44" ON leaderboard.farmer_block_total_counts USING btree (updated_at); -CREATE INDEX "0xeaa4f72de256f32f" ON leaderboard.account_transfer_receiver_total_value_histories USING gist (updated_at, _block_range); CREATE INDEX "0xed196db1fdf8e1ba" ON leaderboard.nominator_deposits_total_counts USING btree (updated_at); CREATE INDEX "0xed89d2ba5685cb9f" ON leaderboard.account_transfer_sender_total_counts USING btree (rank); CREATE INDEX "0xefc871c495be2e8b" ON leaderboard.nominator_withdrawals_total_counts USING btree (updated_at); CREATE INDEX "0xf08c870c8311438f" ON leaderboard.operator_withdrawals_total_counts USING btree (created_at); -CREATE INDEX "0xf0d0d07c02740c62" ON leaderboard.account_transaction_fee_paid_total_value_histories USING gist (created_at, _block_range); -CREATE INDEX "0xf2725a417965f8d8" ON leaderboard.nominator_deposits_total_value_histories USING gist (created_at, _block_range); CREATE INDEX "0xf37e3b354eac5a6e" ON leaderboard.operator_withdrawals_total_counts USING btree (value); CREATE INDEX "0xf3b812b4322af338" ON leaderboard.farmer_block_total_values USING btree (updated_at); -CREATE INDEX "0xf3e7c86856dd5b8c" ON leaderboard.operator_total_rewards_collected_histories USING gist (rank, _block_range); CREATE INDEX "0xf3ee1a0c9ddee938" ON leaderboard.account_transfer_receiver_total_counts USING btree (rank); +CREATE INDEX "0xf44d2de87975dc53" ON leaderboard.operator_deposits_total_value_histories USING gist (block_height, _block_range); CREATE INDEX "0xf458f461b30a6b5e" ON leaderboard.account_extrinsic_failed_total_count_histories USING btree (id); CREATE INDEX "0xf59765eb34448af2" ON leaderboard.account_transaction_fee_paid_total_values USING btree (updated_at); CREATE INDEX "0xf69f639e813865ed" ON leaderboard.nominator_withdrawals_total_count_histories USING gist (value, _block_range); -CREATE INDEX "0xf7b4d5d42d0c08f4" ON leaderboard.farmer_block_total_value_histories USING gist (rank, _block_range); -CREATE INDEX "0xf81f7cbe047781f3" ON leaderboard.nominator_withdrawals_total_count_histories USING gist (created_at, _block_range); CREATE INDEX "0xf8a25fbf0822721a" ON leaderboard.account_remark_counts USING btree (rank); CREATE INDEX "0xf8b032ae97b931bd" ON leaderboard.operator_deposits_total_counts USING btree (updated_at); +CREATE INDEX "0xf8f1f913b372d0d0" ON leaderboard.operator_bundle_total_count_histories USING gist (block_height, _block_range); CREATE INDEX "0xfb5c0413cc0c1767" ON leaderboard.account_transaction_fee_paid_total_value_histories USING gist (value, _block_range); -CREATE INDEX "0xfba7f80d0621780a" ON leaderboard.operator_withdrawals_total_count_histories USING gist (rank, _block_range); -CREATE INDEX "0xfc26abe752b123fe" ON leaderboard.nominator_deposits_total_count_histories USING gist (updated_at, _block_range); -CREATE INDEX "0xfc93123fd50e301f" ON leaderboard.account_transfer_sender_total_value_histories USING gist (created_at, _block_range); CREATE INDEX "0xfe4c85f6ab059ff1" ON leaderboard.account_transfer_sender_total_values USING btree (updated_at); CREATE TRIGGER "0x648269cc35867c16" AFTER UPDATE ON consensus._metadata FOR EACH ROW WHEN (((new.key)::text = 'schemaMigrationCount'::text)) EXECUTE FUNCTION consensus.schema_notification(); From dd50ad8208c2d8b639aa2337b3e89c0a0641eae9 Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:04:03 -0500 Subject: [PATCH 07/10] fix taskboard query --- indexers/taskboard/src/utils/db.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/indexers/taskboard/src/utils/db.ts b/indexers/taskboard/src/utils/db.ts index f3c46e24..038bbab9 100644 --- a/indexers/taskboard/src/utils/db.ts +++ b/indexers/taskboard/src/utils/db.ts @@ -52,28 +52,28 @@ const consensusAccountsQuery = ` // Get unique sections from both extrinsics and events const updateLeaderboardRanking = (sourceTable: string, targetTable: string) => ` WITH aggregated_entries AS ( - SELECT id, - SUM(value) AS total_value, - MAX(last_contribution_at) AS last_contribution_at, - MIN(created_at) AS created_at, - MAX(updated_at) AS updated_at + SELECT account_id, + SUM(value) AS total_value, + MAX(last_contribution_at) AS last_contribution_at, + MIN(block_height) AS created_at, + MAX(block_height) AS updated_at FROM leaderboard.${sourceTable} - GROUP BY id + GROUP BY account_id ), ranked_entries AS ( - SELECT id, - ROW_NUMBER() OVER (ORDER BY total_value DESC, id) AS new_rank, - total_value, - last_contribution_at, - created_at, - updated_at + SELECT account_id as id, + ROW_NUMBER() OVER (ORDER BY total_value DESC, account_id) AS new_rank, + total_value, + last_contribution_at, + created_at, + updated_at FROM aggregated_entries ) INSERT INTO leaderboard.${targetTable} (id, rank, value, last_contribution_at, created_at, updated_at) SELECT id, new_rank, total_value, last_contribution_at, created_at, updated_at FROM ranked_entries ON CONFLICT (id) - DO UPDATE SET rank = EXCLUDED.rank, value = EXCLUDED.value, last_contribution_at = EXCLUDED.last_contribution_at, created_at = EXCLUDED.created_at, updated_at = EXCLUDED.updated_at; - `; + DO UPDATE SET rank = EXCLUDED.rank, value = EXCLUDED.value, last_contribution_at = EXCLUDED.last_contribution_at, updated_at = EXCLUDED.updated_at; +`; const consensusUpsertAccountQuery = ` INSERT INTO consensus.accounts (id, account_id, _id, nonce, free, reserved, total, created_at, updated_at, _block_range) From 2f4d3a0c6774a4cb5447560cd13a6f144b21d651 Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:23:58 -0500 Subject: [PATCH 08/10] apply the same fix to taurus leaderboard indexer --- indexers/mainnet/leaderboard/project.ts | 2 +- indexers/taurus/leaderboard/project.ts | 107 +-- .../taurus/leaderboard/src/mappings/db.ts | 679 +++++++++------ .../src/mappings/mappingHandlers.ts | 784 ++++++++++-------- 4 files changed, 836 insertions(+), 736 deletions(-) diff --git a/indexers/mainnet/leaderboard/project.ts b/indexers/mainnet/leaderboard/project.ts index 96fc7e3e..a32a12c0 100644 --- a/indexers/mainnet/leaderboard/project.ts +++ b/indexers/mainnet/leaderboard/project.ts @@ -45,7 +45,7 @@ const project: SubstrateProject = { dataSources: [ { kind: SubstrateDatasourceKind.Runtime, - startBlock: 562800, + startBlock: 1, mapping: { file: "./dist/index.js", handlers: [ diff --git a/indexers/taurus/leaderboard/project.ts b/indexers/taurus/leaderboard/project.ts index e8034caa..b3f34b04 100644 --- a/indexers/taurus/leaderboard/project.ts +++ b/indexers/taurus/leaderboard/project.ts @@ -49,112 +49,9 @@ const project: SubstrateProject = { mapping: { file: "./dist/index.js", handlers: [ - // accounts { - kind: SubstrateHandlerKind.Event, - handler: "handleTransferEvent", - filter: { - module: "balances", - method: "Transfer", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleRemarkEvent", - filter: { - module: "system", - method: "Remarked", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleExtrinsicSuccessEvent", - filter: { - module: "system", - method: "ExtrinsicSuccess", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleExtrinsicFailedEvent", - filter: { - module: "system", - method: "ExtrinsicFailed", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleTransactionFeePaidEvent", - filter: { - module: "transactionPayment", - method: "TransactionFeePaid", - }, - }, - // farmers - { - kind: SubstrateHandlerKind.Event, - handler: "handleFarmerVoteRewardEvent", - filter: { - module: "rewards", - method: "VoteReward", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleFarmerBlockRewardEvent", - filter: { - module: "rewards", - method: "BlockReward", - }, - }, - // operators & nominators - { - kind: SubstrateHandlerKind.Event, - handler: "handleOperatorRewardedEvent", - filter: { - module: "domains", - method: "OperatorRewarded", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleOperatorTaxCollectedEvent", - filter: { - module: "domains", - method: "OperatorTaxCollected", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleBundleStoredEvent", - filter: { - module: "domains", - method: "BundleStored", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleOperatorRegisteredEvent", - filter: { - module: "domains", - method: "OperatorRegistered", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleOperatorNominatedEvent", - filter: { - module: "domains", - method: "OperatorNominated", - }, - }, - { - kind: SubstrateHandlerKind.Event, - handler: "handleWithdrewStakeEvent", - filter: { - module: "domains", - method: "WithdrewStake", - }, + kind: SubstrateHandlerKind.Block, + handler: "handleBlock", }, ], }, diff --git a/indexers/taurus/leaderboard/src/mappings/db.ts b/indexers/taurus/leaderboard/src/mappings/db.ts index 1cbdbd76..4b81d2e8 100644 --- a/indexers/taurus/leaderboard/src/mappings/db.ts +++ b/indexers/taurus/leaderboard/src/mappings/db.ts @@ -25,437 +25,588 @@ import { OperatorWithdrawalsTotalCountHistory, } from "../types"; -export async function checkAndGetAccountTransferSenderTotalCount( - id: string, +type Cache = { + accountExtrinsicFailedTotalCountHistory: AccountExtrinsicFailedTotalCountHistory[]; + accountExtrinsicSuccessTotalCountHistory: AccountExtrinsicSuccessTotalCountHistory[]; + accountExtrinsicTotalCountHistory: AccountExtrinsicTotalCountHistory[]; + accountRemarkCountHistory: AccountRemarkCountHistory[]; + accountTransactionFeePaidTotalValueHistory: AccountTransactionFeePaidTotalValueHistory[]; + accountTransferReceiverTotalCountHistory: AccountTransferReceiverTotalCountHistory[]; + accountTransferReceiverTotalValueHistory: AccountTransferReceiverTotalValueHistory[]; + accountTransferSenderTotalCountHistory: AccountTransferSenderTotalCountHistory[]; + accountTransferSenderTotalValueHistory: AccountTransferSenderTotalValueHistory[]; + farmerBlockTotalCountHistory: FarmerBlockTotalCountHistory[]; + farmerBlockTotalValueHistory: FarmerBlockTotalValueHistory[]; + farmerVoteAndBlockTotalCountHistory: FarmerVoteAndBlockTotalCountHistory[]; + farmerVoteAndBlockTotalValueHistory: FarmerVoteAndBlockTotalValueHistory[]; + farmerVoteTotalCountHistory: FarmerVoteTotalCountHistory[]; + farmerVoteTotalValueHistory: FarmerVoteTotalValueHistory[]; + nominatorDepositsTotalCountHistory: NominatorDepositsTotalCountHistory[]; + nominatorDepositsTotalValueHistory: NominatorDepositsTotalValueHistory[]; + nominatorWithdrawalsTotalCountHistory: NominatorWithdrawalsTotalCountHistory[]; + operatorBundleTotalCountHistory: OperatorBundleTotalCountHistory[]; + operatorDepositsTotalCountHistory: OperatorDepositsTotalCountHistory[]; + operatorDepositsTotalValueHistory: OperatorDepositsTotalValueHistory[]; + operatorTotalRewardsCollectedHistory: OperatorTotalRewardsCollectedHistory[]; + operatorTotalTaxCollectedHistory: OperatorTotalTaxCollectedHistory[]; + operatorWithdrawalsTotalCountHistory: OperatorWithdrawalsTotalCountHistory[]; +}; + +export const initializeCache = (): Cache => ({ + accountExtrinsicFailedTotalCountHistory: [], + accountExtrinsicSuccessTotalCountHistory: [], + accountExtrinsicTotalCountHistory: [], + accountRemarkCountHistory: [], + accountTransactionFeePaidTotalValueHistory: [], + accountTransferReceiverTotalCountHistory: [], + accountTransferReceiverTotalValueHistory: [], + accountTransferSenderTotalCountHistory: [], + accountTransferSenderTotalValueHistory: [], + farmerBlockTotalCountHistory: [], + farmerBlockTotalValueHistory: [], + farmerVoteAndBlockTotalCountHistory: [], + farmerVoteAndBlockTotalValueHistory: [], + farmerVoteTotalCountHistory: [], + farmerVoteTotalValueHistory: [], + nominatorDepositsTotalCountHistory: [], + nominatorDepositsTotalValueHistory: [], + nominatorWithdrawalsTotalCountHistory: [], + operatorBundleTotalCountHistory: [], + operatorDepositsTotalCountHistory: [], + operatorDepositsTotalValueHistory: [], + operatorTotalRewardsCollectedHistory: [], + operatorTotalTaxCollectedHistory: [], + operatorWithdrawalsTotalCountHistory: [], +}); + +export const saveCache = async (cache: Cache) => { + await Promise.all( + cache.accountTransferSenderTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountTransferReceiverTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountTransferSenderTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountTransferReceiverTotalValueHistory.map((item) => item.save()) + ); + await Promise.all(cache.accountRemarkCountHistory.map((item) => item.save())); + await Promise.all( + cache.accountExtrinsicTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountExtrinsicSuccessTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountExtrinsicFailedTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.accountTransactionFeePaidTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerVoteTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerVoteTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerBlockTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerBlockTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerVoteAndBlockTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.farmerVoteAndBlockTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.nominatorDepositsTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.nominatorDepositsTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.nominatorWithdrawalsTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorBundleTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorDepositsTotalCountHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorDepositsTotalValueHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorTotalRewardsCollectedHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorTotalTaxCollectedHistory.map((item) => item.save()) + ); + await Promise.all( + cache.operatorWithdrawalsTotalCountHistory.map((item) => item.save()) + ); +}; + +export function createAccountTransferSenderTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransferSenderTotalCountHistory.create({ - id, - rank: 0, +): AccountTransferSenderTotalCountHistory { + return AccountTransferSenderTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountTransferSenderTotalValue( - id: string, +export function createAccountTransferSenderTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransferSenderTotalValueHistory.create({ - id, - rank: 0, +): AccountTransferSenderTotalValueHistory { + return AccountTransferSenderTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountTransferReceiverTotalCount( - id: string, +export function createAccountTransferReceiverTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransferReceiverTotalCountHistory.create({ - id, - rank: 0, +): AccountTransferReceiverTotalCountHistory { + return AccountTransferReceiverTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountTransferReceiverTotalValue( - id: string, +export function createAccountTransferReceiverTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransferReceiverTotalValueHistory.create({ - id, - rank: 0, +): AccountTransferReceiverTotalValueHistory { + return AccountTransferReceiverTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountRemarkCount( - id: string, +export function createAccountRemarkCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountRemarkCountHistory.create({ - id, - rank: 0, +): AccountRemarkCountHistory { + return AccountRemarkCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountExtrinsicTotalCount( - id: string, +export function createAccountExtrinsicTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountExtrinsicTotalCountHistory.create({ - id, - rank: 0, +): AccountExtrinsicTotalCountHistory { + return AccountExtrinsicTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountExtrinsicSuccessTotalCount( - id: string, +export function createAccountExtrinsicSuccessTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountExtrinsicSuccessTotalCountHistory.create({ - id, - rank: 0, +): AccountExtrinsicSuccessTotalCountHistory { + return AccountExtrinsicSuccessTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountExtrinsicFailedTotalCount( - id: string, +export function createAccountExtrinsicFailedTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountExtrinsicFailedTotalCountHistory.create({ - id, - rank: 0, +): AccountExtrinsicFailedTotalCountHistory { + return AccountExtrinsicFailedTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetAccountTransactionFeePaidTotalValue( - id: string, +export function createAccountTransactionFeePaidTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = AccountTransactionFeePaidTotalValueHistory.create({ - id, - rank: 0, +): AccountTransactionFeePaidTotalValueHistory { + return AccountTransactionFeePaidTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } // Farmer entities -export async function checkAndGetFarmerVoteTotalCount( - id: string, +export function createFarmerVoteTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerVoteTotalCountHistory.create({ - id, - rank: 0, +): FarmerVoteTotalCountHistory { + return FarmerVoteTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerVoteTotalValue( - id: string, +export function createFarmerVoteTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerVoteTotalValueHistory.create({ - id, - rank: 0, +): FarmerVoteTotalValueHistory { + return FarmerVoteTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerBlockTotalCount( - id: string, +export function createFarmerBlockTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerBlockTotalCountHistory.create({ - id, - rank: 0, +): FarmerBlockTotalCountHistory { + return FarmerBlockTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerBlockTotalValue( - id: string, +export function createFarmerBlockTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerBlockTotalValueHistory.create({ - id, - rank: 0, +): FarmerBlockTotalValueHistory { + return FarmerBlockTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerVoteAndBlockTotalCount( - id: string, +export function createFarmerVoteAndBlockTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerVoteAndBlockTotalCountHistory.create({ - id, - rank: 0, +): FarmerVoteAndBlockTotalCountHistory { + return FarmerVoteAndBlockTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetFarmerVoteAndBlockTotalValue( - id: string, +export function createFarmerVoteAndBlockTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = FarmerVoteAndBlockTotalValueHistory.create({ - id, - rank: 0, +): FarmerVoteAndBlockTotalValueHistory { + return FarmerVoteAndBlockTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } // Operator entities -export async function checkAndGetOperatorTotalRewardsCollected( - id: string, +export function createOperatorTotalRewardsCollected( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorTotalRewardsCollectedHistory.create({ - id, - rank: 0, +): OperatorTotalRewardsCollectedHistory { + return OperatorTotalRewardsCollectedHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorTotalTaxCollected( - id: string, +export function createOperatorTotalTaxCollected( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorTotalTaxCollectedHistory.create({ - id, - rank: 0, +): OperatorTotalTaxCollectedHistory { + return OperatorTotalTaxCollectedHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorBundleTotalCount( - id: string, +export function createOperatorBundleTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorBundleTotalCountHistory.create({ - id, - rank: 0, +): OperatorBundleTotalCountHistory { + return OperatorBundleTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorDepositsTotalCount( - id: string, +export function createOperatorDepositsTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorDepositsTotalCountHistory.create({ - id, - rank: 0, +): OperatorDepositsTotalCountHistory { + return OperatorDepositsTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorDepositsTotalValue( - id: string, +export function createOperatorDepositsTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorDepositsTotalValueHistory.create({ - id, - rank: 0, +): OperatorDepositsTotalValueHistory { + return OperatorDepositsTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetOperatorWithdrawalsTotalCount( - id: string, +export function createOperatorWithdrawalsTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = OperatorWithdrawalsTotalCountHistory.create({ - id, - rank: 0, +): OperatorWithdrawalsTotalCountHistory { + return OperatorWithdrawalsTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } // Nominator entities -export async function checkAndGetNominatorDepositsTotalCount( - id: string, +export function createNominatorDepositsTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = NominatorDepositsTotalCountHistory.create({ - id, - rank: 0, +): NominatorDepositsTotalCountHistory { + return NominatorDepositsTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetNominatorDepositsTotalValue( - id: string, +export function createNominatorDepositsTotalValue( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = NominatorDepositsTotalValueHistory.create({ - id, - rank: 0, +): NominatorDepositsTotalValueHistory { + return NominatorDepositsTotalValueHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } -export async function checkAndGetNominatorWithdrawalsTotalCount( - id: string, +export function createNominatorWithdrawalsTotalCount( + accountId: string, value: bigint, - blockNumber: number, + blockHeight: bigint, + extrinsicId: string, + eventId: string, lastContributionAt: Date = new Date() -): Promise { - const account = NominatorWithdrawalsTotalCountHistory.create({ - id, - rank: 0, +): NominatorWithdrawalsTotalCountHistory { + return NominatorWithdrawalsTotalCountHistory.create({ + id: `${accountId}-${extrinsicId}-${eventId}`, + accountId, value, lastContributionAt, - createdAt: blockNumber, - updatedAt: blockNumber, + blockHeight, + extrinsicId, + eventId, }); - await account.save(); - return account; } diff --git a/indexers/taurus/leaderboard/src/mappings/mappingHandlers.ts b/indexers/taurus/leaderboard/src/mappings/mappingHandlers.ts index 552384cc..14d9b6f6 100644 --- a/indexers/taurus/leaderboard/src/mappings/mappingHandlers.ts +++ b/indexers/taurus/leaderboard/src/mappings/mappingHandlers.ts @@ -1,371 +1,423 @@ -import { SubstrateEvent } from "@subql/types"; +import { SubstrateBlock } from "@subql/types"; import * as db from "./db"; -export async function handleTransferEvent( - event: SubstrateEvent -): Promise { +export async function handleBlock(_block: SubstrateBlock): Promise { const { - event: { - data: [_from, _to, _amount], + block: { + header: { number }, + extrinsics, }, - } = event; - const from = _from.toString(); - const to = _to.toString(); - const amount = BigInt(_amount.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountTransferSenderTotalCount( - from, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetAccountTransferSenderTotalValue( - from, - amount, - blockNumber, - timestamp - ); - - await db.checkAndGetAccountTransferReceiverTotalCount( - to, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetAccountTransferReceiverTotalValue( - to, - amount, - blockNumber, - timestamp - ); -} - -export async function handleRemarkEvent(event: SubstrateEvent): Promise { - const { - event: { index }, - } = event; - - const extrinsicIndex = Number(index); - const extrinsic = event.block.block.extrinsics[extrinsicIndex]; - const accountId = extrinsic.signer.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountRemarkCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); -} - -export async function handleExtrinsicSuccessEvent( - event: SubstrateEvent -): Promise { - const { - event: { index }, - } = event; - - const extrinsicIndex = Number(index); - const extrinsic = event.block.block.extrinsics[extrinsicIndex]; - const accountId = extrinsic.signer.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountExtrinsicTotalCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetAccountExtrinsicSuccessTotalCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); -} - -export async function handleExtrinsicFailedEvent( - event: SubstrateEvent -): Promise { - const { - event: { index }, - } = event; - const extrinsicIndex = Number(index); - const extrinsic = event.block.block.extrinsics[extrinsicIndex]; - const accountId = extrinsic.signer.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountExtrinsicTotalCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetAccountExtrinsicFailedTotalCount( - accountId, - BigInt(1), - blockNumber, - timestamp - ); -} - -export async function handleTransactionFeePaidEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_who, _actualFee, _tip], - }, - } = event; - const who = _who.toString(); - const actualFee = BigInt(_actualFee.toString()); - const tip = BigInt(_tip.toString()); - const totalFeePaid = actualFee + tip; - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetAccountTransactionFeePaidTotalValue( - who, - totalFeePaid, - blockNumber, - timestamp - ); -} - -export async function handleFarmerVoteRewardEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_voter, _reward], - }, - } = event; - const voter = _voter.toString(); - const reward = BigInt(_reward.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetFarmerVoteTotalCount( - voter, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetFarmerVoteTotalValue( - voter, - reward, - blockNumber, - timestamp - ); - - await db.checkAndGetFarmerVoteAndBlockTotalCount( - voter, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetFarmerVoteAndBlockTotalValue( - voter, - reward, - blockNumber, - timestamp - ); -} - -export async function handleFarmerBlockRewardEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_blockAuthor, _reward], - }, - } = event; - const blockAuthor = _blockAuthor.toString(); - const reward = BigInt(_reward.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetFarmerBlockTotalCount( - blockAuthor, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetFarmerBlockTotalValue( - blockAuthor, - reward, - blockNumber, - timestamp - ); - - await db.checkAndGetFarmerVoteAndBlockTotalCount( - blockAuthor, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetFarmerVoteAndBlockTotalValue( - blockAuthor, - reward, - blockNumber, - timestamp - ); -} - -export async function handleOperatorRewardedEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _reward], - }, - } = event; - const operatorId = _operatorId.toString(); - const reward = BigInt(_reward.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - if (reward === BigInt(0)) return; - - await db.checkAndGetOperatorTotalRewardsCollected( - operatorId, - reward, - blockNumber, - timestamp - ); -} - -export async function handleOperatorTaxCollectedEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _tax], - }, - } = event; - const operatorId = _operatorId.toString(); - const tax = BigInt(_tax.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorTotalTaxCollected( - operatorId, - tax, - blockNumber, - timestamp - ); -} - -export async function handleBundleStoredEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_bundleAuthor], - }, - } = event; - const operatorId = _bundleAuthor.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorBundleTotalCount( - operatorId, - BigInt(1), - blockNumber, - timestamp - ); -} - -export async function handleOperatorRegisteredEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _reward], - }, - } = event; - const operatorId = _operatorId.toString(); - const reward = BigInt(_reward.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorTotalRewardsCollected( - operatorId, - reward, - blockNumber, - timestamp - ); -} - -export async function handleOperatorNominatedEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _nominatorId, _amount], - }, - } = event; - const operatorId = _operatorId.toString(); - const nominatorId = _nominatorId.toString(); - const amount = BigInt(_amount.toString()); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorDepositsTotalCount( - operatorId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetOperatorDepositsTotalValue( - operatorId, - amount, - blockNumber, - timestamp - ); - - await db.checkAndGetNominatorDepositsTotalCount( - nominatorId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetNominatorDepositsTotalValue( - nominatorId, - amount, - blockNumber, - timestamp - ); -} - -export async function handleWithdrewStakeEvent( - event: SubstrateEvent -): Promise { - const { - event: { - data: [_operatorId, _nominatorId], - }, - } = event; - const operatorId = _operatorId.toString(); - const nominatorId = _nominatorId.toString(); - const blockNumber = event.block.block.header.number.toNumber(); - const timestamp = event.block.timestamp ?? new Date(0); - - await db.checkAndGetOperatorWithdrawalsTotalCount( - operatorId, - BigInt(1), - blockNumber, - timestamp - ); - await db.checkAndGetNominatorWithdrawalsTotalCount( - nominatorId, - BigInt(1), - blockNumber, - timestamp - ); + timestamp, + events, + } = _block; + const height = BigInt(number.toString()); + + let cache = db.initializeCache(); + let eventIndex = 0; + + // Process extrinsics + extrinsics.forEach((extrinsic, extrinsicIdx) => { + const extrinsicEvents = events.filter( + (e) => + e.phase.isApplyExtrinsic && + e.phase.asApplyExtrinsic.toNumber() === extrinsicIdx + ); + const successEvent = events.find( + (e) => + e.event.section === "system" && e.event.method === "ExtrinsicSuccess" + ); + const successEventId = events.findIndex( + (e) => + e.event.section === "system" && e.event.method === "ExtrinsicSuccess" + ); + const extrinsicId = extrinsic ? height + "-" + extrinsicIdx.toString() : ""; + const extrinsicSigner = extrinsic.signer.toString(); + + cache.accountExtrinsicTotalCountHistory.push( + db.createAccountExtrinsicTotalCount( + extrinsicSigner, + BigInt(1), + height, + extrinsicId, + height + "-" + successEventId.toString(), + timestamp + ) + ); + if (successEvent) { + cache.accountExtrinsicSuccessTotalCountHistory.push( + db.createAccountExtrinsicSuccessTotalCount( + extrinsicSigner, + BigInt(1), + height, + extrinsicId, + height + "-" + successEventId.toString(), + timestamp + ) + ); + + // Process specific extrinsic + switch (`${extrinsic.method.section}.${extrinsic.method.method}`) { + case "system.remark": + case "system.remarkWithEvent": { + cache.accountRemarkCountHistory.push( + db.createAccountRemarkCount( + extrinsicSigner, + BigInt(1), + height, + extrinsicId, + "", + timestamp + ) + ); + break; + } + } + + // Process extrinsic events + extrinsicEvents.forEach((event, eventIdx) => { + const eventId = height + "-" + eventIndex; + + // Process specific events + switch (`${event.event.section}.${event.event.method}`) { + case "balances.Transfer": { + const from = event.event.data[0].toString(); + const to = event.event.data[1].toString(); + const amount = BigInt(event.event.data[2].toString()); + + cache.accountTransferSenderTotalCountHistory.push( + db.createAccountTransferSenderTotalCount( + from, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.accountTransferSenderTotalValueHistory.push( + db.createAccountTransferSenderTotalValue( + from, + amount, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + cache.accountTransferReceiverTotalCountHistory.push( + db.createAccountTransferReceiverTotalCount( + to, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.accountTransferReceiverTotalValueHistory.push( + db.createAccountTransferReceiverTotalValue( + to, + amount, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "transactionPayment.TransactionFeePaid": { + const who = event.event.data[0].toString(); + const actualFee = BigInt(event.event.data[1].toString()); + const tip = BigInt(event.event.data[2].toString()); + + cache.accountTransactionFeePaidTotalValueHistory.push( + db.createAccountTransactionFeePaidTotalValue( + who, + actualFee + tip, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.OperatorRewarded": { + const operatorId = event.event.data[0].toString(); + const reward = BigInt(event.event.data[1].toString()); + if (reward === BigInt(0)) break; + + cache.operatorTotalRewardsCollectedHistory.push( + db.createOperatorTotalRewardsCollected( + operatorId, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.OperatorTaxCollected": { + const operatorId = event.event.data[0].toString(); + const tax = BigInt(event.event.data[1].toString()); + + cache.operatorTotalTaxCollectedHistory.push( + db.createOperatorTotalTaxCollected( + operatorId, + tax, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + break; + } + case "domains.BundleStored": { + const bundleAuthor = event.event.data[0].toString(); + + cache.operatorBundleTotalCountHistory.push( + db.createOperatorBundleTotalCount( + bundleAuthor, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.OperatorRegistered": { + const operatorId = event.event.data[0].toString(); + const reward = BigInt(event.event.data[1].toString()); + + cache.operatorTotalRewardsCollectedHistory.push( + db.createOperatorTotalRewardsCollected( + operatorId, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.OperatorNominated": { + const operatorId = event.event.data[0].toString(); + const nominatorId = event.event.data[1].toString(); + const amount = BigInt(event.event.data[2].toString()); + + cache.operatorDepositsTotalCountHistory.push( + db.createOperatorDepositsTotalCount( + operatorId, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.operatorDepositsTotalValueHistory.push( + db.createOperatorDepositsTotalValue( + operatorId, + amount, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + cache.nominatorDepositsTotalCountHistory.push( + db.createNominatorDepositsTotalCount( + nominatorId, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.nominatorDepositsTotalValueHistory.push( + db.createNominatorDepositsTotalValue( + nominatorId, + amount, + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + case "domains.WithdrewStake": { + const operatorId = event.event.data[0].toString(); + const nominatorId = event.event.data[1].toString(); + + cache.operatorWithdrawalsTotalCountHistory.push( + db.createOperatorWithdrawalsTotalCount( + operatorId, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.nominatorWithdrawalsTotalCountHistory.push( + db.createNominatorWithdrawalsTotalCount( + nominatorId, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + break; + } + default: + break; + } + + // Increment event index + eventIndex++; + }); + } else { + // Process fail extrinsic + cache.accountExtrinsicFailedTotalCountHistory.push( + db.createAccountExtrinsicFailedTotalCount( + extrinsicSigner, + BigInt(1), + height, + extrinsicId, + height + "-" + successEventId.toString(), + timestamp + ) + ); + } + }); + + const finalizationEvents = events.filter((e) => e.phase.isFinalization); + + // Process finalization events + finalizationEvents.forEach((event) => { + const extrinsicId = height + "-" + event.phase.type; // AKA (blockHeight-Finalization) + const eventId = height + "-" + eventIndex; + + // Process specific events + switch (`${event.event.section}.${event.event.method}`) { + case "rewards.VoteReward": { + const voter = event.event.data[0].toString(); + const reward = BigInt(event.event.data[1].toString()); + + cache.farmerVoteTotalCountHistory.push( + db.createFarmerVoteTotalCount( + voter, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.farmerVoteTotalValueHistory.push( + db.createFarmerVoteTotalValue( + voter, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + cache.farmerVoteAndBlockTotalCountHistory.push( + db.createFarmerVoteAndBlockTotalCount( + voter, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.farmerVoteAndBlockTotalValueHistory.push( + db.createFarmerVoteAndBlockTotalValue( + voter, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + break; + } + case "rewards.BlockReward": { + const blockAuthor = event.event.data[0].toString(); + const reward = BigInt(event.event.data[1].toString()); + + cache.farmerBlockTotalCountHistory.push( + db.createFarmerBlockTotalCount( + blockAuthor, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.farmerBlockTotalValueHistory.push( + db.createFarmerBlockTotalValue( + blockAuthor, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + cache.farmerVoteAndBlockTotalCountHistory.push( + db.createFarmerVoteAndBlockTotalCount( + blockAuthor, + BigInt(1), + height, + extrinsicId, + eventId, + timestamp + ) + ); + cache.farmerVoteAndBlockTotalValueHistory.push( + db.createFarmerVoteAndBlockTotalValue( + blockAuthor, + reward, + height, + extrinsicId, + eventId, + timestamp + ) + ); + + break; + } + default: + break; + } + + // Increment event index + eventIndex++; + }); + + // Save cache + await db.saveCache(cache); } From 51b506c705c5a4ae12db79bdec27fbc2d3030a1e Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:46:56 -0500 Subject: [PATCH 09/10] add missing taurus leaderboard schema for build to work --- indexers/taurus/leaderboard/schema.graphql | 168 ++++++++++++--------- 1 file changed, 96 insertions(+), 72 deletions(-) diff --git a/indexers/taurus/leaderboard/schema.graphql b/indexers/taurus/leaderboard/schema.graphql index ef119761..41789f17 100644 --- a/indexers/taurus/leaderboard/schema.graphql +++ b/indexers/taurus/leaderboard/schema.graphql @@ -5,219 +5,243 @@ # account type AccountTransferSenderTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountTransferSenderTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountTransferReceiverTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountTransferReceiverTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountRemarkCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountExtrinsicTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountExtrinsicSuccessTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountExtrinsicFailedTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type AccountTransactionFeePaidTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } # farmer type FarmerVoteTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerVoteTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerBlockTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerBlockTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerVoteAndBlockTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type FarmerVoteAndBlockTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } # operator type OperatorTotalRewardsCollectedHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorTotalTaxCollectedHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorBundleTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorDepositsTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorDepositsTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type OperatorWithdrawalsTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } # nominator/account type NominatorDepositsTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type NominatorDepositsTotalValueHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } type NominatorWithdrawalsTotalCountHistory @entity { id: ID! - rank: Int! @index + accountId: String! @index value: BigInt! @index lastContributionAt: Date! - createdAt: Int! @index - updatedAt: Int! @index + blockHeight: BigInt! @index + extrinsicId: String! + eventId: String! } From 2dfd3e8557505063a0fb3ba62843034296b0157c Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Wed, 18 Dec 2024 08:51:58 -0500 Subject: [PATCH 10/10] change fe base on recent indexer changes --- explorer/gql/graphql.tsx | 687 +++++++++++++++--- .../Account/AccountTransfersList.tsx | 12 +- .../Consensus/Account/BalanceHistory.tsx | 8 +- .../src/components/Consensus/Account/query.ts | 7 +- explorer/src/constants/indexers.ts | 2 +- 5 files changed, 610 insertions(+), 106 deletions(-) diff --git a/explorer/gql/graphql.tsx b/explorer/gql/graphql.tsx index a7a8ed73..b2829e03 100644 --- a/explorer/gql/graphql.tsx +++ b/explorer/gql/graphql.tsx @@ -93,7 +93,6 @@ export type Consensus_Account_Histories = { nonce: Scalars['numeric']['output']; reserved: Scalars['numeric']['output']; total?: Maybe; - updated_at: Scalars['numeric']['output']; uuid: Scalars['uuid']['output']; }; @@ -135,7 +134,6 @@ export type Consensus_Account_Histories_Avg_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; }; /** Boolean expression to filter rows from the table "consensus.account_histories". All fields are combined with a logical 'AND'. */ @@ -151,7 +149,6 @@ export type Consensus_Account_Histories_Bool_Exp = { nonce?: InputMaybe; reserved?: InputMaybe; total?: InputMaybe; - updated_at?: InputMaybe; uuid?: InputMaybe; }; @@ -164,7 +161,6 @@ export type Consensus_Account_Histories_Max_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; uuid?: Maybe; }; @@ -177,7 +173,6 @@ export type Consensus_Account_Histories_Min_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; uuid?: Maybe; }; @@ -191,7 +186,6 @@ export type Consensus_Account_Histories_Order_By = { nonce?: InputMaybe; reserved?: InputMaybe; total?: InputMaybe; - updated_at?: InputMaybe; uuid?: InputMaybe; }; @@ -212,8 +206,6 @@ export enum Consensus_Account_Histories_Select_Column { /** column name */ Total = 'total', /** column name */ - UpdatedAt = 'updated_at', - /** column name */ Uuid = 'uuid' } @@ -225,7 +217,6 @@ export type Consensus_Account_Histories_Stddev_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; }; /** aggregate stddev_pop on columns */ @@ -236,7 +227,6 @@ export type Consensus_Account_Histories_Stddev_Pop_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; }; /** aggregate stddev_samp on columns */ @@ -247,7 +237,6 @@ export type Consensus_Account_Histories_Stddev_Samp_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; }; /** Streaming cursor of the table "consensus_account_histories" */ @@ -267,7 +256,6 @@ export type Consensus_Account_Histories_Stream_Cursor_Value_Input = { nonce?: InputMaybe; reserved?: InputMaybe; total?: InputMaybe; - updated_at?: InputMaybe; uuid?: InputMaybe; }; @@ -279,7 +267,6 @@ export type Consensus_Account_Histories_Sum_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; }; /** aggregate var_pop on columns */ @@ -290,7 +277,6 @@ export type Consensus_Account_Histories_Var_Pop_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; }; /** aggregate var_samp on columns */ @@ -301,7 +287,6 @@ export type Consensus_Account_Histories_Var_Samp_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; }; /** aggregate variance on columns */ @@ -312,7 +297,6 @@ export type Consensus_Account_Histories_Variance_Fields = { nonce?: Maybe; reserved?: Maybe; total?: Maybe; - updated_at?: Maybe; }; /** columns and relationships of "consensus.account_profiles" */ @@ -577,6 +561,7 @@ export type Consensus_Account_Rewards_Stream_Cursor_Value_Input = { export type Consensus_Accounts = { __typename?: 'consensus_accounts'; _block_range: Scalars['int8range']['output']; + account_id: Scalars['String']['output']; created_at: Scalars['numeric']['output']; /** An array relationship */ extrinsics: Array; @@ -684,6 +669,7 @@ export type Consensus_Accounts_Bool_Exp = { _block_range?: InputMaybe; _not?: InputMaybe; _or?: InputMaybe>; + account_id?: InputMaybe; created_at?: InputMaybe; extrinsics?: InputMaybe; extrinsics_aggregate?: InputMaybe; @@ -702,6 +688,7 @@ export type Consensus_Accounts_Bool_Exp = { /** aggregate max on columns */ export type Consensus_Accounts_Max_Fields = { __typename?: 'consensus_accounts_max_fields'; + account_id?: Maybe; created_at?: Maybe; free?: Maybe; id?: Maybe; @@ -715,6 +702,7 @@ export type Consensus_Accounts_Max_Fields = { /** aggregate min on columns */ export type Consensus_Accounts_Min_Fields = { __typename?: 'consensus_accounts_min_fields'; + account_id?: Maybe; created_at?: Maybe; free?: Maybe; id?: Maybe; @@ -728,6 +716,7 @@ export type Consensus_Accounts_Min_Fields = { /** Ordering options when selecting data from "consensus.accounts". */ export type Consensus_Accounts_Order_By = { _block_range?: InputMaybe; + account_id?: InputMaybe; created_at?: InputMaybe; extrinsics_aggregate?: InputMaybe; free?: InputMaybe; @@ -746,6 +735,8 @@ export enum Consensus_Accounts_Select_Column { /** column name */ BlockRange = '_block_range', /** column name */ + AccountId = 'account_id', + /** column name */ CreatedAt = 'created_at', /** column name */ Free = 'free', @@ -807,6 +798,7 @@ export type Consensus_Accounts_Stream_Cursor_Input = { /** Initial value of the column from where the streaming should start */ export type Consensus_Accounts_Stream_Cursor_Value_Input = { _block_range?: InputMaybe; + account_id?: InputMaybe; created_at?: InputMaybe; free?: InputMaybe; id?: InputMaybe; @@ -865,9 +857,27 @@ export type Consensus_Accounts_Variance_Fields = { export type Consensus_Blocks = { __typename?: 'consensus_blocks'; _block_range: Scalars['int8range']['output']; + accounts_count: Scalars['Int']['output']; author_id: Scalars['String']['output']; + block_reward_value: Scalars['numeric']['output']; + block_rewards_count: Scalars['Int']['output']; blockchain_size: Scalars['numeric']['output']; /** An array relationship */ + cids: Array; + /** An aggregate relationship */ + cids_aggregate: Files_Cids_Aggregate; + cumulative_accounts_count: Scalars['numeric']['output']; + cumulative_block_reward_value: Scalars['numeric']['output']; + cumulative_block_rewards_count: Scalars['numeric']['output']; + cumulative_events_count: Scalars['numeric']['output']; + cumulative_extrinsics_count: Scalars['numeric']['output']; + cumulative_reward_value: Scalars['numeric']['output']; + cumulative_rewards_count: Scalars['numeric']['output']; + cumulative_transfer_value: Scalars['numeric']['output']; + cumulative_transfers_count: Scalars['numeric']['output']; + cumulative_vote_reward_value: Scalars['numeric']['output']; + cumulative_vote_rewards_count: Scalars['numeric']['output']; + /** An array relationship */ events: Array; /** An aggregate relationship */ events_aggregate: Consensus_Events_Aggregate; @@ -886,12 +896,38 @@ export type Consensus_Blocks = { /** An aggregate relationship */ logs_aggregate: Consensus_Logs_Aggregate; parent_hash: Scalars['String']['output']; + reward_value: Scalars['numeric']['output']; + rewards_count: Scalars['Int']['output']; sort_id: Scalars['String']['output']; space_pledged: Scalars['numeric']['output']; spec_id: Scalars['String']['output']; state_root: Scalars['String']['output']; timestamp: Scalars['timestamp']['output']; + transfer_value: Scalars['numeric']['output']; + transfers_count: Scalars['Int']['output']; uuid: Scalars['uuid']['output']; + vote_reward_value: Scalars['numeric']['output']; + vote_rewards_count: Scalars['Int']['output']; +}; + + +/** columns and relationships of "consensus.blocks" */ +export type Consensus_BlocksCidsArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + + +/** columns and relationships of "consensus.blocks" */ +export type Consensus_BlocksCids_AggregateArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; }; @@ -987,11 +1023,31 @@ export type Consensus_Blocks_Aggregate_FieldsCountArgs = { /** aggregate avg on columns */ export type Consensus_Blocks_Avg_Fields = { __typename?: 'consensus_blocks_avg_fields'; + accounts_count?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; height?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; space_pledged?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** Boolean expression to filter rows from the table "consensus.blocks". All fields are combined with a logical 'AND'. */ @@ -1000,8 +1056,24 @@ export type Consensus_Blocks_Bool_Exp = { _block_range?: InputMaybe; _not?: InputMaybe; _or?: InputMaybe>; + accounts_count?: InputMaybe; author_id?: InputMaybe; + block_reward_value?: InputMaybe; + block_rewards_count?: InputMaybe; blockchain_size?: InputMaybe; + cids?: InputMaybe; + cids_aggregate?: InputMaybe; + cumulative_accounts_count?: InputMaybe; + cumulative_block_reward_value?: InputMaybe; + cumulative_block_rewards_count?: InputMaybe; + cumulative_events_count?: InputMaybe; + cumulative_extrinsics_count?: InputMaybe; + cumulative_reward_value?: InputMaybe; + cumulative_rewards_count?: InputMaybe; + cumulative_transfer_value?: InputMaybe; + cumulative_transfers_count?: InputMaybe; + cumulative_vote_reward_value?: InputMaybe; + cumulative_vote_rewards_count?: InputMaybe; events?: InputMaybe; events_aggregate?: InputMaybe; events_count?: InputMaybe; @@ -1015,19 +1087,39 @@ export type Consensus_Blocks_Bool_Exp = { logs?: InputMaybe; logs_aggregate?: InputMaybe; parent_hash?: InputMaybe; + reward_value?: InputMaybe; + rewards_count?: InputMaybe; sort_id?: InputMaybe; space_pledged?: InputMaybe; spec_id?: InputMaybe; state_root?: InputMaybe; timestamp?: InputMaybe; + transfer_value?: InputMaybe; + transfers_count?: InputMaybe; uuid?: InputMaybe; + vote_reward_value?: InputMaybe; + vote_rewards_count?: InputMaybe; }; /** aggregate max on columns */ export type Consensus_Blocks_Max_Fields = { __typename?: 'consensus_blocks_max_fields'; + accounts_count?: Maybe; author_id?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; extrinsics_root?: Maybe; @@ -1035,19 +1127,39 @@ export type Consensus_Blocks_Max_Fields = { height?: Maybe; id?: Maybe; parent_hash?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; sort_id?: Maybe; space_pledged?: Maybe; spec_id?: Maybe; state_root?: Maybe; timestamp?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; uuid?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** aggregate min on columns */ export type Consensus_Blocks_Min_Fields = { __typename?: 'consensus_blocks_min_fields'; + accounts_count?: Maybe; author_id?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; extrinsics_root?: Maybe; @@ -1055,19 +1167,40 @@ export type Consensus_Blocks_Min_Fields = { height?: Maybe; id?: Maybe; parent_hash?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; sort_id?: Maybe; space_pledged?: Maybe; spec_id?: Maybe; state_root?: Maybe; timestamp?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; uuid?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** Ordering options when selecting data from "consensus.blocks". */ export type Consensus_Blocks_Order_By = { _block_range?: InputMaybe; + accounts_count?: InputMaybe; author_id?: InputMaybe; + block_reward_value?: InputMaybe; + block_rewards_count?: InputMaybe; blockchain_size?: InputMaybe; + cids_aggregate?: InputMaybe; + cumulative_accounts_count?: InputMaybe; + cumulative_block_reward_value?: InputMaybe; + cumulative_block_rewards_count?: InputMaybe; + cumulative_events_count?: InputMaybe; + cumulative_extrinsics_count?: InputMaybe; + cumulative_reward_value?: InputMaybe; + cumulative_rewards_count?: InputMaybe; + cumulative_transfer_value?: InputMaybe; + cumulative_transfers_count?: InputMaybe; + cumulative_vote_reward_value?: InputMaybe; + cumulative_vote_rewards_count?: InputMaybe; events_aggregate?: InputMaybe; events_count?: InputMaybe; extrinsics_aggregate?: InputMaybe; @@ -1078,12 +1211,18 @@ export type Consensus_Blocks_Order_By = { id?: InputMaybe; logs_aggregate?: InputMaybe; parent_hash?: InputMaybe; + reward_value?: InputMaybe; + rewards_count?: InputMaybe; sort_id?: InputMaybe; space_pledged?: InputMaybe; spec_id?: InputMaybe; state_root?: InputMaybe; timestamp?: InputMaybe; + transfer_value?: InputMaybe; + transfers_count?: InputMaybe; uuid?: InputMaybe; + vote_reward_value?: InputMaybe; + vote_rewards_count?: InputMaybe; }; /** select columns of table "consensus.blocks" */ @@ -1091,10 +1230,38 @@ export enum Consensus_Blocks_Select_Column { /** column name */ BlockRange = '_block_range', /** column name */ + AccountsCount = 'accounts_count', + /** column name */ AuthorId = 'author_id', /** column name */ + BlockRewardValue = 'block_reward_value', + /** column name */ + BlockRewardsCount = 'block_rewards_count', + /** column name */ BlockchainSize = 'blockchain_size', /** column name */ + CumulativeAccountsCount = 'cumulative_accounts_count', + /** column name */ + CumulativeBlockRewardValue = 'cumulative_block_reward_value', + /** column name */ + CumulativeBlockRewardsCount = 'cumulative_block_rewards_count', + /** column name */ + CumulativeEventsCount = 'cumulative_events_count', + /** column name */ + CumulativeExtrinsicsCount = 'cumulative_extrinsics_count', + /** column name */ + CumulativeRewardValue = 'cumulative_reward_value', + /** column name */ + CumulativeRewardsCount = 'cumulative_rewards_count', + /** column name */ + CumulativeTransferValue = 'cumulative_transfer_value', + /** column name */ + CumulativeTransfersCount = 'cumulative_transfers_count', + /** column name */ + CumulativeVoteRewardValue = 'cumulative_vote_reward_value', + /** column name */ + CumulativeVoteRewardsCount = 'cumulative_vote_rewards_count', + /** column name */ EventsCount = 'events_count', /** column name */ ExtrinsicsCount = 'extrinsics_count', @@ -1109,6 +1276,10 @@ export enum Consensus_Blocks_Select_Column { /** column name */ ParentHash = 'parent_hash', /** column name */ + RewardValue = 'reward_value', + /** column name */ + RewardsCount = 'rewards_count', + /** column name */ SortId = 'sort_id', /** column name */ SpacePledged = 'space_pledged', @@ -1119,37 +1290,105 @@ export enum Consensus_Blocks_Select_Column { /** column name */ Timestamp = 'timestamp', /** column name */ - Uuid = 'uuid' + TransferValue = 'transfer_value', + /** column name */ + TransfersCount = 'transfers_count', + /** column name */ + Uuid = 'uuid', + /** column name */ + VoteRewardValue = 'vote_reward_value', + /** column name */ + VoteRewardsCount = 'vote_rewards_count' } /** aggregate stddev on columns */ export type Consensus_Blocks_Stddev_Fields = { __typename?: 'consensus_blocks_stddev_fields'; + accounts_count?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; height?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; space_pledged?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** aggregate stddev_pop on columns */ export type Consensus_Blocks_Stddev_Pop_Fields = { __typename?: 'consensus_blocks_stddev_pop_fields'; + accounts_count?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; height?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; space_pledged?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** aggregate stddev_samp on columns */ export type Consensus_Blocks_Stddev_Samp_Fields = { __typename?: 'consensus_blocks_stddev_samp_fields'; + accounts_count?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; height?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; space_pledged?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** Streaming cursor of the table "consensus_blocks" */ @@ -1163,8 +1402,22 @@ export type Consensus_Blocks_Stream_Cursor_Input = { /** Initial value of the column from where the streaming should start */ export type Consensus_Blocks_Stream_Cursor_Value_Input = { _block_range?: InputMaybe; + accounts_count?: InputMaybe; author_id?: InputMaybe; + block_reward_value?: InputMaybe; + block_rewards_count?: InputMaybe; blockchain_size?: InputMaybe; + cumulative_accounts_count?: InputMaybe; + cumulative_block_reward_value?: InputMaybe; + cumulative_block_rewards_count?: InputMaybe; + cumulative_events_count?: InputMaybe; + cumulative_extrinsics_count?: InputMaybe; + cumulative_reward_value?: InputMaybe; + cumulative_rewards_count?: InputMaybe; + cumulative_transfer_value?: InputMaybe; + cumulative_transfers_count?: InputMaybe; + cumulative_vote_reward_value?: InputMaybe; + cumulative_vote_rewards_count?: InputMaybe; events_count?: InputMaybe; extrinsics_count?: InputMaybe; extrinsics_root?: InputMaybe; @@ -1172,52 +1425,138 @@ export type Consensus_Blocks_Stream_Cursor_Value_Input = { height?: InputMaybe; id?: InputMaybe; parent_hash?: InputMaybe; + reward_value?: InputMaybe; + rewards_count?: InputMaybe; sort_id?: InputMaybe; space_pledged?: InputMaybe; spec_id?: InputMaybe; state_root?: InputMaybe; timestamp?: InputMaybe; + transfer_value?: InputMaybe; + transfers_count?: InputMaybe; uuid?: InputMaybe; + vote_reward_value?: InputMaybe; + vote_rewards_count?: InputMaybe; }; /** aggregate sum on columns */ export type Consensus_Blocks_Sum_Fields = { __typename?: 'consensus_blocks_sum_fields'; + accounts_count?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; height?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; space_pledged?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** aggregate var_pop on columns */ export type Consensus_Blocks_Var_Pop_Fields = { __typename?: 'consensus_blocks_var_pop_fields'; + accounts_count?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; height?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; space_pledged?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** aggregate var_samp on columns */ export type Consensus_Blocks_Var_Samp_Fields = { __typename?: 'consensus_blocks_var_samp_fields'; + accounts_count?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; height?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; space_pledged?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** aggregate variance on columns */ export type Consensus_Blocks_Variance_Fields = { __typename?: 'consensus_blocks_variance_fields'; + accounts_count?: Maybe; + block_reward_value?: Maybe; + block_rewards_count?: Maybe; blockchain_size?: Maybe; + cumulative_accounts_count?: Maybe; + cumulative_block_reward_value?: Maybe; + cumulative_block_rewards_count?: Maybe; + cumulative_events_count?: Maybe; + cumulative_extrinsics_count?: Maybe; + cumulative_reward_value?: Maybe; + cumulative_rewards_count?: Maybe; + cumulative_transfer_value?: Maybe; + cumulative_transfers_count?: Maybe; + cumulative_vote_reward_value?: Maybe; + cumulative_vote_rewards_count?: Maybe; events_count?: Maybe; extrinsics_count?: Maybe; height?: Maybe; + reward_value?: Maybe; + rewards_count?: Maybe; space_pledged?: Maybe; + transfer_value?: Maybe; + transfers_count?: Maybe; + vote_reward_value?: Maybe; + vote_rewards_count?: Maybe; }; /** columns and relationships of "consensus.event_modules" */ @@ -1232,6 +1571,7 @@ export type Consensus_Event_Modules = { method: Scalars['String']['output']; /** An object relationship */ module_section?: Maybe; + name: Scalars['String']['output']; section: Scalars['String']['output']; uuid: Scalars['uuid']['output']; }; @@ -1307,6 +1647,7 @@ export type Consensus_Event_Modules_Bool_Exp = { id?: InputMaybe; method?: InputMaybe; module_section?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1316,6 +1657,7 @@ export type Consensus_Event_Modules_Max_Fields = { __typename?: 'consensus_event_modules_max_fields'; id?: Maybe; method?: Maybe; + name?: Maybe; section?: Maybe; uuid?: Maybe; }; @@ -1324,6 +1666,7 @@ export type Consensus_Event_Modules_Max_Fields = { export type Consensus_Event_Modules_Max_Order_By = { id?: InputMaybe; method?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1333,6 +1676,7 @@ export type Consensus_Event_Modules_Min_Fields = { __typename?: 'consensus_event_modules_min_fields'; id?: Maybe; method?: Maybe; + name?: Maybe; section?: Maybe; uuid?: Maybe; }; @@ -1341,6 +1685,7 @@ export type Consensus_Event_Modules_Min_Fields = { export type Consensus_Event_Modules_Min_Order_By = { id?: InputMaybe; method?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1352,6 +1697,7 @@ export type Consensus_Event_Modules_Order_By = { id?: InputMaybe; method?: InputMaybe; module_section?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1365,6 +1711,8 @@ export enum Consensus_Event_Modules_Select_Column { /** column name */ Method = 'method', /** column name */ + Name = 'name', + /** column name */ Section = 'section', /** column name */ Uuid = 'uuid' @@ -1383,6 +1731,7 @@ export type Consensus_Event_Modules_Stream_Cursor_Value_Input = { _block_range?: InputMaybe; id?: InputMaybe; method?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1396,6 +1745,7 @@ export type Consensus_Events = { block?: Maybe; block_hash: Scalars['String']['output']; block_height: Scalars['numeric']['output']; + cid?: Maybe; /** An object relationship */ event_module?: Maybe; /** An object relationship */ @@ -1495,6 +1845,7 @@ export type Consensus_Events_Bool_Exp = { block?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; event_module?: InputMaybe; extrinsic?: InputMaybe; extrinsic_hash?: InputMaybe; @@ -1517,6 +1868,7 @@ export type Consensus_Events_Max_Fields = { args?: Maybe; block_hash?: Maybe; block_height?: Maybe; + cid?: Maybe; extrinsic_hash?: Maybe; extrinsic_id?: Maybe; id?: Maybe; @@ -1536,6 +1888,7 @@ export type Consensus_Events_Max_Order_By = { args?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; extrinsic_hash?: InputMaybe; extrinsic_id?: InputMaybe; id?: InputMaybe; @@ -1556,6 +1909,7 @@ export type Consensus_Events_Min_Fields = { args?: Maybe; block_hash?: Maybe; block_height?: Maybe; + cid?: Maybe; extrinsic_hash?: Maybe; extrinsic_id?: Maybe; id?: Maybe; @@ -1575,6 +1929,7 @@ export type Consensus_Events_Min_Order_By = { args?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; extrinsic_hash?: InputMaybe; extrinsic_id?: InputMaybe; id?: InputMaybe; @@ -1596,6 +1951,7 @@ export type Consensus_Events_Order_By = { block?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; event_module?: InputMaybe; extrinsic?: InputMaybe; extrinsic_hash?: InputMaybe; @@ -1623,6 +1979,8 @@ export enum Consensus_Events_Select_Column { /** column name */ BlockHeight = 'block_height', /** column name */ + Cid = 'cid', + /** column name */ ExtrinsicHash = 'extrinsic_hash', /** column name */ ExtrinsicId = 'extrinsic_id', @@ -1707,6 +2065,7 @@ export type Consensus_Events_Stream_Cursor_Value_Input = { args?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; extrinsic_hash?: InputMaybe; extrinsic_id?: InputMaybe; id?: InputMaybe; @@ -1793,6 +2152,7 @@ export type Consensus_Extrinsic_Modules = { method: Scalars['String']['output']; /** An object relationship */ module_section?: Maybe; + name: Scalars['String']['output']; section: Scalars['String']['output']; uuid: Scalars['uuid']['output']; }; @@ -1868,6 +2228,7 @@ export type Consensus_Extrinsic_Modules_Bool_Exp = { id?: InputMaybe; method?: InputMaybe; module_section?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1877,6 +2238,7 @@ export type Consensus_Extrinsic_Modules_Max_Fields = { __typename?: 'consensus_extrinsic_modules_max_fields'; id?: Maybe; method?: Maybe; + name?: Maybe; section?: Maybe; uuid?: Maybe; }; @@ -1885,6 +2247,7 @@ export type Consensus_Extrinsic_Modules_Max_Fields = { export type Consensus_Extrinsic_Modules_Max_Order_By = { id?: InputMaybe; method?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1894,6 +2257,7 @@ export type Consensus_Extrinsic_Modules_Min_Fields = { __typename?: 'consensus_extrinsic_modules_min_fields'; id?: Maybe; method?: Maybe; + name?: Maybe; section?: Maybe; uuid?: Maybe; }; @@ -1902,6 +2266,7 @@ export type Consensus_Extrinsic_Modules_Min_Fields = { export type Consensus_Extrinsic_Modules_Min_Order_By = { id?: InputMaybe; method?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1913,6 +2278,7 @@ export type Consensus_Extrinsic_Modules_Order_By = { id?: InputMaybe; method?: InputMaybe; module_section?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1926,6 +2292,8 @@ export enum Consensus_Extrinsic_Modules_Select_Column { /** column name */ Method = 'method', /** column name */ + Name = 'name', + /** column name */ Section = 'section', /** column name */ Uuid = 'uuid' @@ -1944,6 +2312,7 @@ export type Consensus_Extrinsic_Modules_Stream_Cursor_Value_Input = { _block_range?: InputMaybe; id?: InputMaybe; method?: InputMaybe; + name?: InputMaybe; section?: InputMaybe; uuid?: InputMaybe; }; @@ -1957,6 +2326,11 @@ export type Consensus_Extrinsics = { block?: Maybe; block_hash: Scalars['String']['output']; block_height: Scalars['numeric']['output']; + cid?: Maybe; + /** An array relationship */ + cids: Array; + /** An aggregate relationship */ + cids_aggregate: Files_Cids_Aggregate; error: Scalars['String']['output']; /** An array relationship */ events: Array; @@ -1983,6 +2357,26 @@ export type Consensus_Extrinsics = { }; +/** columns and relationships of "consensus.extrinsics" */ +export type Consensus_ExtrinsicsCidsArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + + +/** columns and relationships of "consensus.extrinsics" */ +export type Consensus_ExtrinsicsCids_AggregateArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + + /** columns and relationships of "consensus.extrinsics" */ export type Consensus_ExtrinsicsEventsArgs = { distinct_on?: InputMaybe>; @@ -2105,6 +2499,9 @@ export type Consensus_Extrinsics_Bool_Exp = { block?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; + cids?: InputMaybe; + cids_aggregate?: InputMaybe; error?: InputMaybe; events?: InputMaybe; events_aggregate?: InputMaybe; @@ -2133,6 +2530,7 @@ export type Consensus_Extrinsics_Max_Fields = { args?: Maybe; block_hash?: Maybe; block_height?: Maybe; + cid?: Maybe; error?: Maybe; fee?: Maybe; hash?: Maybe; @@ -2156,6 +2554,7 @@ export type Consensus_Extrinsics_Max_Order_By = { args?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; error?: InputMaybe; fee?: InputMaybe; hash?: InputMaybe; @@ -2180,6 +2579,7 @@ export type Consensus_Extrinsics_Min_Fields = { args?: Maybe; block_hash?: Maybe; block_height?: Maybe; + cid?: Maybe; error?: Maybe; fee?: Maybe; hash?: Maybe; @@ -2203,6 +2603,7 @@ export type Consensus_Extrinsics_Min_Order_By = { args?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; error?: InputMaybe; fee?: InputMaybe; hash?: InputMaybe; @@ -2228,6 +2629,8 @@ export type Consensus_Extrinsics_Order_By = { block?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; + cids_aggregate?: InputMaybe; error?: InputMaybe; events_aggregate?: InputMaybe; extrinsic_module?: InputMaybe; @@ -2260,6 +2663,8 @@ export enum Consensus_Extrinsics_Select_Column { /** column name */ BlockHeight = 'block_height', /** column name */ + Cid = 'cid', + /** column name */ Error = 'error', /** column name */ Fee = 'fee', @@ -2384,6 +2789,7 @@ export type Consensus_Extrinsics_Stream_Cursor_Value_Input = { args?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + cid?: InputMaybe; error?: InputMaybe; fee?: InputMaybe; hash?: InputMaybe; @@ -2492,6 +2898,7 @@ export type Consensus_Log_Kinds = { __typename?: 'consensus_log_kinds'; _block_range: Scalars['int8range']['output']; id: Scalars['String']['output']; + kind: Scalars['String']['output']; /** An array relationship */ logs: Array; /** An aggregate relationship */ @@ -2548,6 +2955,7 @@ export type Consensus_Log_Kinds_Bool_Exp = { _not?: InputMaybe; _or?: InputMaybe>; id?: InputMaybe; + kind?: InputMaybe; logs?: InputMaybe; logs_aggregate?: InputMaybe; uuid?: InputMaybe; @@ -2557,6 +2965,7 @@ export type Consensus_Log_Kinds_Bool_Exp = { export type Consensus_Log_Kinds_Max_Fields = { __typename?: 'consensus_log_kinds_max_fields'; id?: Maybe; + kind?: Maybe; uuid?: Maybe; }; @@ -2564,6 +2973,7 @@ export type Consensus_Log_Kinds_Max_Fields = { export type Consensus_Log_Kinds_Min_Fields = { __typename?: 'consensus_log_kinds_min_fields'; id?: Maybe; + kind?: Maybe; uuid?: Maybe; }; @@ -2571,6 +2981,7 @@ export type Consensus_Log_Kinds_Min_Fields = { export type Consensus_Log_Kinds_Order_By = { _block_range?: InputMaybe; id?: InputMaybe; + kind?: InputMaybe; logs_aggregate?: InputMaybe; uuid?: InputMaybe; }; @@ -2582,6 +2993,8 @@ export enum Consensus_Log_Kinds_Select_Column { /** column name */ Id = 'id', /** column name */ + Kind = 'kind', + /** column name */ Uuid = 'uuid' } @@ -2597,6 +3010,7 @@ export type Consensus_Log_Kinds_Stream_Cursor_Input = { export type Consensus_Log_Kinds_Stream_Cursor_Value_Input = { _block_range?: InputMaybe; id?: InputMaybe; + kind?: InputMaybe; uuid?: InputMaybe; }; @@ -2926,8 +3340,9 @@ export type Consensus_Rewards = { block?: Maybe; block_hash: Scalars['String']['output']; block_height: Scalars['numeric']['output']; + event_id: Scalars['String']['output']; + extrinsic_id: Scalars['String']['output']; id: Scalars['String']['output']; - index_in_block: Scalars['numeric']['output']; reward_type: Scalars['String']['output']; timestamp: Scalars['timestamp']['output']; uuid: Scalars['uuid']['output']; @@ -2994,14 +3409,12 @@ export type Consensus_Rewards_Avg_Fields = { __typename?: 'consensus_rewards_avg_fields'; amount?: Maybe; block_height?: Maybe; - index_in_block?: Maybe; }; /** order by avg() on columns of table "consensus.rewards" */ export type Consensus_Rewards_Avg_Order_By = { amount?: InputMaybe; block_height?: InputMaybe; - index_in_block?: InputMaybe; }; /** Boolean expression to filter rows from the table "consensus.rewards". All fields are combined with a logical 'AND'. */ @@ -3016,8 +3429,9 @@ export type Consensus_Rewards_Bool_Exp = { block?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + event_id?: InputMaybe; + extrinsic_id?: InputMaybe; id?: InputMaybe; - index_in_block?: InputMaybe; reward_type?: InputMaybe; timestamp?: InputMaybe; uuid?: InputMaybe; @@ -3030,8 +3444,9 @@ export type Consensus_Rewards_Max_Fields = { amount?: Maybe; block_hash?: Maybe; block_height?: Maybe; + event_id?: Maybe; + extrinsic_id?: Maybe; id?: Maybe; - index_in_block?: Maybe; reward_type?: Maybe; timestamp?: Maybe; uuid?: Maybe; @@ -3043,8 +3458,9 @@ export type Consensus_Rewards_Max_Order_By = { amount?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + event_id?: InputMaybe; + extrinsic_id?: InputMaybe; id?: InputMaybe; - index_in_block?: InputMaybe; reward_type?: InputMaybe; timestamp?: InputMaybe; uuid?: InputMaybe; @@ -3057,8 +3473,9 @@ export type Consensus_Rewards_Min_Fields = { amount?: Maybe; block_hash?: Maybe; block_height?: Maybe; + event_id?: Maybe; + extrinsic_id?: Maybe; id?: Maybe; - index_in_block?: Maybe; reward_type?: Maybe; timestamp?: Maybe; uuid?: Maybe; @@ -3070,8 +3487,9 @@ export type Consensus_Rewards_Min_Order_By = { amount?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + event_id?: InputMaybe; + extrinsic_id?: InputMaybe; id?: InputMaybe; - index_in_block?: InputMaybe; reward_type?: InputMaybe; timestamp?: InputMaybe; uuid?: InputMaybe; @@ -3086,8 +3504,9 @@ export type Consensus_Rewards_Order_By = { block?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + event_id?: InputMaybe; + extrinsic_id?: InputMaybe; id?: InputMaybe; - index_in_block?: InputMaybe; reward_type?: InputMaybe; timestamp?: InputMaybe; uuid?: InputMaybe; @@ -3106,9 +3525,11 @@ export enum Consensus_Rewards_Select_Column { /** column name */ BlockHeight = 'block_height', /** column name */ - Id = 'id', + EventId = 'event_id', /** column name */ - IndexInBlock = 'index_in_block', + ExtrinsicId = 'extrinsic_id', + /** column name */ + Id = 'id', /** column name */ RewardType = 'reward_type', /** column name */ @@ -3122,14 +3543,12 @@ export type Consensus_Rewards_Stddev_Fields = { __typename?: 'consensus_rewards_stddev_fields'; amount?: Maybe; block_height?: Maybe; - index_in_block?: Maybe; }; /** order by stddev() on columns of table "consensus.rewards" */ export type Consensus_Rewards_Stddev_Order_By = { amount?: InputMaybe; block_height?: InputMaybe; - index_in_block?: InputMaybe; }; /** aggregate stddev_pop on columns */ @@ -3137,14 +3556,12 @@ export type Consensus_Rewards_Stddev_Pop_Fields = { __typename?: 'consensus_rewards_stddev_pop_fields'; amount?: Maybe; block_height?: Maybe; - index_in_block?: Maybe; }; /** order by stddev_pop() on columns of table "consensus.rewards" */ export type Consensus_Rewards_Stddev_Pop_Order_By = { amount?: InputMaybe; block_height?: InputMaybe; - index_in_block?: InputMaybe; }; /** aggregate stddev_samp on columns */ @@ -3152,14 +3569,12 @@ export type Consensus_Rewards_Stddev_Samp_Fields = { __typename?: 'consensus_rewards_stddev_samp_fields'; amount?: Maybe; block_height?: Maybe; - index_in_block?: Maybe; }; /** order by stddev_samp() on columns of table "consensus.rewards" */ export type Consensus_Rewards_Stddev_Samp_Order_By = { amount?: InputMaybe; block_height?: InputMaybe; - index_in_block?: InputMaybe; }; /** Streaming cursor of the table "consensus_rewards" */ @@ -3177,8 +3592,9 @@ export type Consensus_Rewards_Stream_Cursor_Value_Input = { amount?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; + event_id?: InputMaybe; + extrinsic_id?: InputMaybe; id?: InputMaybe; - index_in_block?: InputMaybe; reward_type?: InputMaybe; timestamp?: InputMaybe; uuid?: InputMaybe; @@ -3189,14 +3605,12 @@ export type Consensus_Rewards_Sum_Fields = { __typename?: 'consensus_rewards_sum_fields'; amount?: Maybe; block_height?: Maybe; - index_in_block?: Maybe; }; /** order by sum() on columns of table "consensus.rewards" */ export type Consensus_Rewards_Sum_Order_By = { amount?: InputMaybe; block_height?: InputMaybe; - index_in_block?: InputMaybe; }; /** aggregate var_pop on columns */ @@ -3204,14 +3618,12 @@ export type Consensus_Rewards_Var_Pop_Fields = { __typename?: 'consensus_rewards_var_pop_fields'; amount?: Maybe; block_height?: Maybe; - index_in_block?: Maybe; }; /** order by var_pop() on columns of table "consensus.rewards" */ export type Consensus_Rewards_Var_Pop_Order_By = { amount?: InputMaybe; block_height?: InputMaybe; - index_in_block?: InputMaybe; }; /** aggregate var_samp on columns */ @@ -3219,14 +3631,12 @@ export type Consensus_Rewards_Var_Samp_Fields = { __typename?: 'consensus_rewards_var_samp_fields'; amount?: Maybe; block_height?: Maybe; - index_in_block?: Maybe; }; /** order by var_samp() on columns of table "consensus.rewards" */ export type Consensus_Rewards_Var_Samp_Order_By = { amount?: InputMaybe; block_height?: InputMaybe; - index_in_block?: InputMaybe; }; /** aggregate variance on columns */ @@ -3234,14 +3644,12 @@ export type Consensus_Rewards_Variance_Fields = { __typename?: 'consensus_rewards_variance_fields'; amount?: Maybe; block_height?: Maybe; - index_in_block?: Maybe; }; /** order by variance() on columns of table "consensus.rewards" */ export type Consensus_Rewards_Variance_Order_By = { amount?: InputMaybe; block_height?: InputMaybe; - index_in_block?: InputMaybe; }; /** columns and relationships of "consensus.sections" */ @@ -3257,6 +3665,7 @@ export type Consensus_Sections = { /** An aggregate relationship */ extrinsic_modules_aggregate: Consensus_Extrinsic_Modules_Aggregate; id: Scalars['String']['output']; + section: Scalars['String']['output']; uuid: Scalars['uuid']['output']; }; @@ -3333,6 +3742,7 @@ export type Consensus_Sections_Bool_Exp = { extrinsic_modules?: InputMaybe; extrinsic_modules_aggregate?: InputMaybe; id?: InputMaybe; + section?: InputMaybe; uuid?: InputMaybe; }; @@ -3340,6 +3750,7 @@ export type Consensus_Sections_Bool_Exp = { export type Consensus_Sections_Max_Fields = { __typename?: 'consensus_sections_max_fields'; id?: Maybe; + section?: Maybe; uuid?: Maybe; }; @@ -3347,6 +3758,7 @@ export type Consensus_Sections_Max_Fields = { export type Consensus_Sections_Min_Fields = { __typename?: 'consensus_sections_min_fields'; id?: Maybe; + section?: Maybe; uuid?: Maybe; }; @@ -3356,6 +3768,7 @@ export type Consensus_Sections_Order_By = { event_modules_aggregate?: InputMaybe; extrinsic_modules_aggregate?: InputMaybe; id?: InputMaybe; + section?: InputMaybe; uuid?: InputMaybe; }; @@ -3366,6 +3779,8 @@ export enum Consensus_Sections_Select_Column { /** column name */ Id = 'id', /** column name */ + Section = 'section', + /** column name */ Uuid = 'uuid' } @@ -3381,6 +3796,7 @@ export type Consensus_Sections_Stream_Cursor_Input = { export type Consensus_Sections_Stream_Cursor_Value_Input = { _block_range?: InputMaybe; id?: InputMaybe; + section?: InputMaybe; uuid?: InputMaybe; }; @@ -3388,15 +3804,15 @@ export type Consensus_Sections_Stream_Cursor_Value_Input = { export type Consensus_Transfers = { __typename?: 'consensus_transfers'; _block_range: Scalars['int8range']['output']; - created_at: Scalars['numeric']['output']; - date: Scalars['timestamp']['output']; + block_hash: Scalars['String']['output']; + block_height: Scalars['numeric']['output']; event_id: Scalars['String']['output']; extrinsic_id: Scalars['String']['output']; fee: Scalars['numeric']['output']; from: Scalars['String']['output']; id: Scalars['String']['output']; success: Scalars['Boolean']['output']; - timestamp: Scalars['numeric']['output']; + timestamp: Scalars['timestamp']['output']; to: Scalars['String']['output']; uuid: Scalars['uuid']['output']; value: Scalars['numeric']['output']; @@ -3435,9 +3851,8 @@ export type Consensus_Transfers_Aggregate_FieldsCountArgs = { /** aggregate avg on columns */ export type Consensus_Transfers_Avg_Fields = { __typename?: 'consensus_transfers_avg_fields'; - created_at?: Maybe; + block_height?: Maybe; fee?: Maybe; - timestamp?: Maybe; value?: Maybe; }; @@ -3447,15 +3862,15 @@ export type Consensus_Transfers_Bool_Exp = { _block_range?: InputMaybe; _not?: InputMaybe; _or?: InputMaybe>; - created_at?: InputMaybe; - date?: InputMaybe; + block_hash?: InputMaybe; + block_height?: InputMaybe; event_id?: InputMaybe; extrinsic_id?: InputMaybe; fee?: InputMaybe; from?: InputMaybe; id?: InputMaybe; success?: InputMaybe; - timestamp?: InputMaybe; + timestamp?: InputMaybe; to?: InputMaybe; uuid?: InputMaybe; value?: InputMaybe; @@ -3464,14 +3879,14 @@ export type Consensus_Transfers_Bool_Exp = { /** aggregate max on columns */ export type Consensus_Transfers_Max_Fields = { __typename?: 'consensus_transfers_max_fields'; - created_at?: Maybe; - date?: Maybe; + block_hash?: Maybe; + block_height?: Maybe; event_id?: Maybe; extrinsic_id?: Maybe; fee?: Maybe; from?: Maybe; id?: Maybe; - timestamp?: Maybe; + timestamp?: Maybe; to?: Maybe; uuid?: Maybe; value?: Maybe; @@ -3480,14 +3895,14 @@ export type Consensus_Transfers_Max_Fields = { /** aggregate min on columns */ export type Consensus_Transfers_Min_Fields = { __typename?: 'consensus_transfers_min_fields'; - created_at?: Maybe; - date?: Maybe; + block_hash?: Maybe; + block_height?: Maybe; event_id?: Maybe; extrinsic_id?: Maybe; fee?: Maybe; from?: Maybe; id?: Maybe; - timestamp?: Maybe; + timestamp?: Maybe; to?: Maybe; uuid?: Maybe; value?: Maybe; @@ -3496,8 +3911,8 @@ export type Consensus_Transfers_Min_Fields = { /** Ordering options when selecting data from "consensus.transfers". */ export type Consensus_Transfers_Order_By = { _block_range?: InputMaybe; - created_at?: InputMaybe; - date?: InputMaybe; + block_hash?: InputMaybe; + block_height?: InputMaybe; event_id?: InputMaybe; extrinsic_id?: InputMaybe; fee?: InputMaybe; @@ -3515,9 +3930,9 @@ export enum Consensus_Transfers_Select_Column { /** column name */ BlockRange = '_block_range', /** column name */ - CreatedAt = 'created_at', + BlockHash = 'block_hash', /** column name */ - Date = 'date', + BlockHeight = 'block_height', /** column name */ EventId = 'event_id', /** column name */ @@ -3543,27 +3958,24 @@ export enum Consensus_Transfers_Select_Column { /** aggregate stddev on columns */ export type Consensus_Transfers_Stddev_Fields = { __typename?: 'consensus_transfers_stddev_fields'; - created_at?: Maybe; + block_height?: Maybe; fee?: Maybe; - timestamp?: Maybe; value?: Maybe; }; /** aggregate stddev_pop on columns */ export type Consensus_Transfers_Stddev_Pop_Fields = { __typename?: 'consensus_transfers_stddev_pop_fields'; - created_at?: Maybe; + block_height?: Maybe; fee?: Maybe; - timestamp?: Maybe; value?: Maybe; }; /** aggregate stddev_samp on columns */ export type Consensus_Transfers_Stddev_Samp_Fields = { __typename?: 'consensus_transfers_stddev_samp_fields'; - created_at?: Maybe; + block_height?: Maybe; fee?: Maybe; - timestamp?: Maybe; value?: Maybe; }; @@ -3578,15 +3990,15 @@ export type Consensus_Transfers_Stream_Cursor_Input = { /** Initial value of the column from where the streaming should start */ export type Consensus_Transfers_Stream_Cursor_Value_Input = { _block_range?: InputMaybe; - created_at?: InputMaybe; - date?: InputMaybe; + block_hash?: InputMaybe; + block_height?: InputMaybe; event_id?: InputMaybe; extrinsic_id?: InputMaybe; fee?: InputMaybe; from?: InputMaybe; id?: InputMaybe; success?: InputMaybe; - timestamp?: InputMaybe; + timestamp?: InputMaybe; to?: InputMaybe; uuid?: InputMaybe; value?: InputMaybe; @@ -3595,36 +4007,32 @@ export type Consensus_Transfers_Stream_Cursor_Value_Input = { /** aggregate sum on columns */ export type Consensus_Transfers_Sum_Fields = { __typename?: 'consensus_transfers_sum_fields'; - created_at?: Maybe; + block_height?: Maybe; fee?: Maybe; - timestamp?: Maybe; value?: Maybe; }; /** aggregate var_pop on columns */ export type Consensus_Transfers_Var_Pop_Fields = { __typename?: 'consensus_transfers_var_pop_fields'; - created_at?: Maybe; + block_height?: Maybe; fee?: Maybe; - timestamp?: Maybe; value?: Maybe; }; /** aggregate var_samp on columns */ export type Consensus_Transfers_Var_Samp_Fields = { __typename?: 'consensus_transfers_var_samp_fields'; - created_at?: Maybe; + block_height?: Maybe; fee?: Maybe; - timestamp?: Maybe; value?: Maybe; }; /** aggregate variance on columns */ export type Consensus_Transfers_Variance_Fields = { __typename?: 'consensus_transfers_variance_fields'; - created_at?: Maybe; + block_height?: Maybe; fee?: Maybe; - timestamp?: Maybe; value?: Maybe; }; @@ -3904,10 +4312,14 @@ export type Files_Chunks_Stream_Cursor_Value_Input = { export type Files_Cids = { __typename?: 'files_cids'; _block_range: Scalars['int8range']['output']; + /** An object relationship */ + block?: Maybe; block_hash: Scalars['String']['output']; block_height: Scalars['numeric']['output']; /** An object relationship */ chunk?: Maybe; + /** An object relationship */ + extrinsic?: Maybe; extrinsic_hash: Scalars['String']['output']; extrinsic_id: Scalars['String']['output']; id: Scalars['String']['output']; @@ -3930,6 +4342,17 @@ export type Files_Cids_Aggregate = { nodes: Array; }; +export type Files_Cids_Aggregate_Bool_Exp = { + count?: InputMaybe; +}; + +export type Files_Cids_Aggregate_Bool_Exp_Count = { + arguments?: InputMaybe>; + distinct?: InputMaybe; + filter?: InputMaybe; + predicate: Int_Comparison_Exp; +}; + /** aggregate fields of "files.cids" */ export type Files_Cids_Aggregate_Fields = { __typename?: 'files_cids_aggregate_fields'; @@ -3953,6 +4376,21 @@ export type Files_Cids_Aggregate_FieldsCountArgs = { distinct?: InputMaybe; }; +/** order by aggregate values of table "files.cids" */ +export type Files_Cids_Aggregate_Order_By = { + avg?: InputMaybe; + count?: InputMaybe; + max?: InputMaybe; + min?: InputMaybe; + stddev?: InputMaybe; + stddev_pop?: InputMaybe; + stddev_samp?: InputMaybe; + sum?: InputMaybe; + var_pop?: InputMaybe; + var_samp?: InputMaybe; + variance?: InputMaybe; +}; + /** aggregate avg on columns */ export type Files_Cids_Avg_Fields = { __typename?: 'files_cids_avg_fields'; @@ -3960,15 +4398,23 @@ export type Files_Cids_Avg_Fields = { index_in_block?: Maybe; }; +/** order by avg() on columns of table "files.cids" */ +export type Files_Cids_Avg_Order_By = { + block_height?: InputMaybe; + index_in_block?: InputMaybe; +}; + /** Boolean expression to filter rows from the table "files.cids". All fields are combined with a logical 'AND'. */ export type Files_Cids_Bool_Exp = { _and?: InputMaybe>; _block_range?: InputMaybe; _not?: InputMaybe; _or?: InputMaybe>; + block?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; chunk?: InputMaybe; + extrinsic?: InputMaybe; extrinsic_hash?: InputMaybe; extrinsic_id?: InputMaybe; id?: InputMaybe; @@ -3991,6 +4437,18 @@ export type Files_Cids_Max_Fields = { uuid?: Maybe; }; +/** order by max() on columns of table "files.cids" */ +export type Files_Cids_Max_Order_By = { + block_hash?: InputMaybe; + block_height?: InputMaybe; + extrinsic_hash?: InputMaybe; + extrinsic_id?: InputMaybe; + id?: InputMaybe; + index_in_block?: InputMaybe; + timestamp?: InputMaybe; + uuid?: InputMaybe; +}; + /** aggregate min on columns */ export type Files_Cids_Min_Fields = { __typename?: 'files_cids_min_fields'; @@ -4004,12 +4462,26 @@ export type Files_Cids_Min_Fields = { uuid?: Maybe; }; +/** order by min() on columns of table "files.cids" */ +export type Files_Cids_Min_Order_By = { + block_hash?: InputMaybe; + block_height?: InputMaybe; + extrinsic_hash?: InputMaybe; + extrinsic_id?: InputMaybe; + id?: InputMaybe; + index_in_block?: InputMaybe; + timestamp?: InputMaybe; + uuid?: InputMaybe; +}; + /** Ordering options when selecting data from "files.cids". */ export type Files_Cids_Order_By = { _block_range?: InputMaybe; + block?: InputMaybe; block_hash?: InputMaybe; block_height?: InputMaybe; chunk?: InputMaybe; + extrinsic?: InputMaybe; extrinsic_hash?: InputMaybe; extrinsic_id?: InputMaybe; id?: InputMaybe; @@ -4050,6 +4522,12 @@ export type Files_Cids_Stddev_Fields = { index_in_block?: Maybe; }; +/** order by stddev() on columns of table "files.cids" */ +export type Files_Cids_Stddev_Order_By = { + block_height?: InputMaybe; + index_in_block?: InputMaybe; +}; + /** aggregate stddev_pop on columns */ export type Files_Cids_Stddev_Pop_Fields = { __typename?: 'files_cids_stddev_pop_fields'; @@ -4057,6 +4535,12 @@ export type Files_Cids_Stddev_Pop_Fields = { index_in_block?: Maybe; }; +/** order by stddev_pop() on columns of table "files.cids" */ +export type Files_Cids_Stddev_Pop_Order_By = { + block_height?: InputMaybe; + index_in_block?: InputMaybe; +}; + /** aggregate stddev_samp on columns */ export type Files_Cids_Stddev_Samp_Fields = { __typename?: 'files_cids_stddev_samp_fields'; @@ -4064,6 +4548,12 @@ export type Files_Cids_Stddev_Samp_Fields = { index_in_block?: Maybe; }; +/** order by stddev_samp() on columns of table "files.cids" */ +export type Files_Cids_Stddev_Samp_Order_By = { + block_height?: InputMaybe; + index_in_block?: InputMaybe; +}; + /** Streaming cursor of the table "files_cids" */ export type Files_Cids_Stream_Cursor_Input = { /** Stream column input with initial value */ @@ -4093,6 +4583,12 @@ export type Files_Cids_Sum_Fields = { index_in_block?: Maybe; }; +/** order by sum() on columns of table "files.cids" */ +export type Files_Cids_Sum_Order_By = { + block_height?: InputMaybe; + index_in_block?: InputMaybe; +}; + /** aggregate var_pop on columns */ export type Files_Cids_Var_Pop_Fields = { __typename?: 'files_cids_var_pop_fields'; @@ -4100,6 +4596,12 @@ export type Files_Cids_Var_Pop_Fields = { index_in_block?: Maybe; }; +/** order by var_pop() on columns of table "files.cids" */ +export type Files_Cids_Var_Pop_Order_By = { + block_height?: InputMaybe; + index_in_block?: InputMaybe; +}; + /** aggregate var_samp on columns */ export type Files_Cids_Var_Samp_Fields = { __typename?: 'files_cids_var_samp_fields'; @@ -4107,6 +4609,12 @@ export type Files_Cids_Var_Samp_Fields = { index_in_block?: Maybe; }; +/** order by var_samp() on columns of table "files.cids" */ +export type Files_Cids_Var_Samp_Order_By = { + block_height?: InputMaybe; + index_in_block?: InputMaybe; +}; + /** aggregate variance on columns */ export type Files_Cids_Variance_Fields = { __typename?: 'files_cids_variance_fields'; @@ -4114,6 +4622,12 @@ export type Files_Cids_Variance_Fields = { index_in_block?: Maybe; }; +/** order by variance() on columns of table "files.cids" */ +export type Files_Cids_Variance_Order_By = { + block_height?: InputMaybe; + index_in_block?: InputMaybe; +}; + /** columns and relationships of "files.file_cids" */ export type Files_File_Cids = { __typename?: 'files_file_cids'; @@ -17746,7 +18260,7 @@ export type LatestRewardsWeekQueryVariables = Exact<{ }>; -export type LatestRewardsWeekQuery = { __typename?: 'query_root', consensus_rewards: Array<{ __typename?: 'consensus_rewards', id: string, block_height: any, index_in_block: any, reward_type: string, amount: any, timestamp: any }> }; +export type LatestRewardsWeekQuery = { __typename?: 'query_root', consensus_rewards: Array<{ __typename?: 'consensus_rewards', id: string, block_height: any, reward_type: string, amount: any, timestamp: any }> }; export type RewardsListQueryVariables = Exact<{ accountId: Scalars['String']['input']; @@ -17756,7 +18270,7 @@ export type RewardsListQueryVariables = Exact<{ }>; -export type RewardsListQuery = { __typename?: 'query_root', consensus_rewards_aggregate: { __typename?: 'consensus_rewards_aggregate', aggregate?: { __typename?: 'consensus_rewards_aggregate_fields', count: number } | null }, consensus_rewards: Array<{ __typename?: 'consensus_rewards', id: string, block_height: any, index_in_block: any, reward_type: string, amount: any, timestamp: any, block?: { __typename?: 'consensus_blocks', hash: string, id: string, height: any } | null, account?: { __typename?: 'consensus_accounts', id: string, free: any, reserved: any, total?: any | null, updated_at: any } | null }> }; +export type RewardsListQuery = { __typename?: 'query_root', consensus_rewards_aggregate: { __typename?: 'consensus_rewards_aggregate', aggregate?: { __typename?: 'consensus_rewards_aggregate_fields', count: number } | null }, consensus_rewards: Array<{ __typename?: 'consensus_rewards', id: string, block_height: any, reward_type: string, amount: any, timestamp: any, block?: { __typename?: 'consensus_blocks', hash: string, id: string, height: any } | null, account?: { __typename?: 'consensus_accounts', id: string, free: any, reserved: any, total?: any | null, updated_at: any } | null }> }; export type ExtrinsicsByAccountIdQueryVariables = Exact<{ limit: Scalars['Int']['input']; @@ -17776,7 +18290,7 @@ export type TransfersByAccountIdQueryVariables = Exact<{ }>; -export type TransfersByAccountIdQuery = { __typename?: 'query_root', consensus_transfers_aggregate: { __typename?: 'consensus_transfers_aggregate', aggregate?: { __typename?: 'consensus_transfers_aggregate_fields', count: number } | null }, consensus_transfers: Array<{ __typename?: 'consensus_transfers', id: string, extrinsic_id: string, event_id: string, from: string, to: string, value: any, fee: any, success: boolean, timestamp: any, date: any, created_at: any }> }; +export type TransfersByAccountIdQuery = { __typename?: 'query_root', consensus_transfers_aggregate: { __typename?: 'consensus_transfers_aggregate', aggregate?: { __typename?: 'consensus_transfers_aggregate_fields', count: number } | null }, consensus_transfers: Array<{ __typename?: 'consensus_transfers', id: string, extrinsic_id: string, event_id: string, from: string, to: string, value: any, fee: any, success: boolean, timestamp: any, block_height: any }> }; export type BalanceHistoryByAccountIdQueryVariables = Exact<{ limit: Scalars['Int']['input']; @@ -17786,14 +18300,14 @@ export type BalanceHistoryByAccountIdQueryVariables = Exact<{ }>; -export type BalanceHistoryByAccountIdQuery = { __typename?: 'query_root', consensus_account_histories_aggregate: { __typename?: 'consensus_account_histories_aggregate', aggregate?: { __typename?: 'consensus_account_histories_aggregate_fields', count: number } | null }, consensus_account_histories: Array<{ __typename?: 'consensus_account_histories', reserved: any, total?: any | null, nonce: any, free: any, created_at: any, updated_at: any, _block_range: any, id: any }> }; +export type BalanceHistoryByAccountIdQuery = { __typename?: 'query_root', consensus_account_histories_aggregate: { __typename?: 'consensus_account_histories_aggregate', aggregate?: { __typename?: 'consensus_account_histories_aggregate_fields', count: number } | null }, consensus_account_histories: Array<{ __typename?: 'consensus_account_histories', reserved: any, total?: any | null, nonce: any, free: any, created_at: any, _block_range: any, id: any }> }; export type AllRewardForAccountByIdQueryVariables = Exact<{ accountId: Scalars['String']['input']; }>; -export type AllRewardForAccountByIdQuery = { __typename?: 'query_root', consensus_rewards: Array<{ __typename?: 'consensus_rewards', id: string, block_height: any, index_in_block: any, reward_type: string, amount: any, timestamp: any }> }; +export type AllRewardForAccountByIdQuery = { __typename?: 'query_root', consensus_rewards: Array<{ __typename?: 'consensus_rewards', id: string, block_height: any, reward_type: string, amount: any, timestamp: any }> }; export type BlocksQueryVariables = Exact<{ limit: Scalars['Int']['input']; @@ -18462,7 +18976,6 @@ export const LatestRewardsWeekDocument = gql` ) { id block_height - index_in_block reward_type amount timestamp @@ -18520,7 +19033,6 @@ export const RewardsListDocument = gql` ) { id block_height - index_in_block reward_type amount timestamp @@ -18657,8 +19169,7 @@ export const TransfersByAccountIdDocument = gql` fee success timestamp - date - created_at + block_height } } `; @@ -18717,7 +19228,6 @@ export const BalanceHistoryByAccountIdDocument = gql` nonce free created_at - updated_at _block_range } } @@ -18766,7 +19276,6 @@ export const AllRewardForAccountByIdDocument = gql` ) { id block_height - index_in_block reward_type amount timestamp diff --git a/explorer/src/components/Consensus/Account/AccountTransfersList.tsx b/explorer/src/components/Consensus/Account/AccountTransfersList.tsx index b7ca6025..a2de8c9d 100644 --- a/explorer/src/components/Consensus/Account/AccountTransfersList.tsx +++ b/explorer/src/components/Consensus/Account/AccountTransfersList.tsx @@ -40,7 +40,7 @@ type Row = TransfersByAccountIdQuery['consensus_transfers'][0] export const AccountTransfersList: FC = ({ accountId }) => { const { ref, inView } = useInView() const [sorting, setSorting] = useState([ - { id: TransferColumn.CreatedAt, desc: true }, + { id: TransferColumn.BlockHeight, desc: true }, ]) const [pagination, setPagination] = useState({ pageSize: PAGE_SIZE, @@ -121,17 +121,17 @@ export const AccountTransfersList: FC = ({ accountId }) => { header: 'Block', enableSorting: true, cell: ({ row }: Cell) => ( -
+
-
{row.original.created_at}
+
{row.original.block_height}
), @@ -236,7 +236,7 @@ export const AccountTransfersList: FC = ({ accountId }) => { enableSorting: true, cell: ({ row }: Cell) => (
- {row.original.timestamp(row.original.date)} + {row.original.timestamp(row.original.timestamp)}
), }, diff --git a/explorer/src/components/Consensus/Account/BalanceHistory.tsx b/explorer/src/components/Consensus/Account/BalanceHistory.tsx index 626cb9cd..5c366f51 100644 --- a/explorer/src/components/Consensus/Account/BalanceHistory.tsx +++ b/explorer/src/components/Consensus/Account/BalanceHistory.tsx @@ -11,9 +11,9 @@ import { formatUnits } from 'ethers' import { BalanceHistoryByAccountIdQuery, BalanceHistoryByAccountIdQueryVariables, + Consensus_Account_Histories_Select_Column as BalanceHistoryColumn, + Consensus_Account_Histories_Bool_Exp as BalanceHistoryWhere, Order_By as OrderBy, - Consensus_Transfers_Select_Column as TransferColumn, - Consensus_Transfers_Bool_Exp as TransferWhere, } from 'gql/graphql' import useIndexers from 'hooks/useIndexers' import { useIndexersQuery } from 'hooks/useIndexersQuery' @@ -37,7 +37,7 @@ type Row = BalanceHistoryByAccountIdQuery['consensus_account_histories'][0] export const BalanceHistory: FC = ({ accountId }) => { const { ref, inView } = useInView() const [sorting, setSorting] = useState([ - { id: TransferColumn.CreatedAt, desc: true }, + { id: BalanceHistoryColumn.CreatedAt, desc: true }, ]) const [pagination, setPagination] = useState({ pageSize: PAGE_SIZE, @@ -57,7 +57,7 @@ export const BalanceHistory: FC = ({ accountId }) => { [sorting], ) - const where: TransferWhere = useMemo(() => ({ id: { _eq: accountId } }), [accountId]) + const where: BalanceHistoryWhere = useMemo(() => ({ id: { _eq: accountId } }), [accountId]) const variables = useMemo(() => { return { diff --git a/explorer/src/components/Consensus/Account/query.ts b/explorer/src/components/Consensus/Account/query.ts index a78e2cc6..46da763b 100644 --- a/explorer/src/components/Consensus/Account/query.ts +++ b/explorer/src/components/Consensus/Account/query.ts @@ -69,7 +69,6 @@ export const QUERY_LAST_WEEK_REWARDS = gql` ) { id block_height - index_in_block reward_type amount timestamp @@ -97,7 +96,6 @@ export const QUERY_REWARDS_LIST = gql` ) { id block_height - index_in_block reward_type amount timestamp @@ -164,8 +162,7 @@ export const QUERY_ACCOUNT_TRANSFERS = gql` fee success timestamp - date - created_at + block_height } } ` @@ -189,7 +186,6 @@ export const QUERY_ACCOUNT_BALANCE_HISTORY = gql` nonce free created_at - updated_at _block_range } } @@ -200,7 +196,6 @@ export const QUERY_ALL_REWARDS_FOR_ACCOUNT_BY_ID = gql` consensus_rewards(where: { account_id: { _eq: $accountId }, amount: { _gt: 0 } }, limit: 1) { id block_height - index_in_block reward_type amount timestamp diff --git a/explorer/src/constants/indexers.ts b/explorer/src/constants/indexers.ts index f3f3fe2a..ddee0247 100644 --- a/explorer/src/constants/indexers.ts +++ b/explorer/src/constants/indexers.ts @@ -7,7 +7,7 @@ export interface Indexer { telemetryNetworkName?: string } -const LOCAL_INDEXER = 'https://subql.green.mainnet.subspace.network/v1/graphql' +const LOCAL_INDEXER = 'https://subql.blue.mainnet.subspace.network/v1/graphql' export const indexers: Indexer[] = [ {