From f46091ec065b38f9677f2bb5ad6cbd95478dcc4b Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Fri, 9 Aug 2024 03:02:57 +0700 Subject: [PATCH 1/4] chore: bump widget --- chain-registry | 2 +- initia-registry | 2 +- package-lock.json | 50 +++++++++++++-------------- package.json | 2 +- src/hooks/useURLQueryParams.tsx | 2 +- src/middleware.ts | 19 +++++++++- src/pages/api/fee-assets/[chainID].ts | 2 +- src/utils/chain.client.ts | 2 +- 8 files changed, 49 insertions(+), 32 deletions(-) diff --git a/chain-registry b/chain-registry index 1b45debd..92803f50 160000 --- a/chain-registry +++ b/chain-registry @@ -1 +1 @@ -Subproject commit 1b45debda9e55918acb3f767cd8c4033d6eff426 +Subproject commit 92803f50af1a1a8125ec626113cb36aebc65e128 diff --git a/initia-registry b/initia-registry index 69c39736..d492464b 160000 --- a/initia-registry +++ b/initia-registry @@ -1 +1 @@ -Subproject commit 69c39736760c8245cf581383d0eb8d5a57a2bfd2 +Subproject commit d492464bb00a58f5f0fb3ffd5ea892bd988cf954 diff --git a/package-lock.json b/package-lock.json index 7d340bb7..1cdb0141 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-tooltip": "^1.0.7", "@sentry/nextjs": "^7.99.0", - "@skip-go/widget": "^2.3.7", + "@skip-go/widget": "^2.3.8", "@solana/spl-token": "^0.4.1", "@solana/wallet-adapter-react": "^0.15.35", "@solana/wallet-adapter-wallets": "^0.19.31", @@ -145,9 +145,9 @@ } }, "node_modules/@apollo/client": { - "version": "3.11.3", - "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.11.3.tgz", - "integrity": "sha512-bocd9vQc9PSq4MG6129HKF8ujUirVod98he9OEWpyOs5CXnUC81zNRaUshA4wPSflR6mnx0yRuRankp1V8A+og==", + "version": "3.11.4", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.11.4.tgz", + "integrity": "sha512-bmgYKkULpym8wt8aXlAZ1heaYo0skLJ5ru0qJ+JCRoo03Pe+yIDbBCnqlDw6Mjj76hFkDw3HwFMgZC2Hxp30Mg==", "dependencies": { "@graphql-typed-document-node/core": "^3.1.1", "@wry/caches": "^1.0.0", @@ -7043,9 +7043,9 @@ "integrity": "sha512-T2CiKS2B5n0ZA7CWw0CA6qIAH0XYI1siE50MP+i+V0ZniCGBeL+BMcDw64vFJUcEH+1L5X4sDAzV37fQxGwllA==" }, "node_modules/@keplr-wallet/types": { - "version": "0.12.119", - "resolved": "https://registry.npmjs.org/@keplr-wallet/types/-/types-0.12.119.tgz", - "integrity": "sha512-J0uuKR89S14UDwMHn1eFueKkLcStmenjPg5DNxzRhe4mt8rg9uL+bNkwANrnPrbtB/tv5QQ6+tE5Hr7JyC55RQ==", + "version": "0.12.120", + "resolved": "https://registry.npmjs.org/@keplr-wallet/types/-/types-0.12.120.tgz", + "integrity": "sha512-SpUPHS1o9+XXIrFE1/MmqEhX2/ml7abB2XRQw/MH6hjtmlCzWl2Wl8G9epN4NPrzmzU/8Qg+CevRrm9LmT2MbA==", "dependencies": { "long": "^4.0.0" } @@ -12190,10 +12190,10 @@ "@sinonjs/commons": "^3.0.0" } }, - "node_modules/@skip-go/core": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/@skip-go/core/-/core-0.4.4.tgz", - "integrity": "sha512-053OVKd53BRE5d8YkHnmPIB03Pw8xn2M8049r8PnM40VIm4CvRkBqvtyDAL5U+iClSzZyY7yCBzHM/hru/tn3g==", + "node_modules/@skip-go/client": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@skip-go/client/-/client-0.5.1.tgz", + "integrity": "sha512-QYyyOJjf4TEQcF0sf3UTlpOWgH8J2xfNukNvNWKSrHUho/TvvPCdLCUXW7hOLD3Wku50r1DmdcyBxhZpjM6VPA==", "dependencies": { "@cosmjs/amino": "0.32.4", "@cosmjs/cosmwasm-stargate": "0.32.4", @@ -12216,7 +12216,7 @@ "viem": "2.x" } }, - "node_modules/@skip-go/core/node_modules/@cosmjs/amino": { + "node_modules/@skip-go/client/node_modules/@cosmjs/amino": { "version": "0.32.4", "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.32.4.tgz", "integrity": "sha512-zKYOt6hPy8obIFtLie/xtygCkH9ZROiQ12UHfKsOkWaZfPQUvVbtgmu6R4Kn1tFLI/SRkw7eqhaogmW/3NYu/Q==", @@ -12227,7 +12227,7 @@ "@cosmjs/utils": "^0.32.4" } }, - "node_modules/@skip-go/core/node_modules/@cosmjs/crypto": { + "node_modules/@skip-go/client/node_modules/@cosmjs/crypto": { "version": "0.32.4", "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.32.4.tgz", "integrity": "sha512-zicjGU051LF1V9v7bp8p7ovq+VyC91xlaHdsFOTo2oVry3KQikp8L/81RkXmUIT8FxMwdx1T7DmFwVQikcSDIw==", @@ -12241,7 +12241,7 @@ "libsodium-wrappers-sumo": "^0.7.11" } }, - "node_modules/@skip-go/core/node_modules/@cosmjs/encoding": { + "node_modules/@skip-go/client/node_modules/@cosmjs/encoding": { "version": "0.32.4", "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.32.4.tgz", "integrity": "sha512-tjvaEy6ZGxJchiizzTn7HVRiyTg1i4CObRRaTRPknm5EalE13SV+TCHq38gIDfyUeden4fCuaBVEdBR5+ti7Hw==", @@ -12251,7 +12251,7 @@ "readonly-date": "^1.0.0" } }, - "node_modules/@skip-go/core/node_modules/@cosmjs/math": { + "node_modules/@skip-go/client/node_modules/@cosmjs/math": { "version": "0.32.4", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.32.4.tgz", "integrity": "sha512-++dqq2TJkoB8zsPVYCvrt88oJWsy1vMOuSOKcdlnXuOA/ASheTJuYy4+oZlTQ3Fr8eALDLGGPhJI02W2HyAQaw==", @@ -12259,25 +12259,25 @@ "bn.js": "^5.2.0" } }, - "node_modules/@skip-go/core/node_modules/@cosmjs/utils": { + "node_modules/@skip-go/client/node_modules/@cosmjs/utils": { "version": "0.32.4", "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.32.4.tgz", "integrity": "sha512-D1Yc+Zy8oL/hkUkFUL/bwxvuDBzRGpc4cF7/SkdhxX4iHpSLgdOuTt1mhCh9+kl6NQREy9t7SYZ6xeW5gFe60w==" }, - "node_modules/@skip-go/core/node_modules/@keplr-wallet/unit": { - "version": "0.12.119", - "resolved": "https://registry.npmjs.org/@keplr-wallet/unit/-/unit-0.12.119.tgz", - "integrity": "sha512-PAv9NdPV0NRhmw3d8mzY70Y4WMiia7Bg6Ri1mnTKHVFU+ZDxZLSJpupplWUBGt6ww+uYZMzsWgfFAysaQYG0kw==", + "node_modules/@skip-go/client/node_modules/@keplr-wallet/unit": { + "version": "0.12.120", + "resolved": "https://registry.npmjs.org/@keplr-wallet/unit/-/unit-0.12.120.tgz", + "integrity": "sha512-Iv1DsQ2ziumjLLZWyMbO8D2kmYJd2PB24tNfeDOkb+VGaclbTc56Ryu9na5wwso3EsXtaqmCpF8CNLtzMmTA0g==", "dependencies": { - "@keplr-wallet/types": "0.12.119", + "@keplr-wallet/types": "0.12.120", "big-integer": "^1.6.48", "utility-types": "^3.10.0" } }, "node_modules/@skip-go/widget": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/@skip-go/widget/-/widget-2.3.7.tgz", - "integrity": "sha512-AfGyrHCuxeyB8x7whjAepG8seSmPVcaTNJwEhvAw63vEMfv2PikTvLafPLLTvdqISLmmhi7RUJbWeamWCoYyJw==", + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/@skip-go/widget/-/widget-2.3.8.tgz", + "integrity": "sha512-2MZL0JL2sBZlp4JPBWWe0BYr2Wy89R26RZTsEcdj0dhucCCxpIu70uv82VsVyNwqQDJ/7oaYjpQm7Y/WlATBRw==", "dependencies": { "@cosmos-kit/cosmostation-extension": "^2.7.10", "@cosmos-kit/keplr-extension": "^2.7.9", @@ -12299,7 +12299,7 @@ "@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-switch": "^1.0.3", "@radix-ui/react-tooltip": "^1.0.7", - "@skip-go/core": "0.4.4", + "@skip-go/client": "0.5.1", "@solana/spl-token": "^0.4.6", "@solana/wallet-adapter-react": "^0.15.35", "@solana/wallet-adapter-wallets": "^0.19.32", diff --git a/package.json b/package.json index c9b1e644..2391ccea 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-tooltip": "^1.0.7", "@sentry/nextjs": "^7.99.0", - "@skip-go/widget": "^2.3.7", + "@skip-go/widget": "^2.3.8", "@solana/spl-token": "^0.4.1", "@solana/wallet-adapter-react": "^0.15.35", "@solana/wallet-adapter-wallets": "^0.19.31", diff --git a/src/hooks/useURLQueryParams.tsx b/src/hooks/useURLQueryParams.tsx index 1e5cb7c4..3b142ef0 100644 --- a/src/hooks/useURLQueryParams.tsx +++ b/src/hooks/useURLQueryParams.tsx @@ -1,4 +1,4 @@ -import { Chain } from "@skip-go/core"; +import { Chain } from "@skip-go/client"; import { useAssets, useChains } from "@skip-go/widget"; import { useQueryState } from "nuqs"; import { useEffect, useState } from "react"; diff --git a/src/middleware.ts b/src/middleware.ts index 228aceb7..1fd0d83f 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -44,7 +44,24 @@ const isPreview = (str: string) => { return false; }; +// Donetsk and Luhansk Regions of Ukraine, Russia, Crimea, Cuba, Iran, North Korea or Syria +const BLOCKED_COUNTRY = ["RU", "CU", "IR", "KP", "SY"]; + export async function middleware(request: NextRequest) { + if (request.nextUrl.pathname === "/") { + const country = request.geo?.country || "US"; + + if ( + BLOCKED_COUNTRY.includes(country) || + (country == "UA" && request.geo?.city && request.geo?.city in ["Donetsk", "Luhansk", "Crimea"]) + ) { + request.nextUrl.pathname = "/blocked"; + return NextResponse.rewrite(request.nextUrl); + } + + return NextResponse.next(); + } + // Check the origin from the request const origin = request.headers.get("origin") ?? ""; @@ -94,5 +111,5 @@ export async function middleware(request: NextRequest) { const stringArraySchema = z.array(z.string()).default([]); export const config = { - matcher: "/api/(.*)", + matcher: ["/api/(.*)", "/"], }; diff --git a/src/pages/api/fee-assets/[chainID].ts b/src/pages/api/fee-assets/[chainID].ts index b4a784dc..87c01d6f 100644 --- a/src/pages/api/fee-assets/[chainID].ts +++ b/src/pages/api/fee-assets/[chainID].ts @@ -1,4 +1,4 @@ -import { FeeAsset } from "@skip-go/core"; +import { FeeAsset } from "@skip-go/client"; import { PageConfig } from "next"; import { NextRequest } from "next/server"; diff --git a/src/utils/chain.client.ts b/src/utils/chain.client.ts index a3547cf1..5489824c 100644 --- a/src/utils/chain.client.ts +++ b/src/utils/chain.client.ts @@ -1,7 +1,7 @@ // importing cosmjs deps does not work in edge runtime environments import { GasPrice } from "@cosmjs/stargate"; -import { FeeAsset } from "@skip-go/core"; +import { FeeAsset } from "@skip-go/client"; import { CUSTOM_GAS_PRICE_CHAIN_IDS } from "@/config/gas"; From 7ca02113d944a98604bcefc63b6a8ebe85738a04 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Fri, 9 Aug 2024 03:03:08 +0700 Subject: [PATCH 2/4] feat: geo block --- src/lib/edge-config.ts | 2 +- src/pages/blocked.tsx | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/pages/blocked.tsx diff --git a/src/lib/edge-config.ts b/src/lib/edge-config.ts index 64368cbe..32c6f910 100644 --- a/src/lib/edge-config.ts +++ b/src/lib/edge-config.ts @@ -1,7 +1,7 @@ if (typeof window !== "undefined") { throw new Error("edge-config.ts should only be imported on the server"); } -import { ExperimentalFeature } from "@skip-go/core"; +import { ExperimentalFeature } from "@skip-go/client"; import { createClient } from "@vercel/edge-config"; import { z } from "zod"; diff --git a/src/pages/blocked.tsx b/src/pages/blocked.tsx new file mode 100644 index 00000000..f4a4d8ca --- /dev/null +++ b/src/pages/blocked.tsx @@ -0,0 +1,37 @@ +import DiscordButton from "@/components/DiscordButton"; +import { LogoGo } from "@/components/LogoGo"; +import { VersionCheck } from "@/components/VersionCheck"; +import WidgetButton from "@/components/WidgetButton"; +import { cn } from "@/utils/ui"; + +export default function Home() { + return ( +
+
+
+ +
+ + +
+
+
+
+
+

Sorry!

+

The Skip Go App is unavailable in your region.

+
+
+
+
+ +
+ ); +} From de2e8aed74f6bd6df9cbf44d4f4a7f05c1ce3d3f Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Fri, 9 Aug 2024 13:33:22 +0700 Subject: [PATCH 3/4] test block pakistan --- src/middleware.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware.ts b/src/middleware.ts index 1fd0d83f..d45ed629 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -45,7 +45,7 @@ const isPreview = (str: string) => { }; // Donetsk and Luhansk Regions of Ukraine, Russia, Crimea, Cuba, Iran, North Korea or Syria -const BLOCKED_COUNTRY = ["RU", "CU", "IR", "KP", "SY"]; +const BLOCKED_COUNTRY = ["RU", "CU", "IR", "KP", "SY", "PK"]; export async function middleware(request: NextRequest) { if (request.nextUrl.pathname === "/") { From e634d330af9a9268a4c09d7d1cd2688f171e6ce6 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Fri, 9 Aug 2024 13:42:37 +0700 Subject: [PATCH 4/4] remove pakistan geoblock --- src/middleware.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware.ts b/src/middleware.ts index d45ed629..1fd0d83f 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -45,7 +45,7 @@ const isPreview = (str: string) => { }; // Donetsk and Luhansk Regions of Ukraine, Russia, Crimea, Cuba, Iran, North Korea or Syria -const BLOCKED_COUNTRY = ["RU", "CU", "IR", "KP", "SY", "PK"]; +const BLOCKED_COUNTRY = ["RU", "CU", "IR", "KP", "SY"]; export async function middleware(request: NextRequest) { if (request.nextUrl.pathname === "/") {