Skip to content

Commit

Permalink
static IS_AUTOMATIC & NATIVE_GAS_DROPOFF_SUPPORTED (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
artursapek authored Aug 8, 2024
1 parent 3a77ef4 commit d458954
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion connect/src/routes/cctp/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class AutomaticCCTPRoute<N extends Network>
extends AutomaticRoute<N, Op, Vp, R>
implements StaticRouteMethods<typeof AutomaticCCTPRoute>
{
NATIVE_GAS_DROPOFF_SUPPORTED = true;
static NATIVE_GAS_DROPOFF_SUPPORTED = true;

static meta = {
name: "AutomaticCCTP",
Expand Down
2 changes: 1 addition & 1 deletion connect/src/routes/portico/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class AutomaticPorticoRoute<N extends Network>
extends AutomaticRoute<N, OP, VP, R>
implements StaticRouteMethods<typeof AutomaticPorticoRoute>
{
NATIVE_GAS_DROPOFF_SUPPORTED = false;
static NATIVE_GAS_DROPOFF_SUPPORTED = false;

static meta = {
name: "AutomaticPortico",
Expand Down
17 changes: 8 additions & 9 deletions connect/src/routes/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export abstract class Route<
> {
wh: Wormhole<N>;

// 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<N>) {
this.wh = wh;
}
Expand Down Expand Up @@ -84,6 +79,10 @@ export interface RouteConstructor<OP extends Options = Options> {
new <N extends Network>(wh: Wormhole<N>): Route<N, OP>;
/** 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 */
Expand Down Expand Up @@ -113,13 +112,13 @@ export abstract class AutomaticRoute<
VP extends ValidatedTransferParams<OP> = ValidatedTransferParams<OP>,
R extends Receipt = Receipt,
> extends Route<N, OP, VP, R> {
IS_AUTOMATIC = true;
static IS_AUTOMATIC = true;
// TODO: search for usagees and update arg
public abstract isAvailable(request: RouteTransferRequest<N>): Promise<boolean>;
}

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

/**
Expand All @@ -132,8 +131,8 @@ export abstract class ManualRoute<
VP extends ValidatedTransferParams<OP> = ValidatedTransferParams<OP>,
R extends Receipt = Receipt,
> extends Route<N, OP, VP, R> {
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<R>;
public abstract resume(tx: TransactionId): Promise<R>;
}
Expand Down
2 changes: 1 addition & 1 deletion connect/src/routes/tokenBridge/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class AutomaticTokenBridgeRoute<N extends Network>
extends AutomaticRoute<N, Op, Vp, R>
implements StaticRouteMethods<typeof AutomaticTokenBridgeRoute>
{
NATIVE_GAS_DROPOFF_SUPPORTED = true;
static NATIVE_GAS_DROPOFF_SUPPORTED = true;

static meta = {
name: "AutomaticTokenBridge",
Expand Down

0 comments on commit d458954

Please sign in to comment.