Skip to content

Commit 2a51fc6

Browse files
authored
Don't show wrapped tBTC on chains deployed with canonical tBTC (#1530)
Addresses #1529 Co-authored-by: Kevin Peters <kevin@wormholelabs.xyz>
1 parent 2243a84 commit 2a51fc6

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

wormhole-connect/src/routes/bridge/baseRoute.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { formatGasFee, isIlliquidDestToken } from 'routes/utils';
2222
import { toDecimals } from 'utils/balance';
2323
import { NO_INPUT } from 'utils/style';
2424
import { hexlify } from 'ethers/lib/utils.js';
25+
import { isTBTCToken } from 'routes/tbtc/utils';
2526

2627
export abstract class BaseRoute extends RouteAbstract {
2728
async isSupportedSourceToken(
@@ -41,6 +42,9 @@ export abstract class BaseRoute extends RouteAbstract {
4142
if (!token.tokenId && token.nativeChain !== chainName) {
4243
return false;
4344
}
45+
if (isTBTCToken(token) && token.nativeChain !== chainName) {
46+
return false;
47+
}
4448
return true;
4549
}
4650

@@ -53,6 +57,7 @@ export abstract class BaseRoute extends RouteAbstract {
5357
if (!token) return false;
5458
if (!token.tokenId) return false;
5559
if (destChain && isIlliquidDestToken(token, destChain)) return false;
60+
if (isTBTCToken(token)) return false;
5661
if (sourceToken) {
5762
const wrapped = getWrappedToken(sourceToken);
5863
return wrapped.key === token.key;

wormhole-connect/src/routes/tbtc/tbtc.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ export class TBTCRoute extends BaseRoute {
6060
if (!sourceChain) return false;
6161
if (!token || token.symbol !== TBTC_TOKEN_SYMBOL) return false;
6262
if (destToken && destToken.symbol !== TBTC_TOKEN_SYMBOL) return false;
63-
if (
64-
isTBTCCanonicalChain(sourceChain) &&
65-
token.nativeChain === wh.toChainName(sourceChain)
66-
) {
67-
return true;
63+
if (isTBTCCanonicalChain(sourceChain)) {
64+
return token.nativeChain === wh.toChainName(sourceChain);
6865
}
6966
return wh.toChainId(token.nativeChain) === CHAIN_ID_ETH;
7067
}
@@ -78,11 +75,8 @@ export class TBTCRoute extends BaseRoute {
7875
if (!destChain) return false;
7976
if (!token || token.symbol !== TBTC_TOKEN_SYMBOL) return false;
8077
if (sourceToken && sourceToken.symbol !== TBTC_TOKEN_SYMBOL) return false;
81-
if (
82-
isTBTCCanonicalChain(destChain) &&
83-
token.nativeChain === wh.toChainName(destChain)
84-
) {
85-
return true;
78+
if (isTBTCCanonicalChain(destChain)) {
79+
return token.nativeChain === wh.toChainName(destChain);
8680
}
8781
return wh.toChainId(token.nativeChain) === CHAIN_ID_ETH;
8882
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { ChainId, ChainName } from '@wormhole-foundation/wormhole-connect-sdk';
2+
import { TokenConfig } from 'config/types';
23
import { wh } from 'utils/sdk';
34

45
export const isTBTCCanonicalChain = (chain: ChainId | ChainName): boolean =>
56
!!wh.getContracts(chain)?.tbtcGateway;
7+
8+
export const isTBTCToken = (token: TokenConfig): boolean =>
9+
token.symbol === 'tBTC';

0 commit comments

Comments
 (0)