Skip to content

Commit

Permalink
Merge pull request #281 from poap-xyz/release/v1.13.10
Browse files Browse the repository at this point in the history
Release v1.13.10
  • Loading branch information
jm42 authored May 21, 2024
2 parents 4530cd3 + 7438c74 commit b2e5b2b
Show file tree
Hide file tree
Showing 43 changed files with 551 additions and 229 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/poap-family",
"version": "1.13.9",
"version": "1.13.10",
"author": {
"name": "POAP",
"url": "https://poap.xyz"
Expand Down
8 changes: 8 additions & 0 deletions src/components/AddressAddForm.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import PropTypes from 'prop-types'
import { useState } from 'react'
import { Plus } from 'iconoir-react'
import { parseAddresses } from 'models/address'
import Button from 'components/Button'
import ErrorMessage from 'components/ErrorMessage'
import 'styles/address-add.css'

/**
* @param {PropTypes.InferProps<AddressAddForm.propTypes>} props
*/
function AddressAddForm({
onSubmit =
/**
Expand Down Expand Up @@ -87,4 +91,8 @@ function AddressAddForm({
)
}

AddressAddForm.propTypes = {
onSubmit: PropTypes.func.isRequired,
}

export default AddressAddForm
2 changes: 1 addition & 1 deletion src/components/AddressErrorList.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ AddressErrorList.propTypes = {
PropTypes.shape({
address: PropTypes.string.isRequired,
error: PropTypes.instanceOf(Error).isRequired,
})
}).isRequired
).isRequired
),
onRetry: PropTypes.func.isRequired,
Expand Down
12 changes: 7 additions & 5 deletions src/components/AddressOwner.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ function AddressOwner({

AddressOwner.propTypes = {
address: PropTypes.string.isRequired,
events: PropTypes.objectOf(PropTypes.shape(DropProps)),
eventIds: PropTypes.arrayOf(PropTypes.number),
ownerEventIds: PropTypes.arrayOf(PropTypes.number),
inCommonEventIds: PropTypes.arrayOf(PropTypes.number),
inCommonAddresses: PropTypes.arrayOf(PropTypes.string),
events: PropTypes.objectOf(
PropTypes.shape(DropProps).isRequired
).isRequired,
eventIds: PropTypes.arrayOf(PropTypes.number.isRequired),
ownerEventIds: PropTypes.arrayOf(PropTypes.number.isRequired),
inCommonEventIds: PropTypes.arrayOf(PropTypes.number.isRequired),
inCommonAddresses: PropTypes.arrayOf(PropTypes.string.isRequired),
linkToScan: PropTypes.bool,
}

Expand Down
55 changes: 30 additions & 25 deletions src/components/AddressProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import 'styles/address-profile.css'
*/
function AddressProfile({
address,
events = {},
events,
inCommonEventIds = [],
inCommonAddresses = [],
}) {
Expand All @@ -52,36 +52,36 @@ function AddressProfile({
*/
const [error, setError] = useState(null)
/**
* @type {ReturnType<typeof useState<Awaited<ReturnType<scanAddress>>> | null>}
* @type {ReturnType<typeof useState<Awaited<ReturnType<scanAddress>> | null>>}
*/
const [poaps, setPOAPs] = useState(null)
/**
* @type {ReturnType<typeof useState<Date | null>>}
*/
const [since, setSince] = useState(null)

const poapsTotal = poaps === null ? 0 : poaps.length
const poapsTotal = poaps == null ? 0 : poaps.length
const poapsHasMore = poapsTotal > POAP_PROFILE_LIMIT

let poapsVisible = poaps === null ? [] : poaps.slice()
let poapsVisible = poaps == null ? [] : poaps.slice()
if (poapsHasMore && !showAllPOAPs) {
poapsVisible = poaps.slice(0, POAP_PROFILE_LIMIT)
poapsVisible = poapsVisible.slice(0, POAP_PROFILE_LIMIT)
}

const inCommonEventsTotal = inCommonEventIds.length
const inCommonEventsTotal = inCommonEventIds == null ? 0 : inCommonEventIds.length
const inCommonEventsHasMore = inCommonEventsTotal > INCOMMON_EVENTS_LIMIT

let inCommonEventIdsVisible = inCommonEventIds.slice()
let inCommonEventIdsVisible = inCommonEventIds == null ? [] : inCommonEventIds.slice()
if (inCommonEventsHasMore && !showAllInCommonEvents) {
inCommonEventIdsVisible = inCommonEventIds.slice(0, INCOMMON_EVENTS_LIMIT)
inCommonEventIdsVisible = inCommonEventIdsVisible.slice(0, INCOMMON_EVENTS_LIMIT)
}

const inCommonAddressesTotal = inCommonAddresses.length
const inCommonAddressesTotal = inCommonAddresses == null ? 0 : inCommonAddresses.length
const inCommonAddressesHasMore = inCommonAddressesTotal > INCOMMON_ADDRESSES_LIMIT

let inCommonAddressesVisible = inCommonAddresses.slice()
let inCommonAddressesVisible = inCommonAddresses == null ? [] : inCommonAddresses.slice()
if (inCommonAddressesHasMore && !showAllInCommonAddresses) {
inCommonAddressesVisible = inCommonAddresses.slice(0, INCOMMON_ADDRESSES_LIMIT)
inCommonAddressesVisible = inCommonAddressesVisible.slice(0, INCOMMON_ADDRESSES_LIMIT)
}

useEffect(
Expand All @@ -94,13 +94,13 @@ function AddressProfile({
) &&
!error
) {
setLoading((prevLoading) => prevLoading + 1)
setLoading((prevLoading) => (prevLoading ?? 0) + 1)
resolveMeta(ensNames[address], address).then(
(meta) => {
setLoading((prevLoading) => prevLoading - 1)
setLoading((prevLoading) => (prevLoading ?? 0) - 1)
},
(err) => {
setLoading((prevLoading) => prevLoading - 1)
setLoading((prevLoading) => (prevLoading ?? 0) - 1)
setError(err)
}
)
Expand All @@ -111,23 +111,23 @@ function AddressProfile({

useEffect(
() => {
/**
* @type {AbortController | undefined}
*/
let controller
if (
poaps === null &&
!error
) {
if (poaps == null && error == null) {
controller = new AbortController()
setLoading((prevLoading) => prevLoading + 1)
setLoading((prevLoading) => (prevLoading ?? 0) + 1)
scanAddress(address, controller.signal).then(
(foundPOAPs) => {
setLoading((prevLoading) => prevLoading - 1)
setLoading((prevLoading) => (prevLoading ?? 0) - 1)
setPOAPs(foundPOAPs)
if (Array.isArray(foundPOAPs) && foundPOAPs.length > 0) {
setSince(findInitialPOAPDate(foundPOAPs))
}
},
(err) => {
setLoading((prevLoading) => prevLoading - 1)
setLoading((prevLoading) => (prevLoading ?? 0) - 1)
setError(err)
setPOAPs([])
}
Expand All @@ -144,7 +144,10 @@ function AddressProfile({

const hasAvatarImage = (
address in ensNames &&
ensNames[address] != null &&
ensNames[address] in avatars &&
avatars[ensNames[address]] != null &&
typeof avatars[ensNames[address]] === 'string' &&
avatars[ensNames[address]].startsWith('http') &&
!avatars[ensNames[address]].endsWith('json')
)
Expand Down Expand Up @@ -190,7 +193,7 @@ function AddressProfile({
{address in ensNames && (
<big className="profile-ens">{ensNames[address]}</big>
)}
{poaps !== null && Array.isArray(poaps) && poaps.length > 0 && (
{poaps != null && Array.isArray(poaps) && poaps.length > 0 && (
<div className={clsx('profile-poaps', showAllPOAPs && 'show-all')}>
<h4>{poapsTotal} collected drops
{since && (
Expand Down Expand Up @@ -288,9 +291,11 @@ function AddressProfile({

AddressProfile.propTypes = {
address: PropTypes.string.isRequired,
events: PropTypes.objectOf(PropTypes.shape(DropProps)),
inCommonEventIds: PropTypes.arrayOf(PropTypes.number),
inCommonAddresses: PropTypes.arrayOf(PropTypes.string),
events: PropTypes.objectOf(
PropTypes.shape(DropProps).isRequired
).isRequired,
inCommonEventIds: PropTypes.arrayOf(PropTypes.number.isRequired),
inCommonAddresses: PropTypes.arrayOf(PropTypes.string.isRequired),
}

export default AddressProfile
2 changes: 1 addition & 1 deletion src/components/AddressesForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function AddressesForm({
}

AddressesForm.propTypes = {
addresses: PropTypes.arrayOf(PropTypes.string).isRequired,
addresses: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
onSubmit: PropTypes.func.isRequired,
onClose: PropTypes.func,
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddressesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function AddressesList({
}

AddressesList.propTypes = {
addresses: PropTypes.arrayOf(PropTypes.string).isRequired,
addresses: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
}

export default AddressesList
10 changes: 6 additions & 4 deletions src/components/ButtonAddressProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'styles/button-address-profile.css'
*/
function ButtonAddressProfile({
address,
events = {},
events,
inCommonEventIds = [],
inCommonAddresses = [],
}) {
Expand Down Expand Up @@ -62,9 +62,11 @@ function ButtonAddressProfile({

ButtonAddressProfile.propTypes = {
address: PropTypes.string.isRequired,
events: PropTypes.objectOf(PropTypes.shape(DropProps)),
inCommonEventIds: PropTypes.arrayOf(PropTypes.number),
inCommonAddresses: PropTypes.arrayOf(PropTypes.string),
events: PropTypes.objectOf(
PropTypes.shape(DropProps).isRequired
).isRequired,
inCommonEventIds: PropTypes.arrayOf(PropTypes.number.isRequired),
inCommonAddresses: PropTypes.arrayOf(PropTypes.string.isRequired),
}

export default ButtonAddressProfile
8 changes: 5 additions & 3 deletions src/components/ButtonEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import Button from 'components/Button'
*/
function ButtonEdit({
onEdit = () => {},
...props
title,
}) {
return (
<Button
{...props}
title={title}
secondary={true}
borderless={true}
icon={<EditPencil />}
onClick={() => onEdit()}
>
Expand All @@ -22,7 +24,7 @@ function ButtonEdit({

ButtonEdit.propTypes = {
onEdit: PropTypes.func.isRequired,
...Button.propTypes,
title: PropTypes.string,
}

export default ButtonEdit
6 changes: 4 additions & 2 deletions src/components/ButtonExpand.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ function ButtonExpand({
}

ButtonExpand.propTypes = {
addresses: PropTypes.arrayOf(PropTypes.string).isRequired,
eventIds: PropTypes.arrayOf(PropTypes.number),
addresses: PropTypes.arrayOf(
PropTypes.string.isRequired
).isRequired,
eventIds: PropTypes.arrayOf(PropTypes.number.isRequired),
link: PropTypes.bool,
title: PropTypes.string,
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/ButtonExportAddressCsv.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function ButtonExportAddressCsv({
ButtonExportAddressCsv.propTypes = {
name: PropTypes.string,
filename: PropTypes.string,
addresses: PropTypes.arrayOf(PropTypes.string).isRequired,
addresses: PropTypes.arrayOf(
PropTypes.string.isRequired
).isRequired,
children: PropTypes.node,
title: PropTypes.string,
}
Expand Down
17 changes: 13 additions & 4 deletions src/components/CachedEventList.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function CachedEventList({
(eventId) => {},
}) {
return (
<ul className="cached-drops" style={{ maxHeight }}>
<ul className="cached-drops" style={{ maxHeight: maxHeight ?? undefined }}>
{cachedEvents.map((cachedEvent, index) =>
<li key={`${cachedEvent.id}-${index}`}>
<div className="cached-drop">
Expand All @@ -36,7 +36,11 @@ function CachedEventList({
<div className="name">
<h4 title={cachedEvent.name}>{cachedEvent.name}</h4>
{showClear && (
<ButtonLink onClick={() => onClear(cachedEvent.id)}>clear</ButtonLink>
<ButtonLink
onClick={() => onClear != null && onClear(cachedEvent.id)}
>
clear
</ButtonLink>
)}
</div>
<div className="sub-info">
Expand All @@ -46,7 +50,10 @@ function CachedEventList({
</p>}
{showInCommonCount &&
<p>
<span className="in-common-count">{cachedEvent.in_common_count}</span>{' '}
<span className="in-common-count">
{cachedEvent.in_common_count}
</span>
{' '}
<Link to={`/event/${cachedEvent.id}`}>in common</Link>
</p>}
</div>
Expand All @@ -59,7 +66,9 @@ function CachedEventList({
}

CachedEventList.propTypes = {
cachedEvents: PropTypes.arrayOf(PropTypes.shape(CachedEventProps)).isRequired,
cachedEvents: PropTypes.arrayOf(
PropTypes.shape(CachedEventProps).isRequired
).isRequired,
maxHeight: PropTypes.number,
tokenImageSize: PropTypes.number,
showCachedTs: PropTypes.bool,
Expand Down
4 changes: 3 additions & 1 deletion src/components/CollectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ function CollectionList({
}

CollectionList.propTypes = {
collections: PropTypes.arrayOf(PropTypes.shape(CollectionProps)).isRequired,
collections: PropTypes.arrayOf(
PropTypes.shape(CollectionProps).isRequired
).isRequired,
showLogo: PropTypes.bool,
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/CollectionSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ CollectionSet.propTypes = {
collectionMap: (
PropTypes.objectOf(
PropTypes.arrayOf(
PropTypes.shape(CollectionProps)
)
PropTypes.shape(CollectionProps).isRequired
).isRequired
).isRequired
),
showEmpty: PropTypes.bool,
Expand Down
2 changes: 1 addition & 1 deletion src/components/EventInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ EventInfo.propTypes = {
href: PropTypes.string,
external: PropTypes.bool,
small: PropTypes.bool,
})
}).isRequired
).isRequired
),
highlightStat: PropTypes.string,
Expand Down
Loading

0 comments on commit b2e5b2b

Please sign in to comment.