Skip to content

Commit

Permalink
fix bad expiration date on citizenship
Browse files Browse the repository at this point in the history
  • Loading branch information
lyoshenka committed Mar 14, 2024
1 parent 0160589 commit 1985c33
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Public
NEXT_PUBLIC_APP_ENV="dev" # dev | prod
NEXT_PUBLIC_ALCHEMY_APP_NAME="Cabin Census"
NEXT_PUBLIC_VERCEL_URL='localhost:3000'
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY="" # See README for instructions
NEXT_PUBLIC_IPFS_GATEWAY='https://ipfs.io/ipfs/'
Expand All @@ -17,6 +15,7 @@ IRON_SESSION_PASSWORD="complex_password_at_least_32_characters_long"
SIGNER_PRIVATE_KEY="key"

# Alchemy Providers (Testnets when develop)
NEXT_PUBLIC_ALCHEMY_APP_NAME="Cabin Census"
NEXT_PUBLIC_ETH_ALCHEMY_ID="key"

# Pinata
Expand Down
15 changes: 4 additions & 11 deletions components/hooks/useGetUnlockNFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ export const useGetUnlockNFT = () => {
const { user: profile } = useProfile()
const config = useConfig()

const getDateFromBigint = (bi: bigint) => {
try {
return new Date(Number(bi) * 1000)
} catch (error) {
// Example invalid date: '115792089237316195423570985008687907853269984665640564039457584007913129639935'
console.error('Invalid date', error)
return null
}
}

useEffect(() => {
const getNFT = async () => {
if (!profile?.walletAddress || !profile.citizenshipMintedAt) {
Expand Down Expand Up @@ -51,7 +41,10 @@ export const useGetUnlockNFT = () => {
setActiveNFT({
tokenId: tokenId.toString(),
mintedDate: new Date(profile.citizenshipMintedAt),
expirationDate: getDateFromBigint(expirationTimestamp),
expirationDate:
expirationTimestamp > BigInt(4102462800)
? null
: new Date(Number(expirationTimestamp) * 1000),
image: DEFAULT_NFT_IMAGE,
})
}
Expand Down
7 changes: 2 additions & 5 deletions lib/protocol-config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { NetworkName } from '@/lib/chains'
import { isProd } from '@/utils/dev'

interface GetConfigArgs<T> extends Record<string, T> {
dev: T
prod: T
}

const getAppConfig = <T>(args: GetConfigArgs<T>): T => {
const appEnv = process.env.NEXT_PUBLIC_APP_ENV
if (!appEnv) {
throw new Error('NEXT_PUBLIC_APP_ENV is not set')
}

const appEnv = isProd ? 'prod' : 'dev'
const config = args[appEnv]
if (!config) {
throw new Error(`No config for app env: ${appEnv}`)
Expand Down
3 changes: 2 additions & 1 deletion scripts/postgres-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Decimal,
PrismaClientKnownRequestError,
} from '@prisma/client/runtime/library'
import { isLocalDev } from '@/utils/dev'

// TODO: check that every field in the existing data is imported

Expand Down Expand Up @@ -115,7 +116,7 @@ async function postgresImport() {
console.log(`finished parsing ${fullPath}`)
}

if (process.env.NEXT_PUBLIC_APP_ENV === 'dev') {
if (isLocalDev) {
console.log('updating profile privyDID and externId FOR DEV ENV')
await prisma.profile.update({
data: {
Expand Down

0 comments on commit 1985c33

Please sign in to comment.