From dd576e00b35cf0cace9c6a814192b69acf7233ce Mon Sep 17 00:00:00 2001 From: Artur Sapek Date: Tue, 12 Nov 2024 11:14:21 -0500 Subject: [PATCH] remove redundant method from Route interface (#736) --- connect/__tests__/mocks/routes/automatic.ts | 4 ---- connect/__tests__/mocks/routes/manual.ts | 4 ---- connect/src/routes/cctp/automatic.ts | 4 ---- connect/src/routes/cctp/manual.ts | 4 ---- connect/src/routes/portico/automatic.ts | 8 ++------ connect/src/routes/resolver.ts | 4 +--- connect/src/routes/route.ts | 2 -- connect/src/routes/tokenBridge/automatic.ts | 4 ---- connect/src/routes/tokenBridge/manual.ts | 4 ---- scripts/src/features.ts | 2 +- 10 files changed, 4 insertions(+), 36 deletions(-) diff --git a/connect/__tests__/mocks/routes/automatic.ts b/connect/__tests__/mocks/routes/automatic.ts index f95d57713..49b4b2b3b 100644 --- a/connect/__tests__/mocks/routes/automatic.ts +++ b/connect/__tests__/mocks/routes/automatic.ts @@ -60,10 +60,6 @@ export class AutomaticMockRoute return [nativeTokenId(toChain.chain)]; } - static isProtocolSupported(chain: ChainContext): boolean { - return true; - } - async validate( request: RouteTransferRequest, params: TransferParams, diff --git a/connect/__tests__/mocks/routes/manual.ts b/connect/__tests__/mocks/routes/manual.ts index b2aa13947..2893a4687 100644 --- a/connect/__tests__/mocks/routes/manual.ts +++ b/connect/__tests__/mocks/routes/manual.ts @@ -58,10 +58,6 @@ export class ManualMockRoute return [nativeTokenId(toChain.chain)]; } - static isProtocolSupported(chain: ChainContext): boolean { - return true; - } - async validate( request: RouteTransferRequest, params: TransferParams, diff --git a/connect/src/routes/cctp/automatic.ts b/connect/src/routes/cctp/automatic.ts index c3b4fd8c0..745d11fd4 100644 --- a/connect/src/routes/cctp/automatic.ts +++ b/connect/src/routes/cctp/automatic.ts @@ -100,10 +100,6 @@ export class AutomaticCCTPRoute return [Wormhole.chainAddress(chain, circle.usdcContract.get(network, chain)!)]; } - static isProtocolSupported(chain: ChainContext): boolean { - return chain.supportsAutomaticCircleBridge(); - } - getDefaultOptions(): Op { return { nativeGas: 0.0, diff --git a/connect/src/routes/cctp/manual.ts b/connect/src/routes/cctp/manual.ts index 28584066f..1ac1d53f7 100644 --- a/connect/src/routes/cctp/manual.ts +++ b/connect/src/routes/cctp/manual.ts @@ -93,10 +93,6 @@ export class CCTPRoute return [Wormhole.chainAddress(chain, circle.usdcContract.get(network, chain)!)]; } - static isProtocolSupported(chain: ChainContext): boolean { - return chain.supportsCircleBridge(); - } - getDefaultOptions(): Op { return { payload: undefined, diff --git a/connect/src/routes/portico/automatic.ts b/connect/src/routes/portico/automatic.ts index 5803e66fa..e86ff8457 100644 --- a/connect/src/routes/portico/automatic.ts +++ b/connect/src/routes/portico/automatic.ts @@ -140,10 +140,6 @@ export class AutomaticPorticoRoute .map((t) => t.token); } - static isProtocolSupported(chain: ChainContext): boolean { - return chain.supportsPorticoBridge(); - } - getDefaultOptions(): OP { return {}; } @@ -151,8 +147,8 @@ export class AutomaticPorticoRoute async validate(request: RouteTransferRequest, params: TP): Promise { try { if ( - !AutomaticPorticoRoute.isProtocolSupported(request.fromChain) || - !AutomaticPorticoRoute.isProtocolSupported(request.toChain) + !AutomaticPorticoRoute.supportedChains(request.fromChain.network).includes(request.fromChain.chain) || + !AutomaticPorticoRoute.supportedChains(request.toChain.network).includes(request.toChain.chain) ) { throw new Error("Protocol not supported"); } diff --git a/connect/src/routes/resolver.ts b/connect/src/routes/resolver.ts index 043106c14..a128ed3da 100644 --- a/connect/src/routes/resolver.ts +++ b/connect/src/routes/resolver.ts @@ -62,9 +62,7 @@ export class RouteResolver { const protocolSupported = rc.supportedNetworks().includes(this.wh.network) && rc.supportedChains(this.wh.network).includes(request.toChain.chain) && - rc.supportedChains(this.wh.network).includes(request.fromChain.chain) && - rc.isProtocolSupported(request.fromChain) && - rc.isProtocolSupported(request.toChain); + rc.supportedChains(this.wh.network).includes(request.fromChain.chain) const sourceTokenAddress = canonicalAddress( isNative(request.source.id.address) ? request.source.wrapped! : request.source.id, diff --git a/connect/src/routes/route.ts b/connect/src/routes/route.ts index cb92f2ea4..7479463a3 100644 --- a/connect/src/routes/route.ts +++ b/connect/src/routes/route.ts @@ -87,8 +87,6 @@ export interface RouteConstructor { supportedNetworks(): Network[]; /** get the list of chains this route supports */ supportedChains(network: Network): Chain[]; - /** check that the underlying protocols are supported */ - isProtocolSupported(chain: ChainContext): boolean; /** get the list of source tokens that are possible to send */ supportedSourceTokens(fromChain: ChainContext): Promise; /** get the list of destination tokens that may be received on the destination chain */ diff --git a/connect/src/routes/tokenBridge/automatic.ts b/connect/src/routes/tokenBridge/automatic.ts index 48dcc79e7..ea39c7488 100644 --- a/connect/src/routes/tokenBridge/automatic.ts +++ b/connect/src/routes/tokenBridge/automatic.ts @@ -111,10 +111,6 @@ export class AutomaticTokenBridgeRoute } } - static isProtocolSupported(chain: ChainContext): boolean { - return chain.supportsAutomaticTokenBridge(); - } - getDefaultOptions(): Op { return { nativeGas: 0.0 }; } diff --git a/connect/src/routes/tokenBridge/manual.ts b/connect/src/routes/tokenBridge/manual.ts index 672ad5280..c5e8ced79 100644 --- a/connect/src/routes/tokenBridge/manual.ts +++ b/connect/src/routes/tokenBridge/manual.ts @@ -89,10 +89,6 @@ export class TokenBridgeRoute } } - static isProtocolSupported(chain: ChainContext): boolean { - return chain.supportsTokenBridge(); - } - getDefaultOptions(): Op { return { payload: undefined }; } diff --git a/scripts/src/features.ts b/scripts/src/features.ts index ca86212a9..6a916c1f9 100644 --- a/scripts/src/features.ts +++ b/scripts/src/features.ts @@ -65,7 +65,7 @@ function getSupportmatrix(n: Network) { for (const chain of chains) { try { const ctx = wh.getChain(chain as Chain); - protoSupport[name]![chain] = rc.isProtocolSupported(ctx); + protoSupport[name]![chain] = rc.supportedChains(ctx.network).includes(ctx.chain); } catch (e) { console.log("error on: ", chain); }