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

[current develop] #270

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const parameters = {
// { name: 'light', value: '#ffffff' },
// { name: 'dark', value: '#111' },
// { name: 'aqua', value: '#6aadff' },
// { name: 'kawai', value: '#ffbde6' },
// { name: 'kawaii', value: '#ffbde6' },
// { name: 'midnight', value: '#002633' },
// { name: 'coffee', value: '#170a06' },
// ],
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MIT License

Copyright (c) 2021 Rafael Lima
Copyright (c) 2022 Teia Community
Copyright (c) 2022-2023 Teia Community

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions src/atoms/logo/index.jsx → src/atoms/logo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { memo } from 'react'
import { useMemo } from 'react'
import { RotatingLogoSVG } from '@icons'
import { randomSeed } from '@utils'
export const RotatingLogoRemote = ({ className, seed = 1 }) => {
export const RotatingLogoRemote = ({ className = '', seed = 1 }) => {
const theme = useLocalSettings((state) => state.theme)
const { logos } = useSettings()

Expand All @@ -30,14 +30,14 @@ export const RotatingLogoRemote = ({ className, seed = 1 }) => {
)
}

export const RotatingLogo = ({ className, seed = 1 }) => {
export const RotatingLogo = ({ className = '', seed = 1 }) => {
const Logo = useMemo(() => {
return RotatingLogoSVG[
Math.floor(randomSeed(seed) * RotatingLogoSVG.length)
]
}, [seed])
return (
<div className={styles.container}>
<div className={`${styles.container} ${className}`}>
<Logo fill="var(--text-color)" width="132px" />
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/token-collection/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function MasonryView({ tokens }) {
* @param {number} tkProps.itemsPerLoad - Batch size
* @param {number} tkProps.maxItems - Max items to fetch from the indexer
* @param {(data:NFT, extra:import("@types").TokenResponse) => [NFT]} tkProps.extractTokensFromResponse - Function to filter the response
* @param {([NFT]) => [NFT]} tkProps.postProcessTokens - Final filter pass over tokens?
* @param {(tokens:NFT[]) => NFT[]} tkProps.postProcessTokens - Final filter pass over tokens?
* @returns {React.ReactElement} The feed
*/
function TokenCollection({
Expand Down
2 changes: 1 addition & 1 deletion src/components/collab/sign/SigningUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const SigningUI = ({ id, hasSigned }) => {
const sign = useCollabStore((st) => st.sign)

const do_sign = () => {
sign(id).then((response) => console.log(response))
sign(id).then((response) => console.debug(response))
}

return hasSigned ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useLocalSettings } from '@context/localSettingsStore'
import { useUserStore } from '@context/userStore'
import { useModalStore } from '@context/modalStore'
import { shallow } from 'zustand/shallow'
import { ArtistProfile } from '@types'

export const Header = () => {
const [
Expand Down Expand Up @@ -77,9 +78,9 @@ export const Header = () => {

const isWide = useMedia('(min-width: 600px)')

const [logoSeed, setLogoSeed] = useState()
const [logoSeed, setLogoSeed] = useState<number>()
/** the header is a bit larger just on home */
const [onHome, setOnHome] = useState()
const [onHome, setOnHome] = useState<boolean>()

const [syncLabel, setSyncLabel] = useState('Sync')
const [walletLabel, setWalletLabel] = useState('')
Expand All @@ -97,7 +98,12 @@ export const Header = () => {

// on Menu Toggle or Sign in
useEffect(() => {
const updateTitle = ([address, proxyAddress, proxyName, userInfo]) => {
const updateTitle = ([address, proxyAddress, proxyName, userInfo]: [
string | undefined,
string | undefined,
string | undefined,
ArtistProfile
]) => {
setSyncLabel(address ? 'Unsync' : 'Sync')
if (address) {
// is menu closed?
Expand All @@ -118,12 +124,18 @@ export const Header = () => {
}

return useUserStore.subscribe(
(st) => [st.address, st.proxyAddress, st.proxyName, st.userInfo],
(st) =>
[st.address, st.proxyAddress, st.proxyName, st.userInfo] as [
string | undefined,
string | undefined,
string | undefined,
ArtistProfile
],
updateTitle
)
}, [])

const handleRoute = (path, data) => {
const handleRoute = (path: string, data?: string) => {
setCollapsed(true)
navigate(path, { state: data })
}
Expand Down
1 change: 1 addition & 0 deletions src/components/header/feed_toolbar/FeedToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const locationMap = new Map([
['/feed/sales', 'Recent Sales'],
['/feed/random', 'Random'],
['/feed/newobjkts', 'New OBJKTs'],
['/feed/1-1', '1 / 1'],
['/feed/friends', 'Friends'],
// separator
['---fund_feeds', 'fund_feeds'],
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export const LICENSE_TYPES_OPTIONS = Object.keys(LICENSE_TYPES).map((k) => ({
export const THEMES: { [key: string]: string } = {
dark: 'Dark',
light: 'Light',
kawai: 'Kawai',
kawaii: 'Kawaii',
aqua: 'Aqua',
coffee: 'Coffee',
midnight: 'Midnight',
Expand Down
10 changes: 5 additions & 5 deletions src/context/collabStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export const useCollabStore = create<CollabState>()(
.then((response) => {
const { data } = response

console.log('response from originations call', data[0])
console.debug('response from originations call', data[0])

if (data[0]) {
console.log('There is correct data', data[0])
console.debug('There is correct data', data[0])

// Send the originated contract to the UI via context
const { originatedContract } = data[0]
Expand All @@ -53,7 +53,7 @@ export const useCollabStore = create<CollabState>()(
originationOpHash: undefined,
}) // save hash

console.log(
console.debug(
'Saved state originatedContract',
originatedContract
)
Expand All @@ -68,7 +68,7 @@ export const useCollabStore = create<CollabState>()(
closeModal()
}, 2500)
} else {
console.log('missing data')
console.error('missing data')

// We have got our contract address
showModal(
Expand Down Expand Up @@ -101,7 +101,7 @@ export const useCollabStore = create<CollabState>()(
const step = useModalStore.getState().step
const handleOp = useUserStore.getState().handleOp

console.log('originateProxy', participantData)
console.debug('originateProxy', participantData)

// Clear any existing calls
set({
Expand Down
2 changes: 1 addition & 1 deletion src/context/localSettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { FEED_LIST, DEFAULT_START_FEED } from '@constants'

type ViewMode = 'single' | 'masonry'

export type Theme = 'dark' | 'light' | 'kawai' | 'aqua' | 'coffee' | 'midnight'
export type Theme = 'dark' | 'light' | 'kawaii' | 'aqua' | 'coffee' | 'midnight'

export const rpc_nodes = [
'https://mainnet.api.tez.ie',
Expand Down
2 changes: 1 addition & 1 deletion src/context/mintStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export const useMintStore = create<MintState>()(
// optional
return (state, error) => {
if (error) {
console.log('an error happened during hydration', error)
console.error('an error happened during hydration', error)
}
}
},
Expand Down
7 changes: 2 additions & 5 deletions src/context/userStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const useUserStore = create<UserState>()(
try {
step(
title,
`Awaiting for confirmation of the [operation](https://tzkt.io/${op.opHash})
`Awaiting confirmation of the [operation](https://tzkt.io/${op.opHash})
*closing this dialog has no effect on the transaction*`
)
// skippable
Expand Down Expand Up @@ -208,18 +208,15 @@ export const useUserStore = create<UserState>()(
const current = await wallet.getPKH()
if (current) {
const info = await getUser(current)
console.log('getting user info', info)
set({
address: current,
userInfo: await getUser(current),
userInfo: info,
})
}

// console.log(this.state)
return current
},
unsync: async () => {
// console.log('disconnect wallet')
// This will clear the active account and the next "syncTaquito" will trigger a new sync
await wallet.client.clearActiveAccount()
set({
Expand Down
5 changes: 3 additions & 2 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ import {
IranFeed,
PakistanFeed,
UkraineFeed,
QuakeFeed,
AudioFeed,
GifFeed,
GlbFeed,
HtmlSvgFeed,
ImageFeed,
VideoFeed,
OneOnOneFeed,
NewObjktsFeed,
RandomFeed,
RecentSalesFeed,
TagFeed,
PdfFeed,
MarkdownFeed,
QuakeFeed,
MoroccoQuakeFeed,
} from '@pages/home/feeds'
import Mint from '@pages/mint'
Expand Down Expand Up @@ -80,7 +81,7 @@ const router = createBrowserRouter(
<Route path="feed/*" element={<Home />}>
<Route path="sales" element={<RecentSalesFeed />} />
<Route path="lists" element={<ListsFeed />} />

<Route path="1-1" element={<OneOnOneFeed />} />
<Route
path="tezospride"
element={<TagFeed tag="tezospride" namespace="tezospride" />}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/feeds/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { NewObjktsFeed } from './new-objkts-feed'

export { OneOnOneFeed } from './one-one-feed'
export {
AudioFeed,
GifFeed,
Expand Down
32 changes: 32 additions & 0 deletions src/pages/home/feeds/one-one-feed.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { gql } from 'graphql-request'
import uniqBy from 'lodash/uniqBy'
import { BaseTokenFieldsFragment } from '@data/api'
import { HEN_CONTRACT_FA2 } from '@constants'
import TokenCollection from '@atoms/token-collection'

export function OneOnOneFeed() {
return (
<TokenCollection
feeds_menu
label="1/1 OBJKTs"
namespace="one-on-one-feed"
maxItems={600}
postProcessTokens={(tokens) => uniqBy(tokens, 'artist_address')}
query={gql`
${BaseTokenFieldsFragment}
query getUnoUno($limit: Int!) {
tokens(
where: { metadata_status: { _eq: "processed" }, fa2_address: { _eq: "${HEN_CONTRACT_FA2}"}, editions: {_eq: 1} }
order_by: { minted_at: desc }
limit: $limit

) {
...baseTokenFields
}
}
`}
/>
)
}

export default OneOnOneFeed
10 changes: 1 addition & 9 deletions src/pages/objkt-display/tabs/Swap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,7 @@ export const Swap = () => {
}

// swap is valid call API
console.debug(
address,
nft.royalties_total,
parseFloat(price) * 1000000,
id,
nft.artist_address,
parseFloat(amount)
)
console.log([
console.debug([
address,
nft.royalties_total,
parseFloat(price) * 1e6,
Expand Down
6 changes: 3 additions & 3 deletions src/pages/profile/collabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Checkbox from '@atoms/input/Checkbox'
import styles from '@style'

export default function Collabs() {
const { /*showFilters,*/ showRestricted, address, overrideProtections } =
const { /*showFilters,*/ showRestricted, user_address, overrideProtections } =
useOutletContext()

const [hasUnverifiedTokens, setHasUnverifiedTokens] = useState(false)
Expand All @@ -33,8 +33,8 @@ export default function Collabs() {
overrideProtections={overrideProtections}
label="Artist's Collabs"
namespace="collabs"
swrParams={[address]}
variables={{ address }}
swrParams={[user_address]}
variables={{ address: user_address }}
emptyMessage="no collabs"
maxItems={null}
extractTokensFromResponse={(data) => {
Expand Down
33 changes: 18 additions & 15 deletions src/pages/profile/collections.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const FILTER_FOR_SALE = 'FOR_SALE'
const FILTER_NOT_FOR_SALE = 'NOT_FOR_SALE'

export default function Collections() {
const { showFilters, showRestricted, overrideProtections, address } =
const { showFilters, showRestricted, overrideProtections, user_address } =
useOutletContext()

const [filter, setFilter] = useState(FILTER_ALL)
Expand All @@ -36,25 +36,28 @@ export default function Collections() {
overrideProtections={overrideProtections}
label="Artist's Collection"
namespace="collections"
swrParams={[address]}
variables={{ address }}
swrParams={[user_address]}
variables={{ address: user_address }}
emptyMessage="no collections"
maxItems={null}
postProcessTokens={(tokens) => {
if (filter === FILTER_FOR_SALE) {
return tokens.filter(
({ listing_seller_address }) => listing_seller_address === address
)
}
switch (filter) {
case FILTER_FOR_SALE:
return tokens.filter(
({ listing_seller_address }) =>
listing_seller_address === user_address
)

if (filter === FILTER_NOT_FOR_SALE) {
return tokens.filter(
({ listing_seller_address, artist_address }) =>
artist_address !== address && listing_seller_address !== address
)
}
case FILTER_NOT_FOR_SALE:
return tokens.filter(
({ listing_seller_address, artist_address }) =>
artist_address !== user_address &&
listing_seller_address !== user_address
)

return tokens
default:
return tokens
}
}}
extractTokensFromResponse={(data, { postProcessTokens }) => {
const heldTokens = data.holdings.map(({ token }) => token)
Expand Down
Loading