@defisaver/automation-sdk 1.0.8 → 1.0.10

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.
@@ -43,7 +43,9 @@ export default class StrategiesAutomation extends Automation {
43
43
  }
44
44
  getUpdateDataEventsFromSubStorage(options) {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
- return this.getEventFromSubStorage('UpdateData', options);
46
+ const events = yield this.getEventFromSubStorage('UpdateData', options);
47
+ /** @dev - Some RPCs sort events differently */
48
+ return events.sort((a, b) => a.blockNumber - b.blockNumber);
47
49
  });
48
50
  }
49
51
  getParsedSubscriptions(parseData) {
@@ -61,7 +63,7 @@ export default class StrategiesAutomation extends Automation {
61
63
  var _a;
62
64
  let latestUpdate = subscriptionEvents[index];
63
65
  if (latestUpdate.subHash !== (sub === null || sub === void 0 ? void 0 : sub.strategySubHash)) {
64
- const updates = yield this.getUpdateDataEventsFromSubStorage(Object.assign(Object.assign({}, addToObjectIf(!!_options, _options)), { filter: latestUpdate.subId }));
66
+ const updates = yield this.getUpdateDataEventsFromSubStorage(Object.assign(Object.assign({}, addToObjectIf(!!_options, _options)), { filter: { subId: latestUpdate.subId } }));
65
67
  latestUpdate = Object.assign(Object.assign({}, latestUpdate), (_a = updates === null || updates === void 0 ? void 0 : updates[updates.length - 1]) === null || _a === void 0 ? void 0 : _a.returnValues);
66
68
  }
67
69
  return this.getParsedSubscriptions({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/automation-sdk",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "",
5
5
  "main": "./umd/index.js",
6
6
  "module": "./esm/index.js",
@@ -1,5 +1,5 @@
1
1
  import type Web3 from 'web3';
2
- import type { PastEventOptions, Filter } from 'web3-eth-contract';
2
+ import type { PastEventOptions } from 'web3-eth-contract';
3
3
  import type {
4
4
  Position, Interfaces, EthereumAddress,
5
5
  SubscriptionOptions, Contract, ParseData, PlaceholderType,
@@ -59,7 +59,9 @@ export default class StrategiesAutomation extends Automation {
59
59
  }
60
60
 
61
61
  protected async getUpdateDataEventsFromSubStorage(options?: PastEventOptions) {
62
- return this.getEventFromSubStorage('UpdateData', options);
62
+ const events = await this.getEventFromSubStorage('UpdateData', options);
63
+ /** @dev - Some RPCs sort events differently */
64
+ return events.sort((a, b) => a.blockNumber - b.blockNumber);
63
65
  }
64
66
 
65
67
  protected getParsedSubscriptions(parseData: ParseData) {
@@ -84,7 +86,10 @@ export default class StrategiesAutomation extends Automation {
84
86
  let latestUpdate = subscriptionEvents[index];
85
87
 
86
88
  if (latestUpdate.subHash !== sub?.strategySubHash) {
87
- const updates = await this.getUpdateDataEventsFromSubStorage({ ...addToObjectIf(!!_options, _options), filter: latestUpdate.subId as any as Filter });
89
+ const updates = await this.getUpdateDataEventsFromSubStorage({
90
+ ...addToObjectIf(!!_options, _options),
91
+ filter: { subId: latestUpdate.subId },
92
+ });
88
93
  latestUpdate = {
89
94
  ...latestUpdate, // Update is missing proxy, hence this
90
95
  ...updates?.[updates.length - 1]?.returnValues,
package/umd/index.js CHANGED
@@ -1196,7 +1196,9 @@ class StrategiesAutomation extends _Automation__WEBPACK_IMPORTED_MODULE_3__["def
1196
1196
  getUpdateDataEventsFromSubStorage(options) {
1197
1197
  var _this4 = this;
1198
1198
  return _asyncToGenerator(function* () {
1199
- return _this4.getEventFromSubStorage('UpdateData', options);
1199
+ var events = yield _this4.getEventFromSubStorage('UpdateData', options);
1200
+ /** @dev - Some RPCs sort events differently */
1201
+ return events.sort((a, b) => a.blockNumber - b.blockNumber);
1200
1202
  })();
1201
1203
  }
1202
1204
  getParsedSubscriptions(parseData) {
@@ -1222,7 +1224,9 @@ class StrategiesAutomation extends _Automation__WEBPACK_IMPORTED_MODULE_3__["def
1222
1224
  if (latestUpdate.subHash !== (sub === null || sub === void 0 ? void 0 : sub.strategySubHash)) {
1223
1225
  var _updates;
1224
1226
  var updates = yield _this5.getUpdateDataEventsFromSubStorage(_objectSpread(_objectSpread({}, (0,_services_utils__WEBPACK_IMPORTED_MODULE_0__.addToObjectIf)(!!_options, _options)), {}, {
1225
- filter: latestUpdate.subId
1227
+ filter: {
1228
+ subId: latestUpdate.subId
1229
+ }
1226
1230
  }));
1227
1231
  latestUpdate = _objectSpread(_objectSpread({}, latestUpdate), updates === null || updates === void 0 ? void 0 : (_updates = updates[updates.length - 1]) === null || _updates === void 0 ? void 0 : _updates.returnValues);
1228
1232
  }