viem 2.9.16 → 2.9.18

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/_cjs/chains/definitions/bahamut.js +4 -4
  3. package/_cjs/chains/definitions/bahamut.js.map +1 -1
  4. package/_cjs/chains/definitions/boba.js +2 -2
  5. package/_cjs/chains/definitions/boba.js.map +1 -1
  6. package/_cjs/chains/definitions/chiliz.js +4 -1
  7. package/_cjs/chains/definitions/chiliz.js.map +1 -1
  8. package/_cjs/chains/definitions/darwinia.js +29 -0
  9. package/_cjs/chains/definitions/darwinia.js.map +1 -0
  10. package/_cjs/chains/definitions/holesky.js +1 -1
  11. package/_cjs/chains/definitions/holesky.js.map +1 -1
  12. package/_cjs/chains/definitions/mantaSepoliaTestnet.js +34 -0
  13. package/_cjs/chains/definitions/mantaSepoliaTestnet.js.map +1 -0
  14. package/_cjs/chains/definitions/mode.js +2 -2
  15. package/_cjs/chains/definitions/mode.js.map +1 -1
  16. package/_cjs/chains/definitions/spicy.js +2 -2
  17. package/_cjs/chains/definitions/spicy.js.map +1 -1
  18. package/_cjs/chains/definitions/taikoHekla.js +21 -0
  19. package/_cjs/chains/definitions/taikoHekla.js.map +1 -0
  20. package/_cjs/chains/index.js +12 -4
  21. package/_cjs/chains/index.js.map +1 -1
  22. package/_cjs/clients/createClient.js +5 -1
  23. package/_cjs/clients/createClient.js.map +1 -1
  24. package/_cjs/clients/createPublicClient.js.map +1 -1
  25. package/_cjs/clients/createTestClient.js.map +1 -1
  26. package/_cjs/clients/createWalletClient.js.map +1 -1
  27. package/_cjs/errors/version.js +1 -1
  28. package/_cjs/index.js +9 -8
  29. package/_cjs/index.js.map +1 -1
  30. package/_cjs/utils/getAction.js +3 -1
  31. package/_cjs/utils/getAction.js.map +1 -1
  32. package/_esm/chains/definitions/bahamut.js +4 -4
  33. package/_esm/chains/definitions/bahamut.js.map +1 -1
  34. package/_esm/chains/definitions/boba.js +2 -2
  35. package/_esm/chains/definitions/boba.js.map +1 -1
  36. package/_esm/chains/definitions/chiliz.js +4 -1
  37. package/_esm/chains/definitions/chiliz.js.map +1 -1
  38. package/_esm/chains/definitions/darwinia.js +26 -0
  39. package/_esm/chains/definitions/darwinia.js.map +1 -0
  40. package/_esm/chains/definitions/holesky.js +1 -1
  41. package/_esm/chains/definitions/holesky.js.map +1 -1
  42. package/_esm/chains/definitions/mantaSepoliaTestnet.js +31 -0
  43. package/_esm/chains/definitions/mantaSepoliaTestnet.js.map +1 -0
  44. package/_esm/chains/definitions/mode.js +2 -2
  45. package/_esm/chains/definitions/mode.js.map +1 -1
  46. package/_esm/chains/definitions/spicy.js +2 -2
  47. package/_esm/chains/definitions/spicy.js.map +1 -1
  48. package/_esm/chains/definitions/taikoHekla.js +18 -0
  49. package/_esm/chains/definitions/taikoHekla.js.map +1 -0
  50. package/_esm/chains/index.js +4 -0
  51. package/_esm/chains/index.js.map +1 -1
  52. package/_esm/clients/createClient.js +7 -0
  53. package/_esm/clients/createClient.js.map +1 -1
  54. package/_esm/clients/createPublicClient.js.map +1 -1
  55. package/_esm/clients/createTestClient.js.map +1 -1
  56. package/_esm/clients/createWalletClient.js.map +1 -1
  57. package/_esm/errors/version.js +1 -1
  58. package/_esm/index.js +1 -1
  59. package/_esm/index.js.map +1 -1
  60. package/_esm/utils/getAction.js +6 -3
  61. package/_esm/utils/getAction.js.map +1 -1
  62. package/_types/chains/definitions/bahamut.d.ts +4 -4
  63. package/_types/chains/definitions/boba.d.ts +2 -2
  64. package/_types/chains/definitions/chiliz.d.ts +1 -1
  65. package/_types/chains/definitions/chiliz.d.ts.map +1 -1
  66. package/_types/chains/definitions/darwinia.d.ts +34 -0
  67. package/_types/chains/definitions/darwinia.d.ts.map +1 -0
  68. package/_types/chains/definitions/holesky.d.ts +1 -1
  69. package/_types/chains/definitions/mantaSepoliaTestnet.d.ts +35 -0
  70. package/_types/chains/definitions/mantaSepoliaTestnet.d.ts.map +1 -0
  71. package/_types/chains/definitions/mode.d.ts +2 -2
  72. package/_types/chains/definitions/spicy.d.ts +2 -2
  73. package/_types/chains/definitions/taikoHekla.d.ts +35 -0
  74. package/_types/chains/definitions/taikoHekla.d.ts.map +1 -0
  75. package/_types/chains/index.d.ts +4 -0
  76. package/_types/chains/index.d.ts.map +1 -1
  77. package/_types/clients/createClient.d.ts +9 -3
  78. package/_types/clients/createClient.d.ts.map +1 -1
  79. package/_types/clients/createPublicClient.d.ts +6 -4
  80. package/_types/clients/createPublicClient.d.ts.map +1 -1
  81. package/_types/clients/createTestClient.d.ts +6 -6
  82. package/_types/clients/createTestClient.d.ts.map +1 -1
  83. package/_types/clients/createWalletClient.d.ts +4 -4
  84. package/_types/clients/createWalletClient.d.ts.map +1 -1
  85. package/_types/errors/version.d.ts +1 -1
  86. package/_types/index.d.ts +1 -1
  87. package/_types/index.d.ts.map +1 -1
  88. package/_types/utils/getAction.d.ts.map +1 -1
  89. package/chains/definitions/bahamut.ts +4 -4
  90. package/chains/definitions/boba.ts +2 -2
  91. package/chains/definitions/chiliz.ts +4 -1
  92. package/chains/definitions/darwinia.ts +26 -0
  93. package/chains/definitions/holesky.ts +1 -1
  94. package/chains/definitions/mantaSepoliaTestnet.ts +31 -0
  95. package/chains/definitions/mode.ts +2 -2
  96. package/chains/definitions/spicy.ts +2 -2
  97. package/chains/definitions/taikoHekla.ts +18 -0
  98. package/chains/index.ts +4 -0
  99. package/clients/createClient.ts +17 -5
  100. package/clients/createPublicClient.ts +18 -7
  101. package/clients/createTestClient.ts +30 -11
  102. package/clients/createWalletClient.ts +11 -5
  103. package/errors/version.ts +1 -1
  104. package/index.ts +1 -0
  105. package/package.json +1 -1
  106. package/utils/getAction.ts +10 -7
