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: purchase history #1523

Merged
merged 26 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c443bfa
feat(AccountModal): add purchase history menu item
FBalint Oct 11, 2024
d07d0b6
rebase with latest changes
FBalint Oct 28, 2024
2cae3bd
connect to backend
FBalint Oct 31, 2024
f6455bf
use copyable address component
FBalint Oct 31, 2024
71e32cb
TEMP: forgot rebase process
FBalint Jan 21, 2025
6a50315
fix build errors
FBalint Jan 21, 2025
94f12d0
remove introduced default exports
FBalint Jan 21, 2025
204966e
fix: run biome check
BrickheadJohnny Jan 21, 2025
c5bbcad
feat(PurchaseHistoryDrawer): download receipts
FBalint Jan 21, 2025
d8c45d1
Merge remote-tracking branch 'origin/feat-purchase-history' into feat…
FBalint Jan 21, 2025
e348c0d
feat: initialize order verification on NFT mint
FBalint Jan 22, 2025
23290ed
refactor: include billing service types
FBalint Jan 22, 2025
663609f
fix(RequirementAccessIndicatorUI): exclude `red` color scheme
BrickheadJohnny Jan 22, 2025
d0344dd
refactor: move prettyDate to a util
BrickheadJohnny Jan 22, 2025
9d51ca0
fix(useOrders): don't revalidate on mount
BrickheadJohnny Jan 22, 2025
aef7300
refactor: simplify PurchaseHistoryDrawer
BrickheadJohnny Jan 22, 2025
22e785c
temp: use the dev api
BrickheadJohnny Jan 22, 2025
ffdfbd0
chore: run biome check
BrickheadJohnny Jan 22, 2025
a5ef236
fix: remove deprecated requirement components
BrickheadJohnny Jan 22, 2025
a6aba76
fix(useOrders): dynamic revalidateOnMount value
BrickheadJohnny Jan 22, 2025
b1a9022
fix: don't use custom rpc for sepolia
BrickheadJohnny Jan 22, 2025
8f88502
fix: update the types package
BrickheadJohnny Jan 22, 2025
d41e1e8
feat: limit order download to supported countries
FBalint Jan 23, 2025
5f36609
reset env to prod backend api
FBalint Jan 23, 2025
4f19ef9
fix: order fetching on drawer open
FBalint Jan 24, 2025
4ee3669
Merge remote-tracking branch 'origin/main' into feat-purchase-history
FBalint Feb 4, 2025
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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_API=https://api.guild.xyz/v1
NEXT_PUBLIC_API=https://api.dev.guild-api.xyz/v1
NEXT_PUBLIC_URL=https://$NEXT_PUBLIC_VERCEL_URL
NEXT_PUBLIC_DISCORD_CLIENT_ID=868172385000509460
NEXT_PUBLIC_IPFS_GATEWAY=https://guild-xyz.mypinata.cloud/ipfs/
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"three": "^0.166.1",
"usehooks-ts": "^3.1.0",
"uuidv7": "^0.6.3",
"vaul": "^1.1.2",
"viem": "^2.22.4",
"wagmi": "^2.14.6",
"zod": "^3.22.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ const useMintGuildPin = () => {
shareText: `Just minted my Guild Pin for joining ${name}!\nguild.xyz/${urlName}`,
})

createPurchase(hash)
verifyPurchase(hash)
}

const fetcherWithSign = useFetcherWithSign()

