@steerprotocol/data-connector-loader 4.0.0 → 4.0.2

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.
@@ -19,14 +19,15 @@ export declare class BundleBase {
19
19
  constructor(wasmFile: string | ArrayBuffer, _config: string, executionAppConfig: ExecutionAppConfig, identity?: ethers.Provider, etherRpcConfig?: EtherRpcConfig);
20
20
  load(): Promise<WasmModule>;
21
21
  loadSync(): WasmModule;
22
- execute(response: string): Promise<string>;
22
+ execute(response?: string): Promise<string | null>;
23
23
  transform(): Promise<string>;
24
24
  executeBundle(data: Array<any>): Promise<string>;
25
25
  executeDynamicJobBundle(data: Array<any>): Promise<string>;
26
26
  reset(): void;
27
27
  setExecutionContextStrategyExecution(executionContext: ExecutionContext, forceDeposit?: boolean): void;
28
28
  setExecutionContextDataConnector(executionContext: ExecutionContext): void;
29
- protected executeModule(response: string): Promise<string>;
29
+ protected executeModule(response: string): Promise<string | null>;
30
+ protected executeModuleWithResult(...params: Array<number | string | ArrayBuffer | null>): Promise<string | null>;
30
31
  getProvider(config: any): ethers.Provider | undefined;
31
32
  getResults(): string;
32
33
  version(): number;
@@ -81,8 +81,7 @@ class BundleBase {
81
81
  // If the module is still not initialized, throw an error
82
82
  if (!this.module)
83
83
  throw new Error('Module not initialized');
84
- // Call the main function with the response
85
- return yield this.module.execute(response);
84
+ return response === undefined ? yield this.executeModuleWithResult() : yield this.executeModuleWithResult(response);
86
85
  });
87
86
  }
88
87
  // For dynamic job data connector
@@ -124,8 +123,11 @@ class BundleBase {
124
123
  // If the module is still not initialized, throw an error
125
124
  if (!this.module)
126
125
  throw new Error('Module not initialized');
127
- // Call the main function with the response
128
- return this.module.execute(...data);
126
+ const result = yield this.executeModuleWithResult(...data);
127
+ if (result === null) {
128
+ throw new Error('Module execution returned null');
129
+ }
130
+ return result;
129
131
  });
130
132
  }
131
133
  executeDynamicJobBundle(data) {
@@ -145,8 +147,11 @@ class BundleBase {
145
147
  // If the module is still not initialized, throw an error
146
148
  if (!this.module)
147
149
  throw new Error('Module not initialized');
148
- // Call the main function with the response
149
- return this.module.execute(...data);
150
+ const result = yield this.executeModuleWithResult(...data);
151
+ if (result === null) {
152
+ throw new Error('Module execution returned null');
153
+ }
154
+ return result;
150
155
  });
151
156
  }
152
157
  reset() {
@@ -184,7 +189,15 @@ class BundleBase {
184
189
  if (!this.module) {
185
190
  throw new Error('Module not initialized');
186
191
  }
187
- return yield this.module.execute(response);
192
+ return yield this.executeModuleWithResult(response);
193
+ });
194
+ }
195
+ executeModuleWithResult(...params) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ if (!this.module) {
198
+ throw new Error('Module not initialized');
199
+ }
200
+ return yield this.module.execute(...params);
188
201
  });
189
202
  }
190
203
  // This function returns a provider based on the chainId of the request