@@ -13,11 +13,11 @@ export const spicy = /*#__PURE__*/ defineChain({
13
13
  default: {
14
14
  http: [
15
15
  'https://spicy-rpc.chiliz.com',
16
- 'https://chiliz-spicy.publicnode.com',
16
+ 'https://chiliz-spicy-rpc.publicnode.com',
17
17
  ],
18
18
  webSocket: [
19
19
  'wss://spicy-rpc-ws.chiliz.com',
20
- 'wss://chiliz-spicy.publicnode.com',
20
+ 'wss://chiliz-spicy-rpc.publicnode.com',
21
21
  ],
22
22
  },
23
23
  },
@@ -0,0 +1,18 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const taikoHekla = /*#__PURE__*/ defineChain({
4
+ id: 167_009,
5
+ name: 'Taiko Hekla L2',
6
+ nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://rpc.hekla.taiko.xyz'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'Taikoscan',
15
+ url: 'https://hekla.taikoscan.network',
16
+ },
17
+ },
18
+ })
package/chains/index.ts CHANGED
@@ -52,6 +52,7 @@ export { coreDao } from './definitions/coreDao.js'
52
52
  export { cronos } from './definitions/cronos.js'
53
53
  export { cronosTestnet } from './definitions/cronosTestnet.js'
