viem 2.21.33 → 2.21.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/_cjs/actions/public/waitForTransactionReceipt.js +94 -91
  3. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  4. package/_cjs/chains/definitions/worldchain.js +37 -1
  5. package/_cjs/chains/definitions/worldchain.js.map +1 -1
  6. package/_cjs/chains/definitions/worldchainSepolia.js +36 -1
  7. package/_cjs/chains/definitions/worldchainSepolia.js.map +1 -1
  8. package/_cjs/chains/definitions/xdc.js +5 -5
  9. package/_cjs/chains/definitions/xdc.js.map +1 -1
  10. package/_cjs/errors/version.js +1 -1
  11. package/_cjs/linea/actions/estimateGas.js +1 -4
  12. package/_cjs/linea/actions/estimateGas.js.map +1 -1
  13. package/_cjs/op-stack/chains.js +5 -1
  14. package/_cjs/op-stack/chains.js.map +1 -1
  15. package/_cjs/utils/promise/createBatchScheduler.js +8 -11
  16. package/_cjs/utils/promise/createBatchScheduler.js.map +1 -1
  17. package/_cjs/utils/promise/withResolvers.js +13 -0
  18. package/_cjs/utils/promise/withResolvers.js.map +1 -0
  19. package/_esm/actions/public/waitForTransactionReceipt.js +109 -106
  20. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  21. package/_esm/chains/definitions/worldchain.js +37 -1
  22. package/_esm/chains/definitions/worldchain.js.map +1 -1
  23. package/_esm/chains/definitions/worldchainSepolia.js +36 -1
  24. package/_esm/chains/definitions/worldchainSepolia.js.map +1 -1
  25. package/_esm/chains/definitions/xdc.js +5 -5
  26. package/_esm/chains/definitions/xdc.js.map +1 -1
  27. package/_esm/errors/version.js +1 -1
  28. package/_esm/linea/actions/estimateGas.js +1 -4
  29. package/_esm/linea/actions/estimateGas.js.map +1 -1
  30. package/_esm/op-stack/chains.js +2 -0
  31. package/_esm/op-stack/chains.js.map +1 -1
  32. package/_esm/utils/promise/createBatchScheduler.js +8 -11
  33. package/_esm/utils/promise/createBatchScheduler.js.map +1 -1
  34. package/_esm/utils/promise/withResolvers.js +11 -0
  35. package/_esm/utils/promise/withResolvers.js.map +1 -0
  36. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  37. package/_types/chains/definitions/worldchain.d.ts +52 -12
  38. package/_types/chains/definitions/worldchain.d.ts.map +1 -1
  39. package/_types/chains/definitions/worldchainSepolia.d.ts +51 -12
  40. package/_types/chains/definitions/worldchainSepolia.d.ts.map +1 -1
  41. package/_types/chains/definitions/xdc.d.ts +5 -5
  42. package/_types/errors/version.d.ts +1 -1
  43. package/_types/linea/actions/estimateGas.d.ts.map +1 -1
  44. package/_types/op-stack/chains.d.ts +2 -0
  45. package/_types/op-stack/chains.d.ts.map +1 -1
  46. package/_types/utils/promise/createBatchScheduler.d.ts.map +1 -1
  47. package/_types/utils/promise/withResolvers.d.ts +9 -0
  48. package/_types/utils/promise/withResolvers.d.ts.map +1 -0
  49. package/actions/public/waitForTransactionReceipt.ts +162 -156
  50. package/chains/definitions/worldchain.ts +38 -1
  51. package/chains/definitions/worldchainSepolia.ts +37 -1
  52. package/chains/definitions/xdc.ts +5 -5
  53. package/errors/version.ts +1 -1
  54. package/linea/actions/estimateGas.ts +1 -11
  55. package/op-stack/chains.ts +2 -0
  56. package/package.json +1 -1
  57. package/utils/promise/createBatchScheduler.ts +12 -16
  58. package/utils/promise/withResolvers.ts +19 -0
@@ -1,5 +1,8 @@
1
+ import { chainConfig } from '../../op-stack/chainConfig.js'
1
2
  import { defineChain } from '../../utils/chain/defineChain.js'
2
3
 
