From adaf235068ae5e4512852766a1524d9c53f18090 Mon Sep 17 00:00:00 2001 From: lukachi Date: Mon, 18 Dec 2023 13:14:42 +0200 Subject: [PATCH] add redirect after success transition --- .env-development | 7 +++---- src/contexts/ZkpContext/ZkpContext.tsx | 15 +++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.env-development b/.env-development index 971959b..36ef124 100644 --- a/.env-development +++ b/.env-development @@ -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' diff --git a/src/contexts/ZkpContext/ZkpContext.tsx b/src/contexts/ZkpContext/ZkpContext.tsx index 2e6b34a..846ed64 100644 --- a/src/contexts/ZkpContext/ZkpContext.tsx +++ b/src/contexts/ZkpContext/ZkpContext.tsx @@ -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' @@ -78,11 +79,7 @@ const ZkpContextProvider: FC = ({ 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], ) @@ -106,7 +103,7 @@ const ZkpContextProvider: FC = ({ 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) @@ -160,9 +157,11 @@ const ZkpContextProvider: FC = ({ children, ...rest }) => { return } + navigate(RoutesPaths.authConfirmation) + setIsPending(false) }, - [isStateTransitionValid], + [isStateTransitionValid, navigate], ) useEffectOnce(() => {