54
54
  export { crossbell } from './definitions/crossbell.js'
55
+ export { darwinia } from './definitions/darwinia.js'
55
56
  export { defichainEvm } from './definitions/defichainEvm.js'
56
57
  export { defichainEvmTestnet } from './definitions/defichainEvmTestnet.js'
57
58
  export { degen } from './definitions/degen.js'
@@ -61,6 +62,7 @@ export { edgeless } from './definitions/edgeless.js'
61
62
  export { edgelessTestnet } from './definitions/edgelessTestnet.js'
62
63
  export { edgeware } from './definitions/edgeware.js'
63
64
  export { edgewareTestnet } from './definitions/edgewareTestnet.js'
65
+ export { eon } from './definitions/eon.js'
64
66
  export { eos } from './definitions/eos.js'
65
67
  export { eosTestnet } from './definitions/eosTestnet.js'
66
68
  export { etherlinkTestnet } from './definitions/etherlinkTestnet.js'
@@ -125,6 +127,7 @@ export { luksoTestnet } from './definitions/luksoTestnet.js'
125
127
  export { mainnet } from './definitions/mainnet.js'
126
128
  export { mandala } from './definitions/mandala.js'
127
129
  export { manta } from './definitions/manta.js'
130
+ export { mantaSepoliaTestnet } from './definitions/mantaSepoliaTestnet.js'
128
131
  export { mantaTestnet } from './definitions/mantaTestnet.js'
129
132
  export { mantle } from './definitions/mantle.js'
130
133
  export { mantleTestnet } from './definitions/mantleTestnet.js'
@@ -216,6 +219,7 @@ export { stratis } from './definitions/stratis.js'
216
219
  export { syscoin } from './definitions/syscoin.js'
217
220
  export { syscoinTestnet } from './definitions/syscoinTestnet.js'
218
221
  export { taraxa } from './definitions/taraxa.js'
222
+ export { taikoHekla } from './definitions/taikoHekla.js'
219
223
  export { taikoJolnir } from './definitions/taikoJolnir.js'
220
224
  export { taikoKatla } from './definitions/taikoKatla.js'
221
225
  export { taikoTestnetSepolia } from './definitions/taikoTestnetSepolia.js'
@@ -28,6 +28,7 @@ export type ClientConfig<
28
28
  | Account
29
29
  | Address
30
30
  | undefined,
