Skip to content

Remove Portico route (ETH, wstETH, UDST Bridge) #3384

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

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from
Draft
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
5 changes: 0 additions & 5 deletions wormhole-connect/src/components/SampleApp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
/* @ts-ignore */
window.CCTPRoute = routes.CCTPRoute;
/* @ts-ignore */
window.AutomaticPorticoRoute = routes.AutomaticPorticoRoute;
/* @ts-ignore */
window.TBTCRoute = routes.TBTCRoute;
/* @ts-ignore */
Expand Down Expand Up @@ -198,8 +197,8 @@
localStorage.setItem(LOCAL_STORAGE_KEY_BG, input);
};

useEffect(emitCustomConfig, []);

Check warning on line 200 in wormhole-connect/src/components/SampleApp/index.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'customConfigInput' and 'isLoadingCustomConfig'. Either include them or remove the dependency array
useEffect(emitCustomTheme, []);

Check warning on line 201 in wormhole-connect/src/components/SampleApp/index.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'customThemeInput'. Either include it or remove the dependency array. You can also replace multiple useState variables with useReducer if 'setCustomTheme' needs the current value of 'customThemeInput'

return (
<main style={{ background: backgroundColor }}>
Expand Down Expand Up @@ -252,10 +251,6 @@
<pre>CCTPRoute</pre>
<i>{'RouteConstructor'}</i>
</li>
<li>
<pre>AutomaticPorticoRoute</pre>
<i>{'RouteConstructor'}</i>
</li>
<li>
<pre>TBTCRoute</pre>
<i>{'RouteConstructor'}</i>
Expand Down
98 changes: 3 additions & 95 deletions wormhole-connect/src/hooks/useTransactionHistoryWHScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
import {
amount as sdkAmount,
chainIdToChain,
toNative,
Wormhole,
} from '@wormhole-foundation/sdk';

import config from 'config';
import { WORMSCAN } from 'config/constants';
import { getGasToken } from 'utils';

import type { Chain, ChainId } from '@wormhole-foundation/sdk';
import type { ChainId } from '@wormhole-foundation/sdk';
import type { Transaction } from 'config/types';
import { toFixedDecimals } from 'utils/balance';
import { useTokens } from 'contexts/TokensContext';
import { Token } from 'config/tokens';

Expand Down Expand Up @@ -82,20 +79,6 @@ interface WormholeScanTransaction {
};
}

// TODO: SDKV2 route specific details don't belong here
interface WormholeScanPorticoParsedPayload {
finalTokenAddress: string;
flagSet: {
flags: {
shouldWrapNative: boolean;
shouldUnwrapNative: boolean;
};
};
minAmountFinish: string;
recipientAddress: string;
relayerFee: string;
}

