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

Enable Osmosis chain configuration overwrite #824

Merged
merged 21 commits into from
Nov 9, 2022
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
12 changes: 12 additions & 0 deletions packages/web/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DO NOT ADD SECRETS TO THIS FILE. This is a good place for defaults and overwrites of public variables.
# If you want to add secrets use `.env.production.local` instead.
# More information about how this works [here](https://nextjs.org/docs/basic-features/environment-variables).

# Osmosis Chain Configuration Overwrite
# NEXT_PUBLIC_IS_FRONTIER=false
# NEXT_PUBLIC_IS_TESTNET=true
# NEXT_PUBLIC_OSMOSIS_RPC_OVERWRITE=https://rpc-test.osmosis.zone/
# NEXT_PUBLIC_OSMOSIS_REST_OVERWRITE=https://lcd-test.osmosis.zone/
# NEXT_PUBLIC_OSMOSIS_CHAIN_ID_OVERWRITE=osmo-test-4
# NEXT_PUBLIC_OSMOSIS_EXPLORER_URL_OVERWRITE=https://testnet.mintscan.io/osmosis-testnet/txs/{txHash}
# NEXT_PUBLIC_OSMOSIS_CHAIN_NAME_OVERWRITE=Osmosis (Testnet)
daniel-farina marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions packages/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ On completion, two local html files containing visual bundle trees for client an
### Frontier

Frontier mode is managed by the `NEXT_PUBLIC_IS_FRONTIER=true` env var, deployed from `master` branch.

## Environment Variables

daniel-farina marked this conversation as resolved.
Show resolved Hide resolved
By default, configuration is hardcoded and determined by the NEXT_PUBLIC_IS_TESTNET env var for developer convenience and simplicity. Please directly change those values should the config be changed from here on. For temporary overrides, consult the .env file. To use the testnet version of the frontend use the :testnet versions of the build and dev commands from the root package manifest file.
38 changes: 27 additions & 11 deletions packages/web/config/chain-infos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,32 @@ import { Bech32Address } from "@keplr-wallet/cosmos";
import { createKeplrChainInfos, SimplifiedChainInfo } from "./utils";

const IS_TESTNET = process.env.NEXT_PUBLIC_IS_TESTNET === "true";
const OSMOSIS_RPC_OVERWRITE = process.env.NEXT_PUBLIC_OSMOSIS_RPC_OVERWRITE;
const OSMOSIS_REST_OVERWRITE = process.env.NEXT_PUBLIC_OSMOSIS_REST_OVERWRITE;
const OSMOSIS_EXPLORER_URL_OVERWRITE =
process.env.NEXT_PUBLIC_OSMOSIS_EXPLORER_URL_OVERWRITE;
const OSMOSIS_CHAIN_ID_OVERWRITE =
process.env.NEXT_PUBLIC_OSMOSIS_CHAIN_ID_OVERWRITE;
const OSMOSIS_CHAIN_NAME_OVERWRITE =
process.env.NEXT_PUBLIC_OSMOSIS_CHAIN_NAME_OVERWRITE;

