@gearbox-protocol/sdk 7.2.0 → 7.3.1

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.
@@ -32,6 +32,12 @@ class AccountsCounterPlugin extends import_sdk.SDKConstruct {
32
32
  async syncState() {
33
33
  await this.#load();
34
34
  }
35
+ get accounts() {
36
+ return this.#accounts;
37
+ }
38
+ forCreditManager(addr) {
39
+ return this.#accounts.mustGet(addr);
40
+ }
35
41
  async #load() {
36
42
  const [compressor] = this.sdk.addressProvider.mustGetLatest(
37
43
  import_sdk.AP_CREDIT_ACCOUNT_COMPRESSOR,
@@ -123,6 +123,12 @@ class AddressMap {
123
123
  get name() {
124
124
  return this.#name;
125
125
  }
126
+ static fromRecord(record) {
127
+ return new AddressMap(Object.entries(record));
128
+ }
129
+ static fromMappedArray(array, mapFn) {
130
+ return new AddressMap(array.map((item) => [mapFn(item), item]));
131
+ }
126
132
  }
127
133
  // Annotate the CommonJS export names for ESM import in node:
128
134
  0 && (module.exports = {
@@ -17,6 +17,12 @@ class AccountsCounterPlugin extends SDKConstruct {
17
17
  async syncState() {
18
18
  await this.#load();
19
19
  }
20
+ get accounts() {
21
+ return this.#accounts;
22
+ }
23
+ forCreditManager(addr) {
24
+ return this.#accounts.mustGet(addr);
25
+ }
20
26
  async #load() {
21
27
  const [compressor] = this.sdk.addressProvider.mustGetLatest(
22
28
  AP_CREDIT_ACCOUNT_COMPRESSOR,
@@ -100,6 +100,12 @@ class AddressMap {
100
100
  get name() {
101
101
  return this.#name;
102
102
  }
103
+ static fromRecord(record) {
104
+ return new AddressMap(Object.entries(record));
105
+ }
106
+ static fromMappedArray(array, mapFn) {
107
+ return new AddressMap(array.map((item) => [mapFn(item), item]));
108
+ }
103
109
  }
104
110
  export {
105
111
  AddressMap
@@ -1,6 +1,6 @@
1
1
  import type { Address } from "viem";
2
2
  import type { IGearboxSDKPlugin, IPluginState } from "../sdk/index.js";
3
- import { SDKConstruct } from "../sdk/index.js";
3
+ import { AddressMap, SDKConstruct } from "../sdk/index.js";
4
4
  export interface AccountsCounterPluginState extends IPluginState {
5
5
  /**
6
6
  * Mapping of credit manager addresses to the number of accounts
@@ -12,6 +12,8 @@ export declare class AccountsCounterPlugin extends SDKConstruct implements IGear
12
12
  readonly version = 1;
13
13
  attach(): Promise<void>;
14
14
  syncState(): Promise<void>;
15
+ get accounts(): AddressMap<bigint>;
16
+ forCreditManager(addr: Address): bigint;
15
17
  get state(): AccountsCounterPluginState;
16
18
  hydrate(state: AccountsCounterPluginState): void;
17
19
  }
@@ -40,4 +40,6 @@ export declare class AddressMap<T> {
40
40
  get size(): number;
41
41
  freeze(): void;
42
42
  protected get name(): string | undefined;
43
+ static fromRecord<T>(record: Record<Address, T>): AddressMap<T>;
44
+ static fromMappedArray<T>(array: T[], mapFn: (item: T) => Address): AddressMap<T>;
43
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "7.2.0",
3
+ "version": "7.3.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",