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

fix: typo #1328

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 20 additions & 7 deletions apps/web/src/components/Login/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
IS_MAINNET,
LENS_NAMESPACE_PREFIX,
MOONPAY_URL,
TAPE_SIGNUP_PRICE,
TAPE_SIGNUP_PROXY_ADDRESS,
ZERO_ADDRESS
} from '@tape.xyz/constants'
Expand All @@ -36,8 +35,13 @@ import type { FC } from 'react'
import React, { useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
import toast from 'react-hot-toast'
import { formatUnits, parseEther } from 'viem'
import { useAccount, useBalance, useWriteContract } from 'wagmi'
import { formatUnits } from 'viem'
import {
useAccount,
useBalance,
useReadContract,
useWriteContract
} from 'wagmi'
import type { z } from 'zod'
import { object, string } from 'zod'

Expand Down Expand Up @@ -99,13 +103,22 @@ const Signup: FC<Props> = ({ showLogin, onSuccess, setShowSignup }) => {
query: { refetchInterval: 2000 }
})

const { data: signupPrice } = useReadContract({
abi: TAPE_SIGNUP_PROXY_ABI,
address: TAPE_SIGNUP_PROXY_ADDRESS,
functionName: 'signupPrice',
query: { refetchInterval: 1000 }
})

const signupPriceFormatted = formatUnits((signupPrice ?? 0) as bigint, 18)

const onMinted = (via: string) => {
onSuccess()
reset()
toast.success('Profile created')
setCreating(false)
Tower.track(EVENTS.AUTH.SIGNUP_SUCCESS, {
price: TAPE_SIGNUP_PRICE,
price: signupPriceFormatted,
via
})
}
Expand Down Expand Up @@ -232,15 +245,15 @@ const Signup: FC<Props> = ({ showLogin, onSuccess, setShowSignup }) => {
address: TAPE_SIGNUP_PROXY_ADDRESS,
args: [[address, ZERO_ADDRESS, '0x'], handle, [delegatedExecutor]],
functionName: 'createProfileWithHandleUsingCredits',
value: parseEther(TAPE_SIGNUP_PRICE.toString())
value: signupPrice as bigint
})
} catch {
setCreating(false)
}
}

const balance = balanceData && parseFloat(formatUnits(balanceData.value, 18))
const hasBalance = balance && balance >= TAPE_SIGNUP_PRICE
const hasBalance = balance && balance >= Number(signupPriceFormatted)

return (
<form
Expand Down Expand Up @@ -363,7 +376,7 @@ const Signup: FC<Props> = ({ showLogin, onSuccess, setShowSignup }) => {
loading={creating}
disabled={creating || !isHandleAvailable || checkingAvailability}
>
Mint for {TAPE_SIGNUP_PRICE} MATIC
Mint for {signupPriceFormatted} MATIC
</Button>
{showLogin && (
<div className="flex items-center justify-center space-x-2 pt-3 text-sm">
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Mod/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Signup = () => {
<li>Total Signups Card: {String(totalCountViaCard)}</li>
<hr className="my-3" />
<li>Total Crypto Revenue: {balance} MATIC</li>
<li>Total Card Revenue: {Number(totalCountViaCrypto || 0) * 6} USD</li>
<li>Total Card Revenue: {Number(totalCountViaCard || 0) * 6} USD</li>
<hr className="my-3" />
</ul>
<div className="flex">
Expand Down
1 change: 0 additions & 1 deletion packages/constants/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export const TAPE_GITHUB_HANDLE = 'tapexyz'
export const TAPE_LOGO = `${STATIC_ASSETS}/brand/logo.svg`
export const TAPE_STATUS_PAGE = 'https://status.tape.xyz'
export const TAPE_FEEDBACK_URL = 'https://feedback.tape.xyz'
export const TAPE_SIGNUP_PRICE = 6

// admin
export const ADMIN_IDS = IS_MAINNET ? ['0x2d'] : []
Expand Down