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

sync staging to main #361

Merged
merged 15 commits into from
Aug 17, 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
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
allow:
- dependency-name: "@skip-go/widget"
6 changes: 5 additions & 1 deletion .github/workflows/deploy-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ jobs:
with:
ref: testnet

- id: configure
name: configure
run: git config pull.ff true

- id: pull-staging
name: Pull latest 'staging'
run: git pull --ff-only origin staging
run: git pull origin staging

- id: diff-check
name: Check if 'testnet' is behind 'staging'
Expand Down
2 changes: 1 addition & 1 deletion chain-registry
Submodule chain-registry updated 294 files
906 changes: 171 additions & 735 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,18 @@
"visdeps": "bash ./src/scripts/visdeps.sh"
},
"dependencies": {
"@connectrpc/connect": "1.4.0",
"@fontsource/jost": "^5.0.16",
"@graz-sh/types": "^0.0.14",
"@heroicons/react": "^2.1.1",
"@keplr-wallet/types": "^0.12.66",
"@penumbra-zone/bech32m": "6.1.1",
"@penumbra-zone/client": "14.0.0",
"@penumbra-zone/protobuf": "5.5.0",
"@penumbra-zone/transport-dom": "7.4.0",
"@radix-ui/colors": "^3.0.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-dialog": "^1.0.5",
"@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.4.3",
"@solana/spl-token": "^0.4.1",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/wallet-adapter-wallets": "^0.19.31",
Expand Down Expand Up @@ -72,7 +67,7 @@
"tailwindcss-animate": "^1.0.7",
"tinykeys": "^2.1.0",
"undici": "^6.6.1",
"viem": "^2.7.16",
"viem": "^2.16.4",
"wagmi": "^2.5.7",
"zod": "^3.22.4",
"zustand": "^4.5.0"
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
185 changes: 0 additions & 185 deletions src/lib/prax.ts

This file was deleted.

65 changes: 1 addition & 64 deletions src/lib/skip-go-widget.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { bech32mAddress } from "@penumbra-zone/bech32m/penumbra";
import { bech32CompatAddress } from "@penumbra-zone/bech32m/penumbracompat1";
import { ViewService } from "@penumbra-zone/protobuf";
import { MinimalWallet, SwapWidgetProviderProps } from "@skip-go/widget";
import toast from "react-hot-toast";
import { SwapWidgetProviderProps } from "@skip-go/widget";

import { appUrl } from "@/constants/api";

import { createPraxClient, isPraxInstalled, requestPraxAccess } from "./prax";

export const endpointOptions: SwapWidgetProviderProps["endpointOptions"] = {
getRpcEndpointForChain: async (chainID) => {
return `${appUrl}/api/rpc/${chainID}`;
Expand All @@ -18,60 +12,3 @@ export const endpointOptions: SwapWidgetProviderProps["endpointOptions"] = {
};

export const apiURL = `${appUrl}/api/skip`;

const penumbraBech32ChainIDs = ["noble-1", "grand-1"];
const getPenumbraCompatibleAddress = ({
chainID,
address,
}: {
chainID?: string;
address: { inner: Uint8Array };
}): string => {
if (!chainID) return bech32mAddress(address);
return penumbraBech32ChainIDs.includes(chainID) ? bech32CompatAddress(address) : bech32mAddress(address);
};

export const praxWallet: MinimalWallet = {
walletName: "prax",
walletPrettyName: "Prax Wallet",
walletInfo: {
logo: "https://raw.githubusercontent.com/prax-wallet/web/e8b18f9b997708eab04f57e7a6c44f18b3cf13a8/apps/extension/public/prax-white-vertical.svg",
},
connect: async () => {
console.error("Prax wallet is not supported for connect");
toast.error("Prax wallet is not supported for connect");
},
getAddress: async (props) => {
const penumbraWalletIndex = props?.praxWallet?.index;
const sourceChainID = props?.praxWallet?.sourceChainID;

try {
const isInstalled = await isPraxInstalled();
if (!isInstalled) {
throw new Error("Prax Wallet is not installed");
}
await requestPraxAccess();
const praxClient = createPraxClient(ViewService);
const address = await praxClient.addressByIndex({
addressIndex: {
account: penumbraWalletIndex ? penumbraWalletIndex : 0,
},
});
if (!address.address) throw new Error("No address found");
const bech32Address = getPenumbraCompatibleAddress({
address: address.address,
chainID: sourceChainID,
});
return bech32Address;
} catch (error) {
console.error(error);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
toast.error(error?.message);
}
},
disconnect: async () => {
console.error("Prax wallet is not supported");
},
isWalletConnected: false,
};
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/(.*)", "/"],
};
8 changes: 1 addition & 7 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Analytics } from "@vercel/analytics/react";
import { AppProps } from "next/app";

import { DefaultSeo } from "@/components/DefaultSeo";
import { apiURL, endpointOptions, praxWallet } from "@/lib/skip-go-widget";
import { apiURL, endpointOptions } from "@/lib/skip-go-widget";

export default function App({ Component, pageProps }: AppProps) {
return (
Expand All @@ -15,12 +15,6 @@ export default function App({ Component, pageProps }: AppProps) {
<SwapWidgetProvider
endpointOptions={endpointOptions}
apiURL={apiURL}
makeDestinationWallets={(chainID) => {
if (chainID.includes("penumbra")) {
return [praxWallet];
}
return [];
}}
>
<Component {...pageProps} />
</SwapWidgetProvider>
Expand Down
Loading
Loading