From 190c4da5a676769c5acb8ba42210f41683c1333b Mon Sep 17 00:00:00 2001 From: "nexera-release[bot]" <137495321+nexera-release[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 17:44:04 +0100 Subject: [PATCH 01/15] development to staging (#212) * Feature/web3 123 docs update example apps documentation (#199) * Minor text style improvements * Minor additions to the readme files * Minor style change * Making README NexeraID specific * Updates following review * Feature/web3 149 redeploy aave pool with new verifier and update aave example (#201) * update proxy pool address * use local env for pool and update idenztity sdk use * NEX-399 - Updated versions of Exmaple Apps and Aave interface (#203) * NEX-399 - Updated versions of Exmaple Apps and Aave interface * NEX-399 - Changing ethers version * NEX-399 - Change api url (#204) * Change by default testnet config on Aave interface (#209) * NEX-438 - Refactored example apps webhook response obtained (#210) * NEX-440 - Updated api prod URL (#211) --------- Co-authored-by: Andrew McFarland Campbell <131174751+AndrewMcFarlandCampbellNexeraID@users.noreply.github.com> Co-authored-by: Antoine Estienne Co-authored-by: Lizandro Zerpa Co-authored-by: Marko Smej --- .../components/TestNetModeSwitcher.tsx | 5 +- .../src/utils/marketsAndNetworksConfig.ts | 70 ++++--- example-apps/package-lock.json | 16 +- example-apps/package.json | 2 +- .../identity/useCheckBankWeb3Compliance.tsx | 2 +- .../bank/identity/useCheckBankCompliance.tsx | 2 +- .../useCheckDefiOffchainZKPCompliance.tsx | 2 +- .../useCheckDefiRuleEngineCompliance.tsx | 2 +- example-apps/src/features/kyc/apiClient.ts | 4 +- .../identity/useCheckSygnumWeb3Compliance.tsx | 2 +- .../pages/api/bank-web3/scenario-webhook.ts | 8 +- .../src/pages/api/bank/scenario-webhook.ts | 8 +- .../api/defi-offchain-zkp/scenario-webhook.ts | 9 +- .../api/defi-rule-engine/scenario-webhook.ts | 8 +- .../{access_token.tsx => access-token.tsx} | 0 .../pages/api/kyc/notification_webhook.tsx | 7 - ...o_webhook.post.tsx => scenario-webhook.ts} | 18 +- .../pages/api/kyc/scenario_webhook/index.tsx | 28 --- .../scenario_webhook/scenario_webhook.get.tsx | 21 -- .../pages/api/sygnum-web3/scenario-webhook.ts | 8 +- example-apps/src/pages/bank-web3.tsx | 6 +- example-apps/src/pages/bank.tsx | 6 +- example-apps/src/pages/defi-offchain-zkp.tsx | 6 +- example-apps/src/pages/defi-rule-engine.tsx | 6 +- example-apps/src/pages/sygnum-web3.tsx | 23 ++- .../server/api/routers/complianceRouter.ts | 183 ++++++++---------- 26 files changed, 199 insertions(+), 253 deletions(-) rename example-apps/src/pages/api/kyc/{access_token.tsx => access-token.tsx} (100%) delete mode 100644 example-apps/src/pages/api/kyc/notification_webhook.tsx rename example-apps/src/pages/api/kyc/{scenario_webhook/scenario_webhook.post.tsx => scenario-webhook.ts} (53%) delete mode 100644 example-apps/src/pages/api/kyc/scenario_webhook/index.tsx delete mode 100644 example-apps/src/pages/api/kyc/scenario_webhook/scenario_webhook.get.tsx diff --git a/example-aave/src/layouts/components/TestNetModeSwitcher.tsx b/example-aave/src/layouts/components/TestNetModeSwitcher.tsx index df1a883d..ce45c373 100644 --- a/example-aave/src/layouts/components/TestNetModeSwitcher.tsx +++ b/example-aave/src/layouts/components/TestNetModeSwitcher.tsx @@ -10,7 +10,10 @@ interface TestNetModeSwitcherProps { export const TestNetModeSwitcher = ({ component = ListItem }: TestNetModeSwitcherProps) => { const testnetsEnabledId = 'testnetsEnabled'; - const testnetsEnabledLocalstorage = localStorage.getItem(testnetsEnabledId) === 'true' || false; + // True by default + const testnetsEnabledLocalstorage = localStorage.getItem(testnetsEnabledId) + ? localStorage.getItem(testnetsEnabledId) === 'true' || false + : true; const [testnetsEnabled, setTestnetsMode] = useState(testnetsEnabledLocalstorage); const trackEvent = useRootStore((store) => store.trackEvent); diff --git a/example-aave/src/utils/marketsAndNetworksConfig.ts b/example-aave/src/utils/marketsAndNetworksConfig.ts index c0130671..c03e384b 100644 --- a/example-aave/src/utils/marketsAndNetworksConfig.ts +++ b/example-aave/src/utils/marketsAndNetworksConfig.ts @@ -23,7 +23,9 @@ export type Pool = { export const STAGING_ENV = process.env.NEXT_PUBLIC_ENV === 'staging'; export const PROD_ENV = !process.env.NEXT_PUBLIC_ENV || process.env.NEXT_PUBLIC_ENV === 'prod'; export const ENABLE_TESTNET = - PROD_ENV && global?.window?.localStorage.getItem('testnetsEnabled') === 'true'; + PROD_ENV && + (global?.window?.localStorage.getItem('testnetsEnabled') === 'true' || + !global?.window?.localStorage.getItem('testnetsEnabled')); // determines if forks should be shown export const FORK_ENABLED = @@ -50,42 +52,48 @@ const FORK_WS_RPC_URL = * Generates network configs based on networkConfigs & fork settings. * Forks will have a rpcOnly clone of their underlying base network config. */ -export const networkConfigs = Object.keys(_networkConfigs).reduce((acc, value) => { - acc[value] = _networkConfigs[value]; - if (FORK_ENABLED && Number(value) === FORK_BASE_CHAIN_ID) { - acc[FORK_CHAIN_ID] = { - ..._networkConfigs[value], - name: `${_networkConfigs[value].name} Fork`, - isFork: true, - privateJsonRPCUrl: FORK_RPC_URL, - privateJsonRPCWSUrl: FORK_WS_RPC_URL, - publicJsonRPCUrl: [], - publicJsonRPCWSUrl: '', - underlyingChainId: FORK_BASE_CHAIN_ID, - }; - } - return acc; -}, {} as { [key: string]: BaseNetworkConfig }); +export const networkConfigs = Object.keys(_networkConfigs).reduce( + (acc, value) => { + acc[value] = _networkConfigs[value]; + if (FORK_ENABLED && Number(value) === FORK_BASE_CHAIN_ID) { + acc[FORK_CHAIN_ID] = { + ..._networkConfigs[value], + name: `${_networkConfigs[value].name} Fork`, + isFork: true, + privateJsonRPCUrl: FORK_RPC_URL, + privateJsonRPCWSUrl: FORK_WS_RPC_URL, + publicJsonRPCUrl: [], + publicJsonRPCWSUrl: '', + underlyingChainId: FORK_BASE_CHAIN_ID, + }; + } + return acc; + }, + {} as { [key: string]: BaseNetworkConfig } +); /** * Generates network configs based on marketsData & fork settings. * Fork markets are generated for all markets on the underlying base chain. */ -export const marketsData = Object.keys(_marketsData).reduce((acc, value) => { - acc[value] = _marketsData[value as keyof typeof CustomMarket]; - if ( - FORK_ENABLED && - _marketsData[value as keyof typeof CustomMarket].chainId === FORK_BASE_CHAIN_ID - ) { - acc[`fork_${value}`] = { - ..._marketsData[value as keyof typeof CustomMarket], - chainId: FORK_CHAIN_ID, - isFork: true, - }; - } - return acc; -}, {} as { [key: string]: MarketDataType }); +export const marketsData = Object.keys(_marketsData).reduce( + (acc, value) => { + acc[value] = _marketsData[value as keyof typeof CustomMarket]; + if ( + FORK_ENABLED && + _marketsData[value as keyof typeof CustomMarket].chainId === FORK_BASE_CHAIN_ID + ) { + acc[`fork_${value}`] = { + ..._marketsData[value as keyof typeof CustomMarket], + chainId: FORK_CHAIN_ID, + isFork: true, + }; + } + return acc; + }, + {} as { [key: string]: MarketDataType } +); export function getDefaultChainId() { return marketsData[availableMarkets[0]].chainId; diff --git a/example-apps/package-lock.json b/example-apps/package-lock.json index 1009f558..49487556 100644 --- a/example-apps/package-lock.json +++ b/example-apps/package-lock.json @@ -8,7 +8,7 @@ "name": "root-project", "version": "0.1.0", "dependencies": { - "@nexeraid/identity-sdk": "^1.1.192", + "@nexeraid/identity-sdk": "^1.1.194", "@rainbow-me/rainbowkit": "^1.0.12", "@t3-oss/env-nextjs": "^0.6.0", "@tanstack/react-query": "^4.32.6", @@ -1071,19 +1071,19 @@ } }, "node_modules/@nexeraid/identity-sdk": { - "version": "1.1.192", - "resolved": "https://registry.npmjs.org/@nexeraid/identity-sdk/-/identity-sdk-1.1.192.tgz", - "integrity": "sha512-o5+mMQEkTpwyHYLDK7abIXXr6eN9wrB5pIXwcVnXCg6dwV8pIc6bvTJHLjhMCLcVBPl0cbc03TwGyZijFOR8oQ==", + "version": "1.1.194", + "resolved": "https://registry.npmjs.org/@nexeraid/identity-sdk/-/identity-sdk-1.1.194.tgz", + "integrity": "sha512-EGfl66yY1oE/eYMw74q/nY4moEV0qr2AW1e4ThpiJv3vJDxjKSLHiXb6rA3vlzhLmOKxzWA5/u7onVDDnwOAwA==", "dependencies": { - "@nexeraprotocol/nexera-id-schemas": "1.10.1", + "@nexeraprotocol/nexera-id-schemas": "1.10.3", "zod": "^3.22.4", "zod-validation-error": "^2.1.0" } }, "node_modules/@nexeraprotocol/nexera-id-schemas": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/@nexeraprotocol/nexera-id-schemas/-/nexera-id-schemas-1.10.1.tgz", - "integrity": "sha512-+612cxUcMhjo/uHDKUUF0+g7w2CzffkIk4FHdKuPXhfV3YLmbvCOEYFsxVDgB7sgrqpLEocKfJvg6B9TNpr62w==", + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/@nexeraprotocol/nexera-id-schemas/-/nexera-id-schemas-1.10.3.tgz", + "integrity": "sha512-Yh+C4Sn+aPYlbTCkF/6617YdRv/YoVERG65iAJ5eZPLjEGiJJbIqC58piZhz+W37PEuqw4glKx0Hho4uhmMazw==", "dependencies": { "zod": "^3.22.4" } diff --git a/example-apps/package.json b/example-apps/package.json index 4bb622c5..148ee5c9 100644 --- a/example-apps/package.json +++ b/example-apps/package.json @@ -9,7 +9,7 @@ "start": "next start" }, "dependencies": { - "@nexeraid/identity-sdk": "^1.1.192", + "@nexeraid/identity-sdk": "^1.1.194", "@rainbow-me/rainbowkit": "^1.0.12", "@t3-oss/env-nextjs": "^0.6.0", "@tanstack/react-query": "^4.32.6", diff --git a/example-apps/src/features/bank-web3/identity/useCheckBankWeb3Compliance.tsx b/example-apps/src/features/bank-web3/identity/useCheckBankWeb3Compliance.tsx index 790365c0..5500394a 100644 --- a/example-apps/src/features/bank-web3/identity/useCheckBankWeb3Compliance.tsx +++ b/example-apps/src/features/bank-web3/identity/useCheckBankWeb3Compliance.tsx @@ -11,7 +11,7 @@ export const useCheckBankWeb3Compliance = (enabled: boolean) => { queryFn: async () => { if (!user) return Promise.resolve({ - data: "not_received", + data: "unknown", isValid: false, }); const result = await mutation.mutateAsync({ diff --git a/example-apps/src/features/bank/identity/useCheckBankCompliance.tsx b/example-apps/src/features/bank/identity/useCheckBankCompliance.tsx index 3483687d..047a2970 100644 --- a/example-apps/src/features/bank/identity/useCheckBankCompliance.tsx +++ b/example-apps/src/features/bank/identity/useCheckBankCompliance.tsx @@ -11,7 +11,7 @@ export const useCheckBankCompliance = (enabled: boolean) => { queryFn: async () => { if (!user) return Promise.resolve({ - data: "not_received", + data: "unknown", isValid: false, }); const result = await mutation.mutateAsync({ diff --git a/example-apps/src/features/defi-offchain-zkp/identity/useCheckDefiOffchainZKPCompliance.tsx b/example-apps/src/features/defi-offchain-zkp/identity/useCheckDefiOffchainZKPCompliance.tsx index b577f899..217b3bae 100644 --- a/example-apps/src/features/defi-offchain-zkp/identity/useCheckDefiOffchainZKPCompliance.tsx +++ b/example-apps/src/features/defi-offchain-zkp/identity/useCheckDefiOffchainZKPCompliance.tsx @@ -11,7 +11,7 @@ export const useCheckCompliance = (enabled: boolean) => { queryFn: async () => { if (!user) return Promise.resolve({ - data: "not_received", + data: "unknown", isValid: false, }); console.log("isCompliant", user); diff --git a/example-apps/src/features/defi-rule-engine/identity/useCheckDefiRuleEngineCompliance.tsx b/example-apps/src/features/defi-rule-engine/identity/useCheckDefiRuleEngineCompliance.tsx index 889d5adc..22edfa19 100644 --- a/example-apps/src/features/defi-rule-engine/identity/useCheckDefiRuleEngineCompliance.tsx +++ b/example-apps/src/features/defi-rule-engine/identity/useCheckDefiRuleEngineCompliance.tsx @@ -11,7 +11,7 @@ export const useCheckDefiRuleEngineCompliance = (enabled: boolean) => { queryFn: async () => { if (!user) return Promise.resolve({ - data: "not_received", + data: "unknown", isValid: false, }); const result = await mutation.mutateAsync({ diff --git a/example-apps/src/features/kyc/apiClient.ts b/example-apps/src/features/kyc/apiClient.ts index 7a3c1fe6..85e1fad9 100644 --- a/example-apps/src/features/kyc/apiClient.ts +++ b/example-apps/src/features/kyc/apiClient.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ export const getAccessToken = async (address: string) => { - const response = await fetch(`/api/kyc/access_token?address=${address}`, { + const response = await fetch(`/api/kyc/access-token?address=${address}`, { headers: { "Content-Type": "application/json", }, @@ -15,7 +15,7 @@ export const getAccessToken = async (address: string) => { export const getScenarioWebhook = async (address: string) => { // wait 3 seconds to get the webhook response to be sure it is in redis await new Promise((resolve) => setTimeout(resolve, 3000)); - const response = await fetch(`/api/kyc/scenario_webhook?address=${address}`, { + const response = await fetch(`/api/kyc/scenario-webhook?address=${address}`, { headers: { "Content-Type": "application/json", }, diff --git a/example-apps/src/features/sygnum-web3/identity/useCheckSygnumWeb3Compliance.tsx b/example-apps/src/features/sygnum-web3/identity/useCheckSygnumWeb3Compliance.tsx index 572ae9da..641be029 100644 --- a/example-apps/src/features/sygnum-web3/identity/useCheckSygnumWeb3Compliance.tsx +++ b/example-apps/src/features/sygnum-web3/identity/useCheckSygnumWeb3Compliance.tsx @@ -11,7 +11,7 @@ export const useCheckSygnumWeb3Compliance = (enabled: boolean) => { queryFn: async () => { if (!user) return Promise.resolve({ - data: "not_received", + data: "unknown", isValid: false, }); const result = await mutation.mutateAsync({ diff --git a/example-apps/src/pages/api/bank-web3/scenario-webhook.ts b/example-apps/src/pages/api/bank-web3/scenario-webhook.ts index 522d691f..2f6d2180 100644 --- a/example-apps/src/pages/api/bank-web3/scenario-webhook.ts +++ b/example-apps/src/pages/api/bank-web3/scenario-webhook.ts @@ -1,6 +1,7 @@ import { type NextApiRequest, type NextApiResponse } from "next"; import { env } from "@/env.mjs"; import { redis } from "@/server/redis"; +import { type ScenarioWebhookPayload } from "../../../server/api/routers/complianceRouter"; export const getScenarioWebhookBankWeb3RedisKey = (address: string) => { return ( @@ -14,11 +15,10 @@ const scenarioWebHookPost = async ( res: NextApiResponse ) => { if (req.method === "POST") { - console.log("scenarioWebHookPost req.body", req.body); + console.log("=== scenarioWebHookPost BANK WEB3 req.body ===", req.body); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const body = req.body; - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - const key = getScenarioWebhookBankWeb3RedisKey(body.address as string); + const body: ScenarioWebhookPayload = req.body; + const key = getScenarioWebhookBankWeb3RedisKey(body.address); await redis.set(key, JSON.stringify(body)); res.status(200).json({ response: "ok" }); } diff --git a/example-apps/src/pages/api/bank/scenario-webhook.ts b/example-apps/src/pages/api/bank/scenario-webhook.ts index d61a227a..ee18d280 100644 --- a/example-apps/src/pages/api/bank/scenario-webhook.ts +++ b/example-apps/src/pages/api/bank/scenario-webhook.ts @@ -1,6 +1,7 @@ import { type NextApiRequest, type NextApiResponse } from "next"; import { env } from "@/env.mjs"; import { redis } from "@/server/redis"; +import { type ScenarioWebhookPayload } from "@/server/api/routers/complianceRouter"; export const getScenarioWebhookBankRedisKey = (address: string) => { return ( @@ -14,11 +15,10 @@ const scenarioWebHookPost = async ( res: NextApiResponse ) => { if (req.method === "POST") { - console.log("scenarioWebHookPost req.body", req.body); + console.log("=== scenarioWebHookPost BANK req.body ===", req.body); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const body = req.body; - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - const key = getScenarioWebhookBankRedisKey(body.address as string); + const body: ScenarioWebhookPayload = req.body; + const key = getScenarioWebhookBankRedisKey(body.address); await redis.set(key, JSON.stringify(body)); res.status(200).json({ response: "ok" }); } diff --git a/example-apps/src/pages/api/defi-offchain-zkp/scenario-webhook.ts b/example-apps/src/pages/api/defi-offchain-zkp/scenario-webhook.ts index ba523e45..a750427f 100644 --- a/example-apps/src/pages/api/defi-offchain-zkp/scenario-webhook.ts +++ b/example-apps/src/pages/api/defi-offchain-zkp/scenario-webhook.ts @@ -1,6 +1,7 @@ import { type NextApiRequest, type NextApiResponse } from "next"; import { env } from "@/env.mjs"; import { redis } from "@/server/redis"; +import { type ScenarioWebhookPayload } from "../../../server/api/routers/complianceRouter"; export const getScenarioWebhookDefiOffchainZKPRedisKey = (address: string) => { return ( @@ -14,12 +15,10 @@ const scenarioWebHookPost = async ( res: NextApiResponse ) => { if (req.method === "POST") { - console.log("===scenarioWebHookPost req.body===", req.body); + console.log("=== scenarioWebHookPost DEFI OFFCHAIN req.body ===", req.body); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const body = req.body; - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - const key = getScenarioWebhookDefiOffchainZKPRedisKey(body.address as string); - console.log('key', key) + const body: ScenarioWebhookPayload = req.body; + const key = getScenarioWebhookDefiOffchainZKPRedisKey(body.address); await redis.set(key, JSON.stringify(body)); res.status(200).json({ response: "ok" }); } diff --git a/example-apps/src/pages/api/defi-rule-engine/scenario-webhook.ts b/example-apps/src/pages/api/defi-rule-engine/scenario-webhook.ts index 7bd79aca..ba394e4c 100644 --- a/example-apps/src/pages/api/defi-rule-engine/scenario-webhook.ts +++ b/example-apps/src/pages/api/defi-rule-engine/scenario-webhook.ts @@ -1,6 +1,7 @@ import { type NextApiRequest, type NextApiResponse } from "next"; import { env } from "@/env.mjs"; import { redis } from "@/server/redis"; +import { type ScenarioWebhookPayload } from "@/server/api/routers/complianceRouter"; export const getScenarioWebhookDefiRuleEngineRedisKey = (address: string) => { return ( @@ -14,11 +15,10 @@ const scenarioWebHookPost = async ( res: NextApiResponse ) => { if (req.method === "POST") { - console.log("scenarioWebHookPost req.body", req.body); + console.log("=== scenarioWebHookPost DEFI RULENGINE req.body ===", req.body); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const body = req.body; - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - const key = getScenarioWebhookDefiRuleEngineRedisKey(body.address as string); + const body: ScenarioWebhookPayload = req.body; + const key = getScenarioWebhookDefiRuleEngineRedisKey(body.address ); await redis.set(key, JSON.stringify(body)); res.status(200).json({ response: "ok" }); } diff --git a/example-apps/src/pages/api/kyc/access_token.tsx b/example-apps/src/pages/api/kyc/access-token.tsx similarity index 100% rename from example-apps/src/pages/api/kyc/access_token.tsx rename to example-apps/src/pages/api/kyc/access-token.tsx diff --git a/example-apps/src/pages/api/kyc/notification_webhook.tsx b/example-apps/src/pages/api/kyc/notification_webhook.tsx deleted file mode 100644 index 29363057..00000000 --- a/example-apps/src/pages/api/kyc/notification_webhook.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { type NextApiRequest } from "next"; - -const notificationWebHook = (req: NextApiRequest) => { - console.log("NOTIFICATION: ", req.body); -}; - -export default notificationWebHook; diff --git a/example-apps/src/pages/api/kyc/scenario_webhook/scenario_webhook.post.tsx b/example-apps/src/pages/api/kyc/scenario-webhook.ts similarity index 53% rename from example-apps/src/pages/api/kyc/scenario_webhook/scenario_webhook.post.tsx rename to example-apps/src/pages/api/kyc/scenario-webhook.ts index 4a90503d..f10cb10b 100644 --- a/example-apps/src/pages/api/kyc/scenario_webhook/scenario_webhook.post.tsx +++ b/example-apps/src/pages/api/kyc/scenario-webhook.ts @@ -1,6 +1,7 @@ import { type NextApiRequest, type NextApiResponse } from "next"; -import { redis } from "./index"; import { env } from "@/env.mjs"; +import { redis } from "@/server/redis"; +import { type ScenarioWebhookPayload } from "../../../server/api/routers/complianceRouter"; export const getScenarioWebhookKYCRedisKey = (address: string) => { return ( @@ -11,16 +12,17 @@ export const getScenarioWebhookKYCRedisKey = (address: string) => { const scenarioWebHookPost = async ( req: NextApiRequest, - res: NextApiResponse, + res: NextApiResponse ) => { if (req.method === "POST") { + console.log("=== scenarioWebHookPost KYC req.body===", req.body); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const body = req.body; - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - const key = getScenarioWebhookKYCRedisKey(body.address as string); - console.log("scenarioWebHookPost key", key); - const response = await redis.set(key, JSON.stringify(body)); - console.log("scenarioWebHookPost rule webhook post response", response); + const body: ScenarioWebhookPayload = req.body; + const key = getScenarioWebhookKYCRedisKey(body.address); + await redis.set(key, JSON.stringify(body)); + res.status(200).json({ response: "ok" }); + } + if (req.method === "GET") { res.status(200).json({ response: "ok" }); } }; diff --git a/example-apps/src/pages/api/kyc/scenario_webhook/index.tsx b/example-apps/src/pages/api/kyc/scenario_webhook/index.tsx deleted file mode 100644 index 87399012..00000000 --- a/example-apps/src/pages/api/kyc/scenario_webhook/index.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from "next"; - -import { Redis } from "@upstash/redis"; -import ruleWebHookGet from "./scenario_webhook.get"; -import ruleWebHookPost from "./scenario_webhook.post"; - -export default async function handler( - req: NextApiRequest, - res: NextApiResponse -) { - switch (req.method) { - case "GET": { - await ruleWebHookGet(req, res); - break; - } - case "POST": { - console.log("🪝scenario_webhook/index.tsx - POST"); - await ruleWebHookPost(req, res); - break; - } - default: { - res.status(405).end("Method Not Allowed"); - break; - } - } -} - -export const redis = Redis.fromEnv(); diff --git a/example-apps/src/pages/api/kyc/scenario_webhook/scenario_webhook.get.tsx b/example-apps/src/pages/api/kyc/scenario_webhook/scenario_webhook.get.tsx deleted file mode 100644 index c6457d92..00000000 --- a/example-apps/src/pages/api/kyc/scenario_webhook/scenario_webhook.get.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { type NextApiRequest, type NextApiResponse } from "next"; -import { redis } from "./index"; -import { getScenarioWebhookKYCRedisKey } from "./scenario_webhook.post"; - -const scenarioWebHookGet = async ( - req: NextApiRequest, - res: NextApiResponse, -) => { - if (req.method === "GET") { - const key = getScenarioWebhookKYCRedisKey(req.query.address as string); - console.log("scenarioWebHookGet key", key); - const response = await redis.get(key); - console.log("scenario webhook get response", response); - - // clear redis - await redis.del(key); - res.status(200).json(response || {}); - } -}; - -export default scenarioWebHookGet; diff --git a/example-apps/src/pages/api/sygnum-web3/scenario-webhook.ts b/example-apps/src/pages/api/sygnum-web3/scenario-webhook.ts index 522d691f..c4b4239a 100644 --- a/example-apps/src/pages/api/sygnum-web3/scenario-webhook.ts +++ b/example-apps/src/pages/api/sygnum-web3/scenario-webhook.ts @@ -1,6 +1,7 @@ import { type NextApiRequest, type NextApiResponse } from "next"; import { env } from "@/env.mjs"; import { redis } from "@/server/redis"; +import { type ScenarioWebhookPayload } from "../../../server/api/routers/complianceRouter"; export const getScenarioWebhookBankWeb3RedisKey = (address: string) => { return ( @@ -14,11 +15,10 @@ const scenarioWebHookPost = async ( res: NextApiResponse ) => { if (req.method === "POST") { - console.log("scenarioWebHookPost req.body", req.body); + console.log("=== scenarioWebHookPost SIGNUM req.body===", req.body); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const body = req.body; - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - const key = getScenarioWebhookBankWeb3RedisKey(body.address as string); + const body: ScenarioWebhookPayload = req.body; + const key = getScenarioWebhookBankWeb3RedisKey(body.address); await redis.set(key, JSON.stringify(body)); res.status(200).json({ response: "ok" }); } diff --git a/example-apps/src/pages/bank-web3.tsx b/example-apps/src/pages/bank-web3.tsx index e62074f1..fd50be0a 100644 --- a/example-apps/src/pages/bank-web3.tsx +++ b/example-apps/src/pages/bank-web3.tsx @@ -28,13 +28,13 @@ const Home = () => { console.log("EXECUTING isVerified check compliance: ", data); if (!!data) { if (data.isValid) { - toast(`Your identity has been verified`); + toast(`Compliance Verification: Your identity has been verified`); setIsKycComplete(false); setIsCompliant(true); - } else if (data.data === "not_received") { + } else if (data.data === "unknown") { setIsKycComplete(true); } else { - toast(`Your identity has not been verified`); + toast(`Compliance Verification: Your identity has not been verified`); setIsKycComplete(false); setIsCompliant(false); } diff --git a/example-apps/src/pages/bank.tsx b/example-apps/src/pages/bank.tsx index db87503e..4fae70d0 100644 --- a/example-apps/src/pages/bank.tsx +++ b/example-apps/src/pages/bank.tsx @@ -28,13 +28,13 @@ const Home = () => { console.log("EXECUTING isVerified check compliance: ", data); if (data !== undefined) { if (data.isValid) { - toast(`Your identity has been verified`); + toast(`Compliance Verification: Your identity has been verified`); setKycCompletion(false); setIsCompliance(true); - } else if (data.data === "not_received") { + } else if (data.data === "unknown") { setKycCompletion(true); } else { - toast(`Your identity has not been verified`); + toast(`Compliance Verification: Your identity has not been verified`); setKycCompletion(false); setIsCompliance(false); } diff --git a/example-apps/src/pages/defi-offchain-zkp.tsx b/example-apps/src/pages/defi-offchain-zkp.tsx index 4067441b..52456198 100644 --- a/example-apps/src/pages/defi-offchain-zkp.tsx +++ b/example-apps/src/pages/defi-offchain-zkp.tsx @@ -27,13 +27,13 @@ const Home = () => { console.log("EXECUTING isVerified check compliance ZK: ", data); if (data !== undefined) { if (data.isValid) { - toast(`Your identity has been verified`); + toast(`Compliance Verification: Your identity has been verified`); setKycCompletion(false); setIsCompliance(true); - } else if (data.data === "not_received") { + } else if (data.data === "unknown") { setKycCompletion(true); } else { - toast(`Your identity has not been verified`); + toast(`Compliance Verification: Your identity has not been verified`); setKycCompletion(false); setIsCompliance(false); } diff --git a/example-apps/src/pages/defi-rule-engine.tsx b/example-apps/src/pages/defi-rule-engine.tsx index 315ecc61..b33800b5 100644 --- a/example-apps/src/pages/defi-rule-engine.tsx +++ b/example-apps/src/pages/defi-rule-engine.tsx @@ -24,13 +24,13 @@ const DefiRuleEngine = () => { console.log("EXECUTING isVerified check compliance: ", data); if (data !== undefined) { if (data.isValid) { - toast(`Your identity has been verified`); + toast(`Compliance Verification: Your identity has been verified`); setKycCompletion(false); setIsCompliance(true); - } else if (data.data === "not_received") { + } else if (data.data === "unknown") { setKycCompletion(true); } else { - toast(`Your identity has not been verified`); + toast(`Compliance Verification: Your identity has not been verified`); setKycCompletion(false); setIsCompliance(false); } diff --git a/example-apps/src/pages/sygnum-web3.tsx b/example-apps/src/pages/sygnum-web3.tsx index d5c67491..4e81ac97 100644 --- a/example-apps/src/pages/sygnum-web3.tsx +++ b/example-apps/src/pages/sygnum-web3.tsx @@ -16,17 +16,16 @@ const Home = () => { data: state.data, })); const { user, accessToken, signingMessage, signature } = - useKycSygnumWeb3Authentication(); + useKycSygnumWeb3Authentication(); const signMessage = useSignMessage(); const [kycCompletion, setKycCompletion] = useState(false); const { data } = useCheckSygnumWeb3Compliance(kycCompletion); const [isCompliance, setIsCompliance] = useState(false); useEffect(() => { - if (document.readyState === "complete" && typeof window !== 'undefined') { - const loader = document.getElementById('globalLoader'); - if (loader) - loader.remove(); + if (document.readyState === "complete" && typeof window !== "undefined") { + const loader = document.getElementById("globalLoader"); + if (loader) loader.remove(); } }, []); @@ -34,13 +33,13 @@ const Home = () => { console.log("EXECUTING isVerified check compliance: ", data); if (data !== undefined) { if (data.isValid) { - toast(`Your identity has been verified`); + toast(`Compliance Verification: Your identity has been verified`); setKycCompletion(false); setIsCompliance(true); - } else if (data.data === "not_received") { + } else if (data.data === "unknown") { setKycCompletion(true); } else { - toast(`Your identity has not been verified`); + toast(`Compliance Verification: Your identity has not been verified`); setKycCompletion(false); setIsCompliance(false); } @@ -110,9 +109,13 @@ const Home = () => { header={!isCompliance ?
: <>} className={!isCompliance ? "px-[105px]" : "bg-[#F2F2F2]"} > - {!isCompliance ? : } + {!isCompliance ? ( + + ) : ( + + )} - {!isCompliance ?