Skip to content
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

Remove redundant method from Route interface #736

Merged
merged 1 commit into from
Nov 12, 2024
Merged
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
4 changes: 0 additions & 4 deletions connect/__tests__/mocks/routes/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ export class AutomaticMockRoute<N extends Network>
return [nativeTokenId(toChain.chain)];
}

static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean {
return true;
}

async validate(
request: RouteTransferRequest<N>,
params: TransferParams<Op>,
Expand Down
4 changes: 0 additions & 4 deletions connect/__tests__/mocks/routes/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ export class ManualMockRoute<N extends Network>
return [nativeTokenId(toChain.chain)];
}

static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean {
return true;
}

async validate(
request: RouteTransferRequest<N>,
params: TransferParams<Op>,
Expand Down
4 changes: 0 additions & 4 deletions connect/src/routes/cctp/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ export class AutomaticCCTPRoute<N extends Network>
return [Wormhole.chainAddress(chain, circle.usdcContract.get(network, chain)!)];
}

static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean {
return chain.supportsAutomaticCircleBridge();
}

getDefaultOptions(): Op {
return {
nativeGas: 0.0,
Expand Down
4 changes: 0 additions & 4 deletions connect/src/routes/cctp/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ export class CCTPRoute<N extends Network>
return [Wormhole.chainAddress(chain, circle.usdcContract.get(network, chain)!)];
}

static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean {
return chain.supportsCircleBridge();
}

getDefaultOptions(): Op {
return {
payload: undefined,
Expand Down
8 changes: 2 additions & 6 deletions connect/src/routes/portico/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,15 @@ export class AutomaticPorticoRoute<N extends Network>
.map((t) => t.token);
}

static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean {
return chain.supportsPorticoBridge();
}

getDefaultOptions(): OP {
return {};
}

async validate(request: RouteTransferRequest<N>, params: TP): Promise<VR> {
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");
}
Expand Down
4 changes: 1 addition & 3 deletions connect/src/routes/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ export class RouteResolver<N extends Network> {
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,
Expand Down
2 changes: 0 additions & 2 deletions connect/src/routes/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ export interface RouteConstructor<OP extends Options = Options> {
supportedNetworks(): Network[];
/** get the list of chains this route supports */
supportedChains(network: Network): Chain[];
/** check that the underlying protocols are supported */
isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean;
/** get the list of source tokens that are possible to send */
supportedSourceTokens(fromChain: ChainContext<Network>): Promise<TokenId[]>;
/** get the list of destination tokens that may be received on the destination chain */
Expand Down
4 changes: 0 additions & 4 deletions connect/src/routes/tokenBridge/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ export class AutomaticTokenBridgeRoute<N extends Network>
}
}

static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean {
return chain.supportsAutomaticTokenBridge();
}

getDefaultOptions(): Op {
return { nativeGas: 0.0 };
}
Expand Down
4 changes: 0 additions & 4 deletions connect/src/routes/tokenBridge/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ export class TokenBridgeRoute<N extends Network>
}
}

static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean {
return chain.supportsTokenBridge();
}

getDefaultOptions(): Op {
return { payload: undefined };
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/src/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading