Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/api/blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ export const blocks = {
hash
}
}
rewardTransfers: unified_transaction(
where: {
type: { _eq: "IMMEDIATE" }
hash: { _is_null: true }
block: {
_or: [{ height: { _eq: $height } }, { hash: { _eq: $hash } }]
}
}
) {
amount
detail_id
from {
id
}
to {
id
}
}
}
`;

Expand Down
105 changes: 50 additions & 55 deletions src/api/chain-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ import {
useHomeStatsDayWindows
} from '@/utils/get-home-stats-day-windows';
import { useGetRecentDateRange } from '@/utils/get-recent-date-range';
import {
EXCLUDE_REWARD_TRANSFERS,
withExcludedRewardTransfers
} from '@/utils/unified-transaction-filters';

const GET_HOME_STATS = gql`
query GetHomeChainStats(
$startDate: timestamptz!
$endDate: timestamptz!
$last24HourWhere: unified_transaction_bool_exp!
$allTimeWhere: unified_transaction_bool_exp!
$transfersDay0Where: unified_transaction_bool_exp!
$transfersDay1Where: unified_transaction_bool_exp!
$transfersDay2Where: unified_transaction_bool_exp!
$transfersDay3Where: unified_transaction_bool_exp!
$transfersDay4Where: unified_transaction_bool_exp!
$transfersDay5Where: unified_transaction_bool_exp!
$transfersDay6Where: unified_transaction_bool_exp!
$day0Start: timestamptz!
$day0End: timestamptz!
$day1Start: timestamptz!
Expand All @@ -36,17 +47,13 @@ const GET_HOME_STATS = gql`
block_height
total_accounts
total_deposit_accounts
total_executed_transfers
total_immediate_transfers
total_scheduled_transfers
total_cancelled_transfers
}
last24Hour: transfer_aggregate(
where: {
timestamp: { _gte: $startDate, _lte: $endDate }
extrinsic_id: { _is_null: false }
last24Hour: unified_transaction_aggregate(where: $last24HourWhere) {
aggregate {
count
}
) {
}
allTimeTransactions: unified_transaction_aggregate(where: $allTimeWhere) {
aggregate {
count
}
Expand All @@ -58,12 +65,7 @@ const GET_HOME_STATS = gql`
count
}
}
transfersDay0: transfer_aggregate(
where: {
timestamp: { _gte: $day0Start, _lte: $day0End }
extrinsic_id: { _is_null: false }
}
) {
transfersDay0: unified_transaction_aggregate(where: $transfersDay0Where) {
aggregate {
count
}
Expand All @@ -85,12 +87,7 @@ const GET_HOME_STATS = gql`
count
}
}
transfersDay1: transfer_aggregate(
where: {
timestamp: { _gte: $day1Start, _lte: $day1End }
extrinsic_id: { _is_null: false }
}
) {
transfersDay1: unified_transaction_aggregate(where: $transfersDay1Where) {
aggregate {
count
}
Expand All @@ -112,12 +109,7 @@ const GET_HOME_STATS = gql`
count
}
}
transfersDay2: transfer_aggregate(
where: {
timestamp: { _gte: $day2Start, _lte: $day2End }
extrinsic_id: { _is_null: false }
}
) {
transfersDay2: unified_transaction_aggregate(where: $transfersDay2Where) {
aggregate {
count
}
Expand All @@ -139,12 +131,7 @@ const GET_HOME_STATS = gql`
count
}
}
transfersDay3: transfer_aggregate(
where: {
timestamp: { _gte: $day3Start, _lte: $day3End }
extrinsic_id: { _is_null: false }
}
) {
transfersDay3: unified_transaction_aggregate(where: $transfersDay3Where) {
aggregate {
count
}
Expand All @@ -166,12 +153,7 @@ const GET_HOME_STATS = gql`
count
}
}
transfersDay4: transfer_aggregate(
where: {
timestamp: { _gte: $day4Start, _lte: $day4End }
extrinsic_id: { _is_null: false }
}
) {
transfersDay4: unified_transaction_aggregate(where: $transfersDay4Where) {
aggregate {
count
}
Expand All @@ -193,12 +175,7 @@ const GET_HOME_STATS = gql`
count
}
}
transfersDay5: transfer_aggregate(
where: {
timestamp: { _gte: $day5Start, _lte: $day5End }
extrinsic_id: { _is_null: false }
}
) {
transfersDay5: unified_transaction_aggregate(where: $transfersDay5Where) {
aggregate {
count
}
Expand All @@ -220,12 +197,7 @@ const GET_HOME_STATS = gql`
count
}
}
transfersDay6: transfer_aggregate(
where: {
timestamp: { _gte: $day6Start, _lte: $day6End }
extrinsic_id: { _is_null: false }
}
) {
transfersDay6: unified_transaction_aggregate(where: $transfersDay6Where) {
aggregate {
count
}
Expand Down Expand Up @@ -290,8 +262,31 @@ export const chainStatus = {
}

return {
startDate,
endDate,
last24HourWhere: withExcludedRewardTransfers({
timestamp: { _gte: startDate, _lte: endDate }
}),
allTimeWhere: EXCLUDE_REWARD_TRANSFERS,
transfersDay0Where: withExcludedRewardTransfers({
timestamp: { _gte: day0.start, _lte: day0.end }
}),
transfersDay1Where: withExcludedRewardTransfers({
timestamp: { _gte: day1.start, _lte: day1.end }
}),
transfersDay2Where: withExcludedRewardTransfers({
timestamp: { _gte: day2.start, _lte: day2.end }
}),
transfersDay3Where: withExcludedRewardTransfers({
timestamp: { _gte: day3.start, _lte: day3.end }
}),
transfersDay4Where: withExcludedRewardTransfers({
timestamp: { _gte: day4.start, _lte: day4.end }
}),
transfersDay5Where: withExcludedRewardTransfers({
timestamp: { _gte: day5.start, _lte: day5.end }
}),
transfersDay6Where: withExcludedRewardTransfers({
timestamp: { _gte: day6.start, _lte: day6.end }
}),
day0Start: day0.start,
day0End: day0.end,
day1Start: day1.start,
Expand Down
25 changes: 16 additions & 9 deletions src/api/unified-transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
} from '@/schemas';
import type { PaginatedQueryVariables } from '@/types/query';
import { useGetRecentDateRange } from '@/utils/get-recent-date-range';
import { EXCLUDE_REWARD_TRANSFERS } from '@/utils/unified-transaction-filters';

export const unifiedTransactions = {
useGetAll: (
Expand Down Expand Up @@ -91,11 +92,13 @@ export const unifiedTransactions = {
$limit: Int
$offset: Int
$orderBy: [unified_transaction_order_by!]
$where: unified_transaction_bool_exp
) {
transactions: unified_transaction(
limit: $limit
offset: $offset
order_by: $orderBy
where: $where
) {
id
type
Expand Down Expand Up @@ -125,7 +128,8 @@ export const unifiedTransactions = {
...config,
variables: {
orderBy: { timestamp: 'desc' },
limit: QUERY_RECENT_LIMIT
limit: QUERY_RECENT_LIMIT,
where: EXCLUDE_REWARD_TRANSFERS
}
}
);
Expand All @@ -141,17 +145,15 @@ export const unifiedTransactions = {

const GET_UNIFIED_TRANSACTIONS_STATS = gql`
query GetUnifiedTransactionsStats(
$startDate: timestamptz!
$endDate: timestamptz!
$last24HourWhere: unified_transaction_bool_exp!
$allTimeWhere: unified_transaction_bool_exp!
) {
last24Hour: unified_transaction_aggregate(
where: { timestamp: { _gte: $startDate, _lte: $endDate } }
) {
last24Hour: unified_transaction_aggregate(where: $last24HourWhere) {
aggregate {
totalCount: count
}
}
allTime: unified_transaction_aggregate {
allTime: unified_transaction_aggregate(where: $allTimeWhere) {
aggregate {
totalCount: count
}
Expand All @@ -164,8 +166,13 @@ export const unifiedTransactions = {
{
...config,
variables: {
startDate,
endDate
last24HourWhere: {
_and: [
EXCLUDE_REWARD_TRANSFERS,
{ timestamp: { _gte: startDate, _lte: endDate } }
]
},
allTimeWhere: EXCLUDE_REWARD_TRANSFERS
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const columnHelper = createColumnHelper<UnifiedListTransaction>();
export const UNIFIED_LIST_TRANSACTION_COLUMNS = [
columnHelper.accessor((row) => row.hash ?? row.detail_id, {
id: 'hash',
header: 'Hash / ID',
header: 'Hash',
cell: (props) => {
const row = props.row.original;
const display = row.hash ?? row.detail_id;
Expand Down Expand Up @@ -150,7 +150,7 @@ export const UNIFIED_LIST_TRANSACTION_COLUMNS = [
export const RECENT_UNIFIED_LIST_TRANSACTION_COLUMNS = [
columnHelper.accessor((row) => row.hash ?? row.detail_id, {
id: 'hash',
header: 'Hash / ID',
header: 'Hash',
cell: (props) => {
const row = props.row.original;
const display = row.hash ?? row.detail_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useOrderBy } from '@/hooks/useOrderBy';
import { useTableState } from '@/hooks/useTableState';
import type { UnifiedListTransaction } from '@/schemas';
import { transformSortLiteral } from '@/utils/transform-sort';
import { withExcludedRewardTransfers } from '@/utils/unified-transaction-filters';

export const useAccountAllTransactions = (accountId: string) => {
const api = useApiClient();
Expand All @@ -27,12 +28,13 @@ export const useAccountAllTransactions = (accountId: string) => {
const sortingValue = transformSortLiteral(orderBy);

const where = useMemo(
() => ({
_or: [
{ from: { id: { _eq: accountId } } },
{ to: { id: { _eq: accountId } } }
]
}),
() =>
withExcludedRewardTransfers({
_or: [
{ from: { id: { _eq: accountId } } },
{ to: { id: { _eq: accountId } } }
]
}),
[accountId]
);

Expand Down
Loading
Loading