@@ -19,14 +19,15 @@ export declare class BundleBase {
19
19
  constructor(wasmFile: string | ArrayBuffer, _config: string, executionAppConfig: ExecutionAppConfig, identity?: ethers.Provider, etherRpcConfig?: EtherRpcConfig);
20
20
  load(): Promise<WasmModule>;
21
21
  loadSync(): WasmModule;
22
- execute(response: string): Promise<string>;
22
+ execute(response?: string): Promise<string | null>;
23
23
  transform(): Promise<string>;
24
24
  executeBundle(data: Array<any>): Promise<string>;
25
25
  executeDynamicJobBundle(data: Array<any>): Promise<string>;
26
26
  reset(): void;
27
27
  setExecutionContextStrategyExecution(executionContext: ExecutionContext, forceDeposit?: boolean): void;
28
28
  setExecutionContextDataConnector(executionContext: ExecutionContext): void;
29
- protected executeModule(response: string): Promise<string>;
29
+ protected executeModule(response: string): Promise<string | null>;
30
+ protected executeModuleWithResult(...params: Array<number | string | ArrayBuffer | null>): Promise<string | null>;
30
31
  getProvider(config: any): ethers.Provider | undefined;
31
32
  getResults(): string;
32
33
  version(): number;
@@ -66,8 +66,7 @@ export class BundleBase {
66
66
  // If the module is still not initialized, throw an error
67
67
  if (!this.module)
68
68
  throw new Error('Module not initialized');
69
- // Call the main function with the response
70
- return await this.module.execute(response);
69
+ return response === undefined ? await this.executeModuleWithResult() : await this.executeModuleWithResult(response);
71
70
  }
72
71
  // For dynamic job data connector
73
72
  async transform() {
@@ -105,8 +104,11 @@ export class BundleBase {
105
104
  // If the module is still not initialized, throw an error
106
105
  if (!this.module)
107
106
  throw new Error('Module not initialized');
108
- // Call the main function with the response
109
- return this.module.execute(...data);
107
+ const result = await this.executeModuleWithResult(...data);
108
+ if (result === null) {
109
+ throw new Error('Module execution returned null');
110
+ }
111
+ return result;
110
112
  }
111
113
  async executeDynamicJobBundle(data) {
112
114
  if (!this.executionContext) {
@@ -124,8 +126,11 @@ export class BundleBase {
124
126
  // If the module is still not initialized, throw an error
125
127
  if (!this.module)
126
128
  throw new Error('Module not initialized');
127
- // Call the main function with the response
128
- return this.module.execute(...data);
129
+ const result = await this.executeModuleWithResult(...data);
130
+ if (result === null) {
131
+ throw new Error('Module execution returned null');
132
+ }
133
+ return result;
129
134
  }
130
135
  reset() {
131
136
  if (this.module && this.module['reset']) {
@@ -159,7 +164,13 @@ export class BundleBase {
159
164
  if (!this.module) {
160
165
  throw new Error('Module not initialized');
161
166
  }
162
- return await this.module.execute(response);
167
+ return await this.executeModuleWithResult(response);
168
+ }
169
+ async executeModuleWithResult(...params) {
170
+ if (!this.module) {
171
+ throw new Error('Module not initialized');
172
+ }
173
+ return await this.module.execute(...params);
163
174
  }
164
175
  // This function returns a provider based on the chainId of the request
165
176
  // The chainId is first checked in the data connector config, and if not found
@@ -31,7 +31,10 @@ export class DataConnectorExecution extends ExecutionBase {
31
31
  try {
32
32
  const executionContext = await this.getExecutionContext(dataConnector, vaultConfig);
33
33
  dataConnector.setExecutionContextDataConnector(executionContext);
34
- const initialRequest = await dataConnector.execute('');
34
+ const initialRequest = await dataConnector.execute();
35
+ if (initialRequest === null) {
36
+ throw new Error('Data connector returned null request');
37
+ }
35
38
  const finalResponse = await this.handleRequestResponse(dataConnector, pluginManager, initialRequest);
36
39
  const transformedData = await this.transformData(dataConnector, finalResponse);
37
40
  transformationData.push(transformedData);
@@ -47,7 +50,7 @@ export class DataConnectorExecution extends ExecutionBase {
47
50
  async executeV2Bundle(dataConnector, vaultConfig) {
48
51
  const executionContext = await this.getExecutionContext(dataConnector, vaultConfig);
49
52
  dataConnector.setExecutionContextDataConnector(executionContext);
50
- await dataConnector.execute('');
53
+ await dataConnector.execute();
51
54
  const result = await dataConnector.transform();
52
55
  return JSON.parse(result);
53
56
  }
@@ -62,7 +65,7 @@ export class DataConnectorExecution extends ExecutionBase {
62
65
  }
63
66
  const executionContext = await this.getExecutionContext(dataConnector, vaultConfig);
64
67
  dataConnector.setExecutionContextDataConnector(executionContext);
65
- await dataConnector.execute('');
68
+ await dataConnector.execute();
66
69
  const result = await dataConnector.transform();
67
70
  transformationData.push(JSON.parse(result));
68
71
  }
@@ -87,7 +90,11 @@ export class DataConnectorExecution extends ExecutionBase {
87
90
  await this.delay(1000);
88
91
  response = await fetchData(parsedRequest, 0);
89
92
  }
90
- request = await dataConnector.execute(JSON.stringify(response));
93
+ const nextRequest = await dataConnector.execute(JSON.stringify(response));
94
+ if (nextRequest === null) {
95
+ throw new Error('Data connector returned null request');
96
+ }
97
+ request = nextRequest;
91
98
  }
92
99
  }
93
100
  catch (e) {
@@ -44,7 +44,10 @@ class DataConnectorExecution extends executionBase_js_1.ExecutionBase {
44
44
  try {
45
45
  const executionContext = yield this.getExecutionContext(dataConnector, vaultConfig);
46
46
  dataConnector.setExecutionContextDataConnector(executionContext);
47
- const initialRequest = yield dataConnector.execute('');
47
+ const initialRequest = yield dataConnector.execute();
48
+ if (initialRequest === null) {
49
+ throw new Error('Data connector returned null request');
50
+ }
48
51
  const finalResponse = yield this.handleRequestResponse(dataConnector, pluginManager, initialRequest);
49
52
  const transformedData = yield this.transformData(dataConnector, finalResponse);
50
53
  transformationData.push(transformedData);
@@ -62,7 +65,7 @@ class DataConnectorExecution extends executionBase_js_1.ExecutionBase {
62
65
  return __awaiter(this, void 0, void 0, function* () {
63
66
  const executionContext = yield this.getExecutionContext(dataConnector, vaultConfig);
64
67
  dataConnector.setExecutionContextDataConnector(executionContext);
65
- yield dataConnector.execute('');
68
+ yield dataConnector.execute();
66
69
  const result = yield dataConnector.transform();
67
70
  return JSON.parse(result);
68
71
  });
@@ -79,7 +82,7 @@ class DataConnectorExecution extends executionBase_js_1.ExecutionBase {
79
82
  }
80
83
  const executionContext = yield this.getExecutionContext(dataConnector, vaultConfig);
81
84
  dataConnector.setExecutionContextDataConnector(executionContext);
82
- yield dataConnector.execute('');
85
+ yield dataConnector.execute();
83
86
  const result = yield dataConnector.transform();
84
87
  transformationData.push(JSON.parse(result));
85
88
  }
@@ -103,7 +106,11 @@ class DataConnectorExecution extends executionBase_js_1.ExecutionBase {
103
106
  yield this.delay(1000);
104
107
  response = yield (0, utils_js_1.fetchData)(parsedRequest, 0);
105
108
  }
106
- request = yield dataConnector.execute(JSON.stringify(response));
109
+ const nextRequest = yield dataConnector.execute(JSON.stringify(response));
110
+ if (nextRequest === null) {
111
+ throw new Error('Data connector returned null request');
112
+ }
113
+ request = nextRequest;
107
114
  }
108
115
  }
109
116
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerprotocol/data-connector-loader",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "App Loader for Steer Protocol",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -76,8 +76,8 @@
76
76
  "@commitlint/cli": "^20.5.0",
77
77
  "@commitlint/config-conventional": "^20.5.0",
78
78
  "@semantic-release/commit-analyzer": "^13.0.1",
79
- "@semantic-release/github": "^10.3.5",
80
- "@semantic-release/npm": "^12.0.2",
79
+ "@semantic-release/github": "^12.0.6",
80
+ "@semantic-release/npm": "^13.1.5",
81
81
  "@semantic-release/release-notes-generator": "^14.1.0",
82
82
  "@types/jest": "29.2.4",
83
83
  "@typescript-eslint/eslint-plugin": "5.46.0",
@@ -91,7 +91,7 @@
91
91
  "husky": "^9.1.7",
92
92
  "jest": "29.3.1",
93
93
  "prettier": "2.8.1",
94
- "semantic-release": "^24.2.9",
94
+ "semantic-release": "^25.0.3",
95
95
  "ts-jest": "29.0.3",
96
96
  "typescript": "5.0.4",
97
97
  "viem": "^2.42.1"
@@ -100,7 +100,7 @@
100
100
  "lib/**/*"
101
101
  ],
102
102
  "dependencies": {
103
- "@steerprotocol/app-loader": "^3.0.0",
103
+ "@steerprotocol/app-loader": "^3.0.4",
104
104
  "@steerprotocol/sdk": "^2.0.0",
105
105
  "@steerprotocol/strategy-utils": "^3.1.2",
106
106
  "axios": "^1.3.4",