4
+ const sourceId = 1 // mainnet
5
+
3
6
  export const worldchain = /*#__PURE__*/ defineChain({
4
7
  id: 480,
5
8
  name: 'World Chain',
@@ -10,9 +13,43 @@ export const worldchain = /*#__PURE__*/ defineChain({
10
13
  },
11
14
  blockExplorers: {
12
15
  default: {
13
- name: 'World Chain Explorer',
16
+ name: 'Worldscan',
17
+ url: 'https://worldscan.org',
18
+ apiUrl: 'https://api.worldscan.org/api',
19
+ },
20
+ blockscout: {
21
+ name: 'Blockscout',
14
22
  url: 'https://worldchain-mainnet.explorer.alchemy.com',
23
+ apiUrl: 'https://worldchain-mainnet.explorer.alchemy.com/api',
24
+ },
25
+ },
26
+ contracts: {
27
+ ...chainConfig.contracts,
28
+ multicall3: {
29
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
30
+ blockCreated: 0,
31
+ },
32
+ disputeGameFactory: {
33
+ [sourceId]: {
34
+ address: '0x0E90dCAFBC242D2C861A20Bb20EC8E7182965a52',
35
+ },
36
+ },
37
+ l2OutputOracle: {
38
+ [sourceId]: {
39
+ address: '0x19A6d1E9034596196295CF148509796978343c5D',
40
+ },
41
+ },
42
+ portal: {
43
+ [sourceId]: {
44
+ address: '0xd5ec14a83B7d95BE1E2Ac12523e2dEE12Cbeea6C',
45
+ },
46
+ },
47
+ l1StandardBridge: {
48
+ [sourceId]: {
49
+ address: '0x470458C91978D2d929704489Ad730DC3E3001113',
50
+ },
15
51
  },
16
52
  },
17
53
  testnet: false,
54
+ sourceId,
18
55
  })
@@ -1,5 +1,8 @@
1
+ import { chainConfig } from '../../op-stack/chainConfig.js'
1
2
  import { defineChain } from '../../utils/chain/defineChain.js'
2
3
 
4
+ const sourceId = 11_155_111 // sepolia
5
+
3
6
  export const worldchainSepolia = /*#__PURE__*/ defineChain({
4
7
  id: 4801,
5
8
  name: 'World Chain Sepolia',
@@ -11,9 +14,42 @@ export const worldchainSepolia = /*#__PURE__*/ defineChain({
11
14
  },
12
15
  blockExplorers: {
13
16
  default: {
14
- name: 'World Chain Sepolia Explorer',
17
+ name: 'Worldscan Sepolia',
18
+ url: 'https://sepolia.worldscan.org',
19
+ },
20
+ blockscout: {
21
+ name: 'Blockscout',
15
22
  url: 'https://worldchain-sepolia.explorer.alchemy.com',
23
+ apiUrl: 'https://worldchain-sepolia.explorer.alchemy.com/api',
24
+ },
25
+ },
26
+ contracts: {
27
+ ...chainConfig.contracts,
28
+ multicall3: {
29
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
30
+ blockCreated: 0,
31
+ },
32
+ disputeGameFactory: {
33
+ [sourceId]: {
34
+ address: '0x8cF97Ee616C986a070F5020d973b456D0120C253',
35
+ },
36
+ },
37
+ l2OutputOracle: {
38
+ [sourceId]: {
39
+ address: '0xc8886f8BAb6Eaeb215aDB5f1c686BF699248300e',
40
+ },
41
+ },
42
+ portal: {
43
+ [sourceId]: {
44
+ address: '0xFf6EBa109271fe6d4237EeeD4bAb1dD9A77dD1A4',
45
+ },
46
+ },
47
+ l1StandardBridge: {
48
+ [sourceId]: {
49
+ address: '0xd7DF54b3989855eb66497301a4aAEc33Dbb3F8DE',
50
+ },
16
51
  },
17
52
  },
18
53
  testnet: true,
54
+ sourceId,
19
55
  })
@@ -9,18 +9,18 @@ export const xdc = /*#__PURE__*/ defineChain({
9
9
  symbol: 'XDC',
10
10
  },
11
11
  rpcUrls: {
12
- default: { http: ['https://rpc.xinfin.network'] },
12
+ default: { http: ['https://rpc.xdcrpc.com'] },
13
13
  },
14
14
  blockExplorers: {
15
15
  default: {
16
- name: 'Blocksscan',
17
- url: 'https://xdc.blocksscan.io',
16
+ name: 'XDCScan',
17
+ url: 'https://xdcscan.com',
18
18
  },
19
19
  },
20
20
  contracts: {
21
21
  multicall3: {
22
- address: '0xca11bde05977b3631167028862be2a173976ca11',
23
- blockCreated: 71542788,
22
+ address: '0x0B1795ccA8E4eC4df02346a082df54D437F8D9aF',
23
+ blockCreated: 75884020,
24
24
  },
25
25
  },
26
26
  })
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.21.33'
1
+ export const version = '2.21.34'
@@ -1,10 +1,6 @@
1
1
  import type { Account } from '../../accounts/types.js'
2
2
  import { parseAccount } from '../../accounts/utils/parseAccount.js'
3
3
  import type { EstimateGasParameters as EstimateGasParameters_base } from '../../actions/public/estimateGas.js'
4
- import {
5
- type PrepareTransactionRequestParameters,
6
- prepareTransactionRequest,
7
- } from '../../actions/wallet/prepareTransactionRequest.js'
8
4
  import type { Client } from '../../clients/createClient.js'
9
5
  import type { Transport } from '../../clients/transports/createTransport.js'
10
6
  import { AccountNotFoundError } from '../../errors/account.js'
@@ -82,13 +78,7 @@ export async function estimateGas<
82
78
  to,
83
79
  value,
84
80
  ...rest
85
- } =
86
- account?.type === 'local'
87
- ? ((await prepareTransactionRequest(
88
- client,
89
- args as PrepareTransactionRequestParameters,
90
- )) as EstimateGasParameters)
91
- : args
81
+ } = args
92
82
 
