@steerprotocol/data-connector-loader 5.0.0-next.5 → 5.0.0-next.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,6 +48,20 @@ a fresh temporary directory while reusing npm's download cache.
48
48
  ## Block-pinned strategy execution (recommended)
49
49
 
50
50
  Supply a resolved `SmartPoolExecutionContext` to `ExecutionApp.executeWithContext`.
51
+ Strategy entrypoints return the exact string `"continue"` when no action is needed,
52
+ or the decoded JSON result. Their generic `T` describes the complete JSON result
53
+ (an action object or array), and the return type is `Promise<T | "continue">`.
54
+ All other non-JSON output is rejected as `StrategyExecutionError`.
55
+
56
+ The offline `strategyWasm.integration.test.ts` suite runs retained Liquid Arc and
57
+ Static Stable binaries through the loader, covering both `continue` and JSON
58
+ actions with supplied contexts. It checks binary hashes and runs with `npm test`
59
+ in CI. To run just these cases:
60
+
61
+ ```sh
62
+ npm test -- --runInBand strategyWasm.integration.test.ts
63
+ ```
64
+
51
65
  For connectors, pass an `ExecutionContext` to `DataConnectorExecution.executeWithContext`.
52
66
  `SmartPoolExecutionContext` extends `ExecutionContext`, so the same resolved
53
67
  context can be used for both. Both contexts include the chain ID for comparison
