Skip to content

Commit

Permalink
add redirect after success transition
Browse files Browse the repository at this point in the history
  • Loading branch information
lukachi committed Dec 18, 2023
1 parent fda74f3 commit adaf235
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
7 changes: 3 additions & 4 deletions .env-development
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
VITE_PORT=8095
VITE_API_URL='https://api.polygon.mainnet-beta.rarimo.com'
VITE_APP_NAME='PolyginID identity'

VITE_WORLDCOIN_APP_ID=app_staging_bd301ed345395d5c4021e590a682ed3c

VITE_RARIMO_CORE_API_URL='https://api.mainnet-beta.rarimo.com'
VITE_RARIMO_CORE_API_URL='https://worldcoin.relayer.mainnet-beta.rarimo.com'

VITE_QUERY_VERIFIER_CONTRACT_ADDRESS_SEPOLIA: '0x1eF904bD16C6e3e3f17f3fFD7F9d7785b5433521'
VITE_VERIFIED_SBT_CONTRACT_ADDRESS_SEPOLIA: '0xCe53D12a5c347e0B8E696D9AEAc13c45DC70222F'
VITE_QUERY_VERIFIER_CONTRACT_ADDRESS_SEPOLIA: '0xd3C2c1BA9c596D3F6890cb9C3DF3C7e4113d264c'
VITE_VERIFIED_SBT_CONTRACT_ADDRESS_SEPOLIA: ''

VITE_DEFAULT_CHAIN='SEPOLIA'
15 changes: 7 additions & 8 deletions src/contexts/ZkpContext/ZkpContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fetcher, FetcherError } from '@distributedlab/fetcher'
import { fetcher } from '@distributedlab/fetcher'
import { type ISuccessResult } from '@worldcoin/idkit'
import { providers } from 'ethers'
import get from 'lodash/get'
import { createContext, FC, HTMLAttributes, useCallback, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useEffectOnce } from 'react-use'
Expand Down Expand Up @@ -78,11 +79,7 @@ const ZkpContextProvider: FC<Props> = ({ children, ...rest }) => {

const handleStateValidatingError = useCallback(
(error: unknown) => {
if (!(error instanceof FetcherError)) throw error

if (!('code' in error.response.data)) throw error

return validateStateStatusCode(String(error.response.data.code))
return validateStateStatusCode(String(get(error, 'response.data.code')))
},
[validateStateStatusCode],
)
Expand All @@ -106,7 +103,7 @@ const ZkpContextProvider: FC<Props> = ({ children, ...rest }) => {

await waitTx(data?.tx)

return false
return true
} catch (error) {
// TODO: if error === 400(3) how should we wait transit tx?
return handleStateValidatingError(error)
Expand Down Expand Up @@ -160,9 +157,11 @@ const ZkpContextProvider: FC<Props> = ({ children, ...rest }) => {
return
}

navigate(RoutesPaths.authConfirmation)

setIsPending(false)
},
[isStateTransitionValid],
[isStateTransitionValid, navigate],
)

useEffectOnce(() => {
Expand Down

0 comments on commit adaf235

Please sign in to comment.