@gearbox-protocol/sdk 10.4.1 → 10.4.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.
- package/dist/cjs/dev/RevolverTransport.js +8 -22
- package/dist/cjs/dev/index.js +0 -2
- package/dist/cjs/dev/providers.js +4 -2
- package/dist/esm/dev/RevolverTransport.js +8 -24
- package/dist/esm/dev/index.js +0 -1
- package/dist/esm/dev/providers.js +4 -2
- package/dist/types/dev/RevolverTransport.d.ts +5 -1
- package/dist/types/dev/index.d.ts +0 -1
- package/dist/types/dev/providers.d.ts +1 -22
- package/package.json +5 -5
|
@@ -23,7 +23,6 @@ __export(RevolverTransport_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(RevolverTransport_exports);
|
|
25
25
|
var import_viem = require("viem");
|
|
26
|
-
var import_providers = require("./providers.js");
|
|
27
26
|
class NoAvailableTransportsError extends import_viem.BaseError {
|
|
28
27
|
constructor(cause) {
|
|
29
28
|
super("no available transports", { cause });
|
|
@@ -58,33 +57,20 @@ class RevolverTransport {
|
|
|
58
57
|
...config,
|
|
59
58
|
shouldRetry: config.shouldRetry ?? defaultShouldRetry
|
|
60
59
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
for (const key of keys) {
|
|
65
|
-
const url = (0, import_providers.getProviderUrl)(provider, config.network, key, "http");
|
|
66
|
-
if (url) {
|
|
67
|
-
rpcUrls.set(url, provider);
|
|
68
|
-
if (cooldown) {
|
|
69
|
-
cooldowns.set(url, cooldown);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
this.#transports = Array.from(rpcUrls.entries()).map(
|
|
75
|
-
([url, provider], i) => ({
|
|
76
|
-
provider,
|
|
60
|
+
this.#transports = config.providers.map(
|
|
61
|
+
({ url, name, cooldown }) => ({
|
|
62
|
+
provider: name,
|
|
77
63
|
transport: (0, import_viem.http)(url, {
|
|
78
64
|
retryCount: config.retryCount,
|
|
79
65
|
retryDelay: config.retryDelay,
|
|
80
66
|
timeout: config.timeout,
|
|
81
67
|
batch: !!config.batch,
|
|
82
|
-
key:
|
|
83
|
-
name
|
|
84
|
-
onFetchRequest: this.#config.onRequest ? (...args) => this.#config.onRequest?.(
|
|
85
|
-
onFetchResponse: this.#config.onResponse ? (...args) => this.#config.onResponse?.(
|
|
68
|
+
key: name,
|
|
69
|
+
name,
|
|
70
|
+
onFetchRequest: this.#config.onRequest ? (...args) => this.#config.onRequest?.(name, ...args) : void 0,
|
|
71
|
+
onFetchResponse: this.#config.onResponse ? (...args) => this.#config.onResponse?.(name, ...args) : void 0
|
|
86
72
|
}),
|
|
87
|
-
cooldown:
|
|
73
|
+
cooldown: cooldown ?? 0
|
|
88
74
|
})
|
|
89
75
|
);
|
|
90
76
|
if (this.#transports.length === 0) {
|
package/dist/cjs/dev/index.js
CHANGED
|
@@ -26,7 +26,6 @@ __reExport(dev_exports, require("./EthCallSpy.js"), module.exports);
|
|
|
26
26
|
__reExport(dev_exports, require("./ltUtils.js"), module.exports);
|
|
27
27
|
__reExport(dev_exports, require("./migrateFaucet.js"), module.exports);
|
|
28
28
|
__reExport(dev_exports, require("./mint/index.js"), module.exports);
|
|
29
|
-
__reExport(dev_exports, require("./providers.js"), module.exports);
|
|
30
29
|
__reExport(dev_exports, require("./RevolverTransport.js"), module.exports);
|
|
31
30
|
__reExport(dev_exports, require("./types.js"), module.exports);
|
|
32
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -42,7 +41,6 @@ __reExport(dev_exports, require("./types.js"), module.exports);
|
|
|
42
41
|
...require("./ltUtils.js"),
|
|
43
42
|
...require("./migrateFaucet.js"),
|
|
44
43
|
...require("./mint/index.js"),
|
|
45
|
-
...require("./providers.js"),
|
|
46
44
|
...require("./RevolverTransport.js"),
|
|
47
45
|
...require("./types.js")
|
|
48
46
|
});
|
|
@@ -36,9 +36,11 @@ function getProviderUrl(provider, network, apiKey, protocol) {
|
|
|
36
36
|
return getAnkrUrl(network, apiKey, protocol);
|
|
37
37
|
case "thirdweb":
|
|
38
38
|
return getThirdWebUrl(network, apiKey, protocol);
|
|
39
|
-
|
|
39
|
+
default: {
|
|
40
40
|
if (!apiKey.startsWith(protocol)) {
|
|
41
|
-
throw new Error(
|
|
41
|
+
throw new Error(
|
|
42
|
+
`generic provider's ${provider} key must start with ${protocol}`
|
|
43
|
+
);
|
|
42
44
|
}
|
|
43
45
|
return apiKey;
|
|
44
46
|
}
|
|
@@ -10,9 +10,6 @@ import {
|
|
|
10
10
|
RpcError,
|
|
11
11
|
withRetry
|
|
12
12
|
} from "viem";
|
|
13
|
-
import {
|
|
14
|
-
getProviderUrl
|
|
15
|
-
} from "./providers.js";
|
|
16
13
|
class NoAvailableTransportsError extends BaseError {
|
|
17
14
|
constructor(cause) {
|
|
18
15
|
super("no available transports", { cause });
|
|
@@ -47,33 +44,20 @@ class RevolverTransport {
|
|
|
47
44
|
...config,
|
|
48
45
|
shouldRetry: config.shouldRetry ?? defaultShouldRetry
|
|
49
46
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
for (const key of keys) {
|
|
54
|
-
const url = getProviderUrl(provider, config.network, key, "http");
|
|
55
|
-
if (url) {
|
|
56
|
-
rpcUrls.set(url, provider);
|
|
57
|
-
if (cooldown) {
|
|
58
|
-
cooldowns.set(url, cooldown);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
this.#transports = Array.from(rpcUrls.entries()).map(
|
|
64
|
-
([url, provider], i) => ({
|
|
65
|
-
provider,
|
|
47
|
+
this.#transports = config.providers.map(
|
|
48
|
+
({ url, name, cooldown }) => ({
|
|
49
|
+
provider: name,
|
|
66
50
|
transport: http(url, {
|
|
67
51
|
retryCount: config.retryCount,
|
|
68
52
|
retryDelay: config.retryDelay,
|
|
69
53
|
timeout: config.timeout,
|
|
70
54
|
batch: !!config.batch,
|
|
71
|
-
key:
|
|
72
|
-
name
|
|
73
|
-
onFetchRequest: this.#config.onRequest ? (...args) => this.#config.onRequest?.(
|
|
74
|
-
onFetchResponse: this.#config.onResponse ? (...args) => this.#config.onResponse?.(
|
|
55
|
+
key: name,
|
|
56
|
+
name,
|
|
57
|
+
onFetchRequest: this.#config.onRequest ? (...args) => this.#config.onRequest?.(name, ...args) : void 0,
|
|
58
|
+
onFetchResponse: this.#config.onResponse ? (...args) => this.#config.onResponse?.(name, ...args) : void 0
|
|
75
59
|
}),
|
|
76
|
-
cooldown:
|
|
60
|
+
cooldown: cooldown ?? 0
|
|
77
61
|
})
|
|
78
62
|
);
|
|
79
63
|
if (this.#transports.length === 0) {
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -9,9 +9,11 @@ function getProviderUrl(provider, network, apiKey, protocol) {
|
|
|
9
9
|
return getAnkrUrl(network, apiKey, protocol);
|
|
10
10
|
case "thirdweb":
|
|
11
11
|
return getThirdWebUrl(network, apiKey, protocol);
|
|
12
|
-
|
|
12
|
+
default: {
|
|
13
13
|
if (!apiKey.startsWith(protocol)) {
|
|
14
|
-
throw new Error(
|
|
14
|
+
throw new Error(
|
|
15
|
+
`generic provider's ${provider} key must start with ${protocol}`
|
|
16
|
+
);
|
|
15
17
|
}
|
|
16
18
|
return apiKey;
|
|
17
19
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { BaseError, type ClientConfig, type EIP1193RequestFn, type Transport, type TransportConfig } from "viem";
|
|
2
2
|
import type { HttpRpcClientOptions } from "viem/utils";
|
|
3
3
|
import type { ILogger, NetworkType } from "../sdk/index.js";
|
|
4
|
-
|
|
4
|
+
export interface ProviderConfig {
|
|
5
|
+
name: string;
|
|
6
|
+
url: string;
|
|
7
|
+
cooldown?: number;
|
|
8
|
+
}
|
|
5
9
|
export interface ProviderStatus {
|
|
6
10
|
id: string;
|
|
7
11
|
status: "active" | "cooldown" | "standby";
|
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
import type { HttpTransportConfig, WebSocketTransportConfig } from "viem";
|
|
2
1
|
import { type NetworkType } from "../sdk/index.js";
|
|
3
|
-
export
|
|
4
|
-
export interface ProviderConfig {
|
|
5
|
-
provider: RpcProvider;
|
|
6
|
-
keys: string[];
|
|
7
|
-
cooldown?: number;
|
|
8
|
-
}
|
|
9
|
-
export interface CreateTransportURLOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Known providers, first has highest priority
|
|
12
|
-
*/
|
|
13
|
-
rpcProviders?: ProviderConfig[];
|
|
14
|
-
network: NetworkType;
|
|
15
|
-
}
|
|
16
|
-
export type CreateHTTPTransportConfig = {
|
|
17
|
-
protocol: "http";
|
|
18
|
-
} & HttpTransportConfig & CreateTransportURLOptions;
|
|
19
|
-
export type CreateWSTransportConfig = {
|
|
20
|
-
protocol: "ws";
|
|
21
|
-
} & WebSocketTransportConfig & CreateTransportURLOptions;
|
|
22
|
-
export type CreateTransportConfig = CreateHTTPTransportConfig | CreateWSTransportConfig;
|
|
23
|
-
export declare function getProviderUrl(provider: RpcProvider, network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
2
|
+
export declare function getProviderUrl(provider: string, network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
24
3
|
export declare function getAlchemyUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
25
4
|
export declare function getDrpcUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
26
5
|
export declare function getAnkrUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.2",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.js",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"zod": "^4.1.12"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@biomejs/biome": "^2.3.
|
|
68
|
+
"@biomejs/biome": "^2.3.3",
|
|
69
69
|
"@commitlint/cli": "^20.1.0",
|
|
70
70
|
"@commitlint/config-conventional": "^20.0.0",
|
|
71
|
-
"@gearbox-protocol/biome-config": "^1.0.
|
|
71
|
+
"@gearbox-protocol/biome-config": "^1.0.9",
|
|
72
72
|
"@types/cross-spawn": "^6.0.6",
|
|
73
|
-
"axios": "^1.
|
|
73
|
+
"axios": "^1.13.1",
|
|
74
74
|
"cross-spawn": "^7.0.6",
|
|
75
75
|
"husky": "^9.1.7",
|
|
76
76
|
"lint-staged": "^16.2.6",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"tsx": "^4.20.6",
|
|
81
81
|
"typescript": "^5.9.3",
|
|
82
82
|
"viem-deal": "^2.0.4",
|
|
83
|
-
"vitest": "^4.0.
|
|
83
|
+
"vitest": "^4.0.6"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"axios": "^1.0.0",
|