@gearbox-protocol/sdk 9.10.1 → 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.
|
@@ -19,16 +19,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var providers_exports = {};
|
|
20
20
|
__export(providers_exports, {
|
|
21
21
|
getAlchemyUrl: () => getAlchemyUrl,
|
|
22
|
+
getAnkrUrl: () => getAnkrUrl,
|
|
22
23
|
getDrpcUrl: () => getDrpcUrl,
|
|
23
|
-
getProviderUrl: () => getProviderUrl
|
|
24
|
+
getProviderUrl: () => getProviderUrl,
|
|
25
|
+
getThirdWebUrl: () => getThirdWebUrl
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(providers_exports);
|
|
28
|
+
var import_sdk = require("../sdk/index.js");
|
|
26
29
|
function getProviderUrl(provider, network, apiKey, protocol) {
|
|
27
30
|
switch (provider) {
|
|
28
31
|
case "alchemy":
|
|
29
32
|
return getAlchemyUrl(network, apiKey, protocol);
|
|
30
33
|
case "drpc":
|
|
31
34
|
return getDrpcUrl(network, apiKey, protocol);
|
|
35
|
+
case "ankr":
|
|
36
|
+
return getAnkrUrl(network, apiKey, protocol);
|
|
37
|
+
case "thirdweb":
|
|
38
|
+
return getThirdWebUrl(network, apiKey, protocol);
|
|
32
39
|
case "custom": {
|
|
33
40
|
if (!apiKey.startsWith(protocol)) {
|
|
34
41
|
throw new Error(`Custom RPC URL must start with ${protocol}`);
|
|
@@ -82,9 +89,57 @@ function getDrpcUrl(network, apiKey, protocol) {
|
|
|
82
89
|
const net = DRPC_NETS[network];
|
|
83
90
|
return net ? `${protocol}s://lb.drpc.org/${net}/${apiKey}` : void 0;
|
|
84
91
|
}
|
|
92
|
+
const ANKR_DOMAINS = {
|
|
93
|
+
Arbitrum: "arbitrum",
|
|
94
|
+
Avalanche: "avalanche",
|
|
95
|
+
Base: "base",
|
|
96
|
+
Berachain: null,
|
|
97
|
+
BNB: "bsc",
|
|
98
|
+
Etherlink: "etherlink_mainnet",
|
|
99
|
+
Hemi: null,
|
|
100
|
+
Lisk: null,
|
|
101
|
+
Mainnet: "eth",
|
|
102
|
+
MegaETH: null,
|
|
103
|
+
Monad: "monad_testnet",
|
|
104
|
+
Optimism: "optimism",
|
|
105
|
+
Plasma: null,
|
|
106
|
+
Sonic: "sonic_mainnet",
|
|
107
|
+
WorldChain: null
|
|
108
|
+
};
|
|
109
|
+
function getAnkrUrl(network, apiKey, protocol) {
|
|
110
|
+
const net = ANKR_DOMAINS[network];
|
|
111
|
+
const sep = protocol === "ws" ? "/ws/" : "/";
|
|
112
|
+
return net ? `${protocol}s://rpc.ankr.com/${net}${sep}${apiKey}` : void 0;
|
|
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
|
+
}
|
|
85
138
|
// Annotate the CommonJS export names for ESM import in node:
|
|
86
139
|
0 && (module.exports = {
|
|
87
140
|
getAlchemyUrl,
|
|
141
|
+
getAnkrUrl,
|
|
88
142
|
getDrpcUrl,
|
|
89
|
-
getProviderUrl
|
|
143
|
+
getProviderUrl,
|
|
144
|
+
getThirdWebUrl
|
|
90
145
|
});
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { chains } from "../sdk/index.js";
|
|
1
2
|
function getProviderUrl(provider, network, apiKey, protocol) {
|
|
2
3
|
switch (provider) {
|
|
3
4
|
case "alchemy":
|
|
4
5
|
return getAlchemyUrl(network, apiKey, protocol);
|
|
5
6
|
case "drpc":
|
|
6
7
|
return getDrpcUrl(network, apiKey, protocol);
|
|
8
|
+
case "ankr":
|
|
9
|
+
return getAnkrUrl(network, apiKey, protocol);
|
|
10
|
+
case "thirdweb":
|
|
11
|
+
return getThirdWebUrl(network, apiKey, protocol);
|
|
7
12
|
case "custom": {
|
|
8
13
|
if (!apiKey.startsWith(protocol)) {
|
|
9
14
|
throw new Error(`Custom RPC URL must start with ${protocol}`);
|
|
@@ -57,8 +62,56 @@ function getDrpcUrl(network, apiKey, protocol) {
|
|
|
57
62
|
const net = DRPC_NETS[network];
|
|
58
63
|
return net ? `${protocol}s://lb.drpc.org/${net}/${apiKey}` : void 0;
|
|
59
64
|
}
|
|
65
|
+
const ANKR_DOMAINS = {
|
|
66
|
+
Arbitrum: "arbitrum",
|
|
67
|
+
Avalanche: "avalanche",
|
|
68
|
+
Base: "base",
|
|
69
|
+
Berachain: null,
|
|
70
|
+
BNB: "bsc",
|
|
71
|
+
Etherlink: "etherlink_mainnet",
|
|
72
|
+
Hemi: null,
|
|
73
|
+
Lisk: null,
|
|
74
|
+
Mainnet: "eth",
|
|
75
|
+
MegaETH: null,
|
|
76
|
+
Monad: "monad_testnet",
|
|
77
|
+
Optimism: "optimism",
|
|
78
|
+
Plasma: null,
|
|
79
|
+
Sonic: "sonic_mainnet",
|
|
80
|
+
WorldChain: null
|
|
81
|
+
};
|
|
82
|
+
function getAnkrUrl(network, apiKey, protocol) {
|
|
83
|
+
const net = ANKR_DOMAINS[network];
|
|
84
|
+
const sep = protocol === "ws" ? "/ws/" : "/";
|
|
85
|
+
return net ? `${protocol}s://rpc.ankr.com/${net}${sep}${apiKey}` : void 0;
|
|
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
|
+
}
|
|
60
111
|
export {
|
|
61
112
|
getAlchemyUrl,
|
|
113
|
+
getAnkrUrl,
|
|
62
114
|
getDrpcUrl,
|
|
63
|
-
getProviderUrl
|
|
115
|
+
getProviderUrl,
|
|
116
|
+
getThirdWebUrl
|
|
64
117
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpTransportConfig, WebSocketTransportConfig } from "viem";
|
|
2
|
-
import type
|
|
3
|
-
export type RpcProvider = "alchemy" | "drpc" | "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[];
|
|
@@ -23,3 +23,5 @@ export type CreateTransportConfig = CreateHTTPTransportConfig | CreateWSTranspor
|
|
|
23
23
|
export declare function getProviderUrl(provider: RpcProvider, network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
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
|
+
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;
|