From 317f61accf3d43b36986ba2de8b3772f5c63e115 Mon Sep 17 00:00:00 2001 From: Griko Nibras <griko@nibras.co> Date: Thu, 2 Nov 2023 23:59:11 +0700 Subject: [PATCH 1/5] chore: update lockfile Signed-off-by: Griko Nibras <griko@nibras.co> --- package-lock.json | 60 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index c110658f..7117c9a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4251,9 +4251,9 @@ } }, "node_modules/@keplr-wallet/types": { - "version": "0.12.38", - "resolved": "https://registry.npmjs.org/@keplr-wallet/types/-/types-0.12.38.tgz", - "integrity": "sha512-moHm+q+ixGV8bpH/0JWI4imCIewnn7nnQaNxa4SgDjBhB46ropJQVNrb2xKl5FMqnTTbRb9Ejfv34H9CjIQj+w==", + "version": "0.12.39", + "resolved": "https://registry.npmjs.org/@keplr-wallet/types/-/types-0.12.39.tgz", + "integrity": "sha512-eAgXrAl/56n2F27SV9WARpAdFGBZguSof0MX4yi5QtPlIQO8ksTA7E+raOZu1opD6/ZOiG+uYaKbrdYGMDL9Ng==", "dependencies": { "long": "^4.0.0" } @@ -11707,9 +11707,9 @@ } }, "node_modules/ethers": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.8.0.tgz", - "integrity": "sha512-zrFbmQRlraM+cU5mE4CZTLBurZTs2gdp2ld0nG/f3ecBK+x6lZ69KSxBqZ4NjclxwfTxl5LeNufcBbMsTdY53Q==", + "version": "6.8.1", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.8.1.tgz", + "integrity": "sha512-iEKm6zox5h1lDn6scuRWdIdFJUCGg3+/aQWu0F4K0GVyEZiktFkqrJbRjTn1FlYEPz7RKA707D6g5Kdk6j7Ljg==", "funding": [ { "type": "individual", @@ -12308,9 +12308,9 @@ } }, "node_modules/fs-extra/node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "dev": true, "engines": { "node": ">= 10.0.0" @@ -15260,9 +15260,9 @@ } }, "node_modules/jsonfile/node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "dev": true, "engines": { "node": ">= 10.0.0" @@ -17421,9 +17421,9 @@ } }, "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "engines": { "node": ">=6" } @@ -23683,9 +23683,9 @@ } }, "@keplr-wallet/types": { - "version": "0.12.38", - "resolved": "https://registry.npmjs.org/@keplr-wallet/types/-/types-0.12.38.tgz", - "integrity": "sha512-moHm+q+ixGV8bpH/0JWI4imCIewnn7nnQaNxa4SgDjBhB46ropJQVNrb2xKl5FMqnTTbRb9Ejfv34H9CjIQj+w==", + "version": "0.12.39", + "resolved": "https://registry.npmjs.org/@keplr-wallet/types/-/types-0.12.39.tgz", + "integrity": "sha512-eAgXrAl/56n2F27SV9WARpAdFGBZguSof0MX4yi5QtPlIQO8ksTA7E+raOZu1opD6/ZOiG+uYaKbrdYGMDL9Ng==", "requires": { "long": "^4.0.0" } @@ -29456,9 +29456,9 @@ } }, "ethers": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.8.0.tgz", - "integrity": "sha512-zrFbmQRlraM+cU5mE4CZTLBurZTs2gdp2ld0nG/f3ecBK+x6lZ69KSxBqZ4NjclxwfTxl5LeNufcBbMsTdY53Q==", + "version": "6.8.1", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.8.1.tgz", + "integrity": "sha512-iEKm6zox5h1lDn6scuRWdIdFJUCGg3+/aQWu0F4K0GVyEZiktFkqrJbRjTn1FlYEPz7RKA707D6g5Kdk6j7Ljg==", "requires": { "@adraffy/ens-normalize": "1.10.0", "@noble/curves": "1.2.0", @@ -29905,9 +29905,9 @@ }, "dependencies": { "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "dev": true } } @@ -32090,9 +32090,9 @@ }, "dependencies": { "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "dev": true } } @@ -33682,9 +33682,9 @@ } }, "punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==" + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==" }, "pure-rand": { "version": "6.0.2", From 3b70db2981a60d5b1bd3d7dddce2b0e28a461aa6 Mon Sep 17 00:00:00 2001 From: Griko Nibras <griko@nibras.co> Date: Thu, 2 Nov 2023 23:59:21 +0700 Subject: [PATCH 2/5] chore: update chain registry Signed-off-by: Griko Nibras <griko@nibras.co> --- chain-registry | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chain-registry b/chain-registry index 1bd0493a..353d1b6d 160000 --- a/chain-registry +++ b/chain-registry @@ -1 +1 @@ -Subproject commit 1bd0493a7174565e0b69c85b8e9a7b2dbde7db00 +Subproject commit 353d1b6df891a42f202e790be496d29aac7e5e33 From 01b009f99b935c3a0e5ad27adc8325c5fdd976d4 Mon Sep 17 00:00:00 2001 From: Griko Nibras <griko@nibras.co> Date: Fri, 3 Nov 2023 00:03:24 +0700 Subject: [PATCH 3/5] feat: setup env example and types --- .env.example | 5 +++++ .gitignore | 3 +++ env.d.ts | 5 +++++ example.env | 5 ----- 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .env.example create mode 100644 env.d.ts delete mode 100644 example.env diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..0be8cfa8 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +# production api +NEXT_PUBLIC_API_URL=https://api.skip.money + +# development API +# NEXT_PUBLIC_API_URL=https://solve-dev.skip.money diff --git a/.gitignore b/.gitignore index 0a6a87db..67d3b4d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. +.env* +!.env.example + src/chains/ tests/downloads/ diff --git a/env.d.ts b/env.d.ts new file mode 100644 index 00000000..05a37478 --- /dev/null +++ b/env.d.ts @@ -0,0 +1,5 @@ +declare namespace NodeJS { + interface ProcessEnv { + readonly NEXT_PUBLIC_API_URL?: string; + } +} diff --git a/example.env b/example.env deleted file mode 100644 index 55429bcb..00000000 --- a/example.env +++ /dev/null @@ -1,5 +0,0 @@ -# production api -NEXT_PUBLIC_API_URL=https://api.skip.money/v1 - -# development API -# NEXT_PUBLIC_API_URL=https://solve-dev.skip.money/v1 \ No newline at end of file From ff0dc09d9d640d00d1cc8e2a75e8c6fecd9c80d9 Mon Sep 17 00:00:00 2001 From: Griko Nibras <griko@nibras.co> Date: Fri, 3 Nov 2023 00:03:45 +0700 Subject: [PATCH 4/5] feat: init API_URL constant --- src/constants/api.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/constants/api.ts diff --git a/src/constants/api.ts b/src/constants/api.ts new file mode 100644 index 00000000..d16e0bce --- /dev/null +++ b/src/constants/api.ts @@ -0,0 +1,3 @@ +import { SKIP_API_URL } from "@skip-router/core"; + +export const API_URL = process.env.NEXT_PUBLIC_API_URL || SKIP_API_URL; From c78ee0968b51ba820eb6da3f8a5f38bb410980b7 Mon Sep 17 00:00:00 2001 From: Griko Nibras <griko@nibras.co> Date: Fri, 3 Nov 2023 00:04:00 +0700 Subject: [PATCH 5/5] refactor: swap out env based API_URL --- src/components/__tests__/SwapWidget.test.tsx | 4 +--- src/solve/context.tsx | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/__tests__/SwapWidget.test.tsx b/src/components/__tests__/SwapWidget.test.tsx index 45a1c9b9..bcc8a2a0 100644 --- a/src/components/__tests__/SwapWidget.test.tsx +++ b/src/components/__tests__/SwapWidget.test.tsx @@ -1,7 +1,7 @@ -import { SKIP_API_URL } from "@skip-router/core"; import { rest } from "msw"; import { setupServer } from "msw/node"; +import { API_URL } from "@/constants/api"; import { act, fireEvent, render, screen, waitFor, within } from "@/test"; import { ASSETS_RESPONSE } from "../../../fixtures/assets"; @@ -9,8 +9,6 @@ import { CHAINS_RESPONSE } from "../../../fixtures/chains"; import { SwapWidget } from "../SwapWidget"; import { LAST_SOURCE_CHAIN_KEY } from "../SwapWidget/useSwapWidget"; -const API_URL = SKIP_API_URL; - const handlers = [ rest.get(`${API_URL}/v1/info/chains`, (_, res, ctx) => { return res(ctx.status(200), ctx.json(CHAINS_RESPONSE)); diff --git a/src/solve/context.tsx b/src/solve/context.tsx index d3b4560a..183a0292 100644 --- a/src/solve/context.tsx +++ b/src/solve/context.tsx @@ -1,9 +1,10 @@ import { useWalletClient } from "@cosmos-kit/react"; -import { SKIP_API_URL, SkipRouter } from "@skip-router/core"; +import { SkipRouter } from "@skip-router/core"; import { getWalletClient } from "@wagmi/core"; import { createContext, FC, PropsWithChildren } from "react"; import { useNetwork } from "wagmi"; +import { API_URL } from "@/constants/api"; import { getOfflineSigner, getOfflineSignerOnlyAmino, @@ -22,7 +23,7 @@ export const SkipProvider: FC<PropsWithChildren> = ({ children }) => { const { chains } = useNetwork(); const skipClient = new SkipRouter({ - apiURL: SKIP_API_URL, + apiURL: API_URL, getCosmosSigner: async (chainID) => { if (!walletClient) { throw new Error("No offline signer available");