@gearbox-protocol/sdk 17.12.1 → 17.12.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.
@@ -35,6 +35,8 @@ let viem = require("viem");
35
35
  **/
36
36
  var ChainsNamespace = class extends require_offchain_AbstractOffchainNamespace.AbstractOffchainNamespace {
37
37
  #clients = /* @__PURE__ */ new Map();
38
+ /** Transports the caller supplied, by chain id. See {@link #client}. */
39
+ #transports;
38
40
  #chains;
39
41
  #attaching;
40
42
  /** The scope {@link attach} settled on, which {@link summary} follows. */
@@ -44,6 +46,7 @@ var ChainsNamespace = class extends require_offchain_AbstractOffchainNamespace.A
44
46
  ...options,
45
47
  chainIds: []
46
48
  });
49
+ this.#transports = options.transports ?? {};
47
50
  }
48
51
  /**
49
52
  * Reads the chain list off the backend and builds a client for each chain
@@ -147,14 +150,17 @@ var ChainsNamespace = class extends require_offchain_AbstractOffchainNamespace.A
147
150
  this.#chains = chains;
148
151
  }
149
152
  /**
150
- * A client over the chain's own public endpoints, or nothing when this SDK
151
- * has no definition for it.
153
+ * A client over the transport the caller gave for the chain, or over the
154
+ * chain's own public endpoints, or nothing when this SDK has no definition
155
+ * for it.
152
156
  *
153
157
  * The backend will not hand over its endpoints — they carry provider keys —
154
- * so the chain definition is all there is to go on. A chain the SDK does
155
- * not know stays in {@link list}, because the backend serves it and its
156
- * rows are readable through the backend; only the calls that have to reach
157
- * it directly fail, and they say which chain they could not reach.
158
+ * so without `transports` the chain definition is all there is to go on,
159
+ * and its public endpoints rate limit anything past a glance. A caller that
160
+ * reads in earnest supplies its own. A chain the SDK does not know stays in
161
+ * {@link list}, because the backend serves it and its rows are readable
162
+ * through the backend; only the calls that have to reach it directly fail,
163
+ * and they say which chain they could not reach.
158
164
  **/
159
165
  #client(chainId) {
160
166
  let chain;
@@ -164,6 +170,11 @@ var ChainsNamespace = class extends require_offchain_AbstractOffchainNamespace.A
164
170
  this.logger?.warn(`no chain definition for ${chainId}: it will be listed, but nothing can be read off it directly`);
165
171
  return;
166
172
  }
173
+ const supplied = this.#transports[chainId];
174
+ if (supplied) return (0, viem.createPublicClient)({
175
+ chain,
176
+ transport: supplied
177
+ });
167
178
  const urls = chain.rpcUrls.default.http;
