@gearbox-protocol/sdk 9.10.2 → 9.10.3
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.
|
@@ -21,9 +21,11 @@ __export(providers_exports, {
|
|
|
21
21
|
getAlchemyUrl: () => getAlchemyUrl,
|
|
22
22
|
getAnkrUrl: () => getAnkrUrl,
|
|
23
23
|
getDrpcUrl: () => getDrpcUrl,
|
|
24
|
-
getProviderUrl: () => getProviderUrl
|
|
24
|
+
getProviderUrl: () => getProviderUrl,
|
|
25
|
+
getThirdWebUrl: () => getThirdWebUrl
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(providers_exports);
|
|
28
|
+
var import_sdk = require("../sdk/index.js");
|
|
27
29
|
function getProviderUrl(provider, network, apiKey, protocol) {
|
|
28
30
|
switch (provider) {
|
|
29
31
|
case "alchemy":
|
|
@@ -32,6 +34,8 @@ function getProviderUrl(provider, network, apiKey, protocol) {
|
|
|
32
34
|
return getDrpcUrl(network, apiKey, protocol);
|
|
33
35
|
case "ankr":
|
|
34
36
|
return getAnkrUrl(network, apiKey, protocol);
|
|
37
|
+
case "thirdweb":
|
|
38
|
+
return getThirdWebUrl(network, apiKey, protocol);
|
|
35
39
|
case "custom": {
|
|
36
40
|
if (!apiKey.startsWith(protocol)) {
|
|
37
41
|
throw new Error(`Custom RPC URL must start with ${protocol}`);
|
|
@@ -107,10 +111,35 @@ function getAnkrUrl(network, apiKey, protocol) {
|
|
|
107
111
|
const sep = protocol === "ws" ? "/ws/" : "/";
|
|
108
112
|
return net ? `${protocol}s://rpc.ankr.com/${net}${sep}${apiKey}` : void 0;
|
|
109
113
|
}
|
|
114
|
+
const THIRDWEB_DOMAINS = {
|
|
115
|
+
Arbitrum: import_sdk.chains.Arbitrum.id.toString(),
|
|
116
|
+
Avalanche: import_sdk.chains.Avalanche.id.toString(),
|
|
117
|
+
Base: import_sdk.chains.Base.id.toString(),
|
|
118
|
+
Berachain: import_sdk.chains.Berachain.id.toString(),
|
|
119
|
+
BNB: import_sdk.chains.BNB.id.toString(),
|
|
120
|
+
Etherlink: import_sdk.chains.Etherlink.id.toString(),
|
|
121
|
+
Hemi: import_sdk.chains.Hemi.id.toString(),
|
|
122
|
+
Lisk: import_sdk.chains.Lisk.id.toString(),
|
|
123
|
+
Mainnet: import_sdk.chains.Mainnet.id.toString(),
|
|
124
|
+
MegaETH: import_sdk.chains.MegaETH.id.toString(),
|
|
125
|
+
Monad: import_sdk.chains.Monad.id.toString(),
|
|
126
|
+
Optimism: import_sdk.chains.Optimism.id.toString(),
|
|
127
|
+
Plasma: import_sdk.chains.Plasma.id.toString(),
|
|
128
|
+
Sonic: import_sdk.chains.Sonic.id.toString(),
|
|
129
|
+
WorldChain: import_sdk.chains.WorldChain.id.toString()
|
|
130
|
+
};
|
|
131
|
+
function getThirdWebUrl(network, apiKey, protocol) {
|
|
132
|
+
if (protocol === "ws") {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
const net = THIRDWEB_DOMAINS[network];
|
|
136
|
+
return `https://${net}.rpc.thirdweb.com/${apiKey}`;
|
|
137
|
+
}
|
|
110
138
|
// Annotate the CommonJS export names for ESM import in node:
|
|
111
139
|
0 && (module.exports = {
|
|
112
140
|
getAlchemyUrl,
|
|
113
141
|
getAnkrUrl,
|
|
114
142
|
getDrpcUrl,
|
|
115
|
-
getProviderUrl
|
|
143
|
+
getProviderUrl,
|
|
144
|
+
getThirdWebUrl
|
|
116
145
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { chains } from "../sdk/index.js";
|
|
1
2
|
function getProviderUrl(provider, network, apiKey, protocol) {
|
|
2
3
|
switch (provider) {
|
|
3
4
|
case "alchemy":
|
|
@@ -6,6 +7,8 @@ function getProviderUrl(provider, network, apiKey, protocol) {
|
|
|
6
7
|
return getDrpcUrl(network, apiKey, protocol);
|
|
7
8
|
case "ankr":
|
|
8
9
|
return getAnkrUrl(network, apiKey, protocol);
|
|
10
|
+
case "thirdweb":
|
|
11
|
+
return getThirdWebUrl(network, apiKey, protocol);
|
|
9
12
|
case "custom": {
|
|
10
13
|
if (!apiKey.startsWith(protocol)) {
|
|
11
14
|
throw new Error(`Custom RPC URL must start with ${protocol}`);
|
|
@@ -81,9 +84,34 @@ function getAnkrUrl(network, apiKey, protocol) {
|
|
|
81
84
|
const sep = protocol === "ws" ? "/ws/" : "/";
|
|
82
85
|
return net ? `${protocol}s://rpc.ankr.com/${net}${sep}${apiKey}` : void 0;
|
|
83
86
|
}
|
|
87
|
+
const THIRDWEB_DOMAINS = {
|
|
88
|
+
Arbitrum: chains.Arbitrum.id.toString(),
|
|
89
|
+
Avalanche: chains.Avalanche.id.toString(),
|
|
90
|
+
Base: chains.Base.id.toString(),
|
|
91
|
+
Berachain: chains.Berachain.id.toString(),
|
|
92
|
+
BNB: chains.BNB.id.toString(),
|
|
93
|
+
Etherlink: chains.Etherlink.id.toString(),
|
|
94
|
+
Hemi: chains.Hemi.id.toString(),
|
|
95
|
+
Lisk: chains.Lisk.id.toString(),
|
|
96
|
+
Mainnet: chains.Mainnet.id.toString(),
|
|
97
|
+
MegaETH: chains.MegaETH.id.toString(),
|
|
98
|
+
Monad: chains.Monad.id.toString(),
|
|
99
|
+
Optimism: chains.Optimism.id.toString(),
|
|
100
|
+
Plasma: chains.Plasma.id.toString(),
|
|
101
|
+
Sonic: chains.Sonic.id.toString(),
|
|
102
|
+
WorldChain: chains.WorldChain.id.toString()
|
|
103
|
+
};
|
|
104
|
+
function getThirdWebUrl(network, apiKey, protocol) {
|
|
105
|
+
if (protocol === "ws") {
|
|
106
|
+
return void 0;
|
|
107
|
+
}
|
|
108
|
+
const net = THIRDWEB_DOMAINS[network];
|
|
109
|
+
return `https://${net}.rpc.thirdweb.com/${apiKey}`;
|
|
110
|
+
}
|
|
84
111
|
export {
|
|
85
112
|
getAlchemyUrl,
|
|
86
113
|
getAnkrUrl,
|
|
87
114
|
getDrpcUrl,
|
|
88
|
-
getProviderUrl
|
|
115
|
+
getProviderUrl,
|
|
116
|
+
getThirdWebUrl
|
|
89
117
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpTransportConfig, WebSocketTransportConfig } from "viem";
|
|
2
|
-
import type
|
|
3
|
-
export type RpcProvider = "alchemy" | "drpc" | "ankr" | "custom";
|
|
2
|
+
import { type NetworkType } from "../sdk/index.js";
|
|
3
|
+
export type RpcProvider = "alchemy" | "drpc" | "ankr" | "thirdweb" | "custom";
|
|
4
4
|
export interface ProviderConfig {
|
|
5
5
|
provider: RpcProvider;
|
|
6
6
|
keys: string[];
|
|
@@ -24,3 +24,4 @@ export declare function getProviderUrl(provider: RpcProvider, network: NetworkTy
|
|
|
24
24
|
export declare function getAlchemyUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
25
25
|
export declare function getDrpcUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
26
26
|
export declare function getAnkrUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
27
|
+
export declare function getThirdWebUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|