Skip to content

Commit d458954

Browse files
authored
static IS_AUTOMATIC & NATIVE_GAS_DROPOFF_SUPPORTED (#664)
1 parent 3a77ef4 commit d458954

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

connect/src/routes/cctp/automatic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class AutomaticCCTPRoute<N extends Network>
5454
extends AutomaticRoute<N, Op, Vp, R>
5555
implements StaticRouteMethods<typeof AutomaticCCTPRoute>
5656
{
57-
NATIVE_GAS_DROPOFF_SUPPORTED = true;
57+
static NATIVE_GAS_DROPOFF_SUPPORTED = true;
5858

5959
static meta = {
6060
name: "AutomaticCCTP",

connect/src/routes/portico/automatic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class AutomaticPorticoRoute<N extends Network>
7272
extends AutomaticRoute<N, OP, VP, R>
7373
implements StaticRouteMethods<typeof AutomaticPorticoRoute>
7474
{
75-
NATIVE_GAS_DROPOFF_SUPPORTED = false;
75+
static NATIVE_GAS_DROPOFF_SUPPORTED = false;
7676

7777
static meta = {
7878
name: "AutomaticPortico",

connect/src/routes/route.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ export abstract class Route<
2626
> {
2727
wh: Wormhole<N>;
2828

29-
// true means this route supports native gas dropoff
30-
abstract readonly NATIVE_GAS_DROPOFF_SUPPORTED: boolean;
31-
// true means this is a one-transaction route (using a relayer)
32-
abstract readonly IS_AUTOMATIC: boolean;
33-
3429
public constructor(wh: Wormhole<N>) {
3530
this.wh = wh;
3631
}
@@ -84,6 +79,10 @@ export interface RouteConstructor<OP extends Options = Options> {
8479
new <N extends Network>(wh: Wormhole<N>): Route<N, OP>;
8580
/** Details about the route provided by the implementation */
8681
readonly meta: RouteMeta;
82+
/** true means this route supports native gas dropoff */
83+
readonly NATIVE_GAS_DROPOFF_SUPPORTED: boolean;
84+
/** true means this is a one-transaction route (using a relayer) */
85+
readonly IS_AUTOMATIC: boolean;
8786
/** get the list of networks this route supports */
8887
supportedNetworks(): Network[];
8988
/** get the list of chains this route supports */
@@ -113,13 +112,13 @@ export abstract class AutomaticRoute<
113112
VP extends ValidatedTransferParams<OP> = ValidatedTransferParams<OP>,
114113
R extends Receipt = Receipt,
115114
> extends Route<N, OP, VP, R> {
116-
IS_AUTOMATIC = true;
115+
static IS_AUTOMATIC = true;
117116
// TODO: search for usagees and update arg
118117
public abstract isAvailable(request: RouteTransferRequest<N>): Promise<boolean>;
119118
}
120119

121120
export function isAutomatic<N extends Network>(route: Route<N>): route is AutomaticRoute<N> {
122-
return (route as AutomaticRoute<N>).isAvailable !== undefined && route.IS_AUTOMATIC;
121+
return (route as AutomaticRoute<N>).isAvailable !== undefined && (route.constructor as RouteConstructor).IS_AUTOMATIC;
123122
}
124123

125124
/**
@@ -132,8 +131,8 @@ export abstract class ManualRoute<
132131
VP extends ValidatedTransferParams<OP> = ValidatedTransferParams<OP>,
133132
R extends Receipt = Receipt,
134133
> extends Route<N, OP, VP, R> {
135-
NATIVE_GAS_DROPOFF_SUPPORTED = false;
136-
IS_AUTOMATIC = false;
134+
static NATIVE_GAS_DROPOFF_SUPPORTED = false;
135+
static IS_AUTOMATIC = false;
137136
public abstract complete(sender: Signer, receipt: R): Promise<R>;
138137
public abstract resume(tx: TransactionId): Promise<R>;
139138
}

connect/src/routes/tokenBridge/automatic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class AutomaticTokenBridgeRoute<N extends Network>
5555
extends AutomaticRoute<N, Op, Vp, R>
5656
implements StaticRouteMethods<typeof AutomaticTokenBridgeRoute>
5757
{
58-
NATIVE_GAS_DROPOFF_SUPPORTED = true;
58+
static NATIVE_GAS_DROPOFF_SUPPORTED = true;
5959

6060
static meta = {
6161
name: "AutomaticTokenBridge",

0 commit comments

Comments
 (0)