@steerprotocol/data-connector-loader 5.0.0-next.5 → 5.0.0-next.6
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/lib/esm/execution/executionApp.d.ts +8 -8
- package/lib/esm/execution/executionApp.js +14 -8
- package/lib/esm/execution/executionDataConnector.js +17 -4
- package/lib/esm/utils/replace-old-subgraphs.js +1 -1
- package/lib/execution/executionApp.d.ts +8 -8
- package/lib/execution/executionApp.js +15 -9
- package/lib/execution/executionDataConnector.js +19 -6
- package/lib/utils/replace-old-subgraphs.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
/**
|
|
9
|
-
steerSubgraph
|
|
10
|
-
|
|
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
|
-
/**
|
|
24
|
-
subgraphStudioKey
|
|
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
|
|
27
|
+
sentioApiKey?: string;
|
|
27
28
|
};
|
|
28
29
|
/** Maximum number of retries for execution operations. */
|
|
29
30
|
maxRetries?: number;
|
|
@@ -37,7 +38,6 @@ 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);
|
|
@@ -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
|
|
457
|
-
this.isAlgebraIntegralPool =
|
|
458
|
-
|
|
459
|
-
this.
|
|
460
|
-
this.
|
|
461
|
-
this.
|
|
462
|
-
this.sentioApiKey = config.apiKeys
|
|
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,
|
|
@@ -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
|
|
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":
|
|
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}
|
|
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
|
-
/**
|
|
9
|
-
steerSubgraph
|
|
10
|
-
|
|
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
|
-
/**
|
|
24
|
-
subgraphStudioKey
|
|
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
|
|
27
|
+
sentioApiKey?: string;
|
|
27
28
|
};
|
|
28
29
|
/** Maximum number of retries for execution operations. */
|
|
29
30
|
maxRetries?: number;
|
|
@@ -37,7 +38,6 @@ 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);
|
|
@@ -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 =
|
|
471
|
-
|
|
472
|
-
this.
|
|
473
|
-
this.
|
|
474
|
-
this.
|
|
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,
|
|
@@ -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
|
|
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 (
|
|
195
|
+
catch (_c) {
|
|
186
196
|
/* Axios will report an invalid URL when sending the request. */
|
|
187
197
|
}
|
|
188
|
-
|
|
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":
|
|
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}
|
|
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 [
|