viem 2.18.4 → 2.18.5
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/_cjs/chains/definitions/forma.js +33 -0
- package/_cjs/chains/definitions/forma.js.map +1 -0
- package/_cjs/chains/definitions/sketchpad.js +28 -0
- package/_cjs/chains/definitions/sketchpad.js.map +1 -0
- package/_cjs/chains/index.js +9 -5
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/request.js +21 -3
- package/_cjs/errors/request.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +6 -4
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/rpc/socket.js +4 -0
- package/_cjs/utils/rpc/socket.js.map +1 -1
- package/_cjs/utils/rpc/webSocket.js +3 -4
- package/_cjs/utils/rpc/webSocket.js.map +1 -1
- package/_esm/chains/definitions/forma.js +30 -0
- package/_esm/chains/definitions/forma.js.map +1 -0
- package/_esm/chains/definitions/sketchpad.js +25 -0
- package/_esm/chains/definitions/sketchpad.js.map +1 -0
- package/_esm/chains/index.js +2 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/request.js +19 -2
- package/_esm/errors/request.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/utils/rpc/socket.js +6 -1
- package/_esm/utils/rpc/socket.js.map +1 -1
- package/_esm/utils/rpc/webSocket.js +4 -5
- package/_esm/utils/rpc/webSocket.js.map +1 -1
- package/_types/chains/definitions/forma.d.ts +35 -0
- package/_types/chains/definitions/forma.d.ts.map +1 -0
- package/_types/chains/definitions/sketchpad.d.ts +37 -0
- package/_types/chains/definitions/sketchpad.d.ts.map +1 -0
- package/_types/chains/index.d.ts +2 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/request.d.ts +14 -4
- package/_types/errors/request.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/utils/rpc/compat.d.ts.map +1 -1
- package/_types/utils/rpc/socket.d.ts.map +1 -1
- package/_types/utils/rpc/webSocket.d.ts.map +1 -1
- package/chains/definitions/forma.ts +30 -0
- package/chains/definitions/sketchpad.ts +25 -0
- package/chains/index.ts +2 -0
- package/errors/request.ts +26 -3
- package/errors/version.ts +1 -1
- package/index.ts +2 -0
- package/package.json +1 -1
- package/utils/rpc/socket.ts +7 -1
- package/utils/rpc/webSocket.ts +7 -5
@@ -0,0 +1,30 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const forma = /*#__PURE__*/ defineChain({
|
4
|
+
id: 984122,
|
5
|
+
name: 'Forma',
|
6
|
+
network: 'forma',
|
7
|
+
nativeCurrency: {
|
8
|
+
symbol: 'TIA',
|
9
|
+
name: 'TIA',
|
10
|
+
decimals: 18,
|
11
|
+
},
|
12
|
+
rpcUrls: {
|
13
|
+
default: {
|
14
|
+
http: ['https://rpc.forma.art'],
|
15
|
+
webSocket: ['wss://ws.forma.art'],
|
16
|
+
},
|
17
|
+
},
|
18
|
+
blockExplorers: {
|
19
|
+
default: {
|
20
|
+
name: 'Forma Explorer',
|
21
|
+
url: 'https://explorer.forma.art',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
contracts: {
|
25
|
+
multicall3: {
|
26
|
+
address: '0xd53C6FFB123F7349A32980F87faeD8FfDc9ef079',
|
27
|
+
blockCreated: 252705,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
})
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const sketchpad = /*#__PURE__*/ defineChain({
|
4
|
+
id: 984123,
|
5
|
+
name: 'Forma Sketchpad',
|
6
|
+
network: 'sketchpad',
|
7
|
+
nativeCurrency: {
|
8
|
+
symbol: 'TIA',
|
9
|
+
name: 'TIA',
|
10
|
+
decimals: 18,
|
11
|
+
},
|
12
|
+
rpcUrls: {
|
13
|
+
default: {
|
14
|
+
http: ['https://rpc.sketchpad-1.forma.art'],
|
15
|
+
webSocket: ['wss://ws.sketchpad-1.forma.art'],
|
16
|
+
},
|
17
|
+
},
|
18
|
+
blockExplorers: {
|
19
|
+
default: {
|
20
|
+
name: 'Sketchpad Explorer',
|
21
|
+
url: 'https://explorer.sketchpad-1.forma.art',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
testnet: true,
|
25
|
+
})
|
package/chains/index.ts
CHANGED
@@ -101,6 +101,7 @@ export { flareTestnet } from './definitions/flareTestnet.js'
|
|
101
101
|
export { flowPreviewnet } from './definitions/flowPreviewnet.js'
|
102
102
|
export { flowMainnet } from './definitions/flowMainnet.js'
|
103
103
|
export { flowTestnet } from './definitions/flowTestnet.js'
|
104
|
+
export { forma } from './definitions/forma.js'
|
104
105
|
/** @deprecated Use `anvil` instead. */
|
105
106
|
export { foundry } from './definitions/foundry.js'
|
106
107
|
export { fraxtal } from './definitions/fraxtal.js'
|
@@ -257,6 +258,7 @@ export { skaleNebulaTestnet } from './definitions/skale/nebulaTestnet.js'
|
|
257
258
|
export { skaleRazor } from './definitions/skale/razor.js'
|
258
259
|
export { skaleTitan } from './definitions/skale/titan.js'
|
259
260
|
export { skaleTitanTestnet } from './definitions/skale/titanTestnet.js'
|
261
|
+
export { sketchpad } from './definitions/sketchpad.js'
|
260
262
|
export { songbird } from './definitions/songbird.js'
|
261
263
|
export { songbirdTestnet } from './definitions/songbirdTestnet.js'
|
262
264
|
export { spicy } from './definitions/spicy.js'
|
package/errors/request.ts
CHANGED
@@ -53,16 +53,22 @@ export class WebSocketRequestError extends BaseError {
|
|
53
53
|
|
54
54
|
constructor({
|
55
55
|
body,
|
56
|
+
cause,
|
56
57
|
details,
|
57
58
|
url,
|
58
59
|
}: {
|
59
|
-
body
|
60
|
-
|
60
|
+
body?: { [key: string]: unknown } | undefined
|
61
|
+
cause?: Error | undefined
|
62
|
+
details?: string | undefined
|
61
63
|
url: string
|
62
64
|
}) {
|
63
65
|
super('WebSocket request failed.', {
|
66
|
+
cause,
|
64
67
|
details,
|
65
|
-
metaMessages: [
|
68
|
+
metaMessages: [
|
69
|
+
`URL: ${getUrl(url)}`,
|
70
|
+
body && `Request body: ${stringify(body)}`,
|
71
|
+
].filter(Boolean) as string[],
|
66
72
|
})
|
67
73
|
}
|
68
74
|
}
|
@@ -93,6 +99,23 @@ export class RpcRequestError extends BaseError {
|
|
93
99
|
}
|
94
100
|
}
|
95
101
|
|
102
|
+
export type SocketClosedErrorType = SocketClosedError & {
|
103
|
+
name: 'SocketClosedError'
|
104
|
+
}
|
105
|
+
export class SocketClosedError extends BaseError {
|
106
|
+
override name = 'SocketClosedError'
|
107
|
+
|
108
|
+
constructor({
|
109
|
+
url,
|
110
|
+
}: {
|
111
|
+
url?: string | undefined
|
112
|
+
} = {}) {
|
113
|
+
super('The socket has been closed.', {
|
114
|
+
metaMessages: [url && `URL: ${getUrl(url)}`].filter(Boolean) as string[],
|
115
|
+
})
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
96
119
|
export type TimeoutErrorType = TimeoutError & {
|
97
120
|
name: 'TimeoutError'
|
98
121
|
}
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.18.
|
1
|
+
export const version = '2.18.5'
|
package/index.ts
CHANGED
package/package.json
CHANGED
package/utils/rpc/socket.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { TimeoutError } from '../../errors/request.js'
|
1
|
+
import { SocketClosedError, TimeoutError } from '../../errors/request.js'
|
2
2
|
import type { ErrorType } from '../../errors/utils.js'
|
3
3
|
import type { RpcRequest, RpcResponse } from '../../types/rpc.js'
|
4
4
|
import {
|
@@ -134,6 +134,12 @@ export async function getSocketRpcClient<socket extends {}>(
|
|
134
134
|
async function setup() {
|
135
135
|
const result = await getSocket({
|
136
136
|
onClose() {
|
137
|
+
// Notify all requests and subscriptions of the closure error.
|
138
|
+
for (const request of requests.values())
|
139
|
+
request.onError?.(new SocketClosedError({ url }))
|
140
|
+
for (const subscription of subscriptions.values())
|
141
|
+
subscription.onError?.(new SocketClosedError({ url }))
|
142
|
+
|
137
143
|
// Clear all requests and subscriptions.
|
138
144
|
requests.clear()
|
139
145
|
subscriptions.clear()
|
package/utils/rpc/webSocket.ts
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
import type { MessageEvent } from 'isows'
|
2
2
|
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
SocketClosedError,
|
5
|
+
WebSocketRequestError,
|
6
|
+
} from '../../errors/request.js'
|
4
7
|
import {
|
5
8
|
type GetSocketRpcClientParameters,
|
6
9
|
type Socket,
|
@@ -64,12 +67,11 @@ export async function getWebSocketRpcClient(
|
|
64
67
|
socket.readyState === socket.CLOSING
|
65
68
|
)
|
66
69
|
throw new WebSocketRequestError({
|
67
|
-
body: {},
|
68
70
|
url: socket.url,
|
69
|
-
|
71
|
+
cause: new SocketClosedError({ url: socket.url }),
|
70
72
|
})
|
71
73
|
|
72
|
-
socket.send('
|
74
|
+
socket.send('net_version')
|
73
75
|
} catch (error) {
|
74
76
|
onError(error as Error)
|
75
77
|
}
|
@@ -82,7 +84,7 @@ export async function getWebSocketRpcClient(
|
|
82
84
|
throw new WebSocketRequestError({
|
83
85
|
body,
|
84
86
|
url: socket.url,
|
85
|
-
|
87
|
+
cause: new SocketClosedError({ url: socket.url }),
|
86
88
|
})
|
87
89
|
|
88
90
|
return socket.send(JSON.stringify(body))
|