web3-tools-mcp 1.3.3 → 1.4.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/README.md +51 -4
- package/dist/anvil.d.ts +34 -0
- package/dist/anvil.d.ts.map +1 -0
- package/dist/anvil.js +254 -0
- package/dist/anvil.js.map +1 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -2
- package/dist/client.js.map +1 -1
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/dist/preview.d.ts +55 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +233 -0
- package/dist/preview.js.map +1 -0
- package/dist/tools/advanced.d.ts +67 -9
- package/dist/tools/advanced.d.ts.map +1 -1
- package/dist/tools/advanced.js +206 -67
- package/dist/tools/advanced.js.map +1 -1
- package/dist/tools/balance.d.ts +5 -5
- package/dist/tools/contract-info.d.ts +9 -9
- package/dist/tools/contract.d.ts +8 -8
- package/dist/tools/contract.d.ts.map +1 -1
- package/dist/tools/contract.js +3 -0
- package/dist/tools/contract.js.map +1 -1
- package/dist/tools/ens.d.ts +15 -15
- package/dist/tools/gas.d.ts +18 -18
- package/dist/tools/logs.d.ts +3 -3
- package/dist/tools/transactions.d.ts +9 -9
- package/dist/tools/transactions.d.ts.map +1 -1
- package/dist/tools/transactions.js +92 -113
- package/dist/tools/transactions.js.map +1 -1
- package/dist/utils.d.ts +13 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +76 -0
- package/dist/utils.js.map +1 -1
- package/dist/wallet-client.d.ts +83 -0
- package/dist/wallet-client.d.ts.map +1 -0
- package/dist/wallet-client.js +357 -0
- package/dist/wallet-client.js.map +1 -0
- package/package.json +9 -8
- package/src/anvil.ts +323 -0
- package/src/client.ts +16 -2
- package/src/index.ts +26 -5
- package/src/preview.ts +320 -0
- package/src/tools/advanced.ts +239 -70
- package/src/tools/contract.ts +3 -0
- package/src/tools/transactions.ts +98 -125
- package/src/utils.ts +95 -0
- package/src/wallet-client.ts +380 -0
- package/dist/wallet-server.d.ts +0 -35
- package/dist/wallet-server.d.ts.map +0 -1
- package/dist/wallet-server.js +0 -232
- package/dist/wallet-server.js.map +0 -1
- package/public/wallet-app.js +0 -677
- package/public/wallet.html +0 -723
- package/src/wallet-server.ts +0 -283
package/dist/tools/ens.d.ts
CHANGED
|
@@ -8,16 +8,16 @@ declare const _default: {
|
|
|
8
8
|
name: z.ZodString;
|
|
9
9
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
chain: "
|
|
11
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
12
12
|
name: string;
|
|
13
13
|
universalResolver?: boolean | undefined;
|
|
14
14
|
}, {
|
|
15
15
|
name: string;
|
|
16
|
-
chain?: "
|
|
16
|
+
chain?: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
17
17
|
universalResolver?: boolean | undefined;
|
|
18
18
|
}>;
|
|
19
19
|
handler: (args: {
|
|
20
|
-
chain: "
|
|
20
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
21
21
|
name: string;
|
|
22
22
|
universalResolver?: boolean | undefined;
|
|
23
23
|
}) => Promise<import("../types.js").ToolResult>;
|
|
@@ -30,17 +30,17 @@ declare const _default: {
|
|
|
30
30
|
address: z.ZodString;
|
|
31
31
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
32
32
|
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
34
33
|
address: string;
|
|
34
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
35
35
|
universalResolver?: boolean | undefined;
|
|
36
36
|
}, {
|
|
37
37
|
address: string;
|
|
38
|
-
chain?: "
|
|
38
|
+
chain?: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
39
39
|
universalResolver?: boolean | undefined;
|
|
40
40
|
}>;
|
|
41
41
|
handler: (args: {
|
|
42
|
-
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
43
42
|
address: string;
|
|
43
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
44
44
|
universalResolver?: boolean | undefined;
|
|
45
45
|
}) => Promise<import("../types.js").ToolResult>;
|
|
46
46
|
};
|
|
@@ -53,18 +53,18 @@ declare const _default: {
|
|
|
53
53
|
key: z.ZodString;
|
|
54
54
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
55
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
chain: "
|
|
56
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
57
57
|
key: string;
|
|
58
58
|
name: string;
|
|
59
59
|
universalResolver?: boolean | undefined;
|
|
60
60
|
}, {
|
|
61
61
|
key: string;
|
|
62
62
|
name: string;
|
|
63
|
-
chain?: "
|
|
63
|
+
chain?: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
64
64
|
universalResolver?: boolean | undefined;
|
|
65
65
|
}>;
|
|
66
66
|
handler: (args: {
|
|
67
|
-
chain: "
|
|
67
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
68
68
|
key: string;
|
|
69
69
|
name: string;
|
|
70
70
|
universalResolver?: boolean | undefined;
|
|
@@ -78,16 +78,16 @@ declare const _default: {
|
|
|
78
78
|
name: z.ZodString;
|
|
79
79
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
80
80
|
}, "strip", z.ZodTypeAny, {
|
|
81
|
-
chain: "
|
|
81
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
82
82
|
name: string;
|
|
83
83
|
universalResolver?: boolean | undefined;
|
|
84
84
|
}, {
|
|
85
85
|
name: string;
|
|
86
|
-
chain?: "
|
|
86
|
+
chain?: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
87
87
|
universalResolver?: boolean | undefined;
|
|
88
88
|
}>;
|
|
89
89
|
handler: (args: {
|
|
90
|
-
chain: "
|
|
90
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
91
91
|
name: string;
|
|
92
92
|
universalResolver?: boolean | undefined;
|
|
93
93
|
}) => Promise<import("../types.js").ToolResult>;
|
|
@@ -100,16 +100,16 @@ declare const _default: {
|
|
|
100
100
|
names: z.ZodArray<z.ZodString, "many">;
|
|
101
101
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
102
102
|
}, "strip", z.ZodTypeAny, {
|
|
103
|
-
chain: "
|
|
103
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
104
104
|
names: string[];
|
|
105
105
|
universalResolver?: boolean | undefined;
|
|
106
106
|
}, {
|
|
107
107
|
names: string[];
|
|
108
|
-
chain?: "
|
|
108
|
+
chain?: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
109
109
|
universalResolver?: boolean | undefined;
|
|
110
110
|
}>;
|
|
111
111
|
handler: (args: {
|
|
112
|
-
chain: "
|
|
112
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
113
113
|
names: string[];
|
|
114
114
|
universalResolver?: boolean | undefined;
|
|
115
115
|
}) => Promise<import("../types.js").ToolResult>;
|
package/dist/tools/gas.d.ts
CHANGED
|
@@ -12,29 +12,29 @@ declare const _default: {
|
|
|
12
12
|
value: z.ZodOptional<z.ZodString>;
|
|
13
13
|
blockNumber: z.ZodOptional<z.ZodString>;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
chain: "
|
|
15
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
16
16
|
contractAddress: string;
|
|
17
17
|
functionAbi: string;
|
|
18
|
-
blockNumber?: string | undefined;
|
|
19
18
|
from?: string | undefined;
|
|
20
19
|
value?: string | undefined;
|
|
20
|
+
blockNumber?: string | undefined;
|
|
21
21
|
args?: (string | number | boolean | null)[] | undefined;
|
|
22
22
|
}, {
|
|
23
|
-
chain: "
|
|
23
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
24
24
|
contractAddress: string;
|
|
25
25
|
functionAbi: string;
|
|
26
|
-
blockNumber?: string | undefined;
|
|
27
26
|
from?: string | undefined;
|
|
28
27
|
value?: string | undefined;
|
|
28
|
+
blockNumber?: string | undefined;
|
|
29
29
|
args?: (string | number | boolean | null)[] | undefined;
|
|
30
30
|
}>;
|
|
31
31
|
handler: (args: {
|
|
32
|
-
chain: "
|
|
32
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
33
33
|
contractAddress: string;
|
|
34
34
|
functionAbi: string;
|
|
35
|
-
blockNumber?: string | undefined;
|
|
36
35
|
from?: string | undefined;
|
|
37
36
|
value?: string | undefined;
|
|
37
|
+
blockNumber?: string | undefined;
|
|
38
38
|
args?: (string | number | boolean | null)[] | undefined;
|
|
39
39
|
}) => Promise<import("../types.js").ToolResult>;
|
|
40
40
|
};
|
|
@@ -50,28 +50,28 @@ declare const _default: {
|
|
|
50
50
|
functionAbi: z.ZodOptional<z.ZodString>;
|
|
51
51
|
args: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">>;
|
|
52
52
|
}, "strip", z.ZodTypeAny, {
|
|
53
|
-
chain: "
|
|
54
|
-
from?: string | undefined;
|
|
53
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
55
54
|
to?: string | undefined;
|
|
56
|
-
value?: string | undefined;
|
|
57
55
|
data?: string | undefined;
|
|
56
|
+
from?: string | undefined;
|
|
57
|
+
value?: string | undefined;
|
|
58
58
|
args?: (string | number | boolean | null)[] | undefined;
|
|
59
59
|
functionAbi?: string | undefined;
|
|
60
60
|
}, {
|
|
61
|
-
chain: "
|
|
62
|
-
from?: string | undefined;
|
|
61
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
63
62
|
to?: string | undefined;
|
|
64
|
-
value?: string | undefined;
|
|
65
63
|
data?: string | undefined;
|
|
64
|
+
from?: string | undefined;
|
|
65
|
+
value?: string | undefined;
|
|
66
66
|
args?: (string | number | boolean | null)[] | undefined;
|
|
67
67
|
functionAbi?: string | undefined;
|
|
68
68
|
}>;
|
|
69
69
|
handler: (args: {
|
|
70
|
-
chain: "
|
|
71
|
-
from?: string | undefined;
|
|
70
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
72
71
|
to?: string | undefined;
|
|
73
|
-
value?: string | undefined;
|
|
74
72
|
data?: string | undefined;
|
|
73
|
+
from?: string | undefined;
|
|
74
|
+
value?: string | undefined;
|
|
75
75
|
args?: (string | number | boolean | null)[] | undefined;
|
|
76
76
|
functionAbi?: string | undefined;
|
|
77
77
|
}) => Promise<import("../types.js").ToolResult>;
|
|
@@ -83,14 +83,14 @@ declare const _default: {
|
|
|
83
83
|
chain: z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>;
|
|
84
84
|
formatted: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
85
85
|
}, "strip", z.ZodTypeAny, {
|
|
86
|
-
chain: "
|
|
86
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
87
87
|
formatted: boolean;
|
|
88
88
|
}, {
|
|
89
|
-
chain: "
|
|
89
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
90
90
|
formatted?: boolean | undefined;
|
|
91
91
|
}>;
|
|
92
92
|
handler: (args: {
|
|
93
|
-
chain: "
|
|
93
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
94
94
|
formatted: boolean;
|
|
95
95
|
}) => Promise<import("../types.js").ToolResult>;
|
|
96
96
|
};
|
package/dist/tools/logs.d.ts
CHANGED
|
@@ -11,14 +11,14 @@ declare const _default: {
|
|
|
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: "arbitrum" | "mainnet" | "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: "arbitrum" | "mainnet" | "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,7 +26,7 @@ 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: "arbitrum" | "mainnet" | "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;
|
|
@@ -9,18 +9,18 @@ declare const _default: {
|
|
|
9
9
|
amount: z.ZodString;
|
|
10
10
|
data: z.ZodOptional<z.ZodString>;
|
|
11
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
chain: "
|
|
12
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
13
13
|
to: string;
|
|
14
14
|
amount: string;
|
|
15
15
|
data?: string | undefined;
|
|
16
16
|
}, {
|
|
17
|
-
chain: "
|
|
17
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
18
18
|
to: string;
|
|
19
19
|
amount: string;
|
|
20
20
|
data?: string | undefined;
|
|
21
21
|
}>;
|
|
22
22
|
handler: (args: {
|
|
23
|
-
chain: "
|
|
23
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
24
24
|
to: string;
|
|
25
25
|
amount: string;
|
|
26
26
|
data?: string | undefined;
|
|
@@ -36,20 +36,20 @@ declare const _default: {
|
|
|
36
36
|
amount: z.ZodString;
|
|
37
37
|
decimals: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
38
38
|
}, "strip", z.ZodTypeAny, {
|
|
39
|
-
chain: "
|
|
39
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
40
40
|
to: string;
|
|
41
41
|
tokenAddress: string;
|
|
42
42
|
decimals: number;
|
|
43
43
|
amount: string;
|
|
44
44
|
}, {
|
|
45
|
-
chain: "
|
|
45
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
46
46
|
to: string;
|
|
47
47
|
tokenAddress: string;
|
|
48
48
|
amount: string;
|
|
49
49
|
decimals?: number | undefined;
|
|
50
50
|
}>;
|
|
51
51
|
handler: (args: {
|
|
52
|
-
chain: "
|
|
52
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
53
53
|
to: string;
|
|
54
54
|
tokenAddress: string;
|
|
55
55
|
decimals: number;
|
|
@@ -66,20 +66,20 @@ declare const _default: {
|
|
|
66
66
|
args: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">>;
|
|
67
67
|
value: z.ZodOptional<z.ZodString>;
|
|
68
68
|
}, "strip", z.ZodTypeAny, {
|
|
69
|
-
chain: "
|
|
69
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
70
70
|
contractAddress: string;
|
|
71
71
|
functionAbi: string;
|
|
72
72
|
value?: string | undefined;
|
|
73
73
|
args?: (string | number | boolean)[] | undefined;
|
|
74
74
|
}, {
|
|
75
|
-
chain: "
|
|
75
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
76
76
|
contractAddress: string;
|
|
77
77
|
functionAbi: string;
|
|
78
78
|
value?: string | undefined;
|
|
79
79
|
args?: (string | number | boolean)[] | undefined;
|
|
80
80
|
}>;
|
|
81
81
|
handler: (args: {
|
|
82
|
-
chain: "
|
|
82
|
+
chain: "arbitrum" | "mainnet" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
83
83
|
contractAddress: string;
|
|
84
84
|
functionAbi: string;
|
|
85
85
|
value?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../src/tools/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../src/tools/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDvB,wBAsKC"}
|
|
@@ -1,167 +1,146 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import { SUPPORTED_CHAINS } from '../client.js';
|
|
4
|
-
import {
|
|
5
|
-
import { randomBytes } from 'crypto';
|
|
2
|
+
import { getWalletClient } from '../wallet-client.js';
|
|
3
|
+
import { getClientManager, SUPPORTED_CHAINS } from '../client.js';
|
|
4
|
+
import { encodeFunctionData, isAddress, parseAbiItem, parseUnits } from 'viem';
|
|
5
|
+
import { randomBytes } from 'node:crypto';
|
|
6
|
+
import { buildTxPreview } from '../preview.js';
|
|
6
7
|
import { createTool, formatResponse } from '../utils.js';
|
|
7
8
|
function generateRequestId() {
|
|
8
9
|
return randomBytes(16).toString('hex');
|
|
9
10
|
}
|
|
11
|
+
function requireAddress(label, address) {
|
|
12
|
+
if (!isAddress(address))
|
|
13
|
+
throw new Error(`Invalid ${label}: ${address}`);
|
|
14
|
+
return address;
|
|
15
|
+
}
|
|
16
|
+
function explorerTxUrl(chain, txHash) {
|
|
17
|
+
return `https://${getClientManager().getEtherscanDomain(chain)}/tx/${txHash}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Send a transaction for signing, with a decoded + simulated preview attached so the
|
|
21
|
+
* wallet page can show what it actually does instead of raw calldata.
|
|
22
|
+
*/
|
|
23
|
+
async function requestSignature(chain, tx) {
|
|
24
|
+
const wallet = getWalletClient();
|
|
25
|
+
await wallet.waitForSigner();
|
|
26
|
+
const preview = await buildTxPreview(chain, tx, wallet.getAddress());
|
|
27
|
+
return {
|
|
28
|
+
txHash: await wallet.request({
|
|
29
|
+
id: generateRequestId(),
|
|
30
|
+
type: 'send_transaction',
|
|
31
|
+
chain,
|
|
32
|
+
data: { to: tx.to, value: tx.value ?? '0x0', ...(tx.data && { data: tx.data }) },
|
|
33
|
+
preview
|
|
34
|
+
}),
|
|
35
|
+
preview
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function failure(error, message) {
|
|
39
|
+
return formatResponse({
|
|
40
|
+
success: false,
|
|
41
|
+
error: error instanceof Error ? error.message : String(error),
|
|
42
|
+
message
|
|
43
|
+
});
|
|
44
|
+
}
|
|
10
45
|
export default {
|
|
11
|
-
send_native_token: createTool('Send Native Token', 'Send native tokens (ETH, MATIC, BNB, etc.) to an address.
|
|
46
|
+
send_native_token: createTool('Send Native Token', 'Send native tokens (ETH, MATIC, BNB, etc.) to an address. Simulates the transaction, then opens the browser wallet for approval.', z.object({
|
|
12
47
|
chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network'),
|
|
13
48
|
to: z.string().describe('Recipient address'),
|
|
14
49
|
amount: z.string().describe('Amount in native token (e.g., "0.1" for 0.1 ETH)'),
|
|
15
50
|
data: z.string().optional().describe('Optional hex-encoded data to include with transaction')
|
|
16
51
|
}), async (args) => {
|
|
17
|
-
const walletServer = getWalletServer();
|
|
18
52
|
try {
|
|
19
|
-
|
|
20
|
-
const value =
|
|
21
|
-
const
|
|
22
|
-
id: generateRequestId(),
|
|
23
|
-
type: 'send_transaction',
|
|
24
|
-
chain: args.chain,
|
|
25
|
-
data: {
|
|
26
|
-
to: args.to,
|
|
27
|
-
value,
|
|
28
|
-
...(args.data && { data: args.data })
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
console.error(`[Transaction] Sending ${args.amount} native token to ${args.to} on ${args.chain}`);
|
|
32
|
-
const txHash = await walletServer.sendTransaction(txRequest);
|
|
53
|
+
const to = requireAddress('recipient address', args.to);
|
|
54
|
+
const value = `0x${parseUnits(args.amount, 18).toString(16)}`;
|
|
55
|
+
const { txHash, preview } = await requestSignature(args.chain, { to, value, data: args.data });
|
|
33
56
|
return formatResponse({
|
|
34
57
|
success: true,
|
|
35
58
|
chain: args.chain,
|
|
36
59
|
transactionHash: txHash,
|
|
37
|
-
to
|
|
60
|
+
to,
|
|
38
61
|
amount: args.amount,
|
|
39
|
-
|
|
40
|
-
explorerUrl:
|
|
62
|
+
simulation: preview.simulation,
|
|
63
|
+
explorerUrl: explorerTxUrl(args.chain, txHash)
|
|
41
64
|
});
|
|
42
65
|
}
|
|
43
66
|
catch (error) {
|
|
44
|
-
|
|
45
|
-
return formatResponse({
|
|
46
|
-
success: false,
|
|
47
|
-
error: errorMessage,
|
|
48
|
-
message: 'Transaction failed or was rejected'
|
|
49
|
-
});
|
|
67
|
+
return failure(error, 'Transaction failed or was rejected');
|
|
50
68
|
}
|
|
51
69
|
}),
|
|
52
|
-
send_erc20_token: createTool('Send ERC20 Token', 'Send ERC20 tokens to an address.
|
|
70
|
+
send_erc20_token: createTool('Send ERC20 Token', 'Send ERC20 tokens to an address. Simulates the transfer, then opens the browser wallet for approval.', z.object({
|
|
53
71
|
chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network'),
|
|
54
72
|
tokenAddress: z.string().describe('ERC20 token contract address'),
|
|
55
73
|
to: z.string().describe('Recipient address'),
|
|
56
74
|
amount: z.string().describe('Amount in token units (e.g., "100" for 100 USDC)'),
|
|
57
75
|
decimals: z.number().optional().default(18).describe('Token decimals (default: 18)')
|
|
58
76
|
}), async (args) => {
|
|
59
|
-
const walletServer = getWalletServer();
|
|
60
77
|
try {
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
chain: args.chain,
|
|
69
|
-
data: {
|
|
70
|
-
to: args.tokenAddress,
|
|
71
|
-
data,
|
|
72
|
-
value: '0x0'
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
console.error(`[Transaction] Sending ${args.amount} tokens to ${args.to} on ${args.chain}`);
|
|
76
|
-
const txHash = await walletServer.sendTransaction(txRequest);
|
|
78
|
+
const tokenAddress = requireAddress('token address', args.tokenAddress);
|
|
79
|
+
const to = requireAddress('recipient address', args.to);
|
|
80
|
+
const data = encodeFunctionData({
|
|
81
|
+
abi: [parseAbiItem('function transfer(address to, uint256 amount)')],
|
|
82
|
+
args: [to, parseUnits(args.amount, args.decimals ?? 18)]
|
|
83
|
+
});
|
|
84
|
+
const { txHash, preview } = await requestSignature(args.chain, { to: tokenAddress, data, value: '0x0' });
|
|
77
85
|
return formatResponse({
|
|
78
86
|
success: true,
|
|
79
87
|
chain: args.chain,
|
|
80
88
|
transactionHash: txHash,
|
|
81
|
-
tokenAddress
|
|
82
|
-
to
|
|
89
|
+
tokenAddress,
|
|
90
|
+
to,
|
|
83
91
|
amount: args.amount,
|
|
84
|
-
|
|
85
|
-
explorerUrl:
|
|
92
|
+
simulation: preview.simulation,
|
|
93
|
+
explorerUrl: explorerTxUrl(args.chain, txHash)
|
|
86
94
|
});
|
|
87
95
|
}
|
|
88
96
|
catch (error) {
|
|
89
|
-
|
|
90
|
-
return formatResponse({
|
|
91
|
-
success: false,
|
|
92
|
-
error: errorMessage,
|
|
93
|
-
message: 'Token transfer failed or was rejected'
|
|
94
|
-
});
|
|
97
|
+
return failure(error, 'Token transfer failed or was rejected');
|
|
95
98
|
}
|
|
96
99
|
}),
|
|
97
|
-
call_contract_write: createTool('Call Contract (Write)', 'Call a state-changing contract function
|
|
100
|
+
call_contract_write: createTool('Call Contract (Write)', 'Call a state-changing contract function. Simulates the call, then opens the browser wallet for approval.', z.object({
|
|
98
101
|
chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network'),
|
|
99
102
|
contractAddress: z.string().describe('Contract address'),
|
|
100
103
|
functionAbi: z.string().describe('Function ABI definition (e.g., "function transfer(address to, uint256 amount)")'),
|
|
101
|
-
args: z
|
|
102
|
-
|
|
104
|
+
args: z
|
|
105
|
+
.array(z.union([z.string(), z.number(), z.boolean()]))
|
|
106
|
+
.optional()
|
|
107
|
+
.describe('Function arguments in order matching the ABI signature'),
|
|
108
|
+
value: z.string().optional().describe('Optional native value to send with transaction (in ETH units, e.g., "0.1")')
|
|
103
109
|
}), async (args) => {
|
|
104
|
-
const walletServer = getWalletServer();
|
|
105
110
|
try {
|
|
106
|
-
|
|
107
|
-
console.error(`[Transaction] Parsing ABI: ${args.functionAbi}`);
|
|
108
|
-
console.error(`[Transaction] Args: ${JSON.stringify(args.args)}`);
|
|
111
|
+
const contractAddress = requireAddress('contract address', args.contractAddress);
|
|
109
112
|
const abiItem = parseAbiItem(args.functionAbi);
|
|
110
|
-
console.error(`[Transaction] Parsed function: ${abiItem.name}`);
|
|
111
113
|
const data = encodeFunctionData({
|
|
112
114
|
abi: [abiItem],
|
|
113
115
|
functionName: abiItem.name,
|
|
114
116
|
args: (args.args || [])
|
|
115
117
|
});
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
const txRequest = {
|
|
119
|
-
id: generateRequestId(),
|
|
120
|
-
type: 'send_transaction',
|
|
121
|
-
chain: args.chain,
|
|
122
|
-
data: {
|
|
123
|
-
to: args.contractAddress,
|
|
124
|
-
data,
|
|
125
|
-
value: valueHex
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
console.error(`[Transaction] Calling ${abiItem.name}() on ${args.contractAddress} (${args.chain})`);
|
|
129
|
-
const txHash = await walletServer.sendTransaction(txRequest);
|
|
118
|
+
const value = args.value ? `0x${parseUnits(args.value, 18).toString(16)}` : '0x0';
|
|
119
|
+
const { txHash, preview } = await requestSignature(args.chain, { to: contractAddress, data, value });
|
|
130
120
|
return formatResponse({
|
|
131
121
|
success: true,
|
|
132
122
|
chain: args.chain,
|
|
133
123
|
transactionHash: txHash,
|
|
134
|
-
contractAddress
|
|
124
|
+
contractAddress,
|
|
135
125
|
functionName: abiItem.name,
|
|
136
|
-
|
|
137
|
-
explorerUrl:
|
|
126
|
+
simulation: preview.simulation,
|
|
127
|
+
explorerUrl: explorerTxUrl(args.chain, txHash)
|
|
138
128
|
});
|
|
139
129
|
}
|
|
140
130
|
catch (error) {
|
|
141
|
-
|
|
142
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
143
|
-
return formatResponse({
|
|
144
|
-
success: false,
|
|
145
|
-
error: errorMessage,
|
|
146
|
-
message: 'Contract call failed or was rejected'
|
|
147
|
-
});
|
|
131
|
+
return failure(error, 'Contract call failed or was rejected');
|
|
148
132
|
}
|
|
149
133
|
}),
|
|
150
134
|
sign_message: createTool('Sign Message', 'Sign a message with the connected wallet. Opens browser wallet for approval.', z.object({
|
|
151
135
|
message: z.string().describe('Message to sign')
|
|
152
136
|
}), async (args) => {
|
|
153
|
-
const walletServer = getWalletServer();
|
|
154
137
|
try {
|
|
155
|
-
const
|
|
138
|
+
const signature = await getWalletClient().request({
|
|
156
139
|
id: generateRequestId(),
|
|
157
140
|
type: 'sign_message',
|
|
158
141
|
chain: 'any',
|
|
159
|
-
data: {
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
console.error(`[Transaction] Signing message`);
|
|
164
|
-
const signature = await walletServer.sendTransaction(request);
|
|
142
|
+
data: { message: args.message }
|
|
143
|
+
});
|
|
165
144
|
return formatResponse({
|
|
166
145
|
success: true,
|
|
167
146
|
message: args.message,
|
|
@@ -170,28 +149,28 @@ export default {
|
|
|
170
149
|
});
|
|
171
150
|
}
|
|
172
151
|
catch (error) {
|
|
173
|
-
|
|
174
|
-
return formatResponse({
|
|
175
|
-
success: false,
|
|
176
|
-
error: errorMessage,
|
|
177
|
-
message: 'Message signing failed or was rejected'
|
|
178
|
-
});
|
|
152
|
+
return failure(error, 'Message signing failed or was rejected');
|
|
179
153
|
}
|
|
180
154
|
}),
|
|
181
155
|
wallet_status: createTool('Wallet Status', 'Check if a wallet is connected to the browser interface', z.object({}), async () => {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
156
|
+
const wallet = getWalletClient();
|
|
157
|
+
try {
|
|
158
|
+
await wallet.connect();
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
return failure(error, 'Wallet relay unavailable');
|
|
188
162
|
}
|
|
163
|
+
if (!wallet.isConnected())
|
|
164
|
+
wallet.openBrowser();
|
|
189
165
|
return formatResponse({
|
|
190
|
-
connected: isConnected,
|
|
191
|
-
|
|
192
|
-
|
|
166
|
+
connected: wallet.isConnected(),
|
|
167
|
+
address: wallet.getAddress(),
|
|
168
|
+
walletUrl: wallet.getUrl(),
|
|
169
|
+
openTab: wallet.getPageUrl(),
|
|
170
|
+
hosted: wallet.isRemote,
|
|
171
|
+
message: wallet.isConnected()
|
|
193
172
|
? 'Wallet is connected and ready to sign transactions'
|
|
194
|
-
: `No wallet connected.
|
|
173
|
+
: `No wallet connected. Open ${wallet.getUrl()} and connect your wallet.`
|
|
195
174
|
});
|
|
196
175
|
})
|
|
197
176
|
};
|