From 6f969d1719dac06640d06ad109dd320f5ad1edf5 Mon Sep 17 00:00:00 2001 From: Kevin Peters Date: Tue, 31 Mar 2026 13:02:40 -0500 Subject: [PATCH] feat: support executor callback overrides on WormholeConfig Allow users to pass a getCapabilities callback when constructing the Wormhole SDK object so every route can use it without per-route config. --- connect/src/config.ts | 12 +++++++++++- connect/src/wormhole.ts | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/connect/src/config.ts b/connect/src/config.ts index 54095d8ce..206cd3f28 100644 --- a/connect/src/config.ts +++ b/connect/src/config.ts @@ -1,6 +1,10 @@ import type { Chain, Network, Platform } from "@wormhole-foundation/sdk-base"; import { circle, executor } from "@wormhole-foundation/sdk-base"; -import type { ChainConfig, ChainsConfig } from "@wormhole-foundation/sdk-definitions"; +import type { + CapabilitiesResponse, + ChainConfig, + ChainsConfig, +} from "@wormhole-foundation/sdk-definitions"; import { buildConfig } from "@wormhole-foundation/sdk-definitions"; export const DEFAULT_TASK_TIMEOUT = 60 * 1000; // 1 minute in milliseconds @@ -10,6 +14,10 @@ export type WormholeConfig; + executor?: { + /** Override the default capabilities fetcher (e.g. to cache or use a custom endpoint). */ + getCapabilities?: (network: Network) => Promise; + }; }; export const CONFIG = { @@ -47,6 +55,8 @@ export function networkPlatformConfigs( type RecursivePartial = { [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial[] + : T[P] extends (...args: any[]) => any + ? T[P] : T[P] extends object | undefined ? RecursivePartial : T[P]; diff --git a/connect/src/wormhole.ts b/connect/src/wormhole.ts index d13b78ff9..30c7952eb 100644 --- a/connect/src/wormhole.ts +++ b/connect/src/wormhole.ts @@ -452,6 +452,9 @@ export class Wormhole { } async getExecutorCapabilities(): Promise { + if (this.config.executor?.getCapabilities) { + return await this.config.executor.getCapabilities(this._network); + } return await fetchCapabilities(this.config.executorAPI); }