Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FRE-906] Feat/geo block #360

Merged
merged 4 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chain-registry
Submodule chain-registry updated 70 files
+25 −0 .github/workflows/lint.yml
+2 −2 8ball/chain.json
+32 −0 _IBC/cosmoshub-lava.json
+31 −0 _IBC/kava-noble.json
+31 −0 _IBC/neutron-penumbra.json
+47 −0 _IBC/osmosis-routerchain.json
+6 −2 _non-cosmos/bitcoin/assetlist.json
+7 −0 _non-cosmos/bitcoin/images/btc.svg
+2 −4 acrechain/chain.json
+16 −6 andromeda/chain.json
+0 −17 bandchain/chain.json
+9 −3 bitcanna/chain.json
+217 −110 chain.schema.json
+4 −0 chain4energy/chain.json
+1 −1 cnhostables/chain.json
+35 −7 dhealth/chain.json
+4 −8 doravota/chain.json
+8 −0 eslint.config.mjs
+24 −1 gravitybridge/chain.json
+47 −0 injective/assetlist.json
+17 −6 injective/chain.json
+25 −2 kichain/chain.json
+2 −1 lava/assetlist.json
+80 −5 lava/chain.json
+29 −7 nolus/chain.json
+2 −4 okexchain/chain.json
+136 −0 osmosis/assetlist.json
+ osmosis/images/XTRUMP.png
+ osmosis/images/allTRX.png
+12 −0 osmosis/images/allTRX.svg
+ osmosis/images/eth.axl.png
+34 −0 osmosis/images/eth.axl.svg
+1,984 −19 package-lock.json
+5 −1 package.json
+2 −4 panacea/chain.json
+24 −1 provenance/chain.json
+24 −7 quasar/chain.json
+39 −0 routerchain/assetlist.json
+225 −0 routerchain/chain.json
+ routerchain/images/router.png
+15 −0 routerchain/images/router.svg
+55 −4 self/chain.json
+19 −3 sge/chain.json
+4 −4 source/chain.json
+41 −0 synternet/assetlist.json
+150 −0 synternet/chain.json
+ synternet/images/synt.png
+11 −0 synternet/images/synt.svg
+181 −1 terra2/assetlist.json
+ terra2/images/Alem.png
+ terra2/images/almagem.png
+ terra2/images/arika.png
+ terra2/images/danu.png
+ terra2/images/dmt.png
+ terra2/images/plasma.png
+ terra2/images/trs.png
+6 −6 testnets/_IBC/axelartestnet-titantestnet.json
+1 −1 testnets/_IBC/cosmoshubtestnet-titantestnet.json
+31 −0 testnets/_IBC/nobletestnet-titantestnet.json
+1 −1 testnets/_IBC/osmosistestnet-titantestnet.json
+1 −1 testnets/_IBC/stargazetestnet-titantestnet.json
+3 −7 testnets/deardogetestnet/chain.json
+3 −11 testnets/doravotatestnet/chain.json
+3 −7 testnets/doravotatestnet2/chain.json
+3 −3 testnets/mantrachaintestnet/chain.json
+58 −35 testnets/quasartestnet/chain.json
+11 −11 testnets/symphonytestnet/chain.json
+37 −0 testnets/synternettestnet/assetlist.json
+160 −0 testnets/synternettestnet/chain.json
+10 −10 testnets/uniontestnet/chain.json
2 changes: 1 addition & 1 deletion initia-registry
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useURLQueryParams.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/edge-config.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
19 changes: 18 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") ?? "";

Expand Down Expand Up @@ -94,5 +111,5 @@ export async function middleware(request: NextRequest) {
const stringArraySchema = z.array(z.string()).default([]);

export const config = {
matcher: "/api/(.*)",
matcher: ["/api/(.*)", "/"],
};
2 changes: 1 addition & 1 deletion src/pages/api/fee-assets/[chainID].ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
37 changes: 37 additions & 0 deletions src/pages/blocked.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div
className={cn(
"bg-[#ff86ff] font-sans subpixel-antialiased",
"relative overflow-x-hidden overflow-y-hidden",
"before:fixed before:inset-x-0 before:bottom-0 before:h-[100vh] before:content-['']",
"before:bg-[url(/bg.svg)] before:bg-cover before:bg-[center_top] before:bg-no-repeat",
)}
>
<main className="relative flex min-h-screen flex-col items-center">
<div className="flex h-20 w-full flex-row items-center justify-between px-6 py-4">
<LogoGo />
<div className="flex flex-row space-x-2">
<WidgetButton />
<DiscordButton />
</div>
</div>
<div className="flex flex-grow flex-col items-center pt-36">
<div className="relative h-[250px] w-[95%] overflow-hidden rounded-3xl bg-white p-2 shadow-xl sm:w-[450px]">
<div className="flex h-full w-full flex-col items-center justify-center space-y-4">
<p className="font-diatype text-2xl font-bold">Sorry!</p>
<p className="text-center font-diatype">The Skip Go App is unavailable in your region.</p>
</div>
</div>
</div>
</main>
<VersionCheck />
</div>
);
}
2 changes: 1 addition & 1 deletion src/utils/chain.client.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
Loading