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: add non auth crowdfund support #94

Merged
merged 1 commit into from
Jul 22, 2022
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
12 changes: 6 additions & 6 deletions src/components/Post/Crowdfund/Fund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import splitSignature from '@lib/splitSignature'
import React, { Dispatch, FC, useState } from 'react'
import toast from 'react-hot-toast'
import {
CONNECT_WALLET,
ERROR_MESSAGE,
ERRORS,
LENSHUB_PROXY,
RELAY_ON,
SIGN_WALLET
RELAY_ON
} from 'src/constants'
import { useAppPersistStore, useAppStore } from 'src/store/app'
import {
Expand Down Expand Up @@ -73,7 +73,7 @@ interface Props {

const Fund: FC<Props> = ({ fund, collectModule, setRevenue, revenue }) => {
const { userSigNonce, setUserSigNonce } = useAppStore()
const { isAuthenticated, currentUser } = useAppPersistStore()
const { isConnected } = useAppPersistStore()
const [allowed, setAllowed] = useState<boolean>(true)
const { address } = useAccount()
const { isLoading: signLoading, signTypedDataAsync } = useSignTypedData({
Expand All @@ -82,7 +82,7 @@ const Fund: FC<Props> = ({ fund, collectModule, setRevenue, revenue }) => {
}
})
const { data: balanceData, isLoading: balanceLoading } = useBalance({
addressOrName: currentUser?.ownedBy,
addressOrName: address,
token: collectModule?.amount?.asset?.address,
formatUnits: collectModule?.amount?.asset?.decimals,
watch: true
Expand Down Expand Up @@ -110,7 +110,7 @@ const Fund: FC<Props> = ({ fund, collectModule, setRevenue, revenue }) => {
referenceModules: []
}
},
skip: !collectModule?.amount?.asset?.address || !currentUser,
skip: !collectModule?.amount?.asset?.address || !isConnected,
onCompleted(data) {
setAllowed(data?.approvedModuleAllowanceAmount[0]?.allowance !== '0x00')
Logger.log('[Query]', `Fetched allowance data`)
Expand Down Expand Up @@ -198,7 +198,7 @@ const Fund: FC<Props> = ({ fund, collectModule, setRevenue, revenue }) => {
)

const createCollect = () => {
if (!isAuthenticated) return toast.error(SIGN_WALLET)
if (!isConnected) return toast.error(CONNECT_WALLET)

createCollectTypedData({
variables: {
Expand Down
6 changes: 3 additions & 3 deletions src/components/Post/Crowdfund/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface Props {
}

const Crowdfund: FC<Props> = ({ fund }) => {
const { currentUser } = useAppPersistStore()
const { isConnected, currentUser } = useAppPersistStore()
const [showFundersModal, setShowFundersModal] = useState<boolean>(false)
const [revenue, setRevenue] = useState<number>(0)
const { data, loading } = useQuery(COLLECT_QUERY, {
Expand Down Expand Up @@ -179,7 +179,7 @@ const Crowdfund: FC<Props> = ({ fund }) => {
referralFee={collectModule?.referralFee}
/>
</div>
{currentUser ? (
{isConnected && (
<div className="pt-3 sm:pt-0">
<Fund
fund={fund}
Expand All @@ -188,7 +188,7 @@ const Crowdfund: FC<Props> = ({ fund }) => {
setRevenue={setRevenue}
/>
</div>
) : null}
)}
</div>
{revenueLoading ? (
<div className="w-full h-[13px] !mt-5 rounded-full shimmer" />
Expand Down