viem 2.23.4 → 2.23.6
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 +28 -0
- package/README.md +6 -0
- package/_cjs/actions/wallet/prepareTransactionRequest.js +16 -16
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/chains/definitions/berachainBepolia.js +30 -0
- package/_cjs/chains/definitions/berachainBepolia.js.map +1 -0
- package/_cjs/chains/definitions/fluentTestnet.js +26 -0
- package/_cjs/chains/definitions/fluentTestnet.js.map +1 -0
- package/_cjs/chains/definitions/form.js +60 -0
- package/_cjs/chains/definitions/form.js.map +1 -0
- package/_cjs/chains/definitions/formTestnet.js +61 -0
- package/_cjs/chains/definitions/formTestnet.js.map +1 -0
- package/_cjs/chains/definitions/real.js +1 -1
- package/_cjs/chains/definitions/real.js.map +1 -1
- package/_cjs/chains/definitions/saga.js +2 -2
- package/_cjs/chains/definitions/saga.js.map +1 -1
- package/_cjs/chains/definitions/sonicBlazeTestnet.js +24 -0
- package/_cjs/chains/definitions/sonicBlazeTestnet.js.map +1 -0
- package/_cjs/chains/definitions/telos.js +1 -1
- package/_cjs/chains/definitions/telos.js.map +1 -1
- package/_cjs/chains/definitions/telosTestnet.js +1 -1
- package/_cjs/chains/definitions/zeroNetwork.js +22 -0
- package/_cjs/chains/definitions/zeroNetwork.js.map +1 -0
- package/_cjs/chains/index.js +23 -11
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/transports/http.js +3 -1
- package/_cjs/clients/transports/http.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/types/eip1193.js.map +1 -1
- package/_cjs/utils/rpc/webSocket.js +7 -1
- package/_cjs/utils/rpc/webSocket.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js +16 -16
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/chains/definitions/berachainBepolia.js +27 -0
- package/_esm/chains/definitions/berachainBepolia.js.map +1 -0
- package/_esm/chains/definitions/fluentTestnet.js +23 -0
- package/_esm/chains/definitions/fluentTestnet.js.map +1 -0
- package/_esm/chains/definitions/form.js +57 -0
- package/_esm/chains/definitions/form.js.map +1 -0
- package/_esm/chains/definitions/formTestnet.js +58 -0
- package/_esm/chains/definitions/formTestnet.js.map +1 -0
- package/_esm/chains/definitions/real.js +1 -1
- package/_esm/chains/definitions/real.js.map +1 -1
- package/_esm/chains/definitions/saga.js +2 -2
- package/_esm/chains/definitions/saga.js.map +1 -1
- package/_esm/chains/definitions/sonicBlazeTestnet.js +21 -0
- package/_esm/chains/definitions/sonicBlazeTestnet.js.map +1 -0
- package/_esm/chains/definitions/telos.js +1 -1
- package/_esm/chains/definitions/telos.js.map +1 -1
- package/_esm/chains/definitions/telosTestnet.js +1 -1
- package/_esm/chains/definitions/zeroNetwork.js +19 -0
- package/_esm/chains/definitions/zeroNetwork.js.map +1 -0
- package/_esm/chains/index.js +7 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/transports/http.js +3 -1
- package/_esm/clients/transports/http.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/types/eip1193.js.map +1 -1
- package/_esm/utils/rpc/webSocket.js +7 -1
- package/_esm/utils/rpc/webSocket.js.map +1 -1
- package/_types/chains/definitions/berachainBepolia.d.ts +33 -0
- package/_types/chains/definitions/berachainBepolia.d.ts.map +1 -0
- package/_types/chains/definitions/fluentTestnet.d.ts +37 -0
- package/_types/chains/definitions/fluentTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/form.d.ts +76 -0
- package/_types/chains/definitions/form.d.ts.map +1 -0
- package/_types/chains/definitions/formTestnet.d.ts +76 -0
- package/_types/chains/definitions/formTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/real.d.ts +1 -1
- package/_types/chains/definitions/saga.d.ts +2 -2
- package/_types/chains/definitions/sonicBlazeTestnet.d.ts +37 -0
- package/_types/chains/definitions/sonicBlazeTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/telos.d.ts +1 -1
- package/_types/chains/definitions/telosTestnet.d.ts +1 -1
- package/_types/chains/definitions/zeroNetwork.d.ts +37 -0
- package/_types/chains/definitions/zeroNetwork.d.ts.map +1 -0
- package/_types/chains/index.d.ts +7 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/decorators/test.d.ts +2 -2
- package/_types/clients/transports/http.d.ts +10 -5
- package/_types/clients/transports/http.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/types/eip1193.d.ts +13 -2
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/utils/rpc/webSocket.d.ts.map +1 -1
- package/actions/wallet/prepareTransactionRequest.ts +20 -20
- package/chains/definitions/berachainBepolia.ts +27 -0
- package/chains/definitions/fluentTestnet.ts +23 -0
- package/chains/definitions/form.ts +58 -0
- package/chains/definitions/formTestnet.ts +59 -0
- package/chains/definitions/real.ts +1 -1
- package/chains/definitions/saga.ts +2 -2
- package/chains/definitions/sonicBlazeTestnet.ts +21 -0
- package/chains/definitions/telos.ts +1 -1
- package/chains/definitions/telosTestnet.ts +1 -1
- package/chains/definitions/zeroNetwork.ts +19 -0
- package/chains/index.ts +7 -0
- package/clients/decorators/test.ts +2 -2
- package/clients/transports/http.ts +24 -6
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/types/eip1193.ts +26 -5
- package/utils/rpc/webSocket.ts +6 -1
@@ -0,0 +1,21 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const sonicBlazeTestnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 57_054,
|
5
|
+
name: 'Sonic Blaze Testnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'Sonic',
|
9
|
+
symbol: 'S',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: { http: ['https://rpc.blaze.soniclabs.com'] },
|
13
|
+
},
|
14
|
+
blockExplorers: {
|
15
|
+
default: {
|
16
|
+
name: 'Sonic Blaze Testnet Explorer',
|
17
|
+
url: 'https://testnet.sonicscan.org',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
testnet: true,
|
21
|
+
})
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const zeroNetwork = /*#__PURE__*/ defineChain({
|
4
|
+
id: 543_210,
|
5
|
+
name: 'Zero Network',
|
6
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
7
|
+
rpcUrls: {
|
8
|
+
default: {
|
9
|
+
http: ['https://rpc.zerion.io/v1/zero'],
|
10
|
+
},
|
11
|
+
},
|
12
|
+
blockExplorers: {
|
13
|
+
default: {
|
14
|
+
name: 'Zero Network Explorer',
|
15
|
+
url: 'https://explorer.zero.network',
|
16
|
+
},
|
17
|
+
},
|
18
|
+
testnet: false,
|
19
|
+
})
|
package/chains/index.ts
CHANGED
@@ -48,6 +48,7 @@ export { beamTestnet } from './definitions/beamTestnet.js'
|
|
48
48
|
export { bearNetworkChainMainnet } from './definitions/bearNetworkChainMainnet.js'
|
49
49
|
export { bearNetworkChainTestnet } from './definitions/bearNetworkChainTestnet.js'
|
50
50
|
export { berachain } from './definitions/berachain.js'
|
51
|
+
export { berachainBepolia } from './definitions/berachainBepolia.js'
|
51
52
|
export { berachainTestnet } from './definitions/berachainTestnet.js'
|
52
53
|
export { berachainTestnetbArtio } from './definitions/berachainTestnetbArtio.js'
|
53
54
|
export { bevmMainnet } from './definitions/bevmMainnet.js'
|
@@ -174,7 +175,10 @@ export { flowTestnet } from './definitions/flowTestnet.js'
|
|
174
175
|
export { fluence } from './definitions/fluence.js'
|
175
176
|
export { fluenceStage } from './definitions/fluenceStage.js'
|
176
177
|
export { fluenceTestnet } from './definitions/fluenceTestnet.js'
|
178
|
+
export { fluentTestnet } from './definitions/fluentTestnet.js'
|
177
179
|
export { forma } from './definitions/forma.js'
|
180
|
+
export { form } from './definitions/form.js'
|
181
|
+
export { formTestnet } from './definitions/formTestnet.js'
|
178
182
|
export { forta } from './definitions/forta.js'
|
179
183
|
/** @deprecated Use `anvil` instead. */
|
180
184
|
export { foundry } from './definitions/foundry.js'
|
@@ -442,7 +446,9 @@ export { snaxTestnet } from './definitions/snaxTestnet.js'
|
|
442
446
|
export { soneium } from './definitions/soneium.js'
|
443
447
|
export { soneiumMinato } from './definitions/soneiumMinato.js'
|
444
448
|
export { sonic } from './definitions/sonic.js'
|
449
|
+
/** @deprecated Use `sonicBlazeTestnet` instead. */
|
445
450
|
export { sonicTestnet } from './definitions/sonicTestnet.js'
|
451
|
+
export { sonicBlazeTestnet } from './definitions/sonicBlazeTestnet.js'
|
446
452
|
export { songbird } from './definitions/songbird.js'
|
447
453
|
export { songbirdTestnet } from './definitions/songbirdTestnet.js'
|
448
454
|
export { sophon } from './definitions/sophon.js'
|
@@ -534,6 +540,7 @@ export { yooldoVerseTestnet } from './definitions/yooldoVerseTestnet.js'
|
|
534
540
|
export { zenchainTestnet } from './definitions/zenchainTestnet.js'
|
535
541
|
export { zeniq } from './definitions/zeniq.js'
|
536
542
|
export { zeroG } from './definitions/0g.js'
|
543
|
+
export { zeroNetwork } from './definitions/zeroNetwork.js'
|
537
544
|
export { zetachain } from './definitions/zetachain.js'
|
538
545
|
export { zetachainAthensTestnet } from './definitions/zetachainAthensTestnet.js'
|
539
546
|
export { zhejiang } from './definitions/zhejiang.js'
|
@@ -356,9 +356,9 @@ export type TestActions = {
|
|
356
356
|
*/
|
357
357
|
revert: (args: RevertParameters) => Promise<void>
|
358
358
|
/**
|
359
|
-
*
|
359
|
+
* Executes a transaction regardless of the signature.
|
360
360
|
*
|
361
|
-
* - Docs: https://viem.sh/docs/actions/test/
|
361
|
+
* - Docs: https://viem.sh/docs/actions/test/sendUnsignedTransaction
|
362
362
|
*
|
363
363
|
* @param args – {@link SendUnsignedTransactionParameters}
|
364
364
|
* @returns The transaction hash. {@link SendUnsignedTransactionReturnType}
|
@@ -4,6 +4,7 @@ import {
|
|
4
4
|
type UrlRequiredErrorType,
|
5
5
|
} from '../../errors/transport.js'
|
6
6
|
import type { ErrorType } from '../../errors/utils.js'
|
7
|
+
import type { EIP1193RequestFn, RpcSchema } from '../../types/eip1193.js'
|
7
8
|
import type { RpcRequest } from '../../types/rpc.js'
|
8
9
|
import { createBatchScheduler } from '../../utils/promise/createBatchScheduler.js'
|
9
10
|
import {
|
@@ -18,7 +19,10 @@ import {
|
|
18
19
|
createTransport,
|
19
20
|
} from './createTransport.js'
|
20
21
|
|
21
|
-
export type HttpTransportConfig
|
22
|
+
export type HttpTransportConfig<
|
23
|
+
rpcSchema extends RpcSchema | undefined = undefined,
|
24
|
+
raw extends boolean = false,
|
25
|
+
> = {
|
22
26
|
/**
|
23
27
|
* Whether to enable Batch JSON-RPC.
|
24
28
|
* @link https://www.jsonrpc.org/specification#batch
|
@@ -47,20 +51,28 @@ export type HttpTransportConfig = {
|
|
47
51
|
methods?: TransportConfig['methods'] | undefined
|
48
52
|
/** The name of the HTTP transport. */
|
49
53
|
name?: TransportConfig['name'] | undefined
|
54
|
+
/** Whether to return JSON RPC errors as responses instead of throwing. */
|
55
|
+
raw?: raw | boolean | undefined
|
50
56
|
/** The max number of times to retry. */
|
51
57
|
retryCount?: TransportConfig['retryCount'] | undefined
|
52
58
|
/** The base delay (in ms) between retries. */
|
53
59
|
retryDelay?: TransportConfig['retryDelay'] | undefined
|
60
|
+
/** Typed JSON-RPC schema for the transport. */
|
61
|
+
rpcSchema?: rpcSchema | RpcSchema | undefined
|
54
62
|
/** The timeout (in ms) for the HTTP request. Default: 10_000 */
|
55
63
|
timeout?: TransportConfig['timeout'] | undefined
|
56
64
|
}
|
57
65
|
|
58
|
-
export type HttpTransport
|
66
|
+
export type HttpTransport<
|
67
|
+
rpcSchema extends RpcSchema | undefined = undefined,
|
68
|
+
raw extends boolean = false,
|
69
|
+
> = Transport<
|
59
70
|
'http',
|
60
71
|
{
|
61
72
|
fetchOptions?: HttpTransportConfig['fetchOptions'] | undefined
|
62
73
|
url?: string | undefined
|
63
|
-
}
|
74
|
+
},
|
75
|
+
EIP1193RequestFn<rpcSchema, raw>
|
64
76
|
>
|
65
77
|
|
66
78
|
export type HttpTransportErrorType =
|
@@ -71,11 +83,14 @@ export type HttpTransportErrorType =
|
|
71
83
|
/**
|
72
84
|
* @description Creates a HTTP transport that connects to a JSON-RPC API.
|
73
85
|
*/
|
74
|
-
export function http
|
86
|
+
export function http<
|
87
|
+
rpcSchema extends RpcSchema | undefined = undefined,
|
88
|
+
raw extends boolean = false,
|
89
|
+
>(
|
75
90
|
/** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
|
76
91
|
url?: string | undefined,
|
77
|
-
config: HttpTransportConfig = {},
|
78
|
-
): HttpTransport {
|
92
|
+
config: HttpTransportConfig<rpcSchema, raw> = {},
|
93
|
+
): HttpTransport<rpcSchema, raw> {
|
79
94
|
const {
|
80
95
|
batch,
|
81
96
|
fetchOptions,
|
@@ -85,6 +100,7 @@ export function http(
|
|
85
100
|
onFetchRequest,
|
86
101
|
onFetchResponse,
|
87
102
|
retryDelay,
|
103
|
+
raw,
|
88
104
|
} = config
|
89
105
|
return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {
|
90
106
|
const { batchSize = 1000, wait = 0 } =
|
@@ -132,6 +148,8 @@ export function http(
|
|
132
148
|
]
|
133
149
|
|
134
150
|
const [{ error, result }] = await fn(body)
|
151
|
+
|
152
|
+
if (raw) return { error, result }
|
135
153
|
if (error)
|
136
154
|
throw new RpcRequestError({
|
137
155
|
body,
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.23.
|
1
|
+
export const version = '2.23.6'
|
package/package.json
CHANGED
package/types/eip1193.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
3
|
import type * as BlockOverrides from 'ox/BlockOverrides'
|
4
|
+
import type * as Rpc from 'ox/RpcResponse'
|
4
5
|
import type {
|
5
6
|
RpcEstimateUserOperationGasReturnType,
|
6
7
|
RpcGetUserOperationByHashReturnType,
|
@@ -1950,17 +1951,37 @@ type DerivedRpcSchema<
|
|
1950
1951
|
|
1951
1952
|
export type EIP1193RequestFn<
|
1952
1953
|
rpcSchema extends RpcSchema | undefined = undefined,
|
1954
|
+
raw extends boolean = false,
|
1953
1955
|
> = <
|
1954
1956
|
rpcSchemaOverride extends RpcSchemaOverride | undefined = undefined,
|
1955
1957
|
_parameters extends EIP1193Parameters<
|
1956
1958
|
DerivedRpcSchema<rpcSchema, rpcSchemaOverride>
|
1957
1959
|
> = EIP1193Parameters<DerivedRpcSchema<rpcSchema, rpcSchemaOverride>>,
|
1958
1960
|
_returnType = DerivedRpcSchema<rpcSchema, rpcSchemaOverride> extends RpcSchema
|
1959
|
-
?
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1961
|
+
? raw extends true
|
1962
|
+
? OneOf<
|
1963
|
+
| {
|
1964
|
+
result: Extract<
|
1965
|
+
DerivedRpcSchema<rpcSchema, rpcSchemaOverride>[number],
|
1966
|
+
{ Method: _parameters['method'] }
|
1967
|
+
>['ReturnType']
|
1968
|
+
}
|
1969
|
+
| { error: Rpc.ErrorObject }
|
1970
|
+
>
|
1971
|
+
: Extract<
|
1972
|
+
DerivedRpcSchema<rpcSchema, rpcSchemaOverride>[number],
|
1973
|
+
{ Method: _parameters['method'] }
|
1974
|
+
>['ReturnType']
|
1975
|
+
: raw extends true
|
1976
|
+
? OneOf<
|
1977
|
+
| {
|
1978
|
+
result: unknown
|
1979
|
+
}
|
1980
|
+
| {
|
1981
|
+
error: Rpc.ErrorObject
|
1982
|
+
}
|
1983
|
+
>
|
1984
|
+
: unknown,
|
1964
1985
|
>(
|
1965
1986
|
args: _parameters,
|
1966
1987
|
options?: EIP1193RequestOptions | undefined,
|
package/utils/rpc/webSocket.ts
CHANGED
@@ -36,7 +36,12 @@ export async function getWebSocketRpcClient(
|
|
36
36
|
onClose()
|
37
37
|
}
|
38
38
|
function onMessage({ data }: MessageEvent) {
|
39
|
-
|
39
|
+
try {
|
40
|
+
const _data = JSON.parse(data)
|
41
|
+
onResponse(_data)
|
42
|
+
} catch (error) {
|
43
|
+
onError(error as Error)
|
44
|
+
}
|
40
45
|
}
|
41
46
|
|
42
47
|
// Setup event listeners for RPC & subscription responses.
|