-
Notifications
You must be signed in to change notification settings - Fork 36
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: added ownership registration #513
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
c613371
feat: add free trial button with neon effect and loading state
cswni f7e7d3e
feat: added change wallet feature on deposit/withdraw modals
Jadapema 7331548
refactor: replace LoadingButton with custom StyledBoxGradient
cswni e7a42d3
feat: make free trial as button
Jadapema aa4949a
feat(studio): implement Studio section with publishing process
cswni e3f89a3
feat(marketing): add marketing components and assets
cswni aa92b43
feat: update contracts
Jadapema 7dbf47e
feat: added terms and licenses handling, update subscription campaign…
Jadapema 8e5397b
Merge branch 'next' into app/marketing/studio
Jadapema 562fb98
feat: added modals and cards
Jadapema 29c9f7e
refactor: typo renamed to Paid
geolffreym 8d7b4d7
feat: add ownership illustration SVG to assets
cswni 2437206
refactor: rename StudioPublishModalProps to ModalProps
cswni bfbb36d
feat(marketing): add modular campaign content modal component
cswni a4b844e
refactor(ownership-process): simplify and reorganize component
cswni baedf9b
feat: add ProcessIllustrationCard component implementation
cswni 27c3844
feat: add ProcessSectionCard component
cswni 37ace93
refactor(studio-process): simplify UI components
cswni 05c7fe1
Merge pull request #504 from WatchItDev/next
geolffreym 0ac9a6f
feat: connect register ownership to the contract
Jadapema 53aa4a0
Merge pull request #508 from WatchItDev/next
Jadapema a057b1d
feat: added ownership registration
Jadapema 6489c2a
feat: added ownership registration
Jadapema c29773b
feat: added ownership registration
Jadapema 55787f2
Merge branch 'next' into app/marketing/studio
Jadapema f541a6d
feat: added asset owner validation before register ownership, added s…
Jadapema 137b7de
feat: added new AssetOwnership abi
Jadapema d932975
refactor: remove console logs
Jadapema 2652eea
fix: sonarcloud
Jadapema f60e0a8
Merge branch 'main' into app/marketing/studio
Jadapema 5c83371
refactor: clean unused code
Jadapema File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { FC } from 'react'; | ||
|
||
// MUI IMPORTS | ||
import DialogTitle from '@mui/material/DialogTitle'; | ||
import Dialog, { DialogProps } from '@mui/material/Dialog'; | ||
|
||
interface ModalProps extends DialogProps { | ||
onClose: VoidFunction; | ||
title: string; | ||
renderContent?: JSX.Element; | ||
} | ||
|
||
const Modal: FC<ModalProps> = ({ open, onClose, title, renderContent, ...dialogProps }) => { | ||
return ( | ||
<Dialog open={open} fullWidth maxWidth="xs" onClose={onClose} {...dialogProps}> | ||
<DialogTitle sx={{ pb: 1 }}>{title}</DialogTitle> | ||
{renderContent} | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default Modal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Image from "@src/components/image"; | ||
import Stack from "@mui/material/Stack"; | ||
import {FC} from "react"; | ||
|
||
interface ProcessIllustrationCardProps { | ||
illustration: string; | ||
alt?: string; | ||
} | ||
|
||
const ProcessIllustrationCard: FC<ProcessIllustrationCardProps> = ({illustration, alt}) => { | ||
|
||
return ( | ||
<Stack | ||
flexGrow={1} | ||
justifyContent="center" | ||
sx={{ | ||
display: { xs: 'flex', md: 'flex' }, | ||
p: { xs: 1, md: 1 }, | ||
mb: { xs: 1, md: 0 }, | ||
mx: 'auto', | ||
order: { xs: 1, md: 2 }, | ||
}} | ||
> | ||
<Image | ||
sx={{ | ||
objectFit: 'contain' | ||
}} | ||
src={illustration} | ||
alt={alt} | ||
/> | ||
</Stack> | ||
) | ||
} | ||
|
||
export default ProcessIllustrationCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { FC } from 'react'; | ||
import { Stack, Typography} from '@mui/material'; | ||
import LoadingButton from '@mui/lab/LoadingButton'; | ||
import { alpha, useTheme } from '@mui/material/styles'; | ||
import { bgGradient } from '@src/theme/css'; | ||
import Iconify from '@src/components/iconify'; | ||
import { useResponsive } from '@src/hooks/use-responsive'; | ||
import ProcessIllustrationCard from '@src/components/process-illustration-card.tsx'; | ||
|
||
interface ProcessSectionCardProps { | ||
title: string; | ||
description: string; | ||
buttonText: string; | ||
illustration: string; | ||
illustrationAlt: string; | ||
onClick: () => void; | ||
} | ||
|
||
const ProcessSectionCard: FC<ProcessSectionCardProps> = ({ | ||
title, | ||
description, | ||
buttonText, | ||
illustration, | ||
illustrationAlt, | ||
onClick | ||
}) => { | ||
const lgUp = useResponsive('up', 'lg'); | ||
const theme = useTheme(); | ||
|
||
|
||
return ( | ||
<Stack | ||
sx={{ | ||
...bgGradient({ | ||
direction: '135deg', | ||
}), | ||
width: { | ||
xs: 1, | ||
md: '60%', | ||
}, | ||
maxWidth: { | ||
xs: '100%', | ||
md: 'calc(50%)', | ||
}, | ||
borderRadius: 2, | ||
overflow: 'hidden', | ||
position: 'relative', | ||
}} | ||
> | ||
<Stack | ||
flexDirection={{ xs: 'column', md: 'row' }} | ||
sx={{ | ||
...bgGradient({ | ||
direction: '135deg', | ||
startColor: alpha(theme.palette.primary.light, 0.2), | ||
endColor: alpha(theme.palette.primary.main, 0.2), | ||
}), | ||
height: { md: 1 }, | ||
borderTopRightRadius: 2, | ||
borderTopLeftRadius: 2, | ||
position: 'relative', | ||
color: 'primary.darker', | ||
backgroundColor: 'common.white', | ||
}} | ||
> | ||
<Stack | ||
justifyContent="flex-start" | ||
alignItems={{ xs: 'center', md: 'flex-start' }} | ||
sx={{ | ||
width: '100%', | ||
flexShrink: 0, | ||
maxWidth: { xs: '100%', md: '50%' }, | ||
p: { | ||
xs: theme.spacing(3, 3, 0, 3), | ||
md: theme.spacing(3), | ||
}, | ||
textAlign: { xs: 'center', md: 'left' }, | ||
order: { xs: 2, md: 1 }, | ||
}} | ||
> | ||
<Typography | ||
variant="body1" | ||
sx={{ | ||
display: { md: 'flex' }, | ||
maxWidth: 250, | ||
mb: 1, | ||
whiteSpace: 'pre-line', | ||
}} | ||
> | ||
{description} | ||
</Typography> | ||
<Typography | ||
variant="h3" | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
mb: { xs: 1, xl: 2 }, | ||
}} | ||
> | ||
{title} | ||
</Typography> | ||
<LoadingButton | ||
sx={{ | ||
mt: lgUp ? 1 : null, | ||
mb: !lgUp ? 3 : null, | ||
}} | ||
color="primary" | ||
variant="soft" | ||
startIcon={<Iconify icon="material-symbols:campaign-outline-rounded" />} | ||
onClick={onClick} | ||
> | ||
{buttonText} | ||
</LoadingButton> | ||
</Stack> | ||
<ProcessIllustrationCard illustration={illustration} alt={illustrationAlt} /> | ||
</Stack> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default ProcessSectionCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// REACT IMPORTS | ||
import { useState, useCallback } from 'react'; | ||
|
||
// VIEM IMPORTS | ||
import { Address } from 'viem'; | ||
import { publicClient } from '@src/clients/viem/publicClient'; | ||
|
||
// LOCAL IMPORTS | ||
import AssetOwnershipAbi from '@src/config/abi/AssetOwnership.json'; | ||
import { GLOBAL_CONSTANTS } from '@src/config-global.ts'; | ||
|
||
// ---------------------------------------------------------------------- | ||
|
||
/** | ||
* Interface for handling errors within the hook. | ||
*/ | ||
interface GetAssetOwnerError { | ||
message: string; | ||
code?: number; | ||
[key: string]: any; | ||
} | ||
|
||
/** | ||
* Interface defining the structure of the hook's return value. | ||
*/ | ||
interface UseGetAssetOwnerHook { | ||
ownerAddress?: Address; | ||
loading: boolean; | ||
error?: GetAssetOwnerError | null; | ||
fetchOwnerAddress: (assetIdHex: string) => Promise<Address | undefined>; | ||
} | ||
|
||
/** | ||
* Hook to retrieve the owner's address of a specific asset. | ||
* | ||
* @returns {UseGetAssetOwnerHook} An object containing the owner's address, loading state, error information, and a function to fetch the owner's address. | ||
*/ | ||
export const useGetAssetOwner = (): UseGetAssetOwnerHook => { | ||
// State variables | ||
const [ownerAddress, setOwnerAddress] = useState<Address | undefined>(undefined); | ||
const [loading, setLoading] = useState<boolean>(false); | ||
const [error, setError] = useState<GetAssetOwnerError | null>(null); | ||
|
||
/** | ||
* Converts a hexadecimal asset ID to decimal. | ||
* | ||
* @param hexId - The asset ID in hexadecimal format. | ||
* @returns The asset ID in decimal format as a string. | ||
*/ | ||
const convertHexToDecimal = (hexId: string): string => { | ||
// Remove '0x' prefix if present | ||
const cleanHex = hexId.startsWith('0x') ? hexId.slice(2) : hexId; | ||
return BigInt(`0x${cleanHex}`).toString(10); | ||
}; | ||
|
||
/** | ||
* Fetches the owner's address of the asset. | ||
* | ||
* @param assetIdHex - The asset ID in hexadecimal format. | ||
* @returns {Promise<Address | undefined>} The owner's address if successful, otherwise undefined. | ||
*/ | ||
const fetchOwnerAddress = useCallback(async (assetIdHex: string): Promise<Address | undefined> => { | ||
if (!assetIdHex) { | ||
setError({ message: 'Asset ID is missing.' }); | ||
return undefined; | ||
} | ||
|
||
setLoading(true); | ||
setError(null); | ||
|
||
try { | ||
// Convert assetId from hexadecimal to decimal | ||
const assetIdDecimal = convertHexToDecimal(assetIdHex); | ||
|
||
// Call the 'ownerOf' function on the AssetOwnership contract | ||
const owner: any = await publicClient.readContract({ | ||
address: GLOBAL_CONSTANTS.ASSET_OWNERSHIP_ADDRESS, | ||
abi: AssetOwnershipAbi.abi, | ||
functionName: 'ownerOf', | ||
args: [assetIdDecimal], | ||
}); | ||
|
||
setOwnerAddress(owner); | ||
setError(null); | ||
return owner; | ||
} catch (err: any) { | ||
console.error('USE GET ASSET OWNER ERROR:', err); | ||
setOwnerAddress(undefined); | ||
setError({ | ||
message: err?.message || 'An error occurred while retrieving the asset owner.', | ||
}); | ||
return undefined; | ||
} finally { | ||
setLoading(false); | ||
} | ||
}, []); | ||
|
||
return { | ||
ownerAddress, | ||
loading, | ||
error, | ||
fetchOwnerAddress, | ||
}; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happen of the movie has not subs?