const createPurchase = (txHash: string) => {
const verifyPurchase = (txHash: string) => {
fetcherWithSign([
`/v2/users/${address}/orders/verify`,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Icon } from "@phosphor-icons/react/dist/lib/types"
import { PropsWithChildren, useState } from "react"

type Props = {
colorScheme: NonNullable<Exclude<BadgeProps["colorScheme"], "gold">>
colorScheme: NonNullable<Exclude<BadgeProps["colorScheme"], "gold" | "red">>
icon: Icon
isAlwaysOpen?: boolean
}
Expand All @@ -19,7 +19,7 @@ const CIRCLE_BG_CLASS = {
gray: "bg-secondary",
blue: "bg-info dark:bg-info-subtle-foreground",
green: "bg-success dark:bg-success-subtle-foreground",
orange: "bg-warning dark:bg-warning-subtle-foreground",
orange: "bg-warning dark:bg-warning-subtle-foreground",
} satisfies Record<Props["colorScheme"], string>

const RequirementAccessIndicatorUI = ({
Expand Down
13 changes: 13 additions & 0 deletions src/components/[guild]/collect/hooks/useCollectNft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ const useCollectNft = () => {
})
const claimAmount = claimAmountFromForm ?? 1

const verifyPurchase = (txHash: string) => {
fetcherWithSign([
`/v2/users/${userAddress}/orders/verify`,
{
body: {
txHash: txHash,
chainId,
},
},
])
}

const mint = async () => {
setTxError(null)
setTxSuccess(false)
Expand Down Expand Up @@ -175,6 +187,7 @@ const useCollectNft = () => {

setTxSuccess(true)

verifyPurchase(hash)
return receipt
}

Expand Down
2 changes: 2 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { WagmiProvider } from "wagmi"
import { wagmiConfig } from "wagmiConfig"
import "../app/globals.css"
import { AccountModal } from "@/components/Account/components/AccountModal"
import { PurchaseHistoryDrawer } from "@/components/Account/components/PurchaseHistoryDrawer/PurchaseHistoryDrawer"
import { AnnouncementDialog } from "@/components/AnnouncementDialog"
import AppErrorBoundary from "@/components/AppErrorBoundary"
import { IntercomProvider } from "@/components/Providers/IntercomProvider"
Expand Down Expand Up @@ -84,6 +85,7 @@ const App = ({

<ClientOnly>
<AccountModal />
<PurchaseHistoryDrawer />
</ClientOnly>
</IntercomProvider>

Expand Down
13 changes: 6 additions & 7 deletions src/requirements/Farcaster/components/FarcasterCast.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { prettyDate } from "@/lib/prettyDate"
import { cn } from "@/lib/utils"
import { Icon } from "@phosphor-icons/react/dist/lib/types"
import {
Expand All @@ -24,12 +25,6 @@ export const FarcasterCast = ({
size?: string
}) => {
const url = `https://warpcast.com/${cast?.author.username}/${cast?.hash}`
const prettyDate =
cast?.timestamp &&
new Intl.DateTimeFormat("en-US", {
dateStyle: "short",
timeStyle: "short",
}).format(new Date(cast.timestamp))

if (size === "sm") {
return <FarcasterCastSmall cast={cast} error={error} loading={loading} />
Expand Down Expand Up @@ -76,7 +71,11 @@ export const FarcasterCast = ({
<span className="text-ellipsis font-bold text-sm">
{cast.author.display_name ?? cast.author.username}
</span>
<span className="text-muted-foreground text-xs">{prettyDate}</span>
{cast?.timestamp && (
<span className="text-muted-foreground text-xs">
{prettyDate(cast.timestamp)}
</span>
)}
</div>
</div>

Expand Down
9 changes: 6 additions & 3 deletions src/requirements/Twitter/TwitterRequirement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import TwitterListLink from "./components/TwitterListLink"
import TwitterTweetLink from "./components/TwitterTweetLink"
import TwitterUserLink from "./components/TwitterUserLink"

type TW = Extract<RequirementType, `TWITTER_${string}`> | "LINK_VISIT"
type TwitterRequirementType =
| Extract<RequirementType, `TWITTER_${string}`>
/**
Expand All @@ -37,7 +38,7 @@ const requirementIntentAction: Partial<
export const TWITTER_HANDLE_REGEX = /^[a-z0-9_]+$/i

const TwitterRequirement = (props: RequirementProps) => {
const requirement = useRequirementContext<TwitterRequirementType>()
const requirement = useRequirementContext()
const { id: userId, platformUsers } = useUser()
const isTwitterConnected = platformUsers?.find(
(pu) => pu.platformId === PlatformType.TWITTER_V1
Expand All @@ -53,7 +54,9 @@ const TwitterRequirement = (props: RequirementProps) => {
) : (
<TwitterIntent
action={
requirementIntentAction[requirement.type] as TwitterIntentAction
requirementIntentAction[
requirement.type as TwitterRequirementType
] as TwitterIntentAction
}
/>
)
Expand All @@ -68,7 +71,7 @@ const TwitterRequirement = (props: RequirementProps) => {
"minAmount" in requirement.data ? requirement.data.minAmount : 0
)

switch (requirement.type) {
switch (requirement.type as TwitterRequirementType) {
case "TWITTER_NAME":
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type CovalentRequirementType =
| "COVALENT_TX_VALUE_RELATIVE"

const WalletActivityRequirement = (props: RequirementProps): JSX.Element => {
const requirement = useRequirementContext<CovalentRequirementType>()
const requirement = useRequirementContext()
const reqData = requirement.data as any // Important note: we needed a hotfix for the requirement icon, but we should find a proper solution for this.

const maxAmount = reqData?.timestamps?.maxAmount
Expand Down
15 changes: 0 additions & 15 deletions src/requirements/requirementDisplayComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ export const REQUIREMENT_DISPLAY_COMPONENTS = {
CONTRACT: dynamic<RequirementProps>(
() => import("requirements/ContractState/ContractStateRequirement")
),
// TODO: TX_VALUE requirements are deprecated
COVALENT_TX_VALUE: dynamic<RequirementProps>(
() => import("requirements/WalletActivity/WalletActivityRequirement")
),
COVALENT_TX_VALUE_RELATIVE: dynamic<RequirementProps>(
() => import("requirements/WalletActivity/WalletActivityRequirement")
),
COVALENT_FIRST_TX: dynamic<RequirementProps>(
() => import("requirements/WalletActivity/WalletActivityRequirement")
),
Expand Down Expand Up @@ -119,10 +112,6 @@ export const REQUIREMENT_DISPLAY_COMPONENTS = {
FORM_SUBMISSION: dynamic<RequirementProps>(
() => import("requirements/Form/FormRequirement")
),
// TODO: this is a deprecated requirement
FORM_APPROVAL: dynamic<RequirementProps>(
() => import("requirements/Form/FormRequirement")
),
WORLD_ID_VERIFICATION: dynamic<RequirementProps>(
() => import("requirements/WorldID/WorldIDRequirement")
),
Expand Down Expand Up @@ -180,10 +169,6 @@ export const REQUIREMENT_DISPLAY_COMPONENTS = {
TWITTER_TWEET_COUNT: dynamic<RequirementProps>(
() => import("requirements/Twitter/TwitterRequirement")
),
// TODO: this is a deprecated requirement
TWITTER_LIST_FOLLOW: dynamic<RequirementProps>(
() => import("requirements/Twitter/TwitterRequirement")
),
GITHUB_STARRING: dynamic<RequirementProps>(
() => import("requirements/Github/GithubRequirement")
),
Expand Down
15 changes: 0 additions & 15 deletions src/requirements/requirementFormComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ export const REQUIREMENT_FORM_COMPONENTS = {
CONTRACT: dynamic<RequirementFormProps>(
() => import("requirements/ContractState/ContractStateForm")
),
// TODO: TX_VALUE requirements are deprecated
COVALENT_TX_VALUE: dynamic<RequirementFormProps>(
() => import("requirements/WalletActivity/WalletActivityForm")
),
COVALENT_TX_VALUE_RELATIVE: dynamic<RequirementFormProps>(
() => import("requirements/WalletActivity/WalletActivityForm")
),
COVALENT_FIRST_TX: dynamic<RequirementFormProps>(
() => import("requirements/WalletActivity/WalletActivityForm")
),
Expand Down Expand Up @@ -109,10 +102,6 @@ export const REQUIREMENT_FORM_COMPONENTS = {
FORM_SUBMISSION: dynamic<RequirementFormProps>(
() => import("requirements/Form/FormForm")
),
// TODO: this is a deprecated requirement
FORM_APPROVAL: dynamic<RequirementFormProps>(
() => import("requirements/Form/FormForm")
),
WORLD_ID_VERIFICATION: dynamic<RequirementFormProps>(
() => import("requirements/WorldID/WorldIDForm")
),
Expand Down Expand Up @@ -170,10 +159,6 @@ export const REQUIREMENT_FORM_COMPONENTS = {
TWITTER_TWEET_COUNT: dynamic<RequirementFormProps>(
() => import("requirements/Twitter/TwitterForm")
),
// TODO: this is a deprecated requirement
TWITTER_LIST_FOLLOW: dynamic<RequirementFormProps>(
() => import("requirements/Twitter/TwitterForm")
),
GITHUB_STARRING: dynamic<RequirementFormProps>(
() => import("requirements/Github/GithubForm")
),
Expand Down
8 changes: 7 additions & 1 deletion src/requirements/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { Icon } from "@phosphor-icons/react"
import { UseControllerProps } from "react-hook-form"
import { Requirement } from "types"

export type RequirementType = Schemas["Requirement"]["type"]
export type RequirementType = Exclude<
Schemas["Requirement"]["type"],
| "COVALENT_TX_VALUE"
| "COVALENT_TX_VALUE_RELATIVE"
| "FORM_APPROVAL"
| "TWITTER_LIST_FOLLOW"
>

export type RequirementFormProps = {
baseFieldPath: string
Expand Down
Loading
Loading