93
83
  const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined
94
84
  const block = blockNumberHex || blockTag
@@ -16,6 +16,8 @@ export { shape } from '../chains/definitions/shape.js'
16
16
  export { snax } from '../chains/definitions/snax.js'
17
17
  export { snaxTestnet } from '../chains/definitions/snaxTestnet.js'
18
18
  export { soneiumMinato } from '../chains/definitions/soneiumMinato.js'
19
+ export { worldchain } from '../chains/definitions/worldchain.js'
20
+ export { worldchainSepolia } from '../chains/definitions/worldchainSepolia.js'
19
21
  export { zora } from '../chains/definitions/zora.js'
20
22
  export { zoraSepolia } from '../chains/definitions/zoraSepolia.js'
21
23
  export { zoraTestnet } from '../chains/definitions/zoraTestnet.js'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.21.33",
4
+ "version": "2.21.34",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -1,17 +1,17 @@
1
1
  import type { ErrorType } from '../../errors/utils.js'
2
+ import { type PromiseWithResolvers, withResolvers } from './withResolvers.js'
2
3
 
3
4
  type Resolved<returnType extends readonly unknown[] = any> = [
4
5
  result: returnType[number],
5
6
  results: returnType,
6
7
  ]
7
8
 
8
- type PendingPromise<returnType extends readonly unknown[] = any> = {
9
- resolve?: ((data: Resolved<returnType>) => void) | undefined
10
- reject?: ((reason?: unknown) => void) | undefined
9
+ type SchedulerItem = {
10
+ args: unknown
11
+ resolve: PromiseWithResolvers<unknown>['resolve']
12
+ reject: PromiseWithResolvers<unknown>['reject']
11
13
  }
12
14
 
13
- type SchedulerItem = { args: unknown; pendingPromise: PendingPromise }
14
-
15
15
  type BatchResultsCompareFn<result = unknown> = (a: result, b: result) => number
16
16
 
17
17
  type CreateBatchSchedulerArguments<
@@ -65,14 +65,14 @@ export function createBatchScheduler<
65
65
  .then((data) => {
66
66
  if (sort && Array.isArray(data)) data.sort(sort)
67
67
  for (let i = 0; i < scheduler.length; i++) {
68
- const { pendingPromise } = scheduler[i]
69
- pendingPromise.resolve?.([data[i], data])
68
+ const { resolve } = scheduler[i]
69
+ resolve?.([data[i], data])
70
70
  }
71
71
  })
72
72
  .catch((err) => {
73
73
  for (let i = 0; i < scheduler.length; i++) {
74
- const { pendingPromise } = scheduler[i]
75
- pendingPromise.reject?.(err)
74
+ const { reject } = scheduler[i]
75
+ reject?.(err)
76
76
  }
77
77
  })
78
78
  }
@@ -90,11 +90,7 @@ export function createBatchScheduler<
90
90
  return {
91
91
  flush,
92
92
  async schedule(args: parameters) {
93
- const pendingPromise: PendingPromise<returnType> = {}
94
- const promise = new Promise<Resolved<returnType>>((resolve, reject) => {
95
- pendingPromise.resolve = resolve
96
- pendingPromise.reject = reject
97
- })
93
+ const { promise, resolve, reject } = withResolvers()
98
94
 
99
95
  const split = shouldSplitBatch?.([...getBatchedArgs(), args])
100
96
 
@@ -102,11 +98,11 @@ export function createBatchScheduler<
102
98
 
103
99
  const hasActiveScheduler = getScheduler().length > 0
104
100
  if (hasActiveScheduler) {
105
- setScheduler({ args, pendingPromise })
101
+ setScheduler({ args, resolve, reject })
106
102
  return promise
107
103
  }
108
104
 
109
- setScheduler({ args, pendingPromise })
105
+ setScheduler({ args, resolve, reject })
110
106
  setTimeout(exec, wait)
111
107
  return promise
112
108
  },
@@ -0,0 +1,19 @@
1
+ /** @internal */
2
+ export type PromiseWithResolvers<type> = {
3
+ promise: Promise<type>
4
+ resolve: (value: type | PromiseLike<type>) => void
5
+ reject: (reason?: unknown) => void
6
+ }
7
+
8
+ /** @internal */
9
+ export function withResolvers<type>(): PromiseWithResolvers<type> {
10
+ let resolve: PromiseWithResolvers<type>['resolve'] = () => undefined
11
+ let reject: PromiseWithResolvers<type>['reject'] = () => undefined
12
+
13
+ const promise = new Promise<type>((resolve_, reject_) => {
14
+ resolve = resolve_
15
+ reject = reject_
16
+ })
17
+
18
+ return { promise, resolve, reject }
19
+ }