@gearbox-protocol/sdk 4.1.0 → 4.1.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/createTransport.js +2 -2
- package/dist/cjs/dev/migrateFaucet.js +6 -0
- package/dist/esm/dev/createTransport.js +2 -2
- package/dist/esm/dev/migrateFaucet.js +6 -0
- package/dist/types/dev/createTransport.d.ts +10 -4
- package/dist/types/dev/migrateFaucet.d.ts +2 -1
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(createTransport_exports);
|
|
|
27
27
|
var import_viem = require("viem");
|
|
28
28
|
var import_sdk = require("../sdk/index.js");
|
|
29
29
|
function createTransport(config) {
|
|
30
|
-
const { alchemyKeys, protocol, network } = config;
|
|
30
|
+
const { alchemyKeys, protocol, network, ...rest } = config;
|
|
31
31
|
const rpcUrls = config.rpcUrls.filter((url) => {
|
|
32
32
|
return url.startsWith(protocol) && !alchemyKeys.some((key) => url.includes(key));
|
|
33
33
|
});
|
|
@@ -38,7 +38,7 @@ function createTransport(config) {
|
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
const transports = rpcUrls.map(
|
|
41
|
-
(url) => protocol === "http" ? (0, import_viem.http)(url) : (0, import_viem.webSocket)(url)
|
|
41
|
+
(url) => protocol === "http" ? (0, import_viem.http)(url, rest) : (0, import_viem.webSocket)(url, rest)
|
|
42
42
|
);
|
|
43
43
|
if (transports.length === 0) {
|
|
44
44
|
throw new Error("no fitting rpc urls found");
|
|
@@ -100,6 +100,12 @@ async function migrateFaucet(sdk, faucet) {
|
|
|
100
100
|
} catch (e) {
|
|
101
101
|
sdk.logger?.error(`faucet migration failed: ${e}`);
|
|
102
102
|
}
|
|
103
|
+
return sdk.provider.publicClient.readContract({
|
|
104
|
+
abi: import_v310.iAddressProviderV310Abi,
|
|
105
|
+
address: sdk.addressProvider.address,
|
|
106
|
+
functionName: "getAddressOrRevert",
|
|
107
|
+
args: [(0, import_viem.stringToHex)("FAUCET", { size: 32 }), 0n]
|
|
108
|
+
});
|
|
103
109
|
}
|
|
104
110
|
// Annotate the CommonJS export names for ESM import in node:
|
|
105
111
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fallback, http, webSocket } from "viem";
|
|
2
2
|
import { getChain } from "../sdk/index.js";
|
|
3
3
|
function createTransport(config) {
|
|
4
|
-
const { alchemyKeys, protocol, network } = config;
|
|
4
|
+
const { alchemyKeys, protocol, network, ...rest } = config;
|
|
5
5
|
const rpcUrls = config.rpcUrls.filter((url) => {
|
|
6
6
|
return url.startsWith(protocol) && !alchemyKeys.some((key) => url.includes(key));
|
|
7
7
|
});
|
|
@@ -12,7 +12,7 @@ function createTransport(config) {
|
|
|
12
12
|
);
|
|
13
13
|
}
|
|
14
14
|
const transports = rpcUrls.map(
|
|
15
|
-
(url) => protocol === "http" ? http(url) : webSocket(url)
|
|
15
|
+
(url) => protocol === "http" ? http(url, rest) : webSocket(url, rest)
|
|
16
16
|
);
|
|
17
17
|
if (transports.length === 0) {
|
|
18
18
|
throw new Error("no fitting rpc urls found");
|
|
@@ -76,6 +76,12 @@ async function migrateFaucet(sdk, faucet) {
|
|
|
76
76
|
} catch (e) {
|
|
77
77
|
sdk.logger?.error(`faucet migration failed: ${e}`);
|
|
78
78
|
}
|
|
79
|
+
return sdk.provider.publicClient.readContract({
|
|
80
|
+
abi: iAddressProviderV310Abi,
|
|
81
|
+
address: sdk.addressProvider.address,
|
|
82
|
+
functionName: "getAddressOrRevert",
|
|
83
|
+
args: [stringToHex("FAUCET", { size: 32 }), 0n]
|
|
84
|
+
});
|
|
79
85
|
}
|
|
80
86
|
export {
|
|
81
87
|
migrateFaucet,
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export interface
|
|
1
|
+
import type { HttpTransportConfig, Transport, WebSocketTransportConfig } from "viem";
|
|
2
|
+
import type { NetworkType } from "../sdk/index.js";
|
|
3
|
+
export interface CreateTransportURLOptions {
|
|
4
4
|
rpcUrls: string[];
|
|
5
5
|
alchemyKeys: string[];
|
|
6
|
-
protocol: "http" | "ws";
|
|
7
6
|
network: NetworkType;
|
|
8
7
|
}
|
|
8
|
+
export type CreateHTTPTransportConfig = {
|
|
9
|
+
protocol: "http";
|
|
10
|
+
} & HttpTransportConfig & CreateTransportURLOptions;
|
|
11
|
+
export type CreateWSTransportConfig = {
|
|
12
|
+
protocol: "ws";
|
|
13
|
+
} & WebSocketTransportConfig & CreateTransportURLOptions;
|
|
14
|
+
export type CreateTransportConfig = CreateHTTPTransportConfig | CreateWSTransportConfig;
|
|
9
15
|
/**
|
|
10
16
|
* Helper method to create viem Transport using API keys of well-known RPC providers and explicit fallback URLs
|
|
11
17
|
* Currently only supports Alchemy
|
|
@@ -5,5 +5,6 @@ export declare function unsafeMigrateFaucet(sdk: GearboxSDK, faucet?: Address):
|
|
|
5
5
|
* Sets new faucet address on v3.1 address provider
|
|
6
6
|
* @param sdk
|
|
7
7
|
* @param faucet - new faucet address. If not provided, will try to get one from v3.0 address provider
|
|
8
|
+
* @returns faucet address as read from v3.1 address provider
|
|
8
9
|
*/
|
|
9
|
-
export declare function migrateFaucet(sdk: GearboxSDK, faucet?: Address): Promise<
|
|
10
|
+
export declare function migrateFaucet(sdk: GearboxSDK, faucet?: Address): Promise<Address>;
|