@walletchan/rpc 0.1.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/LICENSE.md +9 -0
- package/README.md +166 -0
- package/SKILL.md +149 -0
- package/dist/chains.d.ts +20 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +130 -0
- package/dist/chains.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +78 -0
- package/dist/cli.js.map +1 -0
- package/dist/clipboard.d.ts +7 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +75 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +104 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +21 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +117 -0
- package/dist/logger.js.map +1 -0
- package/dist/rpcHandler.d.ts +14 -0
- package/dist/rpcHandler.d.ts.map +1 -0
- package/dist/rpcHandler.js +197 -0
- package/dist/rpcHandler.js.map +1 -0
- package/dist/rpcServer.d.ts +5 -0
- package/dist/rpcServer.d.ts.map +1 -0
- package/dist/rpcServer.js +59 -0
- package/dist/rpcServer.js.map +1 -0
- package/dist/rpcTypes.d.ts +29 -0
- package/dist/rpcTypes.d.ts.map +1 -0
- package/dist/rpcTypes.js +39 -0
- package/dist/rpcTypes.js.map +1 -0
- package/dist/skill.d.ts +4 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +158 -0
- package/dist/skill.js.map +1 -0
- package/dist/upstream.d.ts +4 -0
- package/dist/upstream.d.ts.map +1 -0
- package/dist/upstream.js +21 -0
- package/dist/upstream.js.map +1 -0
- package/dist/walletConnect.d.ts +44 -0
- package/dist/walletConnect.d.ts.map +1 -0
- package/dist/walletConnect.js +277 -0
- package/dist/walletConnect.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { mkdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { Core } from "@walletconnect/core";
|
|
5
|
+
import { SignClient } from "@walletconnect/sign-client";
|
|
6
|
+
import { toCaip2 } from "./chains.js";
|
|
7
|
+
import { withSpinner } from "./logger.js";
|
|
8
|
+
const WALLETCHAN_ICON_URL = "https://walletchan.com/images/walletchan-icon.png";
|
|
9
|
+
const BASE_METHODS = [
|
|
10
|
+
"eth_sendTransaction",
|
|
11
|
+
"personal_sign",
|
|
12
|
+
"eth_signTypedData_v3",
|
|
13
|
+
"eth_signTypedData_v4",
|
|
14
|
+
];
|
|
15
|
+
const BATCH_METHODS = [
|
|
16
|
+
"wallet_getCapabilities",
|
|
17
|
+
"wallet_sendCalls",
|
|
18
|
+
"wallet_getCallsStatus",
|
|
19
|
+
"wallet_showCallsStatus",
|
|
20
|
+
];
|
|
21
|
+
const WALLETCONNECT_EVENTS = ["chainChanged", "accountsChanged"];
|
|
22
|
+
const APPROVAL_METHODS = new Set([
|
|
23
|
+
"eth_sendTransaction",
|
|
24
|
+
"personal_sign",
|
|
25
|
+
"eth_signTypedData_v3",
|
|
26
|
+
"eth_signTypedData_v4",
|
|
27
|
+
"wallet_sendCalls",
|
|
28
|
+
]);
|
|
29
|
+
export class WalletConnectBridge {
|
|
30
|
+
config;
|
|
31
|
+
client = null;
|
|
32
|
+
session = null;
|
|
33
|
+
methods;
|
|
34
|
+
constructor(config) {
|
|
35
|
+
this.config = config;
|
|
36
|
+
this.methods = config.includeBatching
|
|
37
|
+
? [...BASE_METHODS, ...BATCH_METHODS]
|
|
38
|
+
: [...BASE_METHODS];
|
|
39
|
+
}
|
|
40
|
+
get connected() {
|
|
41
|
+
return !!this.session;
|
|
42
|
+
}
|
|
43
|
+
get sessionTopic() {
|
|
44
|
+
return this.session?.topic || null;
|
|
45
|
+
}
|
|
46
|
+
async init() {
|
|
47
|
+
process.env.DISABLE_GLOBAL_CORE ||= "true";
|
|
48
|
+
const core = new Core({
|
|
49
|
+
projectId: this.config.projectId,
|
|
50
|
+
customStoragePrefix: `walletchan-rpc-${this.config.host}-${this.config.port}`,
|
|
51
|
+
storageOptions: { database: getStorageBase(this.config.host, this.config.port) },
|
|
52
|
+
logger: "error",
|
|
53
|
+
telemetryEnabled: false,
|
|
54
|
+
});
|
|
55
|
+
this.client = await SignClient.init({
|
|
56
|
+
core,
|
|
57
|
+
metadata: {
|
|
58
|
+
name: "WalletChan RPC",
|
|
59
|
+
description: "Local JSON-RPC proxy for WalletChan and WalletConnect wallets",
|
|
60
|
+
url: `http://${this.config.host}:${this.config.port}`,
|
|
61
|
+
icons: [WALLETCHAN_ICON_URL],
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
this.attachListeners();
|
|
65
|
+
if (this.config.forceNewSession) {
|
|
66
|
+
await this.disconnectStoredSessions("WalletChan RPC started with --force-new-session");
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return this.restoreStoredSession();
|
|
70
|
+
}
|
|
71
|
+
async createSessionProposal() {
|
|
72
|
+
const client = this.getClient();
|
|
73
|
+
const chains = this.config.chains.map((chain) => toCaip2(chain.chainId));
|
|
74
|
+
const { uri, approval } = await client.connect({
|
|
75
|
+
optionalNamespaces: {
|
|
76
|
+
eip155: {
|
|
77
|
+
chains,
|
|
78
|
+
methods: this.methods,
|
|
79
|
+
events: WALLETCONNECT_EVENTS,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
if (!uri) {
|
|
84
|
+
throw new Error("WalletConnect did not return a pairing URI");
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
uri,
|
|
88
|
+
approval: async () => {
|
|
89
|
+
const session = await approval();
|
|
90
|
+
this.validateSession(session);
|
|
91
|
+
this.session = session;
|
|
92
|
+
return this.getSessionInfo();
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async request(chainId, method, params) {
|
|
97
|
+
const client = this.getClient();
|
|
98
|
+
const session = this.getSession();
|
|
99
|
+
const sendRequest = () => client.request({
|
|
100
|
+
topic: session.topic,
|
|
101
|
+
chainId: toCaip2(chainId),
|
|
102
|
+
request: { method, params },
|
|
103
|
+
expiry: this.config.requestTimeoutSeconds,
|
|
104
|
+
});
|
|
105
|
+
if (!APPROVAL_METHODS.has(method)) {
|
|
106
|
+
return sendRequest();
|
|
107
|
+
}
|
|
108
|
+
return withSpinner(formatApprovalMessage(method, this.getChainLabel(chainId)), sendRequest);
|
|
109
|
+
}
|
|
110
|
+
getAccounts(chainId) {
|
|
111
|
+
const session = this.getSession();
|
|
112
|
+
return getSessionAccounts(session, chainId);
|
|
113
|
+
}
|
|
114
|
+
getSessionInfo() {
|
|
115
|
+
const session = this.getSession();
|
|
116
|
+
return {
|
|
117
|
+
accounts: this.getAccounts(),
|
|
118
|
+
peerName: session.peer?.metadata?.name || "WalletConnect wallet",
|
|
119
|
+
peerUrl: session.peer?.metadata?.url || "",
|
|
120
|
+
topic: session.topic,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async disconnectStored(message = "WalletChan RPC stopped") {
|
|
124
|
+
if (!this.client)
|
|
125
|
+
return;
|
|
126
|
+
await this.disconnectStoredSessions(message);
|
|
127
|
+
this.session = null;
|
|
128
|
+
}
|
|
129
|
+
close() {
|
|
130
|
+
this.session = null;
|
|
131
|
+
}
|
|
132
|
+
attachListeners() {
|
|
133
|
+
const client = this.getClient();
|
|
134
|
+
client.on("session_delete", ({ topic }) => {
|
|
135
|
+
if (this.session?.topic === topic) {
|
|
136
|
+
this.session = null;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
client.on("session_expire", ({ topic }) => {
|
|
140
|
+
if (this.session?.topic === topic) {
|
|
141
|
+
this.session = null;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
client.on("session_update", ({ topic }) => {
|
|
145
|
+
if (this.session?.topic === topic) {
|
|
146
|
+
this.session = client.session.get(topic);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
validateSession(session) {
|
|
151
|
+
const approvedMethods = new Set(session.namespaces?.eip155?.methods || []);
|
|
152
|
+
const approvedChains = getSessionChainSet(session);
|
|
153
|
+
const requestedChains = this.config.chains.map((chain) => toCaip2(chain.chainId));
|
|
154
|
+
const missingChains = requestedChains.filter((chain) => !approvedChains.has(chain));
|
|
155
|
+
if (missingChains.length > 0) {
|
|
156
|
+
throw new Error(`Wallet did not approve chains: ${missingChains.join(", ")}`);
|
|
157
|
+
}
|
|
158
|
+
const missingMethods = this.methods.filter((method) => !approvedMethods.has(method));
|
|
159
|
+
if (missingMethods.length > 0) {
|
|
160
|
+
const batchingHint = this.config.includeBatching
|
|
161
|
+
? " Rerun with --skip-batching for wallets without ERC-5792 support."
|
|
162
|
+
: "";
|
|
163
|
+
throw new Error(`Wallet did not approve methods: ${missingMethods.join(", ")}.${batchingHint}`);
|
|
164
|
+
}
|
|
165
|
+
if (getSessionAccounts(session).length === 0) {
|
|
166
|
+
throw new Error("Wallet did not approve any EVM accounts");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
restoreStoredSession() {
|
|
170
|
+
const sessions = Array.from(this.getClient().session.values).reverse();
|
|
171
|
+
for (const session of sessions) {
|
|
172
|
+
if (isSessionExpired(session))
|
|
173
|
+
continue;
|
|
174
|
+
try {
|
|
175
|
+
this.validateSession(session);
|
|
176
|
+
this.session = session;
|
|
177
|
+
return this.getSessionInfo();
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
// A stored session may not match the current chain/method request.
|
|
181
|
+
// Keep it stored; --force-new-session is the explicit cleanup path.
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
async disconnectStoredSessions(message) {
|
|
187
|
+
const client = this.getClient();
|
|
188
|
+
const topics = new Set();
|
|
189
|
+
for (const session of client.session.values) {
|
|
190
|
+
if (session.topic)
|
|
191
|
+
topics.add(session.topic);
|
|
192
|
+
}
|
|
193
|
+
const pairings = (client.pairing?.values || []);
|
|
194
|
+
for (const pairing of pairings) {
|
|
195
|
+
if (pairing.topic)
|
|
196
|
+
topics.add(pairing.topic);
|
|
197
|
+
}
|
|
198
|
+
await Promise.all(Array.from(topics).map((topic) => this.disconnectTopic(topic, message)));
|
|
199
|
+
}
|
|
200
|
+
async disconnectTopic(topic, message) {
|
|
201
|
+
const client = this.getClient();
|
|
202
|
+
try {
|
|
203
|
+
await client.disconnect({
|
|
204
|
+
topic,
|
|
205
|
+
reason: { code: 6000, message },
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// Stale topics are best-effort cleanup only.
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
getClient() {
|
|
213
|
+
if (!this.client) {
|
|
214
|
+
throw new Error("WalletConnect client is not initialized");
|
|
215
|
+
}
|
|
216
|
+
return this.client;
|
|
217
|
+
}
|
|
218
|
+
getSession() {
|
|
219
|
+
if (!this.session) {
|
|
220
|
+
throw new Error("WalletConnect session is not connected");
|
|
221
|
+
}
|
|
222
|
+
return this.session;
|
|
223
|
+
}
|
|
224
|
+
getChainLabel(chainId) {
|
|
225
|
+
const chain = this.config.chains.find((configured) => configured.chainId === chainId);
|
|
226
|
+
return chain ? `${chain.name} (${chain.chainId})` : `chain ${chainId}`;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function formatApprovalMessage(method, chainLabel) {
|
|
230
|
+
return `Waiting for wallet approval: ${method} on ${chainLabel}`;
|
|
231
|
+
}
|
|
232
|
+
function isSessionExpired(session) {
|
|
233
|
+
const expiry = session.expiry;
|
|
234
|
+
return typeof expiry === "number" && expiry <= Math.floor(Date.now() / 1000);
|
|
235
|
+
}
|
|
236
|
+
function getSessionAccounts(session, chainId) {
|
|
237
|
+
const accounts = session.namespaces?.eip155?.accounts || [];
|
|
238
|
+
const seen = new Set();
|
|
239
|
+
const result = [];
|
|
240
|
+
for (const account of accounts) {
|
|
241
|
+
if (typeof account !== "string")
|
|
242
|
+
continue;
|
|
243
|
+
const [namespace, rawChainId, address] = account.split(":");
|
|
244
|
+
if (namespace !== "eip155" || !address)
|
|
245
|
+
continue;
|
|
246
|
+
if (chainId && Number(rawChainId) !== chainId)
|
|
247
|
+
continue;
|
|
248
|
+
const normalized = address.toLowerCase();
|
|
249
|
+
if (!seen.has(normalized)) {
|
|
250
|
+
seen.add(normalized);
|
|
251
|
+
result.push(normalized);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
function getSessionChainSet(session) {
|
|
257
|
+
const chains = new Set();
|
|
258
|
+
for (const chain of session.namespaces?.eip155?.chains || []) {
|
|
259
|
+
if (typeof chain === "string")
|
|
260
|
+
chains.add(chain);
|
|
261
|
+
}
|
|
262
|
+
for (const account of session.namespaces?.eip155?.accounts || []) {
|
|
263
|
+
if (typeof account !== "string")
|
|
264
|
+
continue;
|
|
265
|
+
const [namespace, chainId] = account.split(":");
|
|
266
|
+
if (namespace === "eip155" && chainId) {
|
|
267
|
+
chains.add(`${namespace}:${chainId}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return chains;
|
|
271
|
+
}
|
|
272
|
+
function getStorageBase(host, port) {
|
|
273
|
+
const storageDir = join(tmpdir(), "walletchan-rpc");
|
|
274
|
+
mkdirSync(storageDir, { recursive: true });
|
|
275
|
+
return join(storageDir, `${host.replace(/[^a-zA-Z0-9.-]/g, "_")}-${port}`);
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=walletConnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletConnect.js","sourceRoot":"","sources":["../src/walletConnect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,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proxy that routes wallet requests through WalletConnect",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/apoorvlathey/walletchan/tree/master/apps/walletchan-rpc#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/apoorvlathey/walletchan.git",
|
|
11
|
+
"directory": "apps/walletchan-rpc"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/apoorvlathey/walletchan/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"walletchan",
|
|
18
|
+
"walletconnect",
|
|
19
|
+
"json-rpc",
|
|
20
|
+
"ethereum",
|
|
21
|
+
"foundry",
|
|
22
|
+
"erc-5792"
|
|
23
|
+
],
|
|
24
|
+
"bin": {
|
|
25
|
+
"walletchan-rpc": "dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"SKILL.md",
|
|
33
|
+
"LICENSE.md"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"dev": "tsx src/index.ts",
|
|
37
|
+
"build": "tsc && chmod +x dist/index.js",
|
|
38
|
+
"start": "node dist/index.js",
|
|
39
|
+
"pack:dry-run": "pnpm build && npm pack --dry-run",
|
|
40
|
+
"publish:dry-run": "npm publish --dry-run --access public",
|
|
41
|
+
"publish:npm": "npm publish --access public",
|
|
42
|
+
"prepublishOnly": "pnpm build"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@hono/node-server": "^1.13.0",
|
|
49
|
+
"@walletconnect/core": "2.23.9",
|
|
50
|
+
"@walletconnect/sign-client": "2.23.9",
|
|
51
|
+
"commander": "^14.0.0",
|
|
52
|
+
"hono": "^4.5.0",
|
|
53
|
+
"qrcode-terminal": "^0.12.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.0.0",
|
|
57
|
+
"tsx": "^4.19.0",
|
|
58
|
+
"typescript": "^5.6.3"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=18"
|
|
62
|
+
}
|
|
63
|
+
}
|