From 4230b1399058379237acc56d117ac39ef5da7c0e Mon Sep 17 00:00:00 2001 From: Jack Hamer Date: Sun, 7 Jan 2024 20:26:30 +0200 Subject: [PATCH] fix: update transaction validation --- .github/workflows/feature.yml | 1 + .github/workflows/production.yml | 1 + composables/useScreening.ts | 17 +++++++++++------ nuxt.config.ts | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/feature.yml b/.github/workflows/feature.yml index a75366013..6102d650d 100644 --- a/.github/workflows/feature.yml +++ b/.github/workflows/feature.yml @@ -32,6 +32,7 @@ jobs: run: | echo "WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }}" > .env echo "ANKR_TOKEN=${{ secrets.ANKR_TOKEN }}" >> .env + echo "SCREENING_API_URL=${{ secrets.SCREENING_API_URL }}" >> .env - name: Build run: | diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 923ff93f1..fe78e598c 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -34,6 +34,7 @@ jobs: run: | echo "WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }}" > .env echo "ANKR_TOKEN=${{ secrets.ANKR_TOKEN }}" >> .env + echo "SCREENING_API_URL=${{ secrets.SCREENING_API_URL }}" >> .env - name: Build run: | diff --git a/composables/useScreening.ts b/composables/useScreening.ts index 9488b1905..aaa5c7b27 100644 --- a/composables/useScreening.ts +++ b/composables/useScreening.ts @@ -1,14 +1,19 @@ -/* import { $fetch } from "ofetch"; */ import { useMemoize } from "@vueuse/core"; +import { $fetch } from "ofetch"; /* Returns void if address screening was successful */ /* Fails if address screening was unsuccessful */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars const validateAddress = useMemoize(async (address: string) => { - /* const response = await $fetch(`${env.API_URL}/check-address/${address}`); */ - // TODO: remove mock - await new Promise((resolve) => setTimeout(resolve, 1000)); - // throw new Error("We were unable to process this transaction..."); + const runtimeConfig = useRuntimeConfig(); + if (!runtimeConfig.public.screeningApiUrl) { + return; + } + const url = new URL(runtimeConfig.public.screeningApiUrl); + url.searchParams.append("address", address); + const response = await $fetch(url.toString()); + if (!response.result) { + throw new Error("We were unable to process this transaction..."); + } }); export default () => { diff --git a/nuxt.config.ts b/nuxt.config.ts index ab74e05db..799c507ed 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -69,6 +69,7 @@ export default defineNuxtConfig({ turnstileKey: process.env.TURNSTILE_KEY, nodeType: process.env.NODE_TYPE as undefined | "memory" | "dockerized" | "hyperchain", ankrToken: process.env.ANKR_TOKEN, + screeningApiUrl: process.env.SCREENING_API_URL, }, }, pinia: {