Skip to content

Commit

Permalink
feat: pro build configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Dec 29, 2024
1 parent 45ae3c9 commit 02c3098
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"build": "./build.py && vite build; cp dist/index.html dist/404.html",
"mainnet": "cp src/configs/mainnet.json public/config.json",
"beta": "cp src/configs/beta.json public/config.json",
"pro": "cp src/configs/pro.json public/config.json",
"testnet": "cp src/configs/testnet.json public/config.json",
"prettier": "npx prettier src public tests e2e docs *.js *.ts *.mjs *.json",
"prettier:write": "npm run prettier -- --write",
Expand Down
7 changes: 6 additions & 1 deletion src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useGlobalContext } from "../context/Global";
import locales from "../i18n/i18n";
import "../style/nav.scss";

const Nav = (props: { network: string }) => {
const Nav = (props: { network: string; isPro?: boolean }) => {
let timeout: ReturnType<typeof setTimeout> | undefined;

const { t, setHideHero, setI18nConfigured } = useGlobalContext();
Expand All @@ -28,6 +28,11 @@ const Nav = (props: { network: string }) => {
{props.network}
</div>
</Show>
<Show when={props.isPro}>
<div id="network" class="btn btn-small">
{t("pro")}
</div>
</Show>
<div
id="languages"
onClick={(e) => e.currentTarget.classList.toggle("active")}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Warnings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const Warnings = () => {
<Show when={config.isBeta}>
<div class="banner banner-yellow">{t("beta_caution")}</div>
</Show>
<Show when={config.isPro}>
<div class="banner banner-yellow">{t("pro_banner")}</div>
</Show>
</div>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type Config = {
isBoltzClient?: boolean;
boltzClientApiUrl?: string;
isBeta?: boolean;
isPro?: boolean;
assets?: Record<string, Asset>;
torUrl?: string;
} & typeof defaults;
Expand Down
4 changes: 2 additions & 2 deletions src/configs/beta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"torUrl": "http://boltzzzbnus4m7mta3cxmflnps4fp7dueu2tgurstbvrbt6xswzcocyd.onion/",
"isBeta": true,
"torUrl": "http://boltzzzbnus4m7mta3cxmflnps4fp7dueu2tgurstbvrbt6xswzcocyd.onion/",
"network": "mainnet",
"loglevel": "debug",
"apiUrl": {
Expand All @@ -22,7 +22,7 @@
},
"RBTC": {
"blockExplorerUrl": {
"normal": "https://explorer.rootstock.io"
"normal": "https://rootstock.blockscout.com"
},
"network": {
"chainName": "Rootstock",
Expand Down
45 changes: 45 additions & 0 deletions src/configs/pro.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"isPro": true,
"torUrl": "http://boltzzzbnus4m7mta3cxmflnps4fp7dueu2tgurstbvrbt6xswzcocyd.onion/",
"network": "mainnet",
"loglevel": "debug",
"apiUrl": {
"normal": "https://api.boltz.exchange",
"tor": "http://boltzzzbnus4m7mta3cxmflnps4fp7dueu2tgurstbvrbt6xswzcocyd.onion/api"
},
"assets": {
"BTC": {
"blockExplorerUrl": {
"normal": "https://mempool.space",
"tor": "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion"
}
},
"L-BTC": {
"blockExplorerUrl": {
"normal": "https://blockstream.info/liquid",
"tor": "http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/liquid"
}
},
"RBTC": {
"blockExplorerUrl": {
"normal": "https://rootstock.blockscout.com"
},
"network": {
"chainName": "Rootstock",
"chainId": 30,
"rpcUrls": ["https://public-node.rsk.co"],
"nativeCurrency": {
"name": "RBTC",
"symbol": "RBTC",
"decimals": 18
}
},
"rifRelay": "https://boltz.mainnet.relay.rifcomputing.net",
"contracts": {
"deployHeight": 6747215,
"smartWalletFactory": "0x44944a80861120B58cc48B066d57cDAf5eC213dd",
"deployVerifier": "0xc0F5bEF6b20Be41174F826684c663a8635c6A081"
}
}
}
}
14 changes: 10 additions & 4 deletions src/context/Global.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export type GlobalContextType = {
getRdnsForAddress: (address: string) => Promise<string | null>;
};

const defaultReferral = () => {
if (config.isPro) {
return "pro";
}

return isMobile() ? "boltz_webapp_mobile" : "boltz_webapp_desktop";
};

// Local storage serializer to support the values created by the deprecated "createStorageSignal"
const stringSerializer = {
serialize: (value: never) => value,
Expand Down Expand Up @@ -130,9 +138,7 @@ const GlobalProvider = (props: { children: JSX.Element }) => {

const [ref, setRef] = makePersisted(
// eslint-disable-next-line solid/reactivity
createSignal(
isMobile() ? "boltz_webapp_mobile" : "boltz_webapp_desktop",
),
createSignal(defaultReferral()),
{
name: referralIdKey,
...stringSerializer,
Expand Down Expand Up @@ -427,4 +433,4 @@ const useGlobalContext = () => {
return context;
};

export { useGlobalContext, GlobalProvider };
export { useGlobalContext, GlobalProvider, defaultReferral };
10 changes: 10 additions & 0 deletions src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ const dict = {
peers: "Number of Peers",
num_channels: "Number of Channels",
beta_caution: "BETA - USE WITH CAUTION!",
pro: "pro",
pro_banner: "BETA: AVAILABILITY NOT GUARANTEED",
warning_return: "Important: Return to this page after paying invoice",
warning_expiry:
"Make sure your transaction confirms within ~24 hours after creation of this swap!",
Expand Down Expand Up @@ -390,6 +392,8 @@ const dict = {
peers: "Anzahl der Peers",
num_channels: "Anzahl der Kanäle",
beta_caution: "BETA - OBACHT!",
pro: "pro",
pro_banner: "BETA: VERFÜGBARKEIT NICHT GARANTIERT",
warning_return:
"Wichtig: Kehre nach dem Bezahlen der Rechnung zu dieser Seite zurück!",
warning_expiry:
Expand Down Expand Up @@ -627,6 +631,8 @@ const dict = {
peers: "Número de peers",
num_channels: "Número de canales",
beta_caution: "BETA - ¡ÚSALO CON PRECAUCIÓN!",
pro: "pro",
pro_banner: "BETA: DISPONIBILIDAD NO GARANTIZADA",
warning_return:
"Importante: Regresa a esta página después de pagar la factura!",
warning_expiry:
Expand Down Expand Up @@ -846,6 +852,8 @@ const dict = {
peers: "对端数",
num_channels: "通道数",
beta_caution: "BETA - 谨慎使用!",
pro: "pro",
pro_banner: "测试版:不保证可用性",
warning_return: "重要:支付发票后返回此页面",
warning_expiry: "确保您的交易在创建此交换后的约24小时内确认!",
not_found: "404 - 页面未找到",
Expand Down Expand Up @@ -1071,6 +1079,8 @@ const dict = {
peers: "ピアの数",
num_channels: "チャネルの数",
beta_caution: "ベータ版の為、ご利用は慎重にお願いします",
pro: "pro",
pro_banner: "ベータ版:利用可能性は保証されない",
warning_return:
"重要:インボイスのお支払い後、このページへ戻ってください",
warning_expiry:
Expand Down
5 changes: 4 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ const App = (props: RouteSectionProps) => {
<SwapChecker />
<Chatwoot />
<Show when={!isEmbedded()}>
<Nav network={config.network} />
<Nav
isPro={config.isPro}
network={config.network}
/>
</Show>
{props.children}
<Notification />
Expand Down
3 changes: 2 additions & 1 deletion src/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { chooseUrl, config } from "../config";
import { BTC, LN } from "../consts/Assets";
import { SwapType } from "../consts/Enums";
import { referralIdKey } from "../consts/LocalStorage";
import { defaultReferral } from "../context/Global";
import {
ChainPairTypeTaproot,
Pairs,
Expand Down Expand Up @@ -86,7 +87,7 @@ export const fetcher = async <T = unknown>(
params?: Record<string, unknown>,
): Promise<T> => {
// We cannot use the context here, so we get the data directly from local storage
const referral = localStorage.getItem(referralIdKey);
const referral = localStorage.getItem(referralIdKey) || defaultReferral();
let opts: RequestInit = {
headers: {
referral,
Expand Down

0 comments on commit 02c3098

Please sign in to comment.