168
179
  if (urls.length === 0) {
169
180
  this.logger?.warn(`no public endpoint for chain ${chainId}`);
@@ -7,10 +7,8 @@ const require_onchain_base_ChainContractsRegister = require("../../../onchain/ba
7
7
  const require_onchain_OnchainSDK = require("../../../onchain/OnchainSDK.js");
8
8
  require("../../../onchain/index.js");
9
9
  const require_permissionless_api_errors = require("../errors.js");
10
- const require_permissionless_utils_literals = require("../../utils/literals.js");
11
10
  const require_permissionless_bindings_price_feed_store = require("../../bindings/price-feed-store.js");
12
11
  require("../../deployment/addresses.js");
13
- const require_permissionless_bindings_address_provider = require("../../bindings/address-provider.js");
14
12
  const require_permissionless_bindings_instance_manager = require("../../bindings/instance-manager.js");
15
13
  const require_permissionless_utils_governance_batch = require("../../utils/governance/batch.js");
16
14
  const require_permissionless_utils_price_update_get_updatable_feeds = require("../../utils/price-update/get-updatable-feeds.js");
@@ -163,8 +161,7 @@ var InstanceOwnerTransactions = class {
163
161
  **/
164
162
  async #batchContext(chainId) {
165
163
  const client = this.#chains.client(chainId);
166
- const addressProvider = new require_permissionless_bindings_address_provider.AddressProviderContract("0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38", client);
167
- const instanceManager = new require_permissionless_bindings_instance_manager.InstanceManagerContract(await addressProvider.getAddressOrRevert(require_permissionless_utils_literals.INSTANCE_MANAGER), new require_onchain_base_ChainContractsRegister.ChainContractsRegister(client));
164
+ const instanceManager = new require_permissionless_bindings_instance_manager.InstanceManagerContract("0x77777777144339Bdc3aCceE992D8d4D31734CB2e", new require_onchain_base_ChainContractsRegister.ChainContractsRegister(client));
168
165
  return {
169
166
  chainId,
170
167
  client,
@@ -2,7 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_permissionless_bindings_bytecode_repository = require("./bytecode-repository.js");
3
3
  const require_permissionless_bindings_pricefeeds_index = require("./pricefeeds/index.js");
4
4
  const require_permissionless_bindings_price_feed_store = require("./price-feed-store.js");
5
- const require_permissionless_bindings_address_provider = require("./address-provider.js");
6
5
  const require_permissionless_bindings_compressors_token_compressor = require("./compressors/token-compressor.js");
7
6
  const require_permissionless_bindings_compressors_withdrawal_compressor = require("./compressors/withdrawal-compressor.js");
8
7
  require("./compressors/index.js");
@@ -10,6 +9,7 @@ const require_permissionless_bindings_router_routing_manager = require("./router
10
9
  require("./router/index.js");
11
10
  const require_permissionless_bindings_treasury_splitter = require("./treasury-splitter.js");
12
11
  const require_permissionless_bindings_instance_manager = require("./instance-manager.js");
12
+ const require_permissionless_bindings_address_provider = require("./address-provider.js");
13
13
  const require_permissionless_bindings_market_configurator_factory = require("./market-configurator-factory.js");
14
14
  const require_permissionless_bindings_cross_chain_multisig = require("./cross-chain-multisig.js");
15
15
  const require_permissionless_bindings_types = require("./types.js");
@@ -12,7 +12,6 @@ const require_permissionless_utils_abi_encoder = require("./utils/abi-encoder.js
12
12
  const require_permissionless_api_deploy_PermissionlessDeploy = require("./api/deploy/PermissionlessDeploy.js");
13
13
  const require_permissionless_utils_price_update_get_prices = require("./utils/price-update/get-prices.js");
14
14
  const require_permissionless_api_oracles_PermissionlessOracles = require("./api/oracles/PermissionlessOracles.js");
15
- const require_permissionless_bindings_address_provider = require("./bindings/address-provider.js");
16
15
  const require_permissionless_bindings_compressors_token_compressor = require("./bindings/compressors/token-compressor.js");
17
16
  const require_permissionless_bindings_compressors_withdrawal_compressor = require("./bindings/compressors/withdrawal-compressor.js");
18
17
  const require_permissionless_bindings_router_routing_manager = require("./bindings/router/routing-manager.js");
@@ -23,6 +22,7 @@ const require_permissionless_utils_price_update_get_updatable_feeds = require(".
23
22
  const require_permissionless_api_transactions_InstanceOwnerTransactions = require("./api/transactions/InstanceOwnerTransactions.js");
24
23
  const require_permissionless_api_GearboxPermissionless = require("./api/GearboxPermissionless.js");
25
24
  require("./api/index.js");
25
+ const require_permissionless_bindings_address_provider = require("./bindings/address-provider.js");
26
26
  const require_permissionless_bindings_market_configurator_factory = require("./bindings/market-configurator-factory.js");
27
27
  const require_permissionless_bindings_cross_chain_multisig = require("./bindings/cross-chain-multisig.js");
28
28
  const require_permissionless_utils_create2 = require("./utils/create2.js");
@@ -34,6 +34,8 @@ import { createPublicClient, fallback, http } from "viem";
34
34
  **/
35
35
  var ChainsNamespace = class extends AbstractOffchainNamespace {
36
36
  #clients = /* @__PURE__ */ new Map();
37
+ /** Transports the caller supplied, by chain id. See {@link #client}. */
38
+ #transports;
37
39
  #chains;
38
40
  #attaching;
39
41
  /** The scope {@link attach} settled on, which {@link summary} follows. */
@@ -43,6 +45,7 @@ var ChainsNamespace = class extends AbstractOffchainNamespace {
43
45
  ...options,
44
46
  chainIds: []
45
47
  });
48
+ this.#transports = options.transports ?? {};
46
49
  }
47
50
  /**
48
51
  * Reads the chain list off the backend and builds a client for each chain
@@ -146,14 +149,17 @@ var ChainsNamespace = class extends AbstractOffchainNamespace {
146
149
  this.#chains = chains;
147
150
  }
148
151
  /**
149
- * A client over the chain's own public endpoints, or nothing when this SDK
150
- * has no definition for it.
152
+ * A client over the transport the caller gave for the chain, or over the
153
+ * chain's own public endpoints, or nothing when this SDK has no definition
154
+ * for it.
151
155
  *
152
156
  * The backend will not hand over its endpoints — they carry provider keys —
153
- * so the chain definition is all there is to go on. A chain the SDK does
154
- * not know stays in {@link list}, because the backend serves it and its
155
- * rows are readable through the backend; only the calls that have to reach
156
- * it directly fail, and they say which chain they could not reach.
157
+ * so without `transports` the chain definition is all there is to go on,
158
+ * and its public endpoints rate limit anything past a glance. A caller that
159
+ * reads in earnest supplies its own. A chain the SDK does not know stays in
160
+ * {@link list}, because the backend serves it and its rows are readable
161
+ * through the backend; only the calls that have to reach it directly fail,
162
+ * and they say which chain they could not reach.
157
163
  **/
158
164
  #client(chainId) {
159
165
  let chain;
@@ -163,6 +169,11 @@ var ChainsNamespace = class extends AbstractOffchainNamespace {
163
169
  this.logger?.warn(`no chain definition for ${chainId}: it will be listed, but nothing can be read off it directly`);
164
170
  return;
165
171
  }
172
+ const supplied = this.#transports[chainId];
173
+ if (supplied) return createPublicClient({
174
+ chain,
175
+ transport: supplied
176
+ });
166
177
  const urls = chain.rpcUrls.default.http;
167
178
  if (urls.length === 0) {
168
179
  this.logger?.warn(`no public endpoint for chain ${chainId}`);
@@ -6,10 +6,8 @@ import { ChainContractsRegister } from "../../../onchain/base/ChainContractsRegi
6
6
  import { OnchainSDK } from "../../../onchain/OnchainSDK.js";
7
7
  import "../../../onchain/index.js";
8
8
  import { PriceFeedNotInStoreError } from "../errors.js";
9
- import { INSTANCE_MANAGER } from "../../utils/literals.js";
10
9
  import { PriceFeedStoreContract } from "../../bindings/price-feed-store.js";
11
10
  import "../../deployment/addresses.js";
12
- import { AddressProviderContract } from "../../bindings/address-provider.js";
13
11
  import { InstanceManagerContract } from "../../bindings/instance-manager.js";
14
12
  import { convertRawTxToSafeMultisigTx, getSafeBatch } from "../../utils/governance/batch.js";
15
13
  import { getUpdatablePriceFeeds } from "../../utils/price-update/get-updatable-feeds.js";
@@ -162,8 +160,7 @@ var InstanceOwnerTransactions = class {
162
160
  **/
163
161
  async #batchContext(chainId) {
164
162
  const client = this.#chains.client(chainId);
165
- const addressProvider = new AddressProviderContract("0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38", client);
166
- const instanceManager = new InstanceManagerContract(await addressProvider.getAddressOrRevert(INSTANCE_MANAGER), new ChainContractsRegister(client));
163
+ const instanceManager = new InstanceManagerContract("0x77777777144339Bdc3aCceE992D8d4D31734CB2e", new ChainContractsRegister(client));
167
164
  return {
168
165
  chainId,
169
166
  client,
@@ -1,7 +1,6 @@
1
1
  import { BytecodeRepositoryContract } from "./bytecode-repository.js";
2
2
  import { priceFeedSetupParams } from "./pricefeeds/index.js";
3
3
  import { PriceFeedStoreContract } from "./price-feed-store.js";
4
- import { AddressProviderContract } from "./address-provider.js";
5
4
  import { TokenCompressorContract } from "./compressors/token-compressor.js";
6
5
  import { WithdrawalCompressorContract } from "./compressors/withdrawal-compressor.js";
7
6
  import "./compressors/index.js";
@@ -9,6 +8,7 @@ import { RoutingManagerContract } from "./router/routing-manager.js";
9
8
  import "./router/index.js";
10
9
  import { TreasurySplitterContract } from "./treasury-splitter.js";
11
10
  import { InstanceManagerContract } from "./instance-manager.js";
11
+ import { AddressProviderContract } from "./address-provider.js";
12
12
  import { MarketConfiguratorFactoryContract } from "./market-configurator-factory.js";
13
13
  import { CrossChainMultisigContract } from "./cross-chain-multisig.js";
14
14
  import { AccessMode } from "./types.js";
@@ -11,7 +11,6 @@ import { encodeFunctionParams } from "./utils/abi-encoder.js";
11
11
  import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./api/deploy/PermissionlessDeploy.js";
12
12
  import { getPrices } from "./utils/price-update/get-prices.js";
13
13
  import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./api/oracles/PermissionlessOracles.js";
14
- import { AddressProviderContract } from "./bindings/address-provider.js";
15
14
  import { TokenCompressorContract } from "./bindings/compressors/token-compressor.js";
16
15
  import { WithdrawalCompressorContract } from "./bindings/compressors/withdrawal-compressor.js";
17
16
  import { RoutingManagerContract } from "./bindings/router/routing-manager.js";
@@ -22,6 +21,7 @@ import { getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds
22
21
  import { InstanceOwnerTransactions } from "./api/transactions/InstanceOwnerTransactions.js";
23
22
  import { GearboxPermissionless } from "./api/GearboxPermissionless.js";
24
23
  import "./api/index.js";
24
+ import { AddressProviderContract } from "./bindings/address-provider.js";
25
25
  import { MarketConfiguratorFactoryContract } from "./bindings/market-configurator-factory.js";
26
26
  import { CrossChainMultisigContract } from "./bindings/cross-chain-multisig.js";
27
27
  import { PUBLIC_CREATE2_FACTORY, checkCreate2Deployment, checkCreate2DeploymentAddress, createCreate2DeployRawTx, deployUsingPublicCreate2, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, handleSalt } from "./utils/create2.js";
@@ -1,4 +1,5 @@
1
1
  import { GearboxAPIOptions } from "../../offchain/types.js";
2
+ import { Transport } from "viem";
2
3
  //#region src/permissionless/api/types.d.ts
3
4
  /**
4
5
  * Options for creating a {@link GearboxPermissionless} instance.
@@ -7,6 +8,20 @@ import { GearboxAPIOptions } from "../../offchain/types.js";
7
8
  * backend, minus the chains: those the permissionless backend decides, and
8
9
  * {@link ChainsNamespace} reads that list and builds the clients from it.
9
10
  **/
10
- type GearboxPermissionlessOptions = Omit<GearboxAPIOptions, "chainIds">;
11
+ type GearboxPermissionlessOptions = Omit<GearboxAPIOptions, "chainIds"> & {
12
+ /**
13
+ * Transports to reach chains directly through, by chain id.
14
+ *
15
+ * A chain named here is read over the transport given; one that is not
16
+ * falls back to the public endpoints in its definition, which are rate
17
+ * limited and will refuse a caller that reads at any volume. Anything
18
+ * beyond a glance should pass its own.
19
+ *
20
+ * Which chains exist is still the backend's to decide — a transport for a
21
+ * chain the backend does not serve is ignored, and naming no transport at
22
+ * all leaves every chain reachable as before.
23
+ **/
24
+ transports?: Record<number, Transport>;
25
+ };
11
26
  //#endregion
12
27
  export { GearboxPermissionlessOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "17.12.1",
3
+ "version": "17.12.2",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {