Skip to content

Commit

Permalink
Merge branch 'dev' into fix/action-refetching
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/atlas/src/api/schemas/orion.json
#	packages/atlas/src/components/_crt/BuyMarketTokenModal/BuyMarketTokenModal.tsx
#	packages/atlas/src/components/_crt/ClaimShareModal/ClaimShareModal.tsx
#	packages/atlas/src/components/_crt/CloseMarketModal/CloseMarketModal.tsx
#	packages/atlas/src/components/_crt/CloseRevenueShareButton/CloseRevenueShareButton.tsx
#	packages/atlas/src/components/_crt/CreateTokenSuccessModal/CreateTokenSuccessModal.tsx
#	packages/atlas/src/components/_crt/CrtRevenueShareWidget/CrtRevenueShareWidget.tsx
#	packages/atlas/src/components/_crt/MarketDrawer/MarketDrawer.tsx
#	packages/atlas/src/components/_crt/RevenueShareParticipationWidget/RevenueShareParticipationWidget.tsx
#	packages/atlas/src/components/_crt/SellTokenModal/SellTokenModal.tsx
#	packages/atlas/src/components/_crt/StartMarketModal/StartMarketModal.tsx
#	packages/atlas/src/components/_crt/StartRevenueShareModal/StartRevenueShareModal.tsx
#	packages/atlas/src/hooks/useUnlockTokenStake.ts
#	packages/atlas/src/views/studio/CrtTokenEditView/CrtTokenEditView.tsx
  • Loading branch information
