Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/XLabs/wormscan-ui into s…
Browse files Browse the repository at this point in the history
…taging
  • Loading branch information
valentinoConti committed Feb 25, 2025
2 parents a9d1c75 + 9a54bb5 commit b26508e
Show file tree
Hide file tree
Showing 45 changed files with 12,797 additions and 4,232 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ jobs:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: 18
cache: yarn
registry-url: "https://npm.pkg.github.com"
scope: "@xlabs"

- name: Build and Deploy Github Page
run: |
Expand All @@ -31,3 +33,5 @@ jobs:
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
yarn dlx push-dir --dir=dist --branch=gh-pages --cleanup --verbose
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: "https://npm.pkg.github.com"
scope: "@xlabs"
- name: Install dependencies
run: yarn
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,23 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
cache: yarn
registry-url: "https://npm.pkg.github.com"
scope: "@xlabs"

- name: Install Dependencies
run: |
node --version
yarn install
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build Static Website
run: |
NODE_ENV=production yarn build
cp ./robots.txt ./dist/
cp ./src/og_image.png ./dist/
NODE_ENV=production yarn build
cp ./robots.txt ./dist/
cp ./src/og_image.png ./dist/
- name: Configure AWS CLI + credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -55,4 +59,4 @@ jobs:
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ env.AWS_CF_DIST_ID }} \
--paths "/*"
--paths "/*"
6 changes: 5 additions & 1 deletion .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
cache: yarn
registry-url: "https://npm.pkg.github.com"
scope: "@xlabs"

- name: Install Dependencies
run: |
node --version
yarn install
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build Static Website
run: |
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@xlabs:registry=https://npm.pkg.github.com
12 changes: 11 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
yarnPath: .yarn/releases/yarn-3.5.0.cjs
nodeLinker: node-modules
nodeLinker: node-modules

npmRegistries:
"https://npm.pkg.github.com":
npmAlwaysAuth: true
npmAuthToken: "${NODE_AUTH_TOKEN}"