type Props = {
address: string;
page?: number;
Expand Down Expand Up @@ -125,7 +108,7 @@ const useTransactionHistoryWHScan = (

// Common parsing logic for a single transaction from WHScan API.
// IMPORTANT: Anything specific to a route, please use that route's parser:
// parseTokenBridgeTx | parseNTTTx | parseCCTPTx | parsePorticoTx
// parseTokenBridgeTx | parseNTTTx | parseCCTPTx
const parseSingleTx = useCallback(
async (tx: WormholeScanTransaction) => {
const { content, data, sourceChain, targetChain } = tx;
Expand Down Expand Up @@ -300,68 +283,6 @@ const useTransactionHistoryWHScan = (
[parseSingleTx],
);

// Parser for Portico transactions (appId === ETH_BRIDGE or USDT_BRIDGE)
// IMPORTANT: This is where we can add any customizations specific to Portico data
// that we have retrieved from WHScan API
const parsePorticoTx = useCallback(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will stop showing portico route but if we remove the parsing it won't show previously created txs as well. Is that ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on this. I guess a benefit of removing it is less code. But obviously older TXs won't be shown.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Wesleyleung What should we do here? Show old Portico route TXs in the history or remove support for that?

async (tx: WormholeScanTransaction) => {
const txData = await parseSingleTx(tx);
if (!txData) return;

const payload = tx.content.payload
.parsedPayload as unknown as WormholeScanPorticoParsedPayload;

const {
finalTokenAddress,
flagSet,
minAmountFinish,
recipientAddress,
relayerFee,
} = payload;

const nativeToken = config.tokens.get(
chainIdToChain(tx.content.standarizedProperties.tokenChain) as Chain,
tx.content.standarizedProperties.tokenAddress,
);
if (!nativeToken) return;

const startToken = flagSet.flags?.shouldWrapNative
? getGasToken(txData.fromChain)
: nativeToken;

const finalToken = config.tokens.get(
Wormhole.tokenId(
txData.toChain,
toNative(txData.toChain, finalTokenAddress).toString(),
),
);

if (!finalToken) return;

const receiveAmount = BigInt(minAmountFinish) - BigInt(relayerFee);

// Override with Portico specific data
txData.fromToken = startToken;
txData.toToken = flagSet.flags.shouldUnwrapNative
? getGasToken(txData.toChain)
: finalToken;
txData.receiveAmount =
receiveAmount > 0
? toFixedDecimals(
sdkAmount.display(
sdkAmount.fromBaseUnits(receiveAmount, finalToken.decimals),
0,
),
DECIMALS,
)
: '';
txData.recipient = toNative(txData.toChain, recipientAddress).toString();

return txData;
},
[parseSingleTx],
);

// Parser for WLL or FAST_TRANSFERS transactions (appId === WORMHOLE_LIQUIDITY_LAYER, FAST_TRANSFERS)
// IMPORTANT: This is where we can add any customizations specific to WLL data
// that we have retrieved from WHScan API
Expand All @@ -378,15 +299,12 @@ const useTransactionHistoryWHScan = (
GENERIC_RELAYER: parseGenericRelayer,
NATIVE_TOKEN_TRANSFER: parseNTTTx,
CCTP_WORMHOLE_INTEGRATION: parseCCTPTx,
ETH_BRIDGE: parsePorticoTx,
USDT_BRIDGE: parsePorticoTx,
FAST_TRANSFERS: parseLLTx,
WORMHOLE_LIQUIDITY_LAYER: parseLLTx,
}),
[
parseCCTPTx,
parseNTTTx,
parsePorticoTx,
parseTokenBridgeTx,
parseLLTx,
parseGenericRelayer,
Expand All @@ -403,16 +321,6 @@ const useTransactionHistoryWHScan = (
const appIds: Array<string> =
tx.content?.standarizedProperties?.appIds || [];

// TODO: SDKV2
// Some integrations may compose with multiple protocols and have multiple appIds
// Choose a more specific parser if available
if (
appIds.includes('ETH_BRIDGE') ||
appIds.includes('USDT_BRIDGE')
) {
return parsePorticoTx(tx);
}

for (const appId of appIds) {
// Retrieve the parser for an appId
const parser = PARSERS[appId];
Expand All @@ -426,7 +334,7 @@ const useTransactionHistoryWHScan = (
)
).filter((tx) => !!tx); // Filter out unsupported transactions
},
[PARSERS, parsePorticoTx],
[PARSERS],
);

useEffect(() => {
Expand Down
2 changes: 0 additions & 2 deletions wormhole-connect/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const {
TokenBridgeRoute,
AutomaticCCTPRoute,
CCTPRoute,
AutomaticPorticoRoute,
} = routes;

export default WormholeConnect;
Expand All @@ -59,7 +58,6 @@ export {
TokenBridgeRoute,
AutomaticCCTPRoute,
CCTPRoute,
AutomaticPorticoRoute,
MayanRoute,
MayanRouteWH,
MayanRouteMCTP,
Expand Down
1 change: 0 additions & 1 deletion wormhole-connect/src/routes/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const DEFAULT_ROUTES = [
routes.CCTPRoute,
routes.AutomaticTokenBridgeRoute,
routes.TokenBridgeRoute,
routes.AutomaticPorticoRoute,
routes.TBTCRoute,
];

Expand Down
Loading