const chainInfos = (
[
{
rpc: IS_TESTNET
? "https://rpc.testnet.osmosis.zone/"
: "https://rpc-osmosis.keplr.app/",
rest: IS_TESTNET
? "https://lcd.testnet.osmosis.zone/"
: "https://lcd-osmosis.keplr.app/",
chainId: IS_TESTNET ? "osmo-test-4" : "osmosis-1",
chainName: "Osmosis",
rpc:
OSMOSIS_RPC_OVERWRITE ??
(IS_TESTNET
? "https://rpc.testnet.osmosis.zone/"
: "https://rpc-osmosis.keplr.app/"),
rest:
OSMOSIS_REST_OVERWRITE ??
(IS_TESTNET
? "https://lcd.testnet.osmosis.zone/"
: "https://lcd-osmosis.keplr.app/"),
chainId:
OSMOSIS_CHAIN_ID_OVERWRITE ??
(IS_TESTNET ? "osmo-test-4" : "osmosis-1"),
chainName: OSMOSIS_CHAIN_NAME_OVERWRITE ?? "Osmosis",
bip44: {
coinType: 118,
},
Expand Down Expand Up @@ -43,9 +57,11 @@ const chainInfos = (
high: 0.025,
},
features: ["stargate", "ibc-transfer", "no-legacy-stdTx", "ibc-go"],
explorerUrlToTx: IS_TESTNET
? "https://testnet.mintscan.io/osmosis-testnet/txs/{txHash}"
: "https://www.mintscan.io/osmosis/txs/{txHash}",
explorerUrlToTx:
OSMOSIS_EXPLORER_URL_OVERWRITE ??
(IS_TESTNET
? "https://testnet.mintscan.io/osmosis-testnet/txs/{txHash}"
: "https://www.mintscan.io/osmosis/txs/{txHash}"),
},
{
rpc: "https://rpc-cosmoshub.keplr.app",
Expand Down
67 changes: 35 additions & 32 deletions packages/web/config/price.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { DenomHelper } from "@keplr-wallet/common";
import { IntermediateRoute } from "@osmosis-labs/stores";

const OSMOSIS_DEST_COIN_ID =
process.env.NEXT_PUBLIC_OSMOSIS_CHAIN_ID_OVERWRITE || "osmosis";

/** Used to map pool IDs to spot price info from CoinGecko. */
export const PoolPriceRoutes: IntermediateRoute[] = [
{
Expand Down Expand Up @@ -67,7 +70,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"ubtsg"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:uxki",
Expand All @@ -87,7 +90,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"ustars"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:uhuahua",
Expand All @@ -110,7 +113,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"ulum"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:udsm",
Expand All @@ -133,7 +136,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"udig"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:ugraviton",
Expand All @@ -143,7 +146,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"ugraviton"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:usomm",
Expand All @@ -153,7 +156,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"usomm"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:udarc",
Expand All @@ -163,7 +166,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"udarc"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:neta",
Expand All @@ -173,7 +176,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:marble",
Expand All @@ -183,7 +186,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:uumee",
Expand All @@ -193,7 +196,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"uumee"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:pstake",
Expand All @@ -206,7 +209,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"gravity0xfB5c6815cA3AC72Ce9F5006869AE67f18bF77006"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:crbrus",
Expand All @@ -216,7 +219,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"ucrbrus"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:uustc",
Expand All @@ -226,7 +229,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"uusd"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:ulunc",
Expand All @@ -236,7 +239,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"uluna"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:umntl",
Expand All @@ -246,7 +249,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"umntl"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:umeme",
Expand All @@ -256,7 +259,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"umeme"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:utick",
Expand All @@ -279,7 +282,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:rac",
Expand All @@ -289,7 +292,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:block",
Expand All @@ -299,7 +302,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:nhash",
Expand All @@ -309,7 +312,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"nhash"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:uglx",
Expand All @@ -319,7 +322,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"uglx"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:dhk",
Expand All @@ -329,7 +332,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:raw",
Expand All @@ -339,7 +342,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:asvt",
Expand All @@ -362,7 +365,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:glto",
Expand All @@ -372,7 +375,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno1j0a9ymgngasfn3l5me8qpd53l5zlm9wurfdk7r65s5mg6tkxal3qpgf5se"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:gkey",
Expand All @@ -392,7 +395,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"loki"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:utgd",
Expand All @@ -402,7 +405,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"utgd"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:ucre",
Expand All @@ -412,7 +415,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"ucre"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:geo",
Expand All @@ -422,7 +425,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"mGeo"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:gkey",
Expand All @@ -432,7 +435,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"cw20:juno1gz8cf86zr4vw9cjcyyv432vgdaecvr9n254d3uwwkx9rermekddsxzageh"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:stuatom",
Expand All @@ -455,7 +458,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"mO9W"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:ustrd",
Expand All @@ -465,7 +468,7 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
"ustrd"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
destCoinId: OSMOSIS_DEST_COIN_ID,
},
{
alternativeCoinId: "pool:stustars",
Expand Down
3 changes: 2 additions & 1 deletion packages/web/stores/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export class RootStore {
) {
this.chainStore = new ChainStore(
ChainInfos,
IS_TESTNET ? "osmo-test-4" : "osmosis"
process.env.NEXT_PUBLIC_OSMOSIS_CHAIN_ID_OVERWRITE ??
(IS_TESTNET ? "osmo-test-4" : "osmosis")
);

const eventListener = (() => {
Expand Down