npmScopes:
xlabs:
npmAlwaysAuth: true
npmRegistryServer: "https://npm.pkg.github.com"
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wormscan-ui",
"version": "2.0.14",
"version": "2.0.17",
"private": true,
"source": "src/index.html",
"@parcel/resolver-default": {
Expand Down Expand Up @@ -60,8 +60,10 @@
"stream-browserify": "^3.0.0",
"stream-http": "^3.1.0",
"string_decoder": "^1.3.0",
"svgo": "^3.3.2",
"typescript": "^4.9.4",
"url": "^0.11.0"
"url": "^0.11.0",
"vm-browserify": "^1.1.2"
},
"dependencies": {
"@analytics/google-analytics": "^1.0.7",
Expand All @@ -71,7 +73,10 @@
"@radix-ui/react-toggle-group": "1.0.2",
"@radix-ui/react-tooltip": "1.0.5",
"@types/swagger-ui-react": "^4.18.3",
"@wormhole-foundation/sdk": "^1.4.5",
"@wormhole-foundation/sdk": "1.10.1-beta.0",
"@wormhole-foundation/sdk-solana": "1.10.1-beta.0",
"@wormhole-foundation/sdk-solana-core": "1.10.1-beta.0",
"@xlabs/wormhole-connect": "1.0.0-fork.3-development",
"analytics": "^0.8.9",
"apexcharts": "^3.49.1",
"axios": "^1.4.0",
Expand Down
62 changes: 21 additions & 41 deletions src/api/guardian-network/GuardianNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ import {
TokensSymbolVolumeOutput,
VAACount,
} from "./types";
import {
CONNECT_APP_ID,
FAST_TRANSFERS_APP_ID,
LIQUIDITY_LAYER_APP_ID,
MAYAN_SHUTTLE_APP_ID,
SWAP_LAYER_APP_ID,
} from "src/consts";
import { CONNECT_APP_ID, WORMHOLE_SETTLEMENTS_APP_ID } from "src/consts";

export class GuardianNetwork {
constructor(private readonly _client: APIClient) {}
Expand Down Expand Up @@ -76,17 +70,7 @@ export class GuardianNetwork {

// LIQUIDITY LAYER PATCH
const resultProcessed = result.map(data => {
if (data?.content?.standarizedProperties?.appIds?.includes(FAST_TRANSFERS_APP_ID)) {
// AppID patch
if (data?.content?.standarizedProperties?.appIds?.includes(SWAP_LAYER_APP_ID)) {
data.content.standarizedProperties.appIds = [
MAYAN_SHUTTLE_APP_ID,
LIQUIDITY_LAYER_APP_ID,
];
} else {
data.content.standarizedProperties.appIds = [LIQUIDITY_LAYER_APP_ID];
}

if (data?.content?.standarizedProperties?.appIds?.includes(WORMHOLE_SETTLEMENTS_APP_ID)) {
// Fix for when user got a refund in another chain
if (
!!data?.targetChain?.chainId &&
Expand Down Expand Up @@ -271,44 +255,40 @@ export class GuardianNetwork {
const response = await this._client.doGet<ProtocolsStatsOutput[]>("/protocols/stats");

// --- liquidity layer patch start ---
// (merge swap_layer and fast_transfers and then rename to wormhole_liquidity_layer)
// (merge mayan_shuttle and wormhole_settlements)
const responseProcessed = response
?.map(item => {
// find swap_layer item
if (item.protocol === "swap_layer") {
// Find the fast_transfers item to merge data into
const fastTransfersItem = response.find(i => i.protocol === "fast_transfers");
if (fastTransfersItem) {
// Add swap_layer volumes to fast_transfers
fastTransfersItem.last_24_hour_volume += item.last_24_hour_volume;
fastTransfersItem.total_messages += item.total_messages;
fastTransfersItem.total_value_transferred += item.total_value_transferred;
fastTransfersItem.last_day_messages += item.last_day_messages;
// find mayan_shuttle item
if (item.protocol === "mayan_shuttle") {
// Find the wormhole_settlements item to merge data into
const wormholeSettlementsItem = response.find(i => i.protocol === "wormhole_settlements");
if (wormholeSettlementsItem) {
// Add mayan shuttle volumes to wormhole settlements
wormholeSettlementsItem.last_24_hour_volume += item.last_24_hour_volume;
wormholeSettlementsItem.total_messages += item.total_messages;
wormholeSettlementsItem.total_value_transferred += item.total_value_transferred;
wormholeSettlementsItem.last_day_messages += item.last_day_messages;

// Recalculate percentages
fastTransfersItem.last_day_diff_percentage =
wormholeSettlementsItem.last_day_diff_percentage =
(
((fastTransfersItem.last_day_messages + item.last_day_messages) /
(fastTransfersItem.total_messages + item.total_messages)) *
((wormholeSettlementsItem.last_day_messages + item.last_day_messages) /
(wormholeSettlementsItem.total_messages + item.total_messages)) *
100
).toFixed(2) + "%";

fastTransfersItem.last_day_diff_volume_percentage =
wormholeSettlementsItem.last_day_diff_volume_percentage =
(
((fastTransfersItem.last_24_hour_volume + item.last_24_hour_volume) /
(fastTransfersItem.total_value_transferred + item.total_value_transferred)) *
((wormholeSettlementsItem.last_24_hour_volume + item.last_24_hour_volume) /
(wormholeSettlementsItem.total_value_transferred +
item.total_value_transferred)) *
100
).toFixed(2) + "%";
}
// Remove the swap_layer item since we merged it
// Remove the mayan shuttle item since we merged it
return null;
}

// change name
if (item.protocol === "fast_transfers") {
item.protocol = "wormhole_liquidity_layer";
}

return item;
})
.filter(item => item !== null);
Expand Down
20 changes: 0 additions & 20 deletions src/api/native-token-transfer/NttApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ export class NttApi {

const tokenListWithFallback = await Promise.all(
tokenListResponse.map(async item => {
if (!item?.total_value_transferred) {
try {
const summary = await this.getNttTVT({ coingecko_id: item.coingecko_id });
item.total_value_transferred = summary.totalValueTokenTransferred || "0";
} catch (error) {
console.log("Failed to get total value transferred for token", item.symbol);
}
}

if (item.circulating_supply === "0") {
const symbol = item.symbol.toUpperCase();

Expand All @@ -86,17 +77,6 @@ export class NttApi {
return tokenListWithFallback;
}

async getNttTVT({ coingecko_id }: GetSummary): Promise<{ totalValueTokenTransferred: string }> {
const summaryResponse = await this._client.doGet<GetSummaryResult>(
"/native-token-transfer/summary",
{
coingecko_id,
},
);

return { totalValueTokenTransferred: summaryResponse.totalValueTokenTransferred };
}

async getNttSummary({ coingecko_id }: GetSummary): Promise<GetSummaryResult> {
const summaryResponse = await this._client.doGet<GetSummaryResult>(
"/native-token-transfer/summary",
Expand Down
32 changes: 32 additions & 0 deletions src/components/atoms/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ReactNode } from "react";
import { CrossIcon } from "src/icons/generic";
import "./styles.scss";

interface ModalProps {
shouldShow: boolean;
setShouldShow: (shouldShow: boolean) => void;
children: ReactNode;
}

const Modal = ({ shouldShow, setShouldShow, children }: ModalProps) => {
if (!shouldShow) return null;

const handleOverlayClick = (e: React.MouseEvent) => {
if (e.target === e.currentTarget) {
setShouldShow(false);
}
};

return (
<div className={"modal_overlay"} onClick={handleOverlayClick}>
<div className={"modal_content"}>
{children}
<button className={"modal_close"} onClick={() => setShouldShow(false)}>
<CrossIcon />
</button>
</div>
</div>
);
};

export default Modal;
61 changes: 61 additions & 0 deletions src/components/atoms/Modal/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@use "src/styles/globals.scss" as *;

.modal {
&_overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.7);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}

&_content {
position: fixed;
bottom: 0;
left: 0;
right: 0;
max-width: 100%;
border-radius: 12px 12px 0 0;
box-shadow: 0 -5px 20px var(--color-gray-900);
background-color: var(--color-gray-900);
padding: 30px;

@include desktop {
box-shadow: 20px 20px 40px var(--color-gray-900);
border-radius: 12px;
max-width: 720px;
width: 100%;
text-align: center;
position: relative;
padding: 0;
}
}

&_close {
@include centered-row;
justify-content: center;

position: absolute;
top: 10px;
right: 10px;
border: 0px;
border-radius: 50%;

width: 24px;
height: 24px;

color: var(--color-white);
background-color: var(--color-white-10);
font-size: 14px;
cursor: pointer;

&:hover {
background-color: var(--color-white-20);
}
}
}
Loading

0 comments on commit b26508e

Please sign in to comment.