Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: other V4 activity feed elems #4464

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
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
206 changes: 206 additions & 0 deletions src/packages/v4/graphql/queries/projectEvents.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
query ProjectEvents(
$where: ProjectEvent_filter
$orderBy: ProjectEvent_orderBy
$orderDirection: OrderDirection
$first: Int
$skip: Int
) {
projectEvents(
where: $where
orderBy: $orderBy
orderDirection: $orderDirection
first: $first
skip: $skip
) {
id
addToBalanceEvent {
id
timestamp
txHash
from
amount
note
terminal
projectId
pv
project {
handle
}
}
burnEvent {
id
timestamp
txHash
from
holder
amount
projectId
pv
project {
handle
}
}
configureEvent {
id
timestamp
txHash
from
ballot
discountRate
duration
configuration
projectId
weight
memo
mustStartAtOrAfter
projectId
project {
handle
}
fundingCycle {
projectId
mustStartAtOrAfter
preferClaimedTokenOverride
number
basedOn
startTimestamp
duration
weight
discountRate
ballot
configuration
metadata
transfersPaused
reservedRate
redemptionRate
ballotRedemptionRate
pausePay
distributionsPaused
redeemPaused
burnPaused
mintingAllowed
dataSource
controllerMigrationAllowed
setControllerAllowed
setTerminalsAllowed
shouldHoldFees
terminalMigrationAllowed
useDataSourceForPay
useDataSourceForRedeem
useTotalOverflowForRedemptions
metametadata
withdrawnAmount
}
}
deployedERC20Event {
id
timestamp
txHash
from
symbol
projectId
pv
project {
handle
}
}
deployETHERC20ProjectPayerEvent {
id
timestamp
txHash
from
address
memo
projectId
project {
handle
}
}
distributePayoutsEvent {
id
timestamp
txHash
from
beneficiary
beneficiaryDistributionAmount
distributedAmount
memo
terminal
projectId
project {
handle
}
}
distributeReservedTokensEvent {
id
timestamp
txHash
from
beneficiary
beneficiaryTokenCount
tokenCount
projectId
project {
handle
}
}
payEvent {
id
timestamp
txHash
from
amount
beneficiary
note
feeFromV2Project
terminal
projectId
pv
project {
handle
}
distributionFromProjectId
}
printReservesEvent {
id
timestamp
txHash
from
beneficiary
beneficiaryTicketAmount
count
projectId
project {
handle
}
}
projectCreateEvent {
id
timestamp
txHash
from
projectId
pv
project {
handle
}
}
redeemEvent {
id
timestamp
txHash
from
amount
beneficiary
returnAmount
terminal
metadata
memo
projectId
pv
project {
handle
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { t } from '@lingui/macro'
import Loading from 'components/Loading'
import useNameOfERC20 from 'hooks/ERC20/useNameOfERC20'
import {
NativeTokenValue,
useJBContractContext,
useJBTokenContext,
useReadJbTokensTokenOf
} from 'juice-sdk-react'
import {
OrderDirection,
PayEvent_OrderBy,
PayEventsDocument,
ProjectEvent,
ProjectEvent_OrderBy
} from 'packages/v4/graphql/client/graphql'
import { useSubgraphQuery } from 'packages/v4/graphql/useSubgraphQuery'
import { ActivityEvent } from './activityEventElems/ActivityElement'
import { AnyProjectEvent } from './activityEventElems/AnyProjectEvent'
import { ActivityOptions } from './ActivityOptions'
import { PayEvent } from './models/ActivityEvents'
import { transformPayEventsRes } from './utils/transformEventsData'

export function V4ActivityList() {
const { token } = useJBTokenContext()
const { data: tokenAddress } = useReadJbTokensTokenOf()
const { data: tokenSymbol } = useNameOfERC20(tokenAddress)
const { projectId } = useJBContractContext()

// TODO: pageSize (pagination)
const { data: payEventsData, isLoading } = useSubgraphQuery({
const { data: payEventsData, isLoading: payEventsLoading } = useSubgraphQuery({
document: PayEventsDocument,
variables: {
orderBy: PayEvent_OrderBy.timestamp,
Expand All @@ -32,6 +33,17 @@ export function V4ActivityList() {
}
})

const { data: projectEventsData, isLoading: allEventsLoading } = useSubgraphQuery({
document: ProjectEventsDocument,
variables: {
orderBy: ProjectEvent_OrderBy.timestamp,
orderDirection: OrderDirection.desc,
where: {
projectId: Number(projectId),
},
}
})

const payEvents = transformPayEventsRes(payEventsData) ?? []

return (
Expand All @@ -46,31 +58,21 @@ export function V4ActivityList() {
/>
</div>
<div className="flex flex-col gap-3">
{isLoading && <Loading />}
{isLoading || (payEvents && payEvents.length > 0) ? (
payEvents?.map((event: PayEvent) => {
{allEventsLoading && <Loading />}
{payEventsLoading || (payEvents && payEvents.length > 0) ? (
projectEvents?.map((event: ProjectEvent) => {
return (
<div
className="mb-5 border-b border-smoke-200 pb-5 dark:border-grey-600"
key={event.id}
>
<ActivityEvent
event={{
...event,
from: event.beneficiary,
}}
header={t`Paid`}
subject={
<span className="font-heading text-lg">
<NativeTokenValue wei={event.amount.value} />
</span>
}
extra={
<span>
bought {event.beneficiaryTokenCount?.format(6)}{' '}
{token.data?.symbol ?? 'tokens'}
</span>
<AnyProjectEvent
event={event}
tokenSymbol={
// tokenSymbol should only be provided if projectEvents are restricted to a specific projectId
projectId === undefined ? tokenSymbol : undefined
}
withProjectLink={!projectId}
/>
</div>
)
Expand Down
Loading
Loading