Skip to content

Commit

Permalink
adds changelog, adds settle auction component
Browse files Browse the repository at this point in the history
  • Loading branch information
salieflewis committed May 30, 2023
1 parent 904e001 commit f0f15c3
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-rockets-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@public-assembly/builder-utils': patch
---

Reintroduces wagmi and alongside it, two write hooks, useCreateBid and useSettle. useTokenExplorer now expects a token id object as an argument.
3 changes: 3 additions & 0 deletions apps/router-test/src/app/[tokenId]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Loading() {
return <>Loading...</>
}
2 changes: 1 addition & 1 deletion apps/router-test/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function Page() {
<>
<h1>Home</h1>
{/* Recommended to use the <Link /> tag when navigating between routes */}
<Link href={`/${auctionState?.tokenId}`}>Go to auction</Link>
<Link href={`/${auctionState.tokenId}`}>Go to auction</Link>
</>
)
}
Expand Down
8 changes: 3 additions & 5 deletions apps/router-test/src/components/AuctionCountdown.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react'
import { useCountdown, useSettle } from '@public-assembly/builder-utils'
import { useCountdown } from '@public-assembly/builder-utils'
import { SettleAuction } from './SettleAuction'

export function AuctionCountdown({ endTime }: { endTime: number }) {
const { countdownString, isEnded } = useCountdown(endTime)
const { settle, settleLoading } = useSettle()

return (
<div className="flex flex-col">
Expand All @@ -13,9 +13,7 @@ export function AuctionCountdown({ endTime }: { endTime: number }) {
<span>{countdownString}</span>
</>
) : (
<button disabled={settleLoading} onClick={() => settle?.()}>
Settle auction
</button>
<SettleAuction />
)}
</div>
)
Expand Down
21 changes: 21 additions & 0 deletions apps/router-test/src/components/SettleAuction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useSettle, useAuctionState } from '@public-assembly/builder-utils'
import { useRouter } from 'next/navigation'
import { useEffect } from 'react'

export function SettleAuction() {
const { settle, settleLoading, settleSuccess } = useSettle()
const { auctionState } = useAuctionState()
const router = useRouter()

useEffect(() => {
if (settleSuccess) {
router.push(`/${auctionState.tokenId + 1}`)
}
}, [settleSuccess])

return (
<button disabled={settleLoading} onClick={() => settle?.()}>
Settle auction
</button>
)
}
1 change: 1 addition & 0 deletions packages/builder-utils/src/hooks/useCreateBid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function useCreateBid({ bidAmount }: { bidAmount: string }) {
args: [BigInt(auctionState?.tokenId as number)],
value: BigInt(bidAmount),
chainId: Number(process.env.NEXT_PUBLIC_CHAIN_ID),
enabled: Number(bidAmount) > 0,
})

const {
Expand Down
2 changes: 1 addition & 1 deletion packages/builder-utils/src/hooks/useMinBidAmount.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { useDaoAuctionQuery } from '../graphql/hooks/useDaoAuctionQuery'
import { useManagerContext } from '../context'
import { formatEther, parseUnits, Hex } from 'viem'
import { formatEther, parseUnits } from 'viem'

export function useMinBidAmount() {
const { tokenAddress } = useManagerContext()
Expand Down
1 change: 1 addition & 0 deletions packages/builder-utils/src/hooks/useSettle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useManagerContext } from '../context'
import { auctionAbi } from '../abi'
import { useContractWrite, usePrepareContractWrite, useWaitForTransaction } from 'wagmi'
import { useEffect } from 'react'

export function useSettle() {
const { auctionAddress } = useManagerContext()
Expand Down

0 comments on commit f0f15c3

Please sign in to comment.