From d45895480f663f391f50e36afe5a658e06618b1a Mon Sep 17 00:00:00 2001 From: Artur Sapek Date: Thu, 8 Aug 2024 14:13:30 -0700 Subject: [PATCH] static IS_AUTOMATIC & NATIVE_GAS_DROPOFF_SUPPORTED (#664) --- connect/src/routes/cctp/automatic.ts | 2 +- connect/src/routes/portico/automatic.ts | 2 +- connect/src/routes/route.ts | 17 ++++++++--------- connect/src/routes/tokenBridge/automatic.ts | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/connect/src/routes/cctp/automatic.ts b/connect/src/routes/cctp/automatic.ts index 8f44a9c81..2dff9da65 100644 --- a/connect/src/routes/cctp/automatic.ts +++ b/connect/src/routes/cctp/automatic.ts @@ -54,7 +54,7 @@ export class AutomaticCCTPRoute extends AutomaticRoute implements StaticRouteMethods { - NATIVE_GAS_DROPOFF_SUPPORTED = true; + static NATIVE_GAS_DROPOFF_SUPPORTED = true; static meta = { name: "AutomaticCCTP", diff --git a/connect/src/routes/portico/automatic.ts b/connect/src/routes/portico/automatic.ts index af237d02c..5ec53439e 100644 --- a/connect/src/routes/portico/automatic.ts +++ b/connect/src/routes/portico/automatic.ts @@ -72,7 +72,7 @@ export class AutomaticPorticoRoute extends AutomaticRoute implements StaticRouteMethods { - NATIVE_GAS_DROPOFF_SUPPORTED = false; + static NATIVE_GAS_DROPOFF_SUPPORTED = false; static meta = { name: "AutomaticPortico", diff --git a/connect/src/routes/route.ts b/connect/src/routes/route.ts index 1bf697f0d..04528f075 100644 --- a/connect/src/routes/route.ts +++ b/connect/src/routes/route.ts @@ -26,11 +26,6 @@ export abstract class Route< > { wh: Wormhole; - // true means this route supports native gas dropoff - abstract readonly NATIVE_GAS_DROPOFF_SUPPORTED: boolean; - // true means this is a one-transaction route (using a relayer) - abstract readonly IS_AUTOMATIC: boolean; - public constructor(wh: Wormhole) { this.wh = wh; } @@ -84,6 +79,10 @@ export interface RouteConstructor { new (wh: Wormhole): Route; /** Details about the route provided by the implementation */ readonly meta: RouteMeta; + /** true means this route supports native gas dropoff */ + readonly NATIVE_GAS_DROPOFF_SUPPORTED: boolean; + /** true means this is a one-transaction route (using a relayer) */ + readonly IS_AUTOMATIC: boolean; /** get the list of networks this route supports */ supportedNetworks(): Network[]; /** get the list of chains this route supports */ @@ -113,13 +112,13 @@ export abstract class AutomaticRoute< VP extends ValidatedTransferParams = ValidatedTransferParams, R extends Receipt = Receipt, > extends Route { - IS_AUTOMATIC = true; + static IS_AUTOMATIC = true; // TODO: search for usagees and update arg public abstract isAvailable(request: RouteTransferRequest): Promise; } export function isAutomatic(route: Route): route is AutomaticRoute { - return (route as AutomaticRoute).isAvailable !== undefined && route.IS_AUTOMATIC; + return (route as AutomaticRoute).isAvailable !== undefined && (route.constructor as RouteConstructor).IS_AUTOMATIC; } /** @@ -132,8 +131,8 @@ export abstract class ManualRoute< VP extends ValidatedTransferParams = ValidatedTransferParams, R extends Receipt = Receipt, > extends Route { - NATIVE_GAS_DROPOFF_SUPPORTED = false; - IS_AUTOMATIC = false; + static NATIVE_GAS_DROPOFF_SUPPORTED = false; + static IS_AUTOMATIC = false; public abstract complete(sender: Signer, receipt: R): Promise; public abstract resume(tx: TransactionId): Promise; } diff --git a/connect/src/routes/tokenBridge/automatic.ts b/connect/src/routes/tokenBridge/automatic.ts index bda878113..d19ae699d 100644 --- a/connect/src/routes/tokenBridge/automatic.ts +++ b/connect/src/routes/tokenBridge/automatic.ts @@ -55,7 +55,7 @@ export class AutomaticTokenBridgeRoute extends AutomaticRoute implements StaticRouteMethods { - NATIVE_GAS_DROPOFF_SUPPORTED = true; + static NATIVE_GAS_DROPOFF_SUPPORTED = true; static meta = { name: "AutomaticTokenBridge",