@gearbox-protocol/sdk 7.7.0 → 7.8.0

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.
@@ -210,7 +210,7 @@ class GearboxSDK {
210
210
  return this;
211
211
  }
212
212
  #hydrate(options, state) {
213
- const { logger: _logger, redstone, ...opts } = options;
213
+ const { logger: _logger, ...opts } = options;
214
214
  if (state.version !== STATE_VERSION) {
215
215
  throw new Error(
216
216
  `hydrated state version is ${state.version}, but expected ${STATE_VERSION}`
@@ -218,7 +218,7 @@ class GearboxSDK {
218
218
  }
219
219
  this.#currentBlock = state.currentBlock;
220
220
  this.#timestamp = state.timestamp;
221
- this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, { redstone });
221
+ this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, { redstone: opts.redstone });
222
222
  this.#addressProvider = (0, import_core.hydrateAddressProvider)(this, state.addressProvider);
223
223
  this.logger?.debug(
224
224
  `address provider version: ${this.#addressProvider.version}`
@@ -254,6 +254,19 @@ class GearboxSDK {
254
254
  }
255
255
  await this.#attach(this.#attachConfig);
256
256
  }
257
+ /**
258
+ * Rehydrate existing SDK from new state without re-creating instance
259
+ */
260
+ rehydrate(state) {
261
+ if (!this.#attachConfig) {
262
+ throw new Error("cannot rehydrate, attach config is not set");
263
+ }
264
+ const opts = {
265
+ ignoreUpdateablePrices: this.#attachConfig.ignoreUpdateablePrices,
266
+ redstone: this.#attachConfig.redstone
267
+ };
268
+ this.#hydrate(opts, state);
269
+ }
257
270
  /**
258
271
  * Converts contract call into some human-friendly string
259
272
  * This method is safe and should not throw
@@ -208,7 +208,7 @@ class GearboxSDK {
208
208
  return this;
209
209
  }
210
210
  #hydrate(options, state) {
211
- const { logger: _logger, redstone, ...opts } = options;
211
+ const { logger: _logger, ...opts } = options;
212
212
  if (state.version !== STATE_VERSION) {
213
213
  throw new Error(
214
214
  `hydrated state version is ${state.version}, but expected ${STATE_VERSION}`
@@ -216,7 +216,7 @@ class GearboxSDK {
216
216
  }
217
217
  this.#currentBlock = state.currentBlock;
218
218
  this.#timestamp = state.timestamp;
219
- this.#priceFeeds = new PriceFeedRegister(this, { redstone });
219
+ this.#priceFeeds = new PriceFeedRegister(this, { redstone: opts.redstone });
220
220
  this.#addressProvider = hydrateAddressProvider(this, state.addressProvider);
221
221
  this.logger?.debug(
222
222
  `address provider version: ${this.#addressProvider.version}`
@@ -252,6 +252,19 @@ class GearboxSDK {
252
252
  }
253
253
  await this.#attach(this.#attachConfig);
254
254
  }
255
+ /**
256
+ * Rehydrate existing SDK from new state without re-creating instance
257
+ */
258
+ rehydrate(state) {
259
+ if (!this.#attachConfig) {
260
+ throw new Error("cannot rehydrate, attach config is not set");
261
+ }
262
+ const opts = {
263
+ ignoreUpdateablePrices: this.#attachConfig.ignoreUpdateablePrices,
264
+ redstone: this.#attachConfig.redstone
265
+ };
266
+ this.#hydrate(opts, state);
267
+ }
255
268
  /**
256
269
  * Converts contract call into some human-friendly string
257
270
  * This method is safe and should not throw
@@ -92,6 +92,10 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
92
92
  * Be mindful of block number, for example
93
93
  */
94
94
  reattach(): Promise<void>;
95
+ /**
96
+ * Rehydrate existing SDK from new state without re-creating instance
97
+ */
98
+ rehydrate(state: GearboxState<Plugins>): void;
95
99
  /**
96
100
  * Converts contract call into some human-friendly string
97
101
  * This method is safe and should not throw
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "7.7.0",
3
+ "version": "7.8.0",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",