@gearbox-protocol/sdk 8.18.0 → 8.18.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.
@@ -28,19 +28,16 @@ var import_viem = require("viem");
28
28
  var import_sdk = require("../sdk/index.js");
29
29
  function createTransport(config) {
30
30
  const { rpcProviders = [], protocol, network, ...rest } = config;
31
- const allKeys = rpcProviders.flatMap((provider) => provider.keys) ?? [];
32
- const rpcUrls = config.rpcUrls.filter((url) => {
33
- return url.startsWith(protocol) && !allKeys.some((key) => url.includes(key));
34
- });
31
+ const rpcUrls = /* @__PURE__ */ new Set();
35
32
  for (const { provider, keys } of rpcProviders) {
36
33
  for (const key of keys) {
37
34
  const url = getProviderUrl(provider, network, key, protocol);
38
35
  if (url) {
39
- rpcUrls.push(url);
36
+ rpcUrls.add(url);
40
37
  }
41
38
  }
42
39
  }
43
- const transports = rpcUrls.map(
40
+ const transports = Array.from(rpcUrls).map(
44
41
  (url) => protocol === "http" ? (0, import_viem.http)(url, rest) : (0, import_viem.webSocket)(url, rest)
45
42
  );
46
43
  if (transports.length === 0) {
@@ -54,6 +51,12 @@ function getProviderUrl(provider, network, apiKey, protocol) {
54
51
  return getAlchemyUrl(network, apiKey, protocol);
55
52
  case "drpc":
56
53
  return getDrpcUrl(network, apiKey, protocol);
54
+ case "custom": {
55
+ if (!apiKey.startsWith(protocol)) {
56
+ throw new Error(`Custom RPC URL must start with ${protocol}`);
57
+ }
58
+ return apiKey;
59
+ }
57
60
  }
58
61
  }
59
62
  function getAlchemyUrl(network, apiKey, protocol) {
@@ -74,11 +77,11 @@ const DRPC_NETS = {
74
77
  Berachain: "berachain",
75
78
  Avalanche: "avalanche",
76
79
  Monad: "monad-testnet",
80
+ Hemi: "hemi",
81
+ Lisk: "lisk",
77
82
  // TODO: no drpc
78
83
  MegaETH: "",
79
- Etherlink: "",
80
- Hemi: "hemi",
81
- Lisk: "lisk"
84
+ Etherlink: ""
82
85
  };
83
86
  function getDrpcUrl(network, apiKey, protocol) {
84
87
  const net = DRPC_NETS[network];
@@ -253,11 +253,10 @@ const chains = {
253
253
  Etherlink: (0, import_viem.defineChain)({
254
254
  ...import_chains.etherlink,
255
255
  network: "Etherlink",
256
- defaultMarketConfigurators: {},
257
- testMarketConfigurators: {
256
+ defaultMarketConfigurators: {
258
257
  "0x577424f0e6f50db668cc1bc76babb87e36732291": "Re7"
259
258
  },
260
- isPublic: false,
259
+ isPublic: true,
261
260
  wellKnownToken: {
262
261
  address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9",
263
262
  symbol: "USDC"
@@ -2,19 +2,16 @@ import { fallback, http, webSocket } from "viem";
2
2
  import { getChain } from "../sdk/index.js";
3
3
  function createTransport(config) {
4
4
  const { rpcProviders = [], protocol, network, ...rest } = config;
5
- const allKeys = rpcProviders.flatMap((provider) => provider.keys) ?? [];
6
- const rpcUrls = config.rpcUrls.filter((url) => {
7
- return url.startsWith(protocol) && !allKeys.some((key) => url.includes(key));
8
- });
5
+ const rpcUrls = /* @__PURE__ */ new Set();
9
6
  for (const { provider, keys } of rpcProviders) {
10
7
  for (const key of keys) {
11
8
  const url = getProviderUrl(provider, network, key, protocol);
12
9
  if (url) {
13
- rpcUrls.push(url);
10
+ rpcUrls.add(url);
14
11
  }
15
12
  }
16
13
  }
17
- const transports = rpcUrls.map(
14
+ const transports = Array.from(rpcUrls).map(
18
15
  (url) => protocol === "http" ? http(url, rest) : webSocket(url, rest)
19
16
  );
20
17
  if (transports.length === 0) {
@@ -28,6 +25,12 @@ function getProviderUrl(provider, network, apiKey, protocol) {
28
25
  return getAlchemyUrl(network, apiKey, protocol);
29
26
  case "drpc":
30
27
  return getDrpcUrl(network, apiKey, protocol);
28
+ case "custom": {
29
+ if (!apiKey.startsWith(protocol)) {
30
+ throw new Error(`Custom RPC URL must start with ${protocol}`);
31
+ }
32
+ return apiKey;
33
+ }
31
34
  }
32
35
  }
33
36
  function getAlchemyUrl(network, apiKey, protocol) {
@@ -48,11 +51,11 @@ const DRPC_NETS = {
48
51
  Berachain: "berachain",
49
52
  Avalanche: "avalanche",
50
53
  Monad: "monad-testnet",
54
+ Hemi: "hemi",
55
+ Lisk: "lisk",
51
56
  // TODO: no drpc
52
57
  MegaETH: "",
53
- Etherlink: "",
54
- Hemi: "hemi",
55
- Lisk: "lisk"
58
+ Etherlink: ""
56
59
  };
57
60
  function getDrpcUrl(network, apiKey, protocol) {
58
61
  const net = DRPC_NETS[network];
@@ -238,11 +238,10 @@ const chains = {
238
238
  Etherlink: defineChain({
239
239
  ...etherlink,
240
240
  network: "Etherlink",
241
- defaultMarketConfigurators: {},
242
- testMarketConfigurators: {
241
+ defaultMarketConfigurators: {
243
242
  "0x577424f0e6f50db668cc1bc76babb87e36732291": "Re7"
244
243
  },
245
- isPublic: false,
244
+ isPublic: true,
246
245
  wellKnownToken: {
247
246
  address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9",
248
247
  symbol: "USDC"
@@ -1,16 +1,11 @@
1
1
  import type { HttpTransportConfig, Transport, WebSocketTransportConfig } from "viem";
2
2
  import type { NetworkType } from "../sdk/index.js";
3
- export type RpcProvider = "alchemy" | "drpc";
3
+ export type RpcProvider = "alchemy" | "drpc" | "custom";
4
4
  export interface ProviderConfig {
5
5
  provider: RpcProvider;
6
6
  keys: string[];
7
7
  }
8
8
  export interface CreateTransportURLOptions {
9
- /**
10
- * Explicitly provided RPC URLs, like anvil
11
- * Have highest priority
12
- */
13
- rpcUrls: string[];
14
9
  /**
15
10
  * Known providers, first has highest priority
16
11
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.18.0",
3
+ "version": "8.18.2",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",