web3-tools-mcp 3.0.0 → 3.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/CHANGELOG.md +86 -2
- package/README.md +76 -52
- package/dist/chain-meta.d.ts.map +1 -1
- package/dist/chain-meta.js +19 -8
- package/dist/chain-meta.js.map +1 -1
- package/dist/clear-signing.d.ts.map +1 -1
- package/dist/clear-signing.js +17 -6
- package/dist/clear-signing.js.map +1 -1
- package/dist/http-server.d.ts.map +1 -1
- package/dist/http-server.js +9 -3
- package/dist/http-server.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/kv-storage.d.ts +2 -1
- package/dist/kv-storage.d.ts.map +1 -1
- package/dist/kv-storage.js +5 -2
- package/dist/kv-storage.js.map +1 -1
- package/dist/oauth.d.ts +18 -4
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +62 -26
- package/dist/oauth.js.map +1 -1
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +7 -5
- package/dist/preview.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +14 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/read/advanced.d.ts +9 -4
- package/dist/tools/read/advanced.d.ts.map +1 -1
- package/dist/tools/read/advanced.js +45 -33
- package/dist/tools/read/advanced.js.map +1 -1
- package/dist/tools/read/balance.d.ts.map +1 -1
- package/dist/tools/read/balance.js +17 -32
- package/dist/tools/read/balance.js.map +1 -1
- package/dist/tools/read/contract-info.d.ts +2 -0
- package/dist/tools/read/contract-info.d.ts.map +1 -1
- package/dist/tools/read/contract-info.js +53 -122
- package/dist/tools/read/contract-info.js.map +1 -1
- package/dist/tools/read/contract.d.ts.map +1 -1
- package/dist/tools/read/contract.js +2 -1
- package/dist/tools/read/contract.js.map +1 -1
- package/dist/tools/read/ens.d.ts +20 -40
- package/dist/tools/read/ens.d.ts.map +1 -1
- package/dist/tools/read/ens.js +25 -33
- package/dist/tools/read/ens.js.map +1 -1
- package/dist/tools/read/gas.d.ts.map +1 -1
- package/dist/tools/read/gas.js +13 -48
- package/dist/tools/read/gas.js.map +1 -1
- package/dist/tools/read/logs.d.ts +61 -0
- package/dist/tools/read/logs.d.ts.map +1 -1
- package/dist/tools/read/logs.js +96 -115
- package/dist/tools/read/logs.js.map +1 -1
- package/dist/tools/read/signatures.d.ts.map +1 -1
- package/dist/tools/read/signatures.js +4 -3
- package/dist/tools/read/signatures.js.map +1 -1
- package/dist/tools/read/signing.d.ts.map +1 -1
- package/dist/tools/read/signing.js +8 -2
- package/dist/tools/read/signing.js.map +1 -1
- package/dist/tools/sign/transactions.d.ts +4 -4
- package/dist/tools/sign/transactions.d.ts.map +1 -1
- package/dist/tools/sign/transactions.js +54 -9
- package/dist/tools/sign/transactions.js.map +1 -1
- package/dist/utils.d.ts +18 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +43 -1
- package/dist/utils.js.map +1 -1
- package/dist/wallet-client.d.ts +1 -0
- package/dist/wallet-client.d.ts.map +1 -1
- package/dist/wallet-client.js +16 -3
- package/dist/wallet-client.js.map +1 -1
- package/package.json +4 -7
- package/src/chain-meta.ts +16 -7
- package/src/clear-signing.ts +15 -9
- package/src/http-server.ts +8 -3
- package/src/index.ts +5 -1
- package/src/kv-storage.ts +6 -3
- package/src/oauth.ts +93 -34
- package/src/preview.ts +7 -5
- package/src/tools/index.ts +12 -1
- package/src/tools/read/advanced.ts +63 -34
- package/src/tools/read/balance.ts +18 -33
- package/src/tools/read/contract-info.ts +64 -144
- package/src/tools/read/contract.ts +2 -1
- package/src/tools/read/ens.ts +26 -33
- package/src/tools/read/gas.ts +13 -50
- package/src/tools/read/logs.ts +131 -143
- package/src/tools/read/signatures.ts +4 -4
- package/src/tools/read/signing.ts +8 -2
- package/src/tools/sign/transactions.ts +60 -9
- package/src/utils.ts +47 -1
- package/src/wallet-client.ts +17 -3
package/src/wallet-client.ts
CHANGED
|
@@ -9,6 +9,13 @@ import { HOSTED } from './hosted.js'
|
|
|
9
9
|
|
|
10
10
|
const REQUEST_TIMEOUT = 300_000
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Past this point the page may have signed and broadcast without the answer reaching us, so
|
|
14
|
+
* a failure is not a rejection: retrying blindly could send the same thing twice.
|
|
15
|
+
*/
|
|
16
|
+
const OUTCOME_UNKNOWN =
|
|
17
|
+
'The outcome is unknown — it may still have been signed or broadcast. Check the wallet or a block explorer before retrying.'
|
|
18
|
+
|
|
12
19
|
/**
|
|
13
20
|
* How long a client with nothing in flight keeps its socket. A hosted server makes one per
|
|
14
21
|
* person who ever signed, and without this each would hold a relay connection for the life
|
|
@@ -94,6 +101,7 @@ export class WalletClient {
|
|
|
94
101
|
/** Instance fields so tests can shorten the waits instead of sitting out the real ones. */
|
|
95
102
|
private signerWaitTimeout = SIGNER_WAIT_TIMEOUT
|
|
96
103
|
private idleTimeout = IDLE_TIMEOUT
|
|
104
|
+
private requestTimeout = REQUEST_TIMEOUT
|
|
97
105
|
|
|
98
106
|
private readonly remoteUrl = process.env.WALLET_SERVER_URL
|
|
99
107
|
private readonly remoteToken = process.env.WALLET_TOKEN
|
|
@@ -234,6 +242,10 @@ export class WalletClient {
|
|
|
234
242
|
this.signerAddress = undefined
|
|
235
243
|
this.pageUrl = undefined
|
|
236
244
|
this.pageAgent = undefined
|
|
245
|
+
for (const [id, pending] of this.pending) {
|
|
246
|
+
this.pending.delete(id)
|
|
247
|
+
pending.reject(new Error(`Lost the connection to the wallet relay before the wallet answered. ${OUTCOME_UNKNOWN}`))
|
|
248
|
+
}
|
|
237
249
|
})
|
|
238
250
|
})
|
|
239
251
|
}
|
|
@@ -325,14 +337,16 @@ export class WalletClient {
|
|
|
325
337
|
return new Promise((resolve, reject) => {
|
|
326
338
|
this.pending.set(request.id, { resolve, reject })
|
|
327
339
|
this.rearmIdle()
|
|
328
|
-
ws.send(JSON.stringify(request))
|
|
340
|
+
ws.send(JSON.stringify({ ...request, expiresAt: Date.now() + this.requestTimeout }))
|
|
329
341
|
|
|
330
342
|
setTimeout(() => {
|
|
331
343
|
if (this.pending.delete(request.id)) {
|
|
332
344
|
this.rearmIdle()
|
|
333
|
-
|
|
345
|
+
// So the page stops offering it; its own expiresAt covers a cancel that never lands.
|
|
346
|
+
if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ type: 'cancel', id: request.id }))
|
|
347
|
+
reject(new Error(`Wallet request timed out. ${OUTCOME_UNKNOWN}`))
|
|
334
348
|
}
|
|
335
|
-
},
|
|
349
|
+
}, this.requestTimeout)
|
|
336
350
|
})
|
|
337
351
|
}
|
|
338
352
|
|