WRadoslaw committed Apr 9, 2024
2 parents 14a31d0 + 515f2b6 commit 28fadf0
Show file tree
Hide file tree
Showing 58 changed files with 590 additions and 245 deletions.
40 changes: 20 additions & 20 deletions packages/atlas/src/CommonProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,30 @@ export const CommonProviders: FC<PropsWithChildren> = ({ children }) => {
return (
<>
<GlobalStyles />
<SegmentAnalyticsProvider>
<ApolloProvider client={apolloClient}>
<QueryClientProvider client={queryClient}>
<WalletProvider>
<AuthProvider>
<UserProvider>
<NetworkUtilsProvider>
<OverlayManagerProvider>
<ConfirmationModalProvider>
<BrowserRouter>
<BrowserRouter>
<SegmentAnalyticsProvider>
<ApolloProvider client={apolloClient}>
<QueryClientProvider client={queryClient}>
<WalletProvider>
<AuthProvider>
<UserProvider>
<NetworkUtilsProvider>
<OverlayManagerProvider>
<ConfirmationModalProvider>
<AdminModal />
<MaintenanceWrapper>
<OperatorsContextProvider>{children}</OperatorsContextProvider>
</MaintenanceWrapper>
</BrowserRouter>
</ConfirmationModalProvider>
</OverlayManagerProvider>
</NetworkUtilsProvider>
</UserProvider>
</AuthProvider>
</WalletProvider>
</QueryClientProvider>
</ApolloProvider>
</SegmentAnalyticsProvider>
</ConfirmationModalProvider>
</OverlayManagerProvider>
</NetworkUtilsProvider>
</UserProvider>
</AuthProvider>
</WalletProvider>
</QueryClientProvider>
</ApolloProvider>
</SegmentAnalyticsProvider>
</BrowserRouter>
</>
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/atlas/src/api/hooks/dataObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useDataObjectsAvailabilityLazy = (opts?: QueryHookOptions<GetDataOb

const _getDataObjectsAvailability = useCallback(
(ids: string[]) => {
getDataObjectsAvailability({
return getDataObjectsAvailability({
variables: {
id_in: ids,
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions packages/atlas/src/api/queries/channels.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ query GetChannelPaymentEvents($channelId: String) {
}
}
{ data: { isTypeOf_in: ["ChannelPaymentMadeEventData"], payeeChannel: { id_eq: $channelId } } }
{
data: {
isTypeOf_in: ["CreatorTokenRevenueSplitIssuedEventData"]
token: { channel: { channel: { id_eq: $channelId } } }
}
}
]
}
) {
Expand Down Expand Up @@ -290,6 +296,25 @@ query GetChannelPaymentEvents($channelId: String) {
controllerAccount
}
}
... on CreatorTokenRevenueSplitIssuedEventData {
token {
id
revenueShareRatioPermill
}
revenueShare {
id
allocation
startingAt
stakers {
account {
member {
id
}
}
earnings
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const CrtPreviewLayout = ({
<HoldersWidget
totalSupply={+(token?.totalSupply ?? 0)}
totalHolders={token?.accountsNum ?? 0}
tokenSymbol={token?.symbol ?? ''}
tokenId={token?.id ?? '-1'}
ownerId={memberId ?? ''}
/>
Expand Down
6 changes: 6 additions & 0 deletions packages/atlas/src/components/Table/Table.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import { cVar, sizes } from '@/styles'
export const Wrapper = styled.div`
background-color: ${cVar('colorBackgroundMuted')};
overflow: auto;
* {
.pointer {
cursor: pointer;
}
}
`

export const TableBase = styled.table`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { TextButton } from '@/components/_buttons/Button'
import { DialogModal } from '@/components/_overlays/DialogModal'
import { absoluteRoutes } from '@/config/routes'
import { getMemberAvatar } from '@/providers/assets/assets.helpers'
import { useUser } from '@/providers/user/user.hooks'
import { SentryLogger } from '@/utils/logs'
import { shortenString } from '@/utils/misc'

Expand Down Expand Up @@ -112,6 +113,7 @@ const Sender = ({ sender }: { sender: PaymentHistory['sender'] }) => {
skip: sender === 'council',
}
)
const { activeChannel } = useUser()
const member = memberships?.find((member) => member.controllerAccount === sender)
const { urls: avatarUrls, isLoadingAsset: avatarLoading } = getMemberAvatar(member)

Expand All @@ -128,6 +130,17 @@ const Sender = ({ sender }: { sender: PaymentHistory['sender'] }) => {
/>
)
}

if (sender === 'own-channel') {
return (
<SenderItem
nodeStart={<Avatar assetUrls={activeChannel?.avatarPhoto?.resolvedUrls} size={32} />}
label="Own channel"
isInteractive={false}
/>
)
}

if (member) {
return (
<StyledLink to={absoluteRoutes.viewer.member(member.handle)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const AllTokensSection = () => {
createdAt: new Date(createdAt),
totalRevenue: 0,
holdersNum: accountsNum,
isVerified: true,
isVerified: false,
marketCap: lastPrice && totalSupply ? hapiBnToTokenNumber(new BN(lastPrice).mul(new BN(totalSupply))) ?? 0 : 0,
status,
channelId: channel?.channel.id ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type AmmModalFormTemplateProps = {
tooltipText?: string
}[]
error?: string
maxInputValue?: number
showTresholdButtons?: boolean
}

Expand All @@ -31,6 +32,7 @@ export const AmmModalFormTemplate = ({
control,
error,
showTresholdButtons,
maxInputValue,
}: AmmModalFormTemplateProps) => {
const { convertTokensToUSD } = useTokenPrice()

Expand All @@ -52,6 +54,7 @@ export const AmmModalFormTemplate = ({
value={field.value}
onChange={(value) => field.onChange(value ? Math.round(value) : value)}
placeholder="0"
maxValue={maxInputValue}
nodeEnd={
pricePerUnit ? (
<Text variant="t300" as="p" color="colorTextMuted">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from 'react'

import { ProtectedActionWrapper } from '@/components/_auth/ProtectedActionWrapper'
import { Button } from '@/components/_buttons/Button'
import { BuyMarketTokenModal } from '@/components/_crt/BuyMarketTokenModal'

Expand All @@ -12,9 +13,11 @@ export const BuyFromMarketButton = ({ tokenId }: BuyFromMarketButtonProps) => {
return (
<>
<BuyMarketTokenModal tokenId={tokenId} show={showModal} onClose={() => setShowModal(false)} />
<Button size="large" onClick={() => setShowModal(true)}>
Buy
</Button>
<ProtectedActionWrapper title="You want to buy tokens?" description="Sign in to buy">
<Button size="large" fullWidth onClick={() => setShowModal(true)}>
Buy
</Button>
</ProtectedActionWrapper>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const BuyMarketTokenModal = ({ tokenId, onClose: _onClose, show }: BuySal
SentryLogger.error('Error while fetching creator token', 'BuyMarketTokenModal', error)
},
})
const hasActiveRevenueShare = data?.creatorTokenById?.revenueShares.some((rS) => !rS.finalized)
const { data: memberTokenAccount } = useGetCreatorTokenHoldersQuery({
variables: {
where: {
Expand Down Expand Up @@ -172,8 +173,8 @@ export const BuyMarketTokenModal = ({ tokenId, onClose: _onClose, show }: BuySal
data?.creatorTokenById?.id ?? 'N/A',
data?.creatorTokenById?.symbol ?? 'N/A',
channelId ?? 'N/A',
String(tokenAmount),
String(priceForAllToken)
tokenAmount,
priceForAllToken
)
displaySnackbar({
iconType: 'success',
Expand Down Expand Up @@ -302,7 +303,8 @@ export const BuyMarketTokenModal = ({ tokenId, onClose: _onClose, show }: BuySal
withDenomination="before"
/>
),
tooltipText: 'Price for a single token divided by the token amount.',
tooltipText:
'Price of each incremental unit purchased or sold depends on overall quantity of tokens transacted, the actual average price per unit for the entire purchase or sale will differ from the price displayed for the first unit transacted.',
},
{
title: 'Fee',
Expand Down Expand Up @@ -344,11 +346,19 @@ export const BuyMarketTokenModal = ({ tokenId, onClose: _onClose, show }: BuySal
if (activeStep === BUY_MARKET_TOKEN_STEPS.form) {
setPrimaryButtonProps({
text: 'Continue',
onClick: () =>
onClick: () => {
if (hasActiveRevenueShare) {
displaySnackbar({
iconType: 'error',
title: 'You cannot trade tokens during revenue share.',
})
return
}
handleSubmit((data) => {
amountRef.current = data.tokenAmount
setActiveStep(BUY_MARKET_TOKEN_STEPS.conditions)
})(),
})()
},
})
}

Expand All @@ -358,7 +368,14 @@ export const BuyMarketTokenModal = ({ tokenId, onClose: _onClose, show }: BuySal
onClick: onTransactionSubmit,
})
}
}, [activeStep, data?.creatorTokenById?.symbol, handleSubmit, onTransactionSubmit])
}, [
activeStep,
data?.creatorTokenById?.symbol,
displaySnackbar,
handleSubmit,
hasActiveRevenueShare,
onTransactionSubmit,
])

if (!loading && !currentAmm && show) {
SentryLogger.error('BuyAmmModal invoked on token without active amm', 'BuyMarketTokenModal', {
Expand Down Expand Up @@ -386,7 +403,7 @@ export const BuyMarketTokenModal = ({ tokenId, onClose: _onClose, show }: BuySal
control={control}
details={formDetails}
pricePerUnit={pricePerUnit}
maxValue={10_000_000_000}
maxInputValue={10_000_000}
error={formState.errors.tokenAmount?.message}
validation={(value) => {
if (!value || value < 1) return 'You need to buy at least one token'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useState } from 'react'

import { FullCreatorTokenFragment } from '@/api/queries/__generated__/fragments.generated'
import { Button, ButtonProps } from '@/components/_buttons/Button'
import { ClaimShareModal } from '@/components/_crt/ClaimShareModal'
import { useSnackbar } from '@/providers/snackbars'

export type ClaimRevenueShareButtonProps = {
token: FullCreatorTokenFragment
disabled?: boolean
} & Pick<ButtonProps, 'variant' | 'size' | 'fullWidth'>

export const ClaimRevenueShareButton = ({ token, ...btnProps }: ClaimRevenueShareButtonProps) => {
const [openClaimShareModal, setOpenClaimShareModal] = useState(false)
const { displaySnackbar } = useSnackbar()
const hasActiveRevenueShare = token.revenueShares.some((revenueShare) => !revenueShare.finalized)

return (
<>
<Button
{...btnProps}
onClick={() => {
if (!hasActiveRevenueShare) {
displaySnackbar({
iconType: 'info',
title: 'No active revenue share to claim',
})
return
}

setOpenClaimShareModal(true)
}}
>
Stake your tokens
</Button>
<ClaimShareModal onClose={() => setOpenClaimShareModal(false)} show={openClaimShareModal} tokenId={token.id} />
</>
)
}
Loading

0 comments on commit 28fadf0

Please sign in to comment.