@alchemy/common 0.0.0-alpha.9 → 5.0.0-beta.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/LICENSE +1 -1
- package/README.md +36 -0
- package/dist/esm/chains.d.ts +54 -0
- package/dist/esm/index.d.ts +0 -11
- package/dist/esm/index.js +4 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal.d.ts +6 -0
- package/dist/esm/internal.js +6 -0
- package/dist/esm/internal.js.map +1 -0
- package/dist/esm/tracing/traceHeader.d.ts +8 -4
- package/dist/esm/tracing/traceHeader.js +8 -4
- package/dist/esm/tracing/traceHeader.js.map +1 -1
- package/dist/esm/transport/chainRegistry.d.ts +2 -1
- package/dist/esm/transport/chainRegistry.js +85 -49
- package/dist/esm/transport/chainRegistry.js.map +1 -1
- package/dist/esm/utils/bigint.js +3 -2
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/chains.d.ts +54 -0
- package/dist/types/chains.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/internal.d.ts +7 -0
- package/dist/types/internal.d.ts.map +1 -0
- package/dist/types/tracing/traceHeader.d.ts +8 -4
- package/dist/types/tracing/traceHeader.d.ts.map +1 -1
- package/dist/types/transport/chainRegistry.d.ts +2 -1
- package/dist/types/transport/chainRegistry.d.ts.map +1 -1
- package/dist/types/utils/bigint.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +11 -5
- package/src/index.ts +4 -24
- package/src/internal.ts +15 -0
- package/src/tracing/traceHeader.ts +8 -4
- package/src/transport/chainRegistry.ts +103 -52
- package/src/utils/bigint.ts +4 -2
- package/src/version.ts +1 -1
- package/dist/esm/transport/connection.d.ts +0 -20
- package/dist/esm/transport/connection.js +0 -2
- package/dist/esm/transport/connection.js.map +0 -1
- package/dist/esm/utils/createEip1193HandlerFactory.d.ts +0 -18
- package/dist/esm/utils/createEip1193HandlerFactory.js +0 -11
- package/dist/esm/utils/createEip1193HandlerFactory.js.map +0 -1
- package/dist/types/transport/connection.d.ts +0 -21
- package/dist/types/transport/connection.d.ts.map +0 -1
- package/dist/types/utils/createEip1193HandlerFactory.d.ts +0 -19
- package/dist/types/utils/createEip1193HandlerFactory.d.ts.map +0 -1
- package/src/transport/connection.ts +0 -19
- package/src/utils/createEip1193HandlerFactory.ts +0 -25
|
@@ -1,82 +1,134 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal registry mapping chain IDs to Alchemy RPC base URLs.
|
|
3
3
|
* This replaces the need for custom chain exports with embedded Alchemy URLs.
|
|
4
|
+
*
|
|
5
|
+
* Auto-generated by the ws-tools CLI — do not manually edit.
|
|
4
6
|
*/
|
|
5
7
|
export const ALCHEMY_RPC_MAPPING: Record<number, string> = {
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
// ANIME networks
|
|
9
|
+
6900: "https://anime-sepolia.g.alchemy.com/v2", // animeSepolia
|
|
10
|
+
69000: "https://anime-mainnet.g.alchemy.com/v2", // animeMainnet
|
|
11
|
+
|
|
12
|
+
// APECHAIN networks
|
|
13
|
+
33139: "https://apechain-mainnet.g.alchemy.com/v2", // apechainMainnet
|
|
14
|
+
33111: "https://apechain-curtis.g.alchemy.com/v2", // apechainCurtis
|
|
15
|
+
|
|
16
|
+
// ARB networks
|
|
17
|
+
421614: "https://arb-sepolia.g.alchemy.com/v2", // arbSepolia
|
|
18
|
+
42161: "https://arb-mainnet.g.alchemy.com/v2", // arbMainnet
|
|
19
|
+
|
|
20
|
+
// ARBNOVA networks
|
|
21
|
+
42170: "https://arbnova-mainnet.g.alchemy.com/v2", // arbnovaMainnet
|
|
22
|
+
|
|
23
|
+
// ARC networks
|
|
24
|
+
5042002: "https://arc-testnet.g.alchemy.com/v2", // arcTestnet
|
|
25
|
+
|
|
26
|
+
// BASE networks
|
|
27
|
+
8453: "https://base-mainnet.g.alchemy.com/v2", // baseMainnet
|
|
24
28
|
84532: "https://base-sepolia.g.alchemy.com/v2", // baseSepolia
|
|
25
29
|
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
80002: "https://polygon-amoy.g.alchemy.com/v2", // polygonAmoy
|
|
30
|
+
// BERACHAIN networks
|
|
31
|
+
80094: "https://berachain-mainnet.g.alchemy.com/v2", // berachainMainnet
|
|
32
|
+
80069: "https://berachain-bepolia.g.alchemy.com/v2", // berachainBepolia
|
|
30
33
|
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
// BNB networks
|
|
35
|
+
97: "https://bnb-testnet.g.alchemy.com/v2", // bnbTestnet
|
|
36
|
+
56: "https://bnb-mainnet.g.alchemy.com/v2", // bnbMainnet
|
|
34
37
|
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
// CELO networks
|
|
39
|
+
11142220: "https://celo-sepolia.g.alchemy.com/v2", // celoSepolia
|
|
40
|
+
42220: "https://celo-mainnet.g.alchemy.com/v2", // celoMainnet
|
|
38
41
|
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
1301: "https://unichain-sepolia.g.alchemy.com/v2", // unichainSepolia
|
|
42
|
+
// CLANKERMON networks
|
|
43
|
+
510525: "https://clankermon-mainnet.g.alchemy.com/v2", // clankermonMainnet
|
|
42
44
|
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
// ETH networks
|
|
46
|
+
1: "https://eth-mainnet.g.alchemy.com/v2", // ethMainnet
|
|
47
|
+
11155111: "https://eth-sepolia.g.alchemy.com/v2", // ethSepolia
|
|
46
48
|
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
5611: "https://opbnb-testnet.g.alchemy.com/v2", // opbnbTestnet
|
|
49
|
+
// FRAX networks
|
|
50
|
+
252: "https://frax-mainnet.g.alchemy.com/v2", // fraxMainnet
|
|
50
51
|
|
|
51
|
-
//
|
|
52
|
-
|
|
52
|
+
// GENSYN networks
|
|
53
|
+
685685: "https://gensyn-testnet.g.alchemy.com/v2", // gensynTestnet
|
|
54
|
+
|
|
55
|
+
// HYPERLIQUID networks
|
|
56
|
+
999: "https://hyperliquid-mainnet.g.alchemy.com/v2", // hyperliquidMainnet
|
|
53
57
|
|
|
54
|
-
//
|
|
58
|
+
// INK networks
|
|
55
59
|
57073: "https://ink-mainnet.g.alchemy.com/v2", // inkMainnet
|
|
56
60
|
763373: "https://ink-sepolia.g.alchemy.com/v2", // inkSepolia
|
|
57
61
|
|
|
58
|
-
//
|
|
62
|
+
// MATIC networks
|
|
63
|
+
80002: "https://polygon-amoy.g.alchemy.com/v2", // maticAmoy
|
|
64
|
+
137: "https://polygon-mainnet.g.alchemy.com/v2", // maticMainnet
|
|
65
|
+
|
|
66
|
+
// MEGAETH networks
|
|
67
|
+
4326: "https://megaeth-mainnet.g.alchemy.com/v2", // megaethMainnet
|
|
68
|
+
6343: "https://megaeth-testnet.g.alchemy.com/v2", // megaethTestnet
|
|
69
|
+
|
|
70
|
+
// MONAD networks
|
|
59
71
|
10143: "https://monad-testnet.g.alchemy.com/v2", // monadTestnet
|
|
72
|
+
143: "https://monad-mainnet.g.alchemy.com/v2", // monadMainnet
|
|
73
|
+
|
|
74
|
+
// MYTHOS networks
|
|
75
|
+
42018: "https://mythos-mainnet.g.alchemy.com/v2", // mythosMainnet
|
|
60
76
|
|
|
61
|
-
//
|
|
77
|
+
// OPBNB networks
|
|
78
|
+
5611: "https://opbnb-testnet.g.alchemy.com/v2", // opbnbTestnet
|
|
79
|
+
204: "https://opbnb-mainnet.g.alchemy.com/v2", // opbnbMainnet
|
|
80
|
+
|
|
81
|
+
// OPENLOOT networks
|
|
62
82
|
905905: "https://openloot-sepolia.g.alchemy.com/v2", // openlootSepolia
|
|
63
83
|
|
|
64
|
-
//
|
|
65
|
-
|
|
84
|
+
// OPT networks
|
|
85
|
+
10: "https://opt-mainnet.g.alchemy.com/v2", // optMainnet
|
|
86
|
+
11155420: "https://opt-sepolia.g.alchemy.com/v2", // optSepolia
|
|
66
87
|
|
|
67
|
-
//
|
|
88
|
+
// PLASMA networks
|
|
89
|
+
9746: "https://plasma-testnet.g.alchemy.com/v2", // plasmaTestnet
|
|
90
|
+
9745: "https://plasma-mainnet.g.alchemy.com/v2", // plasmaMainnet
|
|
91
|
+
|
|
92
|
+
// POLYNOMIAL networks
|
|
93
|
+
8008: "https://polynomial-mainnet.g.alchemy.com/v2", // polynomialMainnet
|
|
94
|
+
80008: "https://polynomial-sepolia.g.alchemy.com/v2", // polynomialSepolia
|
|
95
|
+
|
|
96
|
+
// RISE networks
|
|
68
97
|
11155931: "https://rise-testnet.g.alchemy.com/v2", // riseTestnet
|
|
69
98
|
|
|
70
|
-
//
|
|
99
|
+
// ROBINHOOD networks
|
|
100
|
+
46630: "https://robinhood-testnet.g.alchemy.com/v2", // robinhoodTestnet
|
|
101
|
+
|
|
102
|
+
// SHAPE networks
|
|
103
|
+
11011: "https://shape-sepolia.g.alchemy.com/v2", // shapeSepolia
|
|
104
|
+
360: "https://shape-mainnet.g.alchemy.com/v2", // shapeMainnet
|
|
105
|
+
|
|
106
|
+
// SONEIUM networks
|
|
107
|
+
1946: "https://soneium-minato.g.alchemy.com/v2", // soneiumMinato
|
|
108
|
+
1868: "https://soneium-mainnet.g.alchemy.com/v2", // soneiumMainnet
|
|
109
|
+
|
|
110
|
+
// STABLE networks
|
|
111
|
+
988: "https://stable-mainnet.g.alchemy.com/v2", // stableMainnet
|
|
112
|
+
2201: "https://stable-testnet.g.alchemy.com/v2", // stableTestnet
|
|
113
|
+
|
|
114
|
+
// STORY networks
|
|
71
115
|
1514: "https://story-mainnet.g.alchemy.com/v2", // storyMainnet
|
|
72
116
|
1315: "https://story-aeneid.g.alchemy.com/v2", // storyAeneid
|
|
73
117
|
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
118
|
+
// UNICHAIN networks
|
|
119
|
+
1301: "https://unichain-sepolia.g.alchemy.com/v2", // unichainSepolia
|
|
120
|
+
130: "https://unichain-mainnet.g.alchemy.com/v2", // unichainMainnet
|
|
121
|
+
|
|
122
|
+
// WORLDCHAIN networks
|
|
123
|
+
4801: "https://worldchain-sepolia.g.alchemy.com/v2", // worldchainSepolia
|
|
124
|
+
480: "https://worldchain-mainnet.g.alchemy.com/v2", // worldchainMainnet
|
|
125
|
+
|
|
126
|
+
// WORLDMOBILECHAIN networks
|
|
127
|
+
869: "https://worldmobilechain-mainnet.g.alchemy.com/v2", // worldmobilechainMainnet
|
|
77
128
|
|
|
78
|
-
//
|
|
79
|
-
|
|
129
|
+
// ZORA networks
|
|
130
|
+
7777777: "https://zora-mainnet.g.alchemy.com/v2", // zoraMainnet
|
|
131
|
+
999999999: "https://zora-sepolia.g.alchemy.com/v2", // zoraSepolia
|
|
80
132
|
};
|
|
81
133
|
|
|
82
134
|
/**
|
|
@@ -88,7 +140,6 @@ export const ALCHEMY_RPC_MAPPING: Record<number, string> = {
|
|
|
88
140
|
* @example
|
|
89
141
|
* ```ts
|
|
90
142
|
* const rpcUrl = getAlchemyRpcUrl(1); // "https://eth-mainnet.g.alchemy.com/v2"
|
|
91
|
-
* const customUrl = getAlchemyRpcUrl(999); // undefined
|
|
92
143
|
* ```
|
|
93
144
|
*/
|
|
94
145
|
export function getAlchemyRpcUrl(chainId: number): string | undefined {
|
package/src/utils/bigint.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BaseError } from "../errors/BaseError.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* BigNumberish represents values that can be converted to BigInt
|
|
3
5
|
*/
|
|
@@ -42,7 +44,7 @@ export const bigIntMultiply = (
|
|
|
42
44
|
roundingMode: RoundingMode = RoundingMode.ROUND_UP,
|
|
43
45
|
) => {
|
|
44
46
|
if (!isValidMultiplier({ multiplier })) {
|
|
45
|
-
throw new
|
|
47
|
+
throw new BaseError(
|
|
46
48
|
"bigIntMultiply requires a multiplier validated number as the second argument (max 4 decimal places)",
|
|
47
49
|
);
|
|
48
50
|
}
|
|
@@ -65,7 +67,7 @@ export const bigIntMultiply = (
|
|
|
65
67
|
*/
|
|
66
68
|
export const bigIntMax = (...args: bigint[]): bigint => {
|
|
67
69
|
if (!args.length) {
|
|
68
|
-
throw new
|
|
70
|
+
throw new BaseError("bigIntMax requires at least one argument");
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
return args.reduce((m, c) => (m > c ? m : c));
|
package/src/version.ts
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Never } from "../utils/types";
|
|
2
|
-
type AlchemyConnectionBaseConfig = {
|
|
3
|
-
proxyUrl: string;
|
|
4
|
-
apiKey?: never;
|
|
5
|
-
jwt?: never;
|
|
6
|
-
} | {
|
|
7
|
-
proxyUrl?: never;
|
|
8
|
-
apiKey: string;
|
|
9
|
-
jwt?: never;
|
|
10
|
-
} | {
|
|
11
|
-
proxyUrl?: never;
|
|
12
|
-
apiKey?: never;
|
|
13
|
-
jwt: string;
|
|
14
|
-
};
|
|
15
|
-
type AAOnlyChainConfig = {
|
|
16
|
-
alchemyConnection: AlchemyConnectionBaseConfig;
|
|
17
|
-
nodeRpcUrl: string;
|
|
18
|
-
};
|
|
19
|
-
export type AlchemyConnectionConfig = (AlchemyConnectionBaseConfig & Never<AAOnlyChainConfig>) | (AAOnlyChainConfig & Never<AlchemyConnectionBaseConfig>);
|
|
20
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/transport/connection.ts"],"names":[],"mappings":"","sourcesContent":["import type { Never } from \"../utils/types\";\n\n// TODO(v5): remove this file and use connectionSchema.ts instead once other packages are migrated over\ntype AlchemyConnectionBaseConfig =\n // TODO(v5): is this really the best devex? can we do better?\n // basic configuration for connecting to alchemy.\n // proxyUrl is used when making calls to the developer backend.\n | { proxyUrl: string; apiKey?: never; jwt?: never }\n | { proxyUrl?: never; apiKey: string; jwt?: never }\n | { proxyUrl?: never; apiKey?: never; jwt: string };\n\ntype AAOnlyChainConfig = {\n alchemyConnection: AlchemyConnectionBaseConfig;\n nodeRpcUrl: string;\n};\n\nexport type AlchemyConnectionConfig =\n | (AlchemyConnectionBaseConfig & Never<AAOnlyChainConfig>)\n | (AAOnlyChainConfig & Never<AlchemyConnectionBaseConfig>);\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a typed handler factory for EIP1193 request methods.
|
|
3
|
-
* This helps with Viem's typing within custom EIP1193 request functions by
|
|
4
|
-
* automatically casting input params and ensuring the result matches what is required.
|
|
5
|
-
*
|
|
6
|
-
* @returns {(params: unknown) => unknown} A function that creates a handler factory for specific methods
|
|
7
|
-
*/
|
|
8
|
-
export declare const createEip1193HandlerFactory: <TMethods extends readonly {
|
|
9
|
-
Method: string;
|
|
10
|
-
Parameters?: unknown;
|
|
11
|
-
ReturnType?: unknown;
|
|
12
|
-
}[]>() => <TMethod extends TMethods[number]["Method"]>(handle: (params: Extract<TMethods[number], {
|
|
13
|
-
Method: TMethod;
|
|
14
|
-
}>["Parameters"]) => Promise<Extract<TMethods[number], {
|
|
15
|
-
Method: TMethod;
|
|
16
|
-
}>["ReturnType"]>) => (params: unknown) => Promise<Extract<TMethods[number], {
|
|
17
|
-
Method: TMethod;
|
|
18
|
-
}>["ReturnType"]>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a typed handler factory for EIP1193 request methods.
|
|
3
|
-
* This helps with Viem's typing within custom EIP1193 request functions by
|
|
4
|
-
* automatically casting input params and ensuring the result matches what is required.
|
|
5
|
-
*
|
|
6
|
-
* @returns {(params: unknown) => unknown} A function that creates a handler factory for specific methods
|
|
7
|
-
*/
|
|
8
|
-
export const createEip1193HandlerFactory = () => (handle) => (params) => {
|
|
9
|
-
return handle(params);
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=createEip1193HandlerFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createEip1193HandlerFactory.js","sourceRoot":"","sources":["../../../src/utils/createEip1193HandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACtC,GAMI,EAAE,CACN,CACE,MAE0E,EAC1E,EAAE,CACJ,CAAC,MAAe,EAAE,EAAE;IAClB,OAAO,MAAM,CACX,MAAsE,CACvE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Creates a typed handler factory for EIP1193 request methods.\n * This helps with Viem's typing within custom EIP1193 request functions by\n * automatically casting input params and ensuring the result matches what is required.\n *\n * @returns {(params: unknown) => unknown} A function that creates a handler factory for specific methods\n */\nexport const createEip1193HandlerFactory =\n <\n TMethods extends readonly {\n Method: string;\n Parameters?: unknown;\n ReturnType?: unknown;\n }[],\n >() =>\n <TMethod extends TMethods[number][\"Method\"]>(\n handle: (\n params: Extract<TMethods[number], { Method: TMethod }>[\"Parameters\"],\n ) => Promise<Extract<TMethods[number], { Method: TMethod }>[\"ReturnType\"]>,\n ) =>\n (params: unknown) => {\n return handle(\n params as Extract<TMethods[number], { Method: TMethod }>[\"Parameters\"],\n );\n };\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Never } from "../utils/types";
|
|
2
|
-
type AlchemyConnectionBaseConfig = {
|
|
3
|
-
proxyUrl: string;
|
|
4
|
-
apiKey?: never;
|
|
5
|
-
jwt?: never;
|
|
6
|
-
} | {
|
|
7
|
-
proxyUrl?: never;
|
|
8
|
-
apiKey: string;
|
|
9
|
-
jwt?: never;
|
|
10
|
-
} | {
|
|
11
|
-
proxyUrl?: never;
|
|
12
|
-
apiKey?: never;
|
|
13
|
-
jwt: string;
|
|
14
|
-
};
|
|
15
|
-
type AAOnlyChainConfig = {
|
|
16
|
-
alchemyConnection: AlchemyConnectionBaseConfig;
|
|
17
|
-
nodeRpcUrl: string;
|
|
18
|
-
};
|
|
19
|
-
export type AlchemyConnectionConfig = (AlchemyConnectionBaseConfig & Never<AAOnlyChainConfig>) | (AAOnlyChainConfig & Never<AlchemyConnectionBaseConfig>);
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/transport/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAG5C,KAAK,2BAA2B,GAI5B;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAC;IAAC,GAAG,CAAC,EAAE,KAAK,CAAA;CAAE,GACjD;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,KAAK,CAAA;CAAE,GACjD;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD,KAAK,iBAAiB,GAAG;IACvB,iBAAiB,EAAE,2BAA2B,CAAC;IAC/C,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,CAAC,2BAA2B,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC,GACxD,CAAC,iBAAiB,GAAG,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a typed handler factory for EIP1193 request methods.
|
|
3
|
-
* This helps with Viem's typing within custom EIP1193 request functions by
|
|
4
|
-
* automatically casting input params and ensuring the result matches what is required.
|
|
5
|
-
*
|
|
6
|
-
* @returns {(params: unknown) => unknown} A function that creates a handler factory for specific methods
|
|
7
|
-
*/
|
|
8
|
-
export declare const createEip1193HandlerFactory: <TMethods extends readonly {
|
|
9
|
-
Method: string;
|
|
10
|
-
Parameters?: unknown;
|
|
11
|
-
ReturnType?: unknown;
|
|
12
|
-
}[]>() => <TMethod extends TMethods[number]["Method"]>(handle: (params: Extract<TMethods[number], {
|
|
13
|
-
Method: TMethod;
|
|
14
|
-
}>["Parameters"]) => Promise<Extract<TMethods[number], {
|
|
15
|
-
Method: TMethod;
|
|
16
|
-
}>["ReturnType"]>) => (params: unknown) => Promise<Extract<TMethods[number], {
|
|
17
|
-
Method: TMethod;
|
|
18
|
-
}>["ReturnType"]>;
|
|
19
|
-
//# sourceMappingURL=createEip1193HandlerFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createEip1193HandlerFactory.d.ts","sourceRoot":"","sources":["../../../src/utils/createEip1193HandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GAEpC,QAAQ,SAAS,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,EAAE,QAEJ,OAAO,SAAS,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACzC,QAAQ,CACN,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,YAAY,CAAC,KACjE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,YAAY,CAAC,CAAC,MAE3E,QAAQ,OAAO;YAFmC,OAAO;iBAMzD,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Never } from "../utils/types";
|
|
2
|
-
|
|
3
|
-
// TODO(v5): remove this file and use connectionSchema.ts instead once other packages are migrated over
|
|
4
|
-
type AlchemyConnectionBaseConfig =
|
|
5
|
-
// TODO(v5): is this really the best devex? can we do better?
|
|
6
|
-
// basic configuration for connecting to alchemy.
|
|
7
|
-
// proxyUrl is used when making calls to the developer backend.
|
|
8
|
-
| { proxyUrl: string; apiKey?: never; jwt?: never }
|
|
9
|
-
| { proxyUrl?: never; apiKey: string; jwt?: never }
|
|
10
|
-
| { proxyUrl?: never; apiKey?: never; jwt: string };
|
|
11
|
-
|
|
12
|
-
type AAOnlyChainConfig = {
|
|
13
|
-
alchemyConnection: AlchemyConnectionBaseConfig;
|
|
14
|
-
nodeRpcUrl: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type AlchemyConnectionConfig =
|
|
18
|
-
| (AlchemyConnectionBaseConfig & Never<AAOnlyChainConfig>)
|
|
19
|
-
| (AAOnlyChainConfig & Never<AlchemyConnectionBaseConfig>);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a typed handler factory for EIP1193 request methods.
|
|
3
|
-
* This helps with Viem's typing within custom EIP1193 request functions by
|
|
4
|
-
* automatically casting input params and ensuring the result matches what is required.
|
|
5
|
-
*
|
|
6
|
-
* @returns {(params: unknown) => unknown} A function that creates a handler factory for specific methods
|
|
7
|
-
*/
|
|
8
|
-
export const createEip1193HandlerFactory =
|
|
9
|
-
<
|
|
10
|
-
TMethods extends readonly {
|
|
11
|
-
Method: string;
|
|
12
|
-
Parameters?: unknown;
|
|
13
|
-
ReturnType?: unknown;
|
|
14
|
-
}[],
|
|
15
|
-
>() =>
|
|
16
|
-
<TMethod extends TMethods[number]["Method"]>(
|
|
17
|
-
handle: (
|
|
18
|
-
params: Extract<TMethods[number], { Method: TMethod }>["Parameters"],
|
|
19
|
-
) => Promise<Extract<TMethods[number], { Method: TMethod }>["ReturnType"]>,
|
|
20
|
-
) =>
|
|
21
|
-
(params: unknown) => {
|
|
22
|
-
return handle(
|
|
23
|
-
params as Extract<TMethods[number], { Method: TMethod }>["Parameters"],
|
|
24
|
-
);
|
|
25
|
-
};
|