31
+ rpcSchema extends RpcSchema | undefined = undefined,
31
32
  > = {
32
33
  /** The Account to use for the Client. This will be used for Actions that require an account as an argument. */
33
34
  account?: accountOrAddress | Account | Address | undefined
@@ -70,6 +71,10 @@ export type ClientConfig<
70
71
  * @default 4_000
71
72
  */
72
73
  pollingInterval?: number | undefined
74
+ /**
75
+ * Typed JSON-RPC schema for the client.
76
+ */
77
+ rpcSchema?: rpcSchema | undefined
73
78
  /** The RPC transport */
74
79
  transport: transport
75
80
  /** The type of client. */
@@ -188,22 +193,21 @@ export type MulticallBatchOptions = {
188
193
 
189
194
  export type CreateClientErrorType = ParseAccountErrorType | ErrorType
190
195
 
191
- /**
192
- * Creates a base client with the given transport.
193
- */
194
196
  export function createClient<
195
197
  transport extends Transport,
196
198
  chain extends Chain | undefined = undefined,
197
199
  accountOrAddress extends Account | Address | undefined = undefined,
200
+ rpcSchema extends RpcSchema | undefined = undefined,
198
201
  >(
199
- parameters: ClientConfig<transport, chain, accountOrAddress>,
202
+ parameters: ClientConfig<transport, chain, accountOrAddress, rpcSchema>,
200
203
  ): Prettify<
201
204
  Client<
202
205
  transport,
203
206
  chain,
204
207
  accountOrAddress extends Address
205
208
  ? Prettify<JsonRpcAccount<accountOrAddress>>
206
- : accountOrAddress
209
+ : accountOrAddress,
210
+ rpcSchema
207
211
  >
208
212
  >
209
213
 
@@ -255,3 +259,11 @@ export function createClient(parameters: ClientConfig): Client {
255
259
 
256
260
  return Object.assign(client, { extend: extend(client) as any })
257
261
  }
262
+
263
+ /**
264
+ * Defines a typed JSON-RPC schema for the client.
265
+ * Note: This is a runtime noop function.
266
+ */
267
+ export function rpcSchema<rpcSchema extends RpcSchema>(): rpcSchema {
268
+ return null as any
269
+ }
@@ -1,6 +1,8 @@
1
+ import type { Address } from 'abitype'
1
2
  import type { ErrorType } from '../errors/utils.js'
3
+ import type { Account, ParseAccount } from '../types/account.js'
2
4
  import type { Chain } from '../types/chain.js'
3
- import type { PublicRpcSchema } from '../types/eip1193.js'
5
+ import type { PublicRpcSchema, RpcSchema } from '../types/eip1193.js'
4
6
  import type { Prettify } from '../types/utils.js'
5
7
  import {
6
8
  type Client,
@@ -14,9 +16,11 @@ import type { Transport } from './transports/createTransport.js'
14
16
  export type PublicClientConfig<
15
17
  transport extends Transport = Transport,
16
18
  chain extends Chain | undefined = Chain | undefined,
19
+ accountOrAddress extends Account | Address | undefined = undefined,
20
+ rpcSchema extends RpcSchema | undefined = undefined,
17
21
  > = Prettify<
18
22
  Pick<
19
- ClientConfig<transport, chain>,
23
+ ClientConfig<transport, chain, accountOrAddress, rpcSchema>,
20
24
  | 'batch'
21
25
  | 'cacheTime'
22
26
  | 'ccipRead'
@@ -24,6 +28,7 @@ export type PublicClientConfig<
24
28
  | 'key'
25
29
  | 'name'
26
30
  | 'pollingInterval'
31
+ | 'rpcSchema'
27
32
  | 'transport'
28
33
  >
29
34
  >
@@ -31,12 +36,16 @@ export type PublicClientConfig<
31
36
  export type PublicClient<
32
37
  transport extends Transport = Transport,
33
38
  chain extends Chain | undefined = Chain | undefined,
39
+ accountOrAddress extends Account | undefined = undefined,
40
+ rpcSchema extends RpcSchema | undefined = undefined,
34
41
  > = Prettify<
35
42
  Client<
36
43
  transport,
37
44
  chain,
38
- undefined,
39
- PublicRpcSchema,
45
+ accountOrAddress,
46
+ rpcSchema extends RpcSchema
47
+ ? [...PublicRpcSchema, ...rpcSchema]
48
+ : PublicRpcSchema,
40
49
  PublicActions<transport, chain>
41
50
  >
42
51
  >
@@ -65,9 +74,11 @@ export type CreatePublicClientErrorType = CreateClientErrorType | ErrorType
65
74
  export function createPublicClient<
66
75
  transport extends Transport,
67
76
  chain extends Chain | undefined = undefined,
77
+ accountOrAddress extends Account | Address | undefined = undefined,
78
+ rpcSchema extends RpcSchema | undefined = undefined,
68
79
  >(
69
- parameters: PublicClientConfig<transport, chain>,
70
- ): PublicClient<transport, chain> {
80
+ parameters: PublicClientConfig<transport, chain, accountOrAddress, rpcSchema>,
81
+ ): PublicClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema> {
71
82
  const { key = 'public', name = 'Public Client' } = parameters
72
83
  const client = createClient({
73
84
  ...parameters,
@@ -75,5 +86,5 @@ export function createPublicClient<
75
86
  name,
76
87
  type: 'publicClient',
77
88
  })
78
- return client.extend(publicActions)
89
+ return client.extend(publicActions) as any
79
90
  }
@@ -4,7 +4,7 @@ import type { Account } from '../accounts/types.js'
4
4
  import type { ErrorType } from '../errors/utils.js'
5
5
  import type { ParseAccount } from '../types/account.js'
6
6
  import type { Chain } from '../types/chain.js'
7
- import type { TestRpcSchema } from '../types/eip1193.js'
7
+ import type { RpcSchema, TestRpcSchema } from '../types/eip1193.js'
8
8
  import type { Prettify } from '../types/utils.js'
9
9
  import {
10
10
  type Client,
@@ -25,15 +25,17 @@ export type TestClientConfig<
25
25
  | Account
26
26
  | Address
27
27
  | undefined,
28
+ rpcSchema extends RpcSchema | undefined = undefined,
28
29
  > = Prettify<
29
30
  Pick<
30
- ClientConfig<transport, chain, accountOrAddress>,
31
+ ClientConfig<transport, chain, accountOrAddress, rpcSchema>,
31
32
  | 'account'
32
33
  | 'cacheTime'
33
34
  | 'chain'
34
35
  | 'key'
35
36
  | 'name'
36
37
  | 'pollingInterval'
38
+ | 'rpcSchema'
37
39
  | 'transport'
38
40
  > & {
39
41
  /** Mode of the test client. */
@@ -42,18 +44,21 @@ export type TestClientConfig<
42
44
  >
43
45
 
44
46
  export type TestClient<
45
- TMode extends TestClientMode = TestClientMode,
47
+ mode extends TestClientMode = TestClientMode,
46
48
  transport extends Transport = Transport,
47
49
  chain extends Chain | undefined = Chain | undefined,
48
- TAccount extends Account | undefined = Account | undefined,
49
- TIncludeActions extends boolean = true,
50
+ account extends Account | undefined = Account | undefined,
51
+ includeActions extends boolean = true,
52
+ rpcSchema extends RpcSchema | undefined = undefined,
50
53
  > = Prettify<
51
- { mode: TMode } & Client<
54
+ { mode: mode } & Client<
52
55
  transport,
53
56
  chain,
54
- TAccount,
55
- TestRpcSchema<TMode>,
56
- TIncludeActions extends true ? TestActions : Record<string, unknown>
57
+ account,
58
+ rpcSchema extends RpcSchema
59
+ ? [...TestRpcSchema<mode>, ...rpcSchema]
60
+ : TestRpcSchema<mode>,
61
+ includeActions extends true ? TestActions : Record<string, unknown>
57
62
  >
58
63
  >
59
64
 
@@ -87,9 +92,23 @@ export function createTestClient<
87
92
  transport extends Transport,
88
93
  chain extends Chain | undefined = undefined,
89
94
  accountOrAddress extends Account | Address | undefined = undefined,
95
+ rpcSchema extends RpcSchema | undefined = undefined,
90
96
  >(
91
- parameters: TestClientConfig<mode, transport, chain, accountOrAddress>,
92
- ): TestClient<mode, transport, chain, ParseAccount<accountOrAddress>>
97
+ parameters: TestClientConfig<
98
+ mode,
99
+ transport,
100
+ chain,
101
+ accountOrAddress,
102
+ rpcSchema
103
+ >,
104
+ ): TestClient<
105
+ mode,
106
+ transport,
107
+ chain,
108
+ ParseAccount<accountOrAddress>,
109
+ true,
110
+ rpcSchema
111
+ >
93
112
 
94
113
  export function createTestClient(parameters: TestClientConfig): TestClient {
95
114
  const { key = 'test', name = 'Test Client', mode } = parameters
@@ -4,7 +4,7 @@ import type { Account } from '../accounts/types.js'
4
4
  import type { ErrorType } from '../errors/utils.js'
5
5
  import type { ParseAccount } from '../types/account.js'
6
6
  import type { Chain } from '../types/chain.js'
7
- import type { WalletRpcSchema } from '../types/eip1193.js'
7
+ import type { RpcSchema, WalletRpcSchema } from '../types/eip1193.js'
8
8
  import type { Prettify } from '../types/utils.js'
9
9
  import {
10
10
  type Client,
@@ -22,9 +22,10 @@ export type WalletClientConfig<
22
22
  | Account
23
23
  | Address
24
24
  | undefined,
25
+ rpcSchema extends RpcSchema | undefined = undefined,
25
26
  > = Prettify<
26
27
  Pick<
27
- ClientConfig<transport, chain, accountOrAddress>,
28
+ ClientConfig<transport, chain, accountOrAddress, rpcSchema>,
28
29
  | 'account'
29
30
  | 'cacheTime'
30
31
  | 'ccipRead'
@@ -32,6 +33,7 @@ export type WalletClientConfig<
32
33
  | 'key'
33
34
  | 'name'
34
35
  | 'pollingInterval'
36
+ | 'rpcSchema'
35
37
  | 'transport'
36
38
  >
37
39
  >
@@ -40,12 +42,15 @@ export type WalletClient<
40
42
  transport extends Transport = Transport,
41
43
  chain extends Chain | undefined = Chain | undefined,
42
44
  account extends Account | undefined = Account | undefined,
45
+ rpcSchema extends RpcSchema | undefined = undefined,
43
46
  > = Prettify<
44
47
  Client<
45
48
  transport,
46
49
  chain,
47
50
  account,
48
- WalletRpcSchema,
51
+ rpcSchema extends RpcSchema
52
+ ? [...WalletRpcSchema, ...rpcSchema]
53
+ : WalletRpcSchema,
49
54
  WalletActions<chain, account>
50
55
  >
51
56
  >
@@ -92,9 +97,10 @@ export function createWalletClient<
92
97
  transport extends Transport,
93
98
  chain extends Chain | undefined = undefined,
94
99
  accountOrAddress extends Account | Address | undefined = undefined,
100
+ rpcSchema extends RpcSchema | undefined = undefined,
95
101
  >(
96
- parameters: WalletClientConfig<transport, chain, accountOrAddress>,
97
- ): WalletClient<transport, chain, ParseAccount<accountOrAddress>>
102
+ parameters: WalletClientConfig<transport, chain, accountOrAddress, rpcSchema>,
103
+ ): WalletClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema>
98
104
 
99
105
  export function createWalletClient(
100
106
  parameters: WalletClientConfig,
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.9.16'
1
+ export const version = '2.9.18'
package/index.ts CHANGED
@@ -474,6 +474,7 @@ export {
474
474
  type CreateClientErrorType,
475
475
  type MulticallBatchOptions,
476
476
  createClient,
477
+ rpcSchema,
477
478
  } from './clients/createClient.js'
478
479
  export {
479
480
  type CustomTransport,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.9.16",
4
+ "version": "2.9.18",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -10,14 +10,17 @@ import type { Client } from '../clients/createClient.js'
10
10
  export function getAction<params extends {}, returnType extends {}>(
11
11
  client: Client,
12
12
  action: (_: any, params: params) => returnType,
13
- // Some minifiers drop `Function.prototype.name`, meaning that `action.name`
14
- // will not work. For that case, the consumer needs to pass the name explicitly.
13
+ // Some minifiers drop `Function.prototype.name` or can change function
14
+ // names so that getting the name by reflection through `action.name` will
15
+ // not work.
15
16
  name: string,
16
17
  ) {
18
+ type DecoratedClient = Client & {
19
+ [key: string]: (params: params) => returnType
20
+ }
21
+
17
22
  return (params: params): returnType =>
18
- (
19
- client as Client & {
20
- [key: string]: (params: params) => returnType
21
- }
22
- )[action.name || name]?.(params) ?? action(client, params)
23
+ (client as DecoratedClient)[action.name]?.(params) ??
24
+ (client as DecoratedClient)[name]?.(params) ??
25
+ action(client, params)
23
26
  }