@gearbox-protocol/cli-utils 5.71.3 → 5.71.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.
@@ -1,91 +1,5 @@
1
1
  import { RevolverTransport, } from "@gearbox-protocol/sdk/dev";
2
- import { getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getThirdWebUrl, } from "./providers.js";
3
- /**
4
- * Take the last two parts for top-level domain (e.g., "google.com" from "a.b.c.google.com")
5
- **/
6
- function getTopLevelDomain({ hostname }) {
7
- const parts = hostname.split(".");
8
- return parts.length >= 2 ? parts.slice(-2).join(".") : hostname;
9
- }
10
- function getProviders(config) {
11
- const { network, enabledProviders, alchemyKeys = [], ankrKeys = [], drpcKeys = [], thirdwebKeys = [], jsonRpcProviders = [], erpcProjectId, erpcUrl, } = config;
12
- const result = [];
13
- for (const p of enabledProviders) {
14
- switch (p) {
15
- case "alchemy":
16
- result.push(...alchemyKeys.map(k => ({
17
- name: "alchemy",
18
- url: getAlchemyUrl(network, k.value),
19
- })));
20
- break;
21
- case "drpc":
22
- result.push(...drpcKeys.map(k => ({
23
- name: "drpc",
24
- url: getDrpcUrl(network, k.value),
25
- })));
26
- break;
27
- case "ankr":
28
- result.push(...ankrKeys.map(k => ({
29
- name: "ankr",
30
- url: getAnkrUrl(network, k.value),
31
- })));
32
- break;
33
- case "thirdweb":
34
- result.push(...thirdwebKeys.map(k => ({
35
- name: "thirdweb",
36
- url: getThirdWebUrl(network, k.value),
37
- })));
38
- break;
39
- case "custom":
40
- result.push(...jsonRpcProviders.map((url) => {
41
- const urlObj = new URL(url.value);
42
- const hasCredentials = urlObj.username || urlObj.password;
43
- let cleanUrl = url.value;
44
- let httpTransportOptions = {};
45
- if (hasCredentials) {
46
- // Create URL without credentials
47
- const cleanUrlObj = new URL(url.value);
48
- cleanUrlObj.username = "";
49
- cleanUrlObj.password = "";
50
- cleanUrl = cleanUrlObj.toString();
51
- // Create Basic Auth header
52
- const credentials = `${urlObj.username}:${urlObj.password}`;
53
- const encodedCredentials = Buffer.from(credentials).toString("base64");
54
- httpTransportOptions = {
55
- fetchOptions: {
56
- headers: {
57
- Authorization: `Basic ${encodedCredentials}`,
58
- },
59
- },
60
- };
61
- }
62
- return {
63
- name: getTopLevelDomain(urlObj),
64
- url: cleanUrl,
65
- httpTransportOptions,
66
- };
67
- }));
68
- break;
69
- case "erpc":
70
- if (erpcProjectId && erpcUrl) {
71
- result.push({
72
- name: "erpc",
73
- url: getErpcKey(network, erpcProjectId, erpcUrl),
74
- });
75
- }
76
- break;
77
- }
78
- }
79
- return result
80
- .map(p => ({
81
- ...p,
82
- httpClientOptions: {
83
- ...p.httpTransportOptions,
84
- methods: { exclude: ["eth_fillTransaction"] },
85
- },
86
- }))
87
- .filter(p => !!p.url);
88
- }
2
+ import { getProviders } from "./getProviders.js";
89
3
  export function createRevolverTransport(providers, config) {
90
4
  return RevolverTransport.create({
91
5
  providers: getProviders(providers),
@@ -0,0 +1,7 @@
1
+ import type { HttpTransportConfig } from "viem";
2
+ import type { ProvidersSchema } from "./providers-schema.js";
3
+ export interface HttpTransportOptions {
4
+ url?: string | undefined;
5
+ config: HttpTransportConfig;
6
+ }
7
+ export declare function getFirstHttpTransportOptions(config: ProvidersSchema): HttpTransportOptions;
@@ -0,0 +1,13 @@
1
+ import { getProviders } from "./getProviders.js";
2
+ export function getFirstHttpTransportOptions(config) {
3
+ const [provider] = getProviders(config);
4
+ if (!provider) {
5
+ throw new Error("No provider found");
6
+ }
7
+ return {
8
+ url: provider.url,
9
+ config: {
10
+ ...provider.httpTransportOptions,
11
+ },
12
+ };
13
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProviderConfig } from "@gearbox-protocol/sdk/dev";
2
+ import type { ProvidersSchema } from "./providers-schema.js";
3
+ export declare function getProviders(config: ProvidersSchema): ProviderConfig[];
@@ -0,0 +1,87 @@
1
+ import { getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getThirdWebUrl, } from "./providers.js";
2
+ export function getProviders(config) {
3
+ const { network, enabledProviders, alchemyKeys = [], ankrKeys = [], drpcKeys = [], thirdwebKeys = [], jsonRpcProviders = [], erpcProjectId, erpcUrl, } = config;
4
+ const result = [];
5
+ for (const p of enabledProviders) {
6
+ switch (p) {
7
+ case "alchemy":
8
+ result.push(...alchemyKeys.map(k => ({
9
+ name: "alchemy",
10
+ url: getAlchemyUrl(network, k.value),
11
+ })));
12
+ break;
13
+ case "drpc":
14
+ result.push(...drpcKeys.map(k => ({
15
+ name: "drpc",
16
+ url: getDrpcUrl(network, k.value),
17
+ })));
18
+ break;
19
+ case "ankr":
20
+ result.push(...ankrKeys.map(k => ({
21
+ name: "ankr",
22
+ url: getAnkrUrl(network, k.value),
23
+ })));
24
+ break;
25
+ case "thirdweb":
26
+ result.push(...thirdwebKeys.map(k => ({
27
+ name: "thirdweb",
28
+ url: getThirdWebUrl(network, k.value),
29
+ })));
30
+ break;
31
+ case "custom":
32
+ result.push(...jsonRpcProviders.map((url) => {
33
+ const urlObj = new URL(url.value);
34
+ const hasCredentials = urlObj.username || urlObj.password;
35
+ let cleanUrl = url.value;
36
+ let httpTransportOptions = {};
37
+ if (hasCredentials) {
38
+ // Create URL without credentials
39
+ const cleanUrlObj = new URL(url.value);
40
+ cleanUrlObj.username = "";
41
+ cleanUrlObj.password = "";
42
+ cleanUrl = cleanUrlObj.toString();
43
+ // Create Basic Auth header
44
+ const credentials = `${urlObj.username}:${urlObj.password}`;
45
+ const encodedCredentials = Buffer.from(credentials).toString("base64");
46
+ httpTransportOptions = {
47
+ fetchOptions: {
48
+ headers: {
49
+ Authorization: `Basic ${encodedCredentials}`,
50
+ },
51
+ },
52
+ };
53
+ }
54
+ return {
55
+ name: getTopLevelDomain(urlObj),
56
+ url: cleanUrl,
57
+ httpTransportOptions,
58
+ };
59
+ }));
60
+ break;
61
+ case "erpc":
62
+ if (erpcProjectId && erpcUrl) {
63
+ result.push({
64
+ name: "erpc",
65
+ url: getErpcKey(network, erpcProjectId, erpcUrl),
66
+ });
67
+ }
68
+ break;
69
+ }
70
+ }
71
+ return result
72
+ .map(p => ({
73
+ ...p,
74
+ httpClientOptions: {
75
+ ...p.httpTransportOptions,
76
+ methods: { exclude: ["eth_fillTransaction"] },
77
+ },
78
+ }))
79
+ .filter(p => !!p.url);
80
+ }
81
+ /**
82
+ * Take the last two parts for top-level domain (e.g., "google.com" from "a.b.c.google.com")
83
+ **/
84
+ function getTopLevelDomain({ hostname }) {
85
+ const parts = hostname.split(".");
86
+ return parts.length >= 2 ? parts.slice(-2).join(".") : hostname;
87
+ }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ export * from "./CensoredString.js";
2
2
  export * from "./CensoredURL.js";
3
3
  export * from "./compressedConfig.js";
4
4
  export * from "./createRevolverTransport.js";
5
+ export * from "./getFirstHttpTransportOptions.js";
6
+ export * from "./getProviders.js";
5
7
  export * from "./notifications/index.js";
6
8
  export * from "./providers.js";
7
9
  export * from "./providers-schema.js";
package/dist/index.js CHANGED
@@ -2,6 +2,8 @@ export * from "./CensoredString.js";
2
2
  export * from "./CensoredURL.js";
3
3
  export * from "./compressedConfig.js";
4
4
  export * from "./createRevolverTransport.js";
5
+ export * from "./getFirstHttpTransportOptions.js";
6
+ export * from "./getProviders.js";
5
7
  export * from "./notifications/index.js";
6
8
  export * from "./providers.js";
7
9
  export * from "./providers-schema.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/cli-utils",
3
3
  "description": "Utils for creating cli apps",
4
- "version": "5.71.3",
4
+ "version": "5.71.5",
5
5
  "homepage": "https://gearbox.fi",
6
6
  "keywords": [
7
7
  "gearbox"
@@ -29,23 +29,23 @@
29
29
  "package:version": "yarn version"
30
30
  },
31
31
  "dependencies": {
32
- "@aws-sdk/client-s3": "^3.993.0",
33
- "@aws-sdk/client-secrets-manager": "^3.993.0",
34
- "@aws-sdk/client-ssm": "^3.993.0",
35
- "@gearbox-protocol/sdk": ">=12.6.8",
32
+ "@aws-sdk/client-s3": "^3.1008.0",
33
+ "@aws-sdk/client-secrets-manager": "^3.1008.0",
34
+ "@aws-sdk/client-ssm": "^3.1008.0",
35
+ "@gearbox-protocol/sdk": "13.0.0-next.30",
36
36
  "@vlad-yakovlev/telegram-md": "^2.1.0",
37
37
  "abitype": "^1.2.3",
38
38
  "commander": "^14.0.3",
39
39
  "lodash-es": "^4.17.23",
40
40
  "lru-cache": "^11.2.6",
41
41
  "p-queue": "^9.1.0",
42
- "viem": "^2.46.2",
42
+ "viem": "^2.47.2",
43
43
  "yaml": "^2.8.2",
44
44
  "zod": "^4.3.6"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@commander-js/extra-typings": "^14.0.0",
48
48
  "@types/lodash-es": "^4.17.12",
49
- "@types/node": "^25.3.0"
49
+ "@types/node": "^25.5.0"
50
50
  }
51
51
  }