web3-tools-mcp 2.0.1 → 3.0.0
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/CHANGELOG.md +117 -0
- package/README.md +5 -0
- package/dist/anvil.d.ts +17 -19
- package/dist/anvil.d.ts.map +1 -1
- package/dist/anvil.js +124 -228
- package/dist/anvil.js.map +1 -1
- package/dist/chains.d.ts +9 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +11 -2
- package/dist/chains.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +22 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +24 -0
- package/dist/context.js.map +1 -0
- package/dist/hosted.d.ts +12 -0
- package/dist/hosted.d.ts.map +1 -0
- package/dist/hosted.js +12 -0
- package/dist/hosted.js.map +1 -0
- package/dist/http-server.d.ts +13 -0
- package/dist/http-server.d.ts.map +1 -1
- package/dist/http-server.js +13 -4
- package/dist/http-server.js.map +1 -1
- package/dist/index.js +19 -15
- package/dist/index.js.map +1 -1
- package/dist/lib.d.ts +24 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +23 -0
- package/dist/lib.js.map +1 -0
- package/dist/log.d.ts +16 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +20 -0
- package/dist/log.js.map +1 -0
- package/dist/mcp-server.d.ts +4 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +43 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/oauth.d.ts +41 -6
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +75 -41
- package/dist/oauth.js.map +1 -1
- package/dist/preview.d.ts +7 -0
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +14 -2
- package/dist/preview.js.map +1 -1
- package/dist/signing-requests.d.ts +81 -0
- package/dist/signing-requests.d.ts.map +1 -0
- package/dist/signing-requests.js +138 -0
- package/dist/signing-requests.js.map +1 -0
- package/dist/tools/index.d.ts +27 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +37 -15
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/{advanced.d.ts → read/advanced.d.ts} +30 -26
- package/dist/tools/read/advanced.d.ts.map +1 -0
- package/dist/tools/{advanced.js → read/advanced.js} +10 -10
- package/dist/tools/read/advanced.js.map +1 -0
- package/dist/tools/{balance.d.ts → read/balance.d.ts} +8 -7
- package/dist/tools/read/balance.d.ts.map +1 -0
- package/dist/tools/{balance.js → read/balance.js} +2 -2
- package/dist/tools/read/balance.js.map +1 -0
- package/dist/tools/{contract-info.d.ts → read/contract-info.d.ts} +18 -15
- package/dist/tools/read/contract-info.d.ts.map +1 -0
- package/dist/tools/{contract-info.js → read/contract-info.js} +2 -2
- package/dist/tools/read/contract-info.js.map +1 -0
- package/dist/tools/{contract.d.ts → read/contract.d.ts} +14 -12
- package/dist/tools/read/contract.d.ts.map +1 -0
- package/dist/tools/{contract.js → read/contract.js} +2 -2
- package/dist/tools/read/contract.js.map +1 -0
- package/dist/tools/{ens.d.ts → read/ens.d.ts} +30 -25
- package/dist/tools/read/ens.d.ts.map +1 -0
- package/dist/tools/{ens.js → read/ens.js} +2 -2
- package/dist/tools/read/ens.js.map +1 -0
- package/dist/tools/read/gas.d.ts +171 -0
- package/dist/tools/read/gas.d.ts.map +1 -0
- package/dist/tools/read/gas.js +368 -0
- package/dist/tools/read/gas.js.map +1 -0
- package/dist/tools/{logs.d.ts → read/logs.d.ts} +6 -5
- package/dist/tools/read/logs.d.ts.map +1 -0
- package/dist/tools/{logs.js → read/logs.js} +2 -2
- package/dist/tools/read/logs.js.map +1 -0
- package/dist/tools/{signatures.d.ts → read/signatures.d.ts} +8 -4
- package/dist/tools/read/signatures.d.ts.map +1 -0
- package/dist/tools/{signatures.js → read/signatures.js} +1 -1
- package/dist/tools/read/signatures.js.map +1 -0
- package/dist/tools/read/signing.d.ts +27 -0
- package/dist/tools/read/signing.d.ts.map +1 -0
- package/dist/tools/read/signing.js +75 -0
- package/dist/tools/read/signing.js.map +1 -0
- package/dist/tools/sign/errors.d.ts +9 -0
- package/dist/tools/sign/errors.d.ts.map +1 -0
- package/dist/tools/sign/errors.js +29 -0
- package/dist/tools/sign/errors.js.map +1 -0
- package/dist/tools/{transactions.d.ts → sign/transactions.d.ts} +48 -62
- package/dist/tools/sign/transactions.d.ts.map +1 -0
- package/dist/tools/sign/transactions.js +316 -0
- package/dist/tools/sign/transactions.js.map +1 -0
- package/dist/tools/sign/wallet.d.ts +50 -0
- package/dist/tools/sign/wallet.d.ts.map +1 -0
- package/dist/tools/sign/wallet.js +180 -0
- package/dist/tools/sign/wallet.js.map +1 -0
- package/dist/utils.d.ts +5 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +5 -2
- package/dist/utils.js.map +1 -1
- package/dist/wallet-client.d.ts +33 -4
- package/dist/wallet-client.d.ts.map +1 -1
- package/dist/wallet-client.js +90 -24
- package/dist/wallet-client.js.map +1 -1
- package/dist/walletconnect.d.ts +111 -13
- package/dist/walletconnect.d.ts.map +1 -1
- package/dist/walletconnect.js +248 -68
- package/dist/walletconnect.js.map +1 -1
- package/package.json +10 -4
- package/src/anvil.ts +150 -271
- package/src/chains.ts +14 -2
- package/src/client.ts +0 -1
- package/src/context.ts +27 -0
- package/src/hosted.ts +11 -0
- package/src/http-server.ts +30 -5
- package/src/index.ts +19 -16
- package/src/lib.ts +24 -0
- package/src/log.ts +25 -0
- package/src/mcp-server.ts +47 -0
- package/src/oauth.ts +98 -45
- package/src/preview.ts +21 -2
- package/src/signing-requests.ts +198 -0
- package/src/tools/index.ts +67 -16
- package/src/tools/{advanced.ts → read/advanced.ts} +13 -11
- package/src/tools/{balance.ts → read/balance.ts} +3 -3
- package/src/tools/{contract-info.ts → read/contract-info.ts} +3 -3
- package/src/tools/{contract.ts → read/contract.ts} +3 -3
- package/src/tools/{ens.ts → read/ens.ts} +3 -3
- package/src/tools/read/gas.ts +480 -0
- package/src/tools/{logs.ts → read/logs.ts} +3 -3
- package/src/tools/{signatures.ts → read/signatures.ts} +2 -2
- package/src/tools/read/signing.ts +86 -0
- package/src/tools/sign/errors.ts +28 -0
- package/src/tools/sign/transactions.ts +428 -0
- package/src/tools/sign/wallet.ts +216 -0
- package/src/utils.ts +5 -2
- package/src/wallet-client.ts +91 -22
- package/src/walletconnect.ts +286 -66
- package/dist/tools/advanced.d.ts.map +0 -1
- package/dist/tools/advanced.js.map +0 -1
- package/dist/tools/balance.d.ts.map +0 -1
- package/dist/tools/balance.js.map +0 -1
- package/dist/tools/contract-info.d.ts.map +0 -1
- package/dist/tools/contract-info.js.map +0 -1
- package/dist/tools/contract.d.ts.map +0 -1
- package/dist/tools/contract.js.map +0 -1
- package/dist/tools/ens.d.ts.map +0 -1
- package/dist/tools/ens.js.map +0 -1
- package/dist/tools/gas.d.ts +0 -99
- package/dist/tools/gas.d.ts.map +0 -1
- package/dist/tools/gas.js +0 -181
- package/dist/tools/gas.js.map +0 -1
- package/dist/tools/logs.d.ts.map +0 -1
- package/dist/tools/logs.js.map +0 -1
- package/dist/tools/signatures.d.ts.map +0 -1
- package/dist/tools/signatures.js.map +0 -1
- package/dist/tools/transactions.d.ts.map +0 -1
- package/dist/tools/transactions.js +0 -361
- package/dist/tools/transactions.js.map +0 -1
- package/src/tools/gas.ts +0 -219
- package/src/tools/transactions.ts +0 -452
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
simulate_contract: {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
schema: z.ZodObject<{
|
|
7
|
+
chain: z.ZodEnum<["mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost", ...("mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost")[]]>;
|
|
8
|
+
contractAddress: z.ZodString;
|
|
9
|
+
functionAbi: z.ZodString;
|
|
10
|
+
args: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">>;
|
|
11
|
+
from: z.ZodOptional<z.ZodString>;
|
|
12
|
+
value: z.ZodOptional<z.ZodString>;
|
|
13
|
+
blockNumber: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
16
|
+
contractAddress: string;
|
|
17
|
+
functionAbi: string;
|
|
18
|
+
blockNumber?: string | undefined;
|
|
19
|
+
from?: string | undefined;
|
|
20
|
+
value?: string | undefined;
|
|
21
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
24
|
+
contractAddress: string;
|
|
25
|
+
functionAbi: string;
|
|
26
|
+
blockNumber?: string | undefined;
|
|
27
|
+
from?: string | undefined;
|
|
28
|
+
value?: string | undefined;
|
|
29
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
handler: (args: {
|
|
32
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
33
|
+
contractAddress: string;
|
|
34
|
+
functionAbi: string;
|
|
35
|
+
blockNumber?: string | undefined;
|
|
36
|
+
from?: string | undefined;
|
|
37
|
+
value?: string | undefined;
|
|
38
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
39
|
+
}, identity: string) => Promise<import("../../types.js").ToolResult>;
|
|
40
|
+
available: (() => boolean) | undefined;
|
|
41
|
+
};
|
|
42
|
+
simulate_bundle: {
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
schema: z.ZodObject<{
|
|
46
|
+
chain: z.ZodEnum<["mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost", ...("mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost")[]]>;
|
|
47
|
+
from: z.ZodOptional<z.ZodString>;
|
|
48
|
+
calls: z.ZodArray<z.ZodObject<{
|
|
49
|
+
to: z.ZodString;
|
|
50
|
+
functionAbi: z.ZodOptional<z.ZodString>;
|
|
51
|
+
args: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">>;
|
|
52
|
+
data: z.ZodOptional<z.ZodString>;
|
|
53
|
+
value: z.ZodOptional<z.ZodString>;
|
|
54
|
+
from: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
to: string;
|
|
57
|
+
from?: string | undefined;
|
|
58
|
+
value?: string | undefined;
|
|
59
|
+
data?: string | undefined;
|
|
60
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
61
|
+
functionAbi?: string | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
to: string;
|
|
64
|
+
from?: string | undefined;
|
|
65
|
+
value?: string | undefined;
|
|
66
|
+
data?: string | undefined;
|
|
67
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
68
|
+
functionAbi?: string | undefined;
|
|
69
|
+
}>, "many">;
|
|
70
|
+
blockNumber: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
73
|
+
calls: {
|
|
74
|
+
to: string;
|
|
75
|
+
from?: string | undefined;
|
|
76
|
+
value?: string | undefined;
|
|
77
|
+
data?: string | undefined;
|
|
78
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
79
|
+
functionAbi?: string | undefined;
|
|
80
|
+
}[];
|
|
81
|
+
blockNumber?: string | undefined;
|
|
82
|
+
from?: string | undefined;
|
|
83
|
+
}, {
|
|
84
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
85
|
+
calls: {
|
|
86
|
+
to: string;
|
|
87
|
+
from?: string | undefined;
|
|
88
|
+
value?: string | undefined;
|
|
89
|
+
data?: string | undefined;
|
|
90
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
91
|
+
functionAbi?: string | undefined;
|
|
92
|
+
}[];
|
|
93
|
+
blockNumber?: string | undefined;
|
|
94
|
+
from?: string | undefined;
|
|
95
|
+
}>;
|
|
96
|
+
handler: (args: {
|
|
97
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
98
|
+
calls: {
|
|
99
|
+
to: string;
|
|
100
|
+
from?: string | undefined;
|
|
101
|
+
value?: string | undefined;
|
|
102
|
+
data?: string | undefined;
|
|
103
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
104
|
+
functionAbi?: string | undefined;
|
|
105
|
+
}[];
|
|
106
|
+
blockNumber?: string | undefined;
|
|
107
|
+
from?: string | undefined;
|
|
108
|
+
}, identity: string) => Promise<import("../../types.js").ToolResult>;
|
|
109
|
+
available: (() => boolean) | undefined;
|
|
110
|
+
};
|
|
111
|
+
estimate_gas: {
|
|
112
|
+
title: string;
|
|
113
|
+
description: string;
|
|
114
|
+
schema: z.ZodObject<{
|
|
115
|
+
chain: z.ZodEnum<["mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost", ...("mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost")[]]>;
|
|
116
|
+
to: z.ZodOptional<z.ZodString>;
|
|
117
|
+
from: z.ZodOptional<z.ZodString>;
|
|
118
|
+
value: z.ZodOptional<z.ZodString>;
|
|
119
|
+
data: z.ZodOptional<z.ZodString>;
|
|
120
|
+
functionAbi: z.ZodOptional<z.ZodString>;
|
|
121
|
+
args: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">>;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
124
|
+
from?: string | undefined;
|
|
125
|
+
to?: string | undefined;
|
|
126
|
+
value?: string | undefined;
|
|
127
|
+
data?: string | undefined;
|
|
128
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
129
|
+
functionAbi?: string | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
132
|
+
from?: string | undefined;
|
|
133
|
+
to?: string | undefined;
|
|
134
|
+
value?: string | undefined;
|
|
135
|
+
data?: string | undefined;
|
|
136
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
137
|
+
functionAbi?: string | undefined;
|
|
138
|
+
}>;
|
|
139
|
+
handler: (args: {
|
|
140
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
141
|
+
from?: string | undefined;
|
|
142
|
+
to?: string | undefined;
|
|
143
|
+
value?: string | undefined;
|
|
144
|
+
data?: string | undefined;
|
|
145
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
146
|
+
functionAbi?: string | undefined;
|
|
147
|
+
}, identity: string) => Promise<import("../../types.js").ToolResult>;
|
|
148
|
+
available: (() => boolean) | undefined;
|
|
149
|
+
};
|
|
150
|
+
get_gas_price: {
|
|
151
|
+
title: string;
|
|
152
|
+
description: string;
|
|
153
|
+
schema: z.ZodObject<{
|
|
154
|
+
chain: z.ZodEnum<["mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost", ...("mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost")[]]>;
|
|
155
|
+
formatted: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
156
|
+
}, "strip", z.ZodTypeAny, {
|
|
157
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
158
|
+
formatted: boolean;
|
|
159
|
+
}, {
|
|
160
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
161
|
+
formatted?: boolean | undefined;
|
|
162
|
+
}>;
|
|
163
|
+
handler: (args: {
|
|
164
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
165
|
+
formatted: boolean;
|
|
166
|
+
}, identity: string) => Promise<import("../../types.js").ToolResult>;
|
|
167
|
+
available: (() => boolean) | undefined;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
export default _default;
|
|
171
|
+
//# sourceMappingURL=gas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../../../src/tools/read/gas.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmLvB,wBAgSC"}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { decodeFunctionResult, encodeFunctionData, formatEther, isAddress, parseAbiItem, toHex } from 'viem';
|
|
2
|
+
import { simulateBlocks } from 'viem/actions';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { getClientManager, SUPPORTED_CHAINS } from '../../client.js';
|
|
5
|
+
import { enrichTransfers } from '../../preview.js';
|
|
6
|
+
import { convertArgumentsToTypes, createTool, formatResponse } from '../../utils.js';
|
|
7
|
+
/** Alchemy's bundle method takes at most this many transactions. */
|
|
8
|
+
const ALCHEMY_BUNDLE_LIMIT = 3;
|
|
9
|
+
/** One tool call is one quota unit, so an unbounded bundle would be a way around the quota. */
|
|
10
|
+
const MAX_BUNDLE = 25;
|
|
11
|
+
/** Where eth_simulateV1's traced native transfers say they come from. */
|
|
12
|
+
const NATIVE_TOKEN = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
|
|
13
|
+
const argsSchema = z.array(z.union([z.string(), z.number(), z.boolean(), z.null()]));
|
|
14
|
+
/**
|
|
15
|
+
* Why an RPC call failed, without the request URL — viem puts it in `message`, and with a
|
|
16
|
+
* provider key configured that URL carries the key.
|
|
17
|
+
*/
|
|
18
|
+
function rpcReason(error) {
|
|
19
|
+
const { details, shortMessage } = error;
|
|
20
|
+
return details || shortMessage || 'The RPC request failed';
|
|
21
|
+
}
|
|
22
|
+
function bundleCall(call, from, index) {
|
|
23
|
+
const sender = call.from ?? from;
|
|
24
|
+
if (!isAddress(call.to))
|
|
25
|
+
throw new Error(`Call ${index}: invalid to address ${call.to}`);
|
|
26
|
+
if (sender && !isAddress(sender))
|
|
27
|
+
throw new Error(`Call ${index}: invalid from address ${sender}`);
|
|
28
|
+
if (call.functionAbi && call.data)
|
|
29
|
+
throw new Error(`Call ${index}: give functionAbi and args, or data — not both`);
|
|
30
|
+
const abi = call.functionAbi ? parseAbiItem(call.functionAbi) : undefined;
|
|
31
|
+
const data = abi
|
|
32
|
+
? encodeFunctionData({ abi: [abi], functionName: abi.name, args: convertArgumentsToTypes(call.args ?? [], abi.inputs) })
|
|
33
|
+
: call.data;
|
|
34
|
+
return { from: sender, to: call.to, data, value: call.value ? BigInt(call.value) : undefined, abi };
|
|
35
|
+
}
|
|
36
|
+
/** Native, ERC20, ERC721 and ERC1155 changes with token metadata — on Alchemy's paid plans only. */
|
|
37
|
+
async function viaAlchemy(chain, calls, blockNumber) {
|
|
38
|
+
const client = getClientManager().getClient(chain);
|
|
39
|
+
const transactions = calls.map((call) => ({
|
|
40
|
+
from: call.from,
|
|
41
|
+
to: call.to,
|
|
42
|
+
data: call.data,
|
|
43
|
+
value: call.value !== undefined ? toHex(call.value) : undefined
|
|
44
|
+
}));
|
|
45
|
+
const params = blockNumber === undefined ? [transactions] : [transactions, toHex(blockNumber)];
|
|
46
|
+
const outcomes = (await client.request({ method: 'alchemy_simulateAssetChangesBundle', params }));
|
|
47
|
+
return outcomes.map((outcome) => ({
|
|
48
|
+
status: outcome.error ? 'failure' : 'success',
|
|
49
|
+
gasUsed: outcome.gasUsed ? BigInt(outcome.gasUsed).toString() : undefined,
|
|
50
|
+
error: outcome.error?.message,
|
|
51
|
+
assetChanges: outcome.changes.map((change) => ({
|
|
52
|
+
assetType: change.assetType,
|
|
53
|
+
token: change.contractAddress,
|
|
54
|
+
symbol: change.symbol,
|
|
55
|
+
tokenId: change.tokenId,
|
|
56
|
+
from: change.from,
|
|
57
|
+
to: change.to,
|
|
58
|
+
amount: change.amount,
|
|
59
|
+
rawAmount: change.rawAmount
|
|
60
|
+
}))
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
function decodeResult(abi, data) {
|
|
64
|
+
if (!abi?.outputs.length)
|
|
65
|
+
return data;
|
|
66
|
+
try {
|
|
67
|
+
return decodeFunctionResult({ abi: [abi], functionName: abi.name, data });
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Any RPC with eth_simulateV1: decoded return values, and native, ERC20 and ERC721 transfers.
|
|
75
|
+
*
|
|
76
|
+
* ponytail: ERC1155 moves tokens with TransferSingle / TransferBatch, which are not read
|
|
77
|
+
* here, so those changes are missing on this path. Parse them if 1155 bundles matter.
|
|
78
|
+
*/
|
|
79
|
+
async function viaSimulateV1(chain, calls, blockNumber) {
|
|
80
|
+
const client = getClientManager().getClient(chain);
|
|
81
|
+
const [block] = await simulateBlocks(client, {
|
|
82
|
+
blocks: [{ calls: calls.map((call) => ({ account: call.from, to: call.to, data: call.data, value: call.value })) }],
|
|
83
|
+
traceTransfers: true,
|
|
84
|
+
validation: false,
|
|
85
|
+
...(blockNumber !== undefined && { blockNumber })
|
|
86
|
+
});
|
|
87
|
+
if (!block)
|
|
88
|
+
throw new Error('The RPC returned no simulated block');
|
|
89
|
+
const nativeSymbol = client.chain?.nativeCurrency.symbol;
|
|
90
|
+
return Promise.all(block.calls.map(async (call, index) => {
|
|
91
|
+
const error = call.error;
|
|
92
|
+
const transfers = await enrichTransfers(chain, (call.logs ?? []));
|
|
93
|
+
return {
|
|
94
|
+
status: call.status,
|
|
95
|
+
gasUsed: call.gasUsed.toString(),
|
|
96
|
+
error: call.status === 'success' ? undefined : (error?.shortMessage ?? error?.message ?? 'execution reverted'),
|
|
97
|
+
result: call.status === 'success' ? decodeResult(calls[index]?.abi, call.data) : undefined,
|
|
98
|
+
assetChanges: transfers.map((transfer) => {
|
|
99
|
+
if (transfer.tokenId !== undefined) {
|
|
100
|
+
return {
|
|
101
|
+
assetType: 'ERC721',
|
|
102
|
+
token: transfer.token,
|
|
103
|
+
symbol: transfer.symbol,
|
|
104
|
+
tokenId: transfer.tokenId,
|
|
105
|
+
from: transfer.from,
|
|
106
|
+
to: transfer.to,
|
|
107
|
+
amount: '1',
|
|
108
|
+
rawAmount: '1'
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const native = transfer.token.toLowerCase() === NATIVE_TOKEN;
|
|
112
|
+
return {
|
|
113
|
+
assetType: native ? 'NATIVE' : 'ERC20',
|
|
114
|
+
token: native ? undefined : transfer.token,
|
|
115
|
+
symbol: native ? nativeSymbol : transfer.symbol,
|
|
116
|
+
from: transfer.from,
|
|
117
|
+
to: transfer.to,
|
|
118
|
+
amount: native ? formatEther(BigInt(transfer.amount)) : transfer.humanAmount,
|
|
119
|
+
rawAmount: transfer.amount
|
|
120
|
+
};
|
|
121
|
+
})
|
|
122
|
+
};
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
export default {
|
|
126
|
+
simulate_contract: createTool('Simulate Contract Call', 'Simulate a contract call (including state-changing functions) without broadcasting. Returns simulation result and estimated gas.', z.object({
|
|
127
|
+
chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network to simulate on'),
|
|
128
|
+
contractAddress: z.string().describe('Contract address to call'),
|
|
129
|
+
functionAbi: z
|
|
130
|
+
.string()
|
|
131
|
+
.describe('Function ABI signature (e.g., "function transfer(address to, uint256 amount)"). Can be any function type.'),
|
|
132
|
+
args: z
|
|
133
|
+
.array(z.union([z.string(), z.number(), z.boolean(), z.null()]))
|
|
134
|
+
.optional()
|
|
135
|
+
.describe('Function arguments in order matching the ABI signature'),
|
|
136
|
+
from: z.string().optional().describe('Sender address (defaults to zero address)'),
|
|
137
|
+
value: z.string().optional().describe('ETH value to send with the transaction (in wei as string)'),
|
|
138
|
+
blockNumber: z.string().optional().describe('Block number for simulation (defaults to latest)')
|
|
139
|
+
}), async (args) => {
|
|
140
|
+
if (!isAddress(args.contractAddress)) {
|
|
141
|
+
throw new Error(`Invalid contract address: ${args.contractAddress}`);
|
|
142
|
+
}
|
|
143
|
+
if (args.from && !isAddress(args.from)) {
|
|
144
|
+
throw new Error(`Invalid from address: ${args.from}`);
|
|
145
|
+
}
|
|
146
|
+
const clientManager = getClientManager();
|
|
147
|
+
const client = clientManager.getClient(args.chain);
|
|
148
|
+
try {
|
|
149
|
+
const abiItem = parseAbiItem(args.functionAbi);
|
|
150
|
+
const convertedArgs = convertArgumentsToTypes(args.args || [], abiItem.inputs);
|
|
151
|
+
const blockTag = args.blockNumber ? BigInt(args.blockNumber) : undefined;
|
|
152
|
+
// Simulate the call
|
|
153
|
+
const result = await client.call({
|
|
154
|
+
to: args.contractAddress,
|
|
155
|
+
data: encodeFunctionData({
|
|
156
|
+
abi: [abiItem],
|
|
157
|
+
functionName: abiItem.name,
|
|
158
|
+
args: convertedArgs
|
|
159
|
+
}),
|
|
160
|
+
account: args.from ? args.from : undefined,
|
|
161
|
+
value: args.value ? BigInt(args.value) : undefined,
|
|
162
|
+
blockNumber: blockTag
|
|
163
|
+
});
|
|
164
|
+
// Also estimate gas
|
|
165
|
+
const gasEstimate = await client.estimateGas({
|
|
166
|
+
to: args.contractAddress,
|
|
167
|
+
data: encodeFunctionData({
|
|
168
|
+
abi: [abiItem],
|
|
169
|
+
functionName: abiItem.name,
|
|
170
|
+
args: convertedArgs
|
|
171
|
+
}),
|
|
172
|
+
account: args.from ? args.from : undefined,
|
|
173
|
+
value: args.value ? BigInt(args.value) : undefined,
|
|
174
|
+
blockNumber: blockTag
|
|
175
|
+
});
|
|
176
|
+
// Decode the result if the function has outputs
|
|
177
|
+
let decodedResult = result.data;
|
|
178
|
+
if (abiItem.outputs && abiItem.outputs.length > 0 && result.data) {
|
|
179
|
+
decodedResult = decodeFunctionResult({
|
|
180
|
+
abi: [abiItem],
|
|
181
|
+
functionName: abiItem.name,
|
|
182
|
+
data: result.data
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return formatResponse({
|
|
186
|
+
success: true,
|
|
187
|
+
chain: args.chain,
|
|
188
|
+
contractAddress: args.contractAddress,
|
|
189
|
+
functionName: abiItem.name,
|
|
190
|
+
result: decodedResult,
|
|
191
|
+
rawData: result.data,
|
|
192
|
+
gasEstimate: gasEstimate.toString(),
|
|
193
|
+
blockNumber: args.blockNumber || 'latest'
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
// Check if it's a revert error
|
|
198
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
199
|
+
return formatResponse({
|
|
200
|
+
success: false,
|
|
201
|
+
chain: args.chain,
|
|
202
|
+
contractAddress: args.contractAddress,
|
|
203
|
+
error: errorMessage,
|
|
204
|
+
reverted: errorMessage.includes('revert') || errorMessage.includes('execution reverted')
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}),
|
|
208
|
+
simulate_bundle: createTool('Simulate Transaction Bundle', 'Simulate several transactions in order, in one block, each seeing the state the previous ones left — e.g. ' +
|
|
209
|
+
'approve then swap, or deposit then borrow. Nothing is broadcast. Returns per transaction whether it ' +
|
|
210
|
+
'succeeded, gas used, the revert reason, and the assets that moved. Up to 3 transactions go through ' +
|
|
211
|
+
"Alchemy's asset-change simulation (native, ERC20, ERC721, ERC1155, with symbols) where the plan allows it; " +
|
|
212
|
+
'otherwise eth_simulateV1, which adds decoded return values but reports only native and ERC20 transfers.', z.object({
|
|
213
|
+
chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network to simulate on'),
|
|
214
|
+
from: z.string().optional().describe('Sender for every transaction that does not name its own'),
|
|
215
|
+
calls: z
|
|
216
|
+
.array(z.object({
|
|
217
|
+
to: z.string().describe('Contract or recipient address'),
|
|
218
|
+
functionAbi: z
|
|
219
|
+
.string()
|
|
220
|
+
.optional()
|
|
221
|
+
.describe('Function signature to encode the call, e.g. "function approve(address spender, uint256 amount)"'),
|
|
222
|
+
args: argsSchema.optional().describe('Arguments for functionAbi, in order'),
|
|
223
|
+
data: z.string().optional().describe('Raw calldata, instead of functionAbi and args'),
|
|
224
|
+
value: z.string().optional().describe('Native value to send, in wei'),
|
|
225
|
+
from: z.string().optional().describe('Sender of this transaction, if not the bundle-wide from')
|
|
226
|
+
}))
|
|
227
|
+
.min(1)
|
|
228
|
+
.max(MAX_BUNDLE)
|
|
229
|
+
.describe('Transactions to run, in order'),
|
|
230
|
+
blockNumber: z.string().optional().describe('Block to simulate on top of (defaults to latest)')
|
|
231
|
+
}), async (args) => {
|
|
232
|
+
const chain = args.chain;
|
|
233
|
+
const calls = args.calls.map((call, index) => bundleCall(call, args.from, index));
|
|
234
|
+
const blockNumber = args.blockNumber ? BigInt(args.blockNumber) : undefined;
|
|
235
|
+
let outcomes;
|
|
236
|
+
let via = 'alchemy_simulateAssetChangesBundle';
|
|
237
|
+
let fallbackReason;
|
|
238
|
+
if (calls.length <= ALCHEMY_BUNDLE_LIMIT) {
|
|
239
|
+
try {
|
|
240
|
+
outcomes = await viaAlchemy(chain, calls, blockNumber);
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
// A free plan, a chain Alchemy does not simulate on, or a custom RPC that is not Alchemy.
|
|
244
|
+
fallbackReason = rpcReason(error);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
fallbackReason = `Alchemy simulates at most ${ALCHEMY_BUNDLE_LIMIT} transactions per bundle`;
|
|
249
|
+
}
|
|
250
|
+
if (!outcomes) {
|
|
251
|
+
via = 'eth_simulateV1';
|
|
252
|
+
try {
|
|
253
|
+
outcomes = await viaSimulateV1(chain, calls, blockNumber);
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
return formatResponse({ success: false, chain, error: rpcReason(error), alchemyBundleError: fallbackReason });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return formatResponse({
|
|
260
|
+
success: outcomes.every((outcome) => outcome.status === 'success'),
|
|
261
|
+
chain,
|
|
262
|
+
via,
|
|
263
|
+
...(fallbackReason && { fallbackReason }),
|
|
264
|
+
totalGasUsed: outcomes.reduce((sum, outcome) => sum + BigInt(outcome.gasUsed ?? 0), 0n),
|
|
265
|
+
calls: outcomes.map((outcome, index) => ({
|
|
266
|
+
index,
|
|
267
|
+
to: calls[index]?.to,
|
|
268
|
+
...(calls[index]?.abi && { functionName: calls[index].abi.name }),
|
|
269
|
+
...outcome
|
|
270
|
+
}))
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
// Offered only where a provider RPC backs it: public endpoints rarely serve eth_simulateV1.
|
|
274
|
+
() => Boolean(getClientManager().getConfig().alchemyApiKey)),
|
|
275
|
+
estimate_gas: createTool('Estimate Gas', 'Estimate gas required for a transaction. Supports contract calls, transfers, and deployments.', z.object({
|
|
276
|
+
chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network'),
|
|
277
|
+
to: z.string().optional().describe('Recipient address (omit for contract deployment)'),
|
|
278
|
+
from: z.string().optional().describe('Sender address (optional)'),
|
|
279
|
+
value: z.string().optional().describe('ETH value to send (in wei as string)'),
|
|
280
|
+
data: z.string().optional().describe('Transaction data (hex string for contract calls or deployment bytecode)'),
|
|
281
|
+
functionAbi: z.string().optional().describe('Optional: Function ABI signature to encode call data automatically'),
|
|
282
|
+
args: z
|
|
283
|
+
.array(z.union([z.string(), z.number(), z.boolean(), z.null()]))
|
|
284
|
+
.optional()
|
|
285
|
+
.describe('Optional: Function arguments (only used with functionAbi)')
|
|
286
|
+
}), async (args) => {
|
|
287
|
+
if (args.to && !isAddress(args.to)) {
|
|
288
|
+
throw new Error(`Invalid to address: ${args.to}`);
|
|
289
|
+
}
|
|
290
|
+
if (args.from && !isAddress(args.from)) {
|
|
291
|
+
throw new Error(`Invalid from address: ${args.from}`);
|
|
292
|
+
}
|
|
293
|
+
const clientManager = getClientManager();
|
|
294
|
+
const client = clientManager.getClient(args.chain);
|
|
295
|
+
let callData = args.data;
|
|
296
|
+
// If functionAbi is provided, encode the call data
|
|
297
|
+
if (args.functionAbi) {
|
|
298
|
+
const abiItem = parseAbiItem(args.functionAbi);
|
|
299
|
+
const convertedArgs = convertArgumentsToTypes(args.args || [], abiItem.inputs);
|
|
300
|
+
callData = encodeFunctionData({
|
|
301
|
+
abi: [abiItem],
|
|
302
|
+
functionName: abiItem.name,
|
|
303
|
+
args: convertedArgs
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
const gasEstimate = await client.estimateGas({
|
|
307
|
+
to: args.to ? args.to : undefined,
|
|
308
|
+
account: args.from ? args.from : undefined,
|
|
309
|
+
value: args.value ? BigInt(args.value) : undefined,
|
|
310
|
+
data: callData
|
|
311
|
+
});
|
|
312
|
+
return formatResponse({
|
|
313
|
+
success: true,
|
|
314
|
+
chain: args.chain,
|
|
315
|
+
gasEstimate: gasEstimate.toString(),
|
|
316
|
+
to: args.to,
|
|
317
|
+
from: args.from,
|
|
318
|
+
value: args.value
|
|
319
|
+
});
|
|
320
|
+
}),
|
|
321
|
+
get_gas_price: createTool('Get Gas Price', 'Get current gas prices for a chain. Returns both legacy gasPrice and EIP-1559 fees (maxFeePerGas, maxPriorityFeePerGas).', z.object({
|
|
322
|
+
chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network'),
|
|
323
|
+
formatted: z.boolean().optional().default(true).describe('Return prices in Gwei (default: true). If false, returns wei.')
|
|
324
|
+
}), async (args) => {
|
|
325
|
+
const clientManager = getClientManager();
|
|
326
|
+
const client = clientManager.getClient(args.chain);
|
|
327
|
+
// Get both legacy and EIP-1559 gas prices
|
|
328
|
+
const [gasPrice, feeData] = await Promise.all([
|
|
329
|
+
client.getGasPrice(),
|
|
330
|
+
client.estimateFeesPerGas().catch(() => null) // Some chains don't support EIP-1559
|
|
331
|
+
]);
|
|
332
|
+
const formatPrice = (wei) => {
|
|
333
|
+
if (args.formatted) {
|
|
334
|
+
// Convert to Gwei (1 Gwei = 1e9 wei)
|
|
335
|
+
const gwei = Number(wei) / 1e9;
|
|
336
|
+
return `${gwei.toFixed(2)} Gwei`;
|
|
337
|
+
}
|
|
338
|
+
return wei.toString();
|
|
339
|
+
};
|
|
340
|
+
const response = {
|
|
341
|
+
chain: args.chain,
|
|
342
|
+
timestamp: new Date().toISOString(),
|
|
343
|
+
legacy: {
|
|
344
|
+
gasPrice: args.formatted ? formatPrice(gasPrice) : gasPrice.toString(),
|
|
345
|
+
gasPriceWei: gasPrice.toString()
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
// Add EIP-1559 data if available
|
|
349
|
+
if (feeData) {
|
|
350
|
+
response.eip1559 = {
|
|
351
|
+
maxFeePerGas: args.formatted ? formatPrice(feeData.maxFeePerGas) : feeData.maxFeePerGas.toString(),
|
|
352
|
+
maxPriorityFeePerGas: args.formatted
|
|
353
|
+
? formatPrice(feeData.maxPriorityFeePerGas)
|
|
354
|
+
: feeData.maxPriorityFeePerGas.toString(),
|
|
355
|
+
maxFeePerGasWei: feeData.maxFeePerGas.toString(),
|
|
356
|
+
maxPriorityFeePerGasWei: feeData.maxPriorityFeePerGas.toString()
|
|
357
|
+
};
|
|
358
|
+
// Calculate estimated total cost for a standard 21000 gas transaction
|
|
359
|
+
const standardGasLimit = 21000n;
|
|
360
|
+
const estimatedCost = feeData.maxFeePerGas * standardGasLimit;
|
|
361
|
+
response.eip1559.estimatedCostFor21kGas = args.formatted
|
|
362
|
+
? `${(Number(estimatedCost) / 1e18).toFixed(6)} ETH`
|
|
363
|
+
: estimatedCost.toString();
|
|
364
|
+
}
|
|
365
|
+
return formatResponse(response);
|
|
366
|
+
})
|
|
367
|
+
};
|
|
368
|
+
//# sourceMappingURL=g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,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAA;QAC9B,CAAC;QAED,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAA;IACjC,CAAC,CACF;CACF,CAAA"}
|
|
@@ -4,21 +4,21 @@ declare const _default: {
|
|
|
4
4
|
title: string;
|
|
5
5
|
description: string;
|
|
6
6
|
schema: z.ZodObject<{
|
|
7
|
-
chain: z.ZodEnum<["
|
|
7
|
+
chain: z.ZodEnum<["mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost", ...("mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost")[]]>;
|
|
8
8
|
eventAbi: z.ZodString;
|
|
9
9
|
address: z.ZodOptional<z.ZodString>;
|
|
10
10
|
fromBlock: z.ZodOptional<z.ZodString>;
|
|
11
11
|
toBlock: z.ZodOptional<z.ZodString>;
|
|
12
12
|
eventArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
chain: "
|
|
14
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
15
15
|
eventAbi: string;
|
|
16
16
|
address?: string | undefined;
|
|
17
17
|
fromBlock?: string | undefined;
|
|
18
18
|
toBlock?: string | undefined;
|
|
19
19
|
eventArgs?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
|
|
20
20
|
}, {
|
|
21
|
-
chain: "
|
|
21
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
22
22
|
eventAbi: string;
|
|
23
23
|
address?: string | undefined;
|
|
24
24
|
fromBlock?: string | undefined;
|
|
@@ -26,13 +26,14 @@ declare const _default: {
|
|
|
26
26
|
eventArgs?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
|
|
27
27
|
}>;
|
|
28
28
|
handler: (args: {
|
|
29
|
-
chain: "
|
|
29
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
30
30
|
eventAbi: string;
|
|
31
31
|
address?: string | undefined;
|
|
32
32
|
fromBlock?: string | undefined;
|
|
33
33
|
toBlock?: string | undefined;
|
|
34
34
|
eventArgs?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
|
|
35
|
-
}) => Promise<import("
|
|
35
|
+
}, identity: string) => Promise<import("../../types.js").ToolResult>;
|
|
36
|
+
available: (() => boolean) | undefined;
|
|
36
37
|
};
|
|
37
38
|
};
|
|
38
39
|
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/tools/read/logs.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwHvB,wBA8JC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HypersyncClient, LogField } from '@envio-dev/hypersync-client';
|
|
2
2
|
import { decodeEventLog, isAddress, keccak256, numberToHex, padHex, parseAbiItem, toBytes, toEventSignature } from 'viem';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { getClientManager, SUPPORTED_CHAINS } from '
|
|
5
|
-
import { convertEventArgsToTypes, createTool, formatResponse } from '
|
|
4
|
+
import { getClientManager, SUPPORTED_CHAINS } from '../../client.js';
|
|
5
|
+
import { convertEventArgsToTypes, createTool, formatResponse } from '../../utils.js';
|
|
6
6
|
/**
|
|
7
7
|
* A topic is always 32 bytes, so an address, a number or a short hex value has to be
|
|
8
8
|
* left-padded to fit. Passing one through unpadded is rejected outright by Hypersync.
|