@@ -5,9 +5,10 @@ export interface ExecutionAppConfig {
5
5
  vault: string;
6
6
  /** Chain ID used to resolve RPC configuration and on-chain reads. */
7
7
  chainId: number;
8
- /** Subgraph endpoint used for protocol data queries. */
9
- steerSubgraph: string;
10
- poolType: {
8
+ /** Required by execute() for protocol discovery queries. */
9
+ steerSubgraph?: string;
10
+ /** Required by execute() for pool discovery; unused by executeWithContext(). */
11
+ poolType?: {
11
12
  /** Set true when the pool uses Algebra v1 semantics. */
12
13
  isAlgebraPool: boolean;
13
14
  /** Set true when the pool uses Algebra Integral semantics. */
@@ -19,11 +20,11 @@ export interface ExecutionAppConfig {
19
20
  /** Set true when the pool uses Aerodrome semantics. */
20
21
  isAerodromePool: boolean;
21
22
  };
22
- apiKeys: {
23
- /** API key for The Graph Studio / gateway endpoints. */
24
- subgraphStudioKey: string;
23
+ apiKeys?: {
24
+ /** Host-only Graph credential; never added to WASM configuration. */
25
+ subgraphStudioKey?: string;
25
26
  /** API key for Sentio endpoints, if applicable. */
26
- sentioApiKey: string;
27
+ sentioApiKey?: string;
27
28
  };
28
29
  /** Maximum number of retries for execution operations. */
29
30
  maxRetries?: number;
@@ -37,22 +38,23 @@ export declare class ExecutionApp extends ExecutionBase {
37
38
  isDirectionalPool: boolean;
38
39
  isPoolSharkPool: boolean;
39
40
  isAerodromePool: boolean;
40
- subgraphStudioKey: string;
41
41
  sentioApiKey: string;
42
42
  config: ExecutionAppConfig;
43
43
  constructor(config: ExecutionAppConfig);
44
- execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<Array<T>>;
44
+ execute<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
45
45
  /**
46
46
  * Executes a strategy against a supplied execution context.
47
47
  * This is the recommended API for new consumers. It intentionally bypasses
48
48
  * all legacy vault, pool, subgraph, clock, and block-estimation reads.
49
49
  */
50
- executeWithContext<T>(options: ExecuteWithContextOptions): Promise<Array<T>>;
50
+ executeWithContext<T = unknown>(options: ExecuteWithContextOptions): Promise<T | "continue">;
51
+ /** T is the complete decoded JSON result. Only the exact sentinel skips JSON decoding. */
52
+ private parseStrategyResult;
51
53
  private parseVaultConfig;
52
54
  private validateExecutionContext;
53
55
  private redactError;
54
- executeStabilityVault<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<Array<T>>;
55
- executeDynamicJobs<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, _job: JobDetails, rpc?: RpcAccess, forceDeposit?: boolean): Promise<Array<T>>;
56
+ executeStabilityVault<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
57
+ executeDynamicJobs<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, _job: JobDetails, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
56
58
  private getSmartPoolExecutionContext;
57
59
  private getPoolCurrentTick;
58
60
  private getTickSpacing;
@@ -451,18 +451,24 @@ export class ExecutionApp extends ExecutionBase {
451
451
  };
452
452
  };
453
453
  this.vault = config.vault;
454
- this.steerSubgraph = config.steerSubgraph;
454
+ this.steerSubgraph = config.steerSubgraph ?? "";
455
455
  this.chainId = config.chainId;
456
- this.isAlgebraPool = config.poolType.isAlgebraPool;
457
- this.isAlgebraIntegralPool = config.poolType.isAlgebraIntegralPool;
458
- this.isDirectionalPool = config.poolType.isDirectionalPool;
459
- this.isPoolSharkPool = config.poolType.isPoolSharkPool;
460
- this.isAerodromePool = config.poolType.isAerodromePool;
461
- this.subgraphStudioKey = config.apiKeys.subgraphStudioKey;
462
- this.sentioApiKey = config.apiKeys.sentioApiKey;
456
+ this.isAlgebraPool = config.poolType?.isAlgebraPool ?? false;
457
+ this.isAlgebraIntegralPool =
458
+ config.poolType?.isAlgebraIntegralPool ?? false;
459
+ this.isDirectionalPool = config.poolType?.isDirectionalPool ?? false;
460
+ this.isPoolSharkPool = config.poolType?.isPoolSharkPool ?? false;
461
+ this.isAerodromePool = config.poolType?.isAerodromePool ?? false;
462
+ this.sentioApiKey = config.apiKeys?.sentioApiKey ?? "";
463
463
  this.config = config;
464
464
  }
465
465
  async execute(_wasmFile, _vaultConfig, _data, rpc, forceDeposit) {
466
+ if (!this.config.poolType) {
467
+ throw new Error("poolType is required by execute() for pool discovery.");
468
+ }
469
+ if (!this.steerSubgraph.trim()) {
470
+ throw new Error("steerSubgraph is required by execute() for pool discovery.");
471
+ }
466
472
  const dataConnector = new DataConnector({
467
473
  wasmFile: _wasmFile,
468
474
  config: _vaultConfig,
@@ -478,7 +484,7 @@ export class ExecutionApp extends ExecutionBase {
478
484
  }, forceDeposit);
479
485
  _data = _data.map((element) => JSON.stringify(element));
480
486
  const result = await dataConnector.executeBundle(_data);
481
- return JSON.parse(result);
487
+ return this.parseStrategyResult(result);
482
488
  }
483
489
  /**
484
490
  * Executes a strategy against a supplied execution context.
@@ -503,7 +509,7 @@ export class ExecutionApp extends ExecutionBase {
503
509
  await dataConnector.loadSync();
504
510
  dataConnector.initializeStrategyWithContext(executionContext, options.forceDeposit);
505
511
  const result = await dataConnector.executeBundle(options.data.map((item) => JSON.stringify(item)));
506
- return JSON.parse(result);
512
+ return this.parseStrategyResult(result);
507
513
  }
508
514
  catch (error) {
509
515
  if (error instanceof ExecutionContextError)
@@ -511,6 +517,17 @@ export class ExecutionApp extends ExecutionBase {
511
517
  throw new StrategyExecutionError(this.redactError(error));
512
518
  }
513
519
  }
520
+ /** T is the complete decoded JSON result. Only the exact sentinel skips JSON decoding. */
521
+ parseStrategyResult(result) {
522
+ if (result === "continue")
523
+ return result;
524
+ try {
525
+ return JSON.parse(result);
526
+ }
527
+ catch (error) {
528
+ throw new StrategyExecutionError(this.redactError(error));
529
+ }
530
+ }
514
531
  parseVaultConfig(vaultConfig) {
515
532
  try {
516
533
  return JSON.parse(vaultConfig);
@@ -595,7 +612,7 @@ export class ExecutionApp extends ExecutionBase {
595
612
  }, forceDeposit);
596
613
  _data = _data.map((element) => JSON.stringify(element));
597
614
  const result = await dataConnector.executeDynamicJobBundle(_data);
598
- return JSON.parse(result);
615
+ return this.parseStrategyResult(result);
599
616
  }
600
617
  async executeDynamicJobs(_wasmFile, _vaultConfig, _data, _job, rpc, forceDeposit) {
601
618
  const dataConnector = new DataConnector({
@@ -619,7 +636,7 @@ export class ExecutionApp extends ExecutionBase {
619
636
  }, forceDeposit);
620
637
  _data = _data.map((element) => JSON.stringify(element));
621
638
  const result = await dataConnector.executeDynamicJobBundle(_data);
622
- return JSON.parse(result);
639
+ return this.parseStrategyResult(result);
623
640
  }
624
641
  async getSmartPoolExecutionContext(currentExecutionContext, dataConnector, vaultConfig) {
625
642
  const smartPoolExecutionContext = {};
@@ -7,7 +7,7 @@ export declare class ExecutionBase {
7
7
  protected delay(ms: number): Promise<void>;
8
8
  protected log(...args: Array<any>): void;
9
9
  protected getExecutionContext(dataConnector: DataConnector, vaultConfig: VaultConfigPayload): Promise<ExecutionContext>;
10
- execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess): Promise<Array<T>>;
10
+ execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess): Promise<T | Array<T> | "continue">;
11
11
  protected getDataConnectorVersion(dataConnector: DataConnector): Promise<number>;
12
12
  getAverageBlockTime(provider: PublicClient, blockCount?: number): Promise<number>;
13
13
  getBlockNumberFromAvgBlockTime(provider: PublicClient, targetTimestamp: number, avgBlockTime: number): Promise<number>;
@@ -142,12 +142,21 @@ export class DataConnectorExecution extends ExecutionBase {
142
142
  }
143
143
  else {
144
144
  let parsedRequest = typeof request === "string" ? JSON.parse(request) : request;
145
- const url = changeUrlIfOld(parsedRequest.url, dataConnector.configObj.subgraphStudioKey);
145
+ const graphApiKey = dataConnector.executionAppConfig.apiKeys?.subgraphStudioKey;
146
+ const url = changeUrlIfOld(parsedRequest.url, graphApiKey ? undefined : dataConnector.configObj.subgraphStudioKey);
146
147
  parsedRequest.url = url;
147
148
  let sentio = false;
149
+ let graph = false;
148
150
  try {
149
151
  const destination = new URL(axios.getUri(parsedRequest));
150
152
  const hostname = destination.hostname.toLowerCase();
153
+ graph =
154
+ (destination.origin === "https://gateway.thegraph.com" ||
155
+ destination.origin ===
156
+ "https://gateway-arbitrum.network.thegraph.com") &&
157
+ /^\/api\/(subgraphs|deployments)\/id\/[a-zA-Z0-9]+$/.test(destination.pathname) &&
158
+ !destination.username &&
159
+ !destination.password;
151
160
  sentio =
152
161
  destination.protocol === "https:" &&
153
162
  (hostname === "sentio.xyz" || hostname.endsWith(".sentio.xyz"));
@@ -155,18 +164,22 @@ export class DataConnectorExecution extends ExecutionBase {
155
164
  catch {
156
165
  /* Axios will report an invalid URL when sending the request. */
157
166
  }
167
+ const sentioApiKey = dataConnector.executionAppConfig.apiKeys?.sentioApiKey;
158
168
  parsedRequest.headers = {
159
169
  "Content-Type": url && !url.includes("subgraph-proxy-server")
160
170
  ? "application/json"
161
171
  : "text/plain;charset=UTF-8",
162
- ...(sentio
172
+ ...(sentio && sentioApiKey
163
173
  ? {
164
- "api-key": dataConnector.executionAppConfig.apiKeys.sentioApiKey,
174
+ "api-key": sentioApiKey,
165
175
  }
166
176
  : {}),
177
+ ...(graph && graphApiKey
178
+ ? { Authorization: `Bearer ${graphApiKey}` }
179
+ : {}),
167
180
  ...parsedRequest.headers,
168
181
  };
169
- if (sentio) {
182
+ if (sentio || (graph && graphApiKey)) {
170
183
  const { url, baseURL, method, params, data, headers, timeout, responseType, allowAbsoluteUrls, } = parsedRequest;
171
184
  parsedRequest = {
172
185
  url,
@@ -11,7 +11,7 @@ export class SubgraphUrlReplacer {
11
11
  return url;
12
12
  }
13
13
  getArbitrumSubgraphUrl(subgraphId, isDeploymentId) {
14
- return `https://gateway-arbitrum.network.thegraph.com/api/${this.subgraphStudioKey}/${isDeploymentId ? "deployments" : "subgraphs"}/id/${subgraphId}`;
14
+ return `https://gateway-arbitrum.network.thegraph.com/api/${this.subgraphStudioKey ? `${this.subgraphStudioKey}/` : ""}${isDeploymentId ? "deployments" : "subgraphs"}/id/${subgraphId}`;
15
15
  }
16
16
  getDefaultConfigs() {
17
17
  return [
@@ -5,9 +5,10 @@ export interface ExecutionAppConfig {
5
5
  vault: string;
6
6
  /** Chain ID used to resolve RPC configuration and on-chain reads. */
7
7
  chainId: number;
8
- /** Subgraph endpoint used for protocol data queries. */
9
- steerSubgraph: string;
10
- poolType: {
8
+ /** Required by execute() for protocol discovery queries. */
9
+ steerSubgraph?: string;
10
+ /** Required by execute() for pool discovery; unused by executeWithContext(). */
11
+ poolType?: {
11
12
  /** Set true when the pool uses Algebra v1 semantics. */
12
13
  isAlgebraPool: boolean;
13
14
  /** Set true when the pool uses Algebra Integral semantics. */
@@ -19,11 +20,11 @@ export interface ExecutionAppConfig {
19
20
  /** Set true when the pool uses Aerodrome semantics. */
20
21
  isAerodromePool: boolean;
21
22
  };
22
- apiKeys: {
23
- /** API key for The Graph Studio / gateway endpoints. */
24
- subgraphStudioKey: string;
23
+ apiKeys?: {
24
+ /** Host-only Graph credential; never added to WASM configuration. */
25
+ subgraphStudioKey?: string;
25
26
  /** API key for Sentio endpoints, if applicable. */
26
- sentioApiKey: string;
27
+ sentioApiKey?: string;
27
28
  };
28
29
  /** Maximum number of retries for execution operations. */
29
30
  maxRetries?: number;
@@ -37,22 +38,23 @@ export declare class ExecutionApp extends ExecutionBase {
37
38
  isDirectionalPool: boolean;
38
39
  isPoolSharkPool: boolean;
39
40
  isAerodromePool: boolean;
40
- subgraphStudioKey: string;
41
41
  sentioApiKey: string;
42
42
  config: ExecutionAppConfig;
43
43
  constructor(config: ExecutionAppConfig);
44
- execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<Array<T>>;
44
+ execute<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
45
45
  /**
46
46
  * Executes a strategy against a supplied execution context.
47
47
  * This is the recommended API for new consumers. It intentionally bypasses
48
48
  * all legacy vault, pool, subgraph, clock, and block-estimation reads.
49
49
  */
50
- executeWithContext<T>(options: ExecuteWithContextOptions): Promise<Array<T>>;
50
+ executeWithContext<T = unknown>(options: ExecuteWithContextOptions): Promise<T | "continue">;
51
+ /** T is the complete decoded JSON result. Only the exact sentinel skips JSON decoding. */
52
+ private parseStrategyResult;
51
53
  private parseVaultConfig;
52
54
  private validateExecutionContext;
53
55
  private redactError;
54
- executeStabilityVault<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<Array<T>>;
55
- executeDynamicJobs<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, _job: JobDetails, rpc?: RpcAccess, forceDeposit?: boolean): Promise<Array<T>>;
56
+ executeStabilityVault<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
57
+ executeDynamicJobs<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, _job: JobDetails, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
56
58
  private getSmartPoolExecutionContext;
57
59
  private getPoolCurrentTick;
58
60
  private getTickSpacing;
@@ -16,7 +16,7 @@ const utils_js_1 = require("../utils/utils.js");
16
16
  const executionBase_js_1 = require("./executionBase.js");
17
17
  class ExecutionApp extends executionBase_js_1.ExecutionBase {
18
18
  constructor(config) {
19
- var _a;
19
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
20
20
  super((_a = config.maxRetries) !== null && _a !== void 0 ? _a : 3);
21
21
  this.getSlot0 = (pool, currentExecutionContext, provider) => __awaiter(this, void 0, void 0, function* () {
22
22
  const slot0Abi = [
@@ -464,19 +464,25 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
464
464
  };
465
465
  });
466
466
  this.vault = config.vault;
467
- this.steerSubgraph = config.steerSubgraph;
467
+ this.steerSubgraph = (_b = config.steerSubgraph) !== null && _b !== void 0 ? _b : "";
468
468
  this.chainId = config.chainId;
469
- this.isAlgebraPool = config.poolType.isAlgebraPool;
470
- this.isAlgebraIntegralPool = config.poolType.isAlgebraIntegralPool;
471
- this.isDirectionalPool = config.poolType.isDirectionalPool;
472
- this.isPoolSharkPool = config.poolType.isPoolSharkPool;
473
- this.isAerodromePool = config.poolType.isAerodromePool;
474
- this.subgraphStudioKey = config.apiKeys.subgraphStudioKey;
475
- this.sentioApiKey = config.apiKeys.sentioApiKey;
469
+ this.isAlgebraPool = (_d = (_c = config.poolType) === null || _c === void 0 ? void 0 : _c.isAlgebraPool) !== null && _d !== void 0 ? _d : false;
470
+ this.isAlgebraIntegralPool =
471
+ (_f = (_e = config.poolType) === null || _e === void 0 ? void 0 : _e.isAlgebraIntegralPool) !== null && _f !== void 0 ? _f : false;
472
+ this.isDirectionalPool = (_h = (_g = config.poolType) === null || _g === void 0 ? void 0 : _g.isDirectionalPool) !== null && _h !== void 0 ? _h : false;
473
+ this.isPoolSharkPool = (_k = (_j = config.poolType) === null || _j === void 0 ? void 0 : _j.isPoolSharkPool) !== null && _k !== void 0 ? _k : false;
474
+ this.isAerodromePool = (_m = (_l = config.poolType) === null || _l === void 0 ? void 0 : _l.isAerodromePool) !== null && _m !== void 0 ? _m : false;
475
+ this.sentioApiKey = (_p = (_o = config.apiKeys) === null || _o === void 0 ? void 0 : _o.sentioApiKey) !== null && _p !== void 0 ? _p : "";
476
476
  this.config = config;
477
477
  }
478
478
  execute(_wasmFile, _vaultConfig, _data, rpc, forceDeposit) {
479
479
  return __awaiter(this, void 0, void 0, function* () {
480
+ if (!this.config.poolType) {
481
+ throw new Error("poolType is required by execute() for pool discovery.");
482
+ }
483
+ if (!this.steerSubgraph.trim()) {
484
+ throw new Error("steerSubgraph is required by execute() for pool discovery.");
485
+ }
480
486
  const dataConnector = new bundleDataConnector_js_1.DataConnector({
481
487
  wasmFile: _wasmFile,
482
488
  config: _vaultConfig,
@@ -489,7 +495,7 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
489
495
  dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), smartPoolExecutionContext), forceDeposit);
490
496
  _data = _data.map((element) => JSON.stringify(element));
491
497
  const result = yield dataConnector.executeBundle(_data);
492
- return JSON.parse(result);
498
+ return this.parseStrategyResult(result);
493
499
  });
494
500
  }
495
501
  /**
@@ -511,7 +517,7 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
511
517
  yield dataConnector.loadSync();
512
518
  dataConnector.initializeStrategyWithContext(executionContext, options.forceDeposit);
513
519
  const result = yield dataConnector.executeBundle(options.data.map((item) => JSON.stringify(item)));
514
- return JSON.parse(result);
520
+ return this.parseStrategyResult(result);
515
521
  }
516
522
  catch (error) {
517
523
  if (error instanceof types_js_1.ExecutionContextError)
@@ -520,6 +526,17 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
520
526
  }
521
527
  });
522
528
  }
529
+ /** T is the complete decoded JSON result. Only the exact sentinel skips JSON decoding. */
530
+ parseStrategyResult(result) {
531
+ if (result === "continue")
532
+ return result;
533
+ try {
534
+ return JSON.parse(result);
535
+ }
536
+ catch (error) {
537
+ throw new types_js_1.StrategyExecutionError(this.redactError(error));
538
+ }
539
+ }
523
540
  parseVaultConfig(vaultConfig) {
524
541
  try {
525
542
  return JSON.parse(vaultConfig);
@@ -603,7 +620,7 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
603
620
  dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), dynamicJobExecutionContext), forceDeposit);
604
621
  _data = _data.map((element) => JSON.stringify(element));
605
622
  const result = yield dataConnector.executeDynamicJobBundle(_data);
606
- return JSON.parse(result);
623
+ return this.parseStrategyResult(result);
607
624
  });
608
625
  }
609
626
  executeDynamicJobs(_wasmFile, _vaultConfig, _data, _job, rpc, forceDeposit) {
@@ -626,7 +643,7 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
626
643
  dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), dynamicJobExecutionContext), forceDeposit);
627
644
  _data = _data.map((element) => JSON.stringify(element));
628
645
  const result = yield dataConnector.executeDynamicJobBundle(_data);
629
- return JSON.parse(result);
646
+ return this.parseStrategyResult(result);
630
647
  });
631
648
  }
632
649
  getSmartPoolExecutionContext(currentExecutionContext, dataConnector, vaultConfig) {
@@ -7,7 +7,7 @@ export declare class ExecutionBase {
7
7
  protected delay(ms: number): Promise<void>;
8
8
  protected log(...args: Array<any>): void;
9
9
  protected getExecutionContext(dataConnector: DataConnector, vaultConfig: VaultConfigPayload): Promise<ExecutionContext>;
10
- execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess): Promise<Array<T>>;
10
+ execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess): Promise<T | Array<T> | "continue">;
11
11
  protected getDataConnectorVersion(dataConnector: DataConnector): Promise<number>;
12
12
  getAverageBlockTime(provider: PublicClient, blockCount?: number): Promise<number>;
13
13
  getBlockNumberFromAvgBlockTime(provider: PublicClient, targetTimestamp: number, avgBlockTime: number): Promise<number>;
@@ -156,6 +156,7 @@ class DataConnectorExecution extends executionBase_js_1.ExecutionBase {
156
156
  });
157
157
  }
158
158
  handleRequestResponse(dataConnector, initialRequest, context) {
159
+ var _a, _b;
159
160
  return __awaiter(this, void 0, void 0, function* () {
160
161
  let request = initialRequest;
161
162
  let response;
@@ -172,27 +173,39 @@ class DataConnectorExecution extends executionBase_js_1.ExecutionBase {
172
173
  }
173
174
  else {
174
175
  let parsedRequest = typeof request === "string" ? JSON.parse(request) : request;
175
- const url = (0, replace_old_subgraphs_js_1.changeUrlIfOld)(parsedRequest.url, dataConnector.configObj.subgraphStudioKey);
176
+ const graphApiKey = (_a = dataConnector.executionAppConfig.apiKeys) === null || _a === void 0 ? void 0 : _a.subgraphStudioKey;
177
+ const url = (0, replace_old_subgraphs_js_1.changeUrlIfOld)(parsedRequest.url, graphApiKey ? undefined : dataConnector.configObj.subgraphStudioKey);
176
178
  parsedRequest.url = url;
177
179
  let sentio = false;
180
+ let graph = false;
178
181
  try {
179
182
  const destination = new URL(axios_1.default.getUri(parsedRequest));
180
183
  const hostname = destination.hostname.toLowerCase();
184
+ graph =
185
+ (destination.origin === "https://gateway.thegraph.com" ||
186
+ destination.origin ===
187
+ "https://gateway-arbitrum.network.thegraph.com") &&
188
+ /^\/api\/(subgraphs|deployments)\/id\/[a-zA-Z0-9]+$/.test(destination.pathname) &&
189
+ !destination.username &&
190
+ !destination.password;
181
191
  sentio =
182
192
  destination.protocol === "https:" &&
183
193
  (hostname === "sentio.xyz" || hostname.endsWith(".sentio.xyz"));
184
194
  }
185
- catch (_a) {
195
+ catch (_c) {
186
196
  /* Axios will report an invalid URL when sending the request. */
187
197
  }
188
- parsedRequest.headers = Object.assign(Object.assign({ "Content-Type": url && !url.includes("subgraph-proxy-server")
198
+ const sentioApiKey = (_b = dataConnector.executionAppConfig.apiKeys) === null || _b === void 0 ? void 0 : _b.sentioApiKey;
199
+ parsedRequest.headers = Object.assign(Object.assign(Object.assign({ "Content-Type": url && !url.includes("subgraph-proxy-server")
189
200
  ? "application/json"
190
- : "text/plain;charset=UTF-8" }, (sentio
201
+ : "text/plain;charset=UTF-8" }, (sentio && sentioApiKey
191
202
  ? {
192
- "api-key": dataConnector.executionAppConfig.apiKeys.sentioApiKey,
203
+ "api-key": sentioApiKey,
193
204
  }
205
+ : {})), (graph && graphApiKey
206
+ ? { Authorization: `Bearer ${graphApiKey}` }
194
207
  : {})), parsedRequest.headers);
195
- if (sentio) {
208
+ if (sentio || (graph && graphApiKey)) {
196
209
  const { url, baseURL, method, params, data, headers, timeout, responseType, allowAbsoluteUrls, } = parsedRequest;
197
210
  parsedRequest = {
198
211
  url,
@@ -15,7 +15,7 @@ class SubgraphUrlReplacer {
15
15
  return url;
16
16
  }
17
17
  getArbitrumSubgraphUrl(subgraphId, isDeploymentId) {
18
- return `https://gateway-arbitrum.network.thegraph.com/api/${this.subgraphStudioKey}/${isDeploymentId ? "deployments" : "subgraphs"}/id/${subgraphId}`;
18
+ return `https://gateway-arbitrum.network.thegraph.com/api/${this.subgraphStudioKey ? `${this.subgraphStudioKey}/` : ""}${isDeploymentId ? "deployments" : "subgraphs"}/id/${subgraphId}`;
19
19
  }
20
20
  getDefaultConfigs() {
21
21
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerprotocol/data-connector-loader",
3
- "version": "5.0.0-next.5",
3
+ "version": "5.0.0-next.7",
4
4
  "description": "App Loader for Steer Protocol",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",