@gearbox-protocol/sdk 12.9.0-txparser.4 → 12.9.0-txparser.5

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.
@@ -26,7 +26,7 @@ var import_createAdapter = require("../plugins/adapters/createAdapter.js");
26
26
  var import_sdk = require("../sdk/index.js");
27
27
  function populateContractsRegister(options) {
28
28
  const { client, deployments, tokens, logger, strict } = options;
29
- const register = import_sdk.ChainContractsRegister.for(client, logger);
29
+ const register = new import_sdk.ChainContractsRegister(client, logger);
30
30
  for (const d of deployments) {
31
31
  let contractType;
32
32
  if ("contractType" in d) {
@@ -36,13 +36,13 @@ function populateContractsRegister(options) {
36
36
  }
37
37
  if (contractType === "CREDIT_FACADE" && (0, import_sdk.isV310)(d.version)) {
38
38
  new import_sdk.CreditFacadeV310BaseContract(
39
- { client: register.client, logger },
39
+ { register, logger },
40
40
  { addr: d.address, version: d.version, contractType }
41
41
  );
42
42
  } else if (contractType.startsWith("ADAPTER::")) {
43
43
  (0, import_createAdapter.createAdapter)(
44
44
  {
45
- client: register.client,
45
+ register,
46
46
  logger
47
47
  },
48
48
  {
@@ -51,15 +51,15 @@ class BaseContract extends import_Construct.Construct {
51
51
  version;
52
52
  address;
53
53
  name;
54
- constructor({ client, logger }, args) {
55
- super({ client, logger });
54
+ constructor(options, args) {
55
+ super(options);
56
56
  this.abi = args.abi;
57
57
  this.address = (0, import_viem.getAddress)(args.addr);
58
58
  this.contract = (0, import_viem.getContract)({
59
59
  address: this.address,
60
60
  // add exceptions for better error decoding
61
61
  abi: [...this.abi, ...import_errors.errorAbis],
62
- client
62
+ client: this.client
63
63
  });
64
64
  this.version = Number(args.version || 0);
65
65
  this.contractType = args.contractType ?? "";
@@ -31,9 +31,17 @@ class Construct {
31
31
  * Indicates that contract state needs to be updated
32
32
  */
33
33
  #dirty = false;
34
- constructor({ client, logger }) {
35
- this.client = client;
36
- this.register = import_ChainContractsRegister.ChainContractsRegister.for(client, logger);
34
+ constructor(options) {
35
+ const { logger } = options;
36
+ if ("client" in options) {
37
+ const { client } = options;
38
+ this.client = client;
39
+ this.register = import_ChainContractsRegister.ChainContractsRegister.for(client, logger);
40
+ } else {
41
+ const { register } = options;
42
+ this.register = register;
43
+ this.client = register.client;
44
+ }
37
45
  this.logger = (0, import_utils.childLogger)(
38
46
  this.constructor.name,
39
47
  this.register.logger ?? logger
@@ -11,7 +11,7 @@ import {
11
11
  } from "../sdk/index.js";
12
12
  function populateContractsRegister(options) {
13
13
  const { client, deployments, tokens, logger, strict } = options;
14
- const register = ChainContractsRegister.for(client, logger);
14
+ const register = new ChainContractsRegister(client, logger);
15
15
  for (const d of deployments) {
16
16
  let contractType;
17
17
  if ("contractType" in d) {
@@ -21,13 +21,13 @@ function populateContractsRegister(options) {
21
21
  }
22
22
  if (contractType === "CREDIT_FACADE" && isV310(d.version)) {
23
23
  new CreditFacadeV310BaseContract(
24
- { client: register.client, logger },
24
+ { register, logger },
25
25
  { addr: d.address, version: d.version, contractType }
26
26
  );
27
27
  } else if (contractType.startsWith("ADAPTER::")) {
28
28
  createAdapter(
29
29
  {
30
- client: register.client,
30
+ register,
31
31
  logger
32
32
  },
33
33
  {
@@ -41,15 +41,15 @@ class BaseContract extends Construct {
41
41
  version;
42
42
  address;
43
43
  name;
44
- constructor({ client, logger }, args) {
45
- super({ client, logger });
44
+ constructor(options, args) {
45
+ super(options);
46
46
  this.abi = args.abi;
47
47
  this.address = getAddress(args.addr);
48
48
  this.contract = getContract({
49
49
  address: this.address,
50
50
  // add exceptions for better error decoding
51
51
  abi: [...this.abi, ...errorAbis],
52
- client
52
+ client: this.client
53
53
  });
54
54
  this.version = Number(args.version || 0);
55
55
  this.contractType = args.contractType ?? "";
@@ -8,9 +8,17 @@ class Construct {
8
8
  * Indicates that contract state needs to be updated
9
9
  */
10
10
  #dirty = false;
11
- constructor({ client, logger }) {
12
- this.client = client;
13
- this.register = ChainContractsRegister.for(client, logger);
11
+ constructor(options) {
12
+ const { logger } = options;
13
+ if ("client" in options) {
14
+ const { client } = options;
15
+ this.client = client;
16
+ this.register = ChainContractsRegister.for(client, logger);
17
+ } else {
18
+ const { register } = options;
19
+ this.register = register;
20
+ this.client = register.client;
21
+ }
14
22
  this.logger = childLogger(
15
23
  this.constructor.name,
16
24
  this.register.logger ?? logger
@@ -28,7 +28,7 @@ export declare class BaseContract<abi extends Abi | readonly unknown[]> extends
28
28
  readonly version: number;
29
29
  readonly address: Address;
30
30
  readonly name: string;
31
- constructor({ client, logger }: ConstructOptions, args: BaseContractArgs<abi>);
31
+ constructor(options: ConstructOptions, args: BaseContractArgs<abi>);
32
32
  stateHuman(_?: boolean): BaseContractStateHuman;
33
33
  /**
34
34
  * Updates (or not) contract's internal state from event
@@ -3,16 +3,19 @@ import type { NetworkType } from "../chain/index.js";
3
3
  import type { ILogger } from "../types/index.js";
4
4
  import { ChainContractsRegister } from "./ChainContractsRegister.js";
5
5
  import type { TokensMeta } from "./TokensMeta.js";
6
- export interface ConstructOptions {
6
+ export type ConstructOptions = {
7
7
  client: PublicClient<Transport, Chain>;
8
8
  logger?: ILogger;
9
- }
9
+ } | {
10
+ register: ChainContractsRegister;
11
+ logger?: ILogger;
12
+ };
10
13
  export declare class Construct {
11
14
  #private;
12
15
  readonly logger?: ILogger;
13
16
  readonly client: PublicClient<Transport, Chain>;
14
17
  readonly register: ChainContractsRegister;
15
- constructor({ client, logger }: ConstructOptions);
18
+ constructor(options: ConstructOptions);
16
19
  get chain(): Chain;
17
20
  get chainId(): number;
18
21
  get networkType(): NetworkType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "12.9.0-txparser.4",
3
+ "version": "12.9.0-txparser.5",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",