viem 2.21.56 → 2.21.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/_cjs/account-abstraction/errors/bundler.js +8 -1
  3. package/_cjs/account-abstraction/errors/bundler.js.map +1 -1
  4. package/_cjs/account-abstraction/utils/errors/getBundlerError.js +1 -0
  5. package/_cjs/account-abstraction/utils/errors/getBundlerError.js.map +1 -1
  6. package/_cjs/chains/definitions/alephZero.js +28 -0
  7. package/_cjs/chains/definitions/alephZero.js.map +1 -0
  8. package/_cjs/chains/definitions/neoxMainnet.js +25 -0
  9. package/_cjs/chains/definitions/neoxMainnet.js.map +1 -0
  10. package/_cjs/chains/definitions/neoxT4.js +22 -0
  11. package/_cjs/chains/definitions/neoxT4.js.map +1 -0
  12. package/_cjs/chains/index.js +16 -10
  13. package/_cjs/chains/index.js.map +1 -1
  14. package/_cjs/errors/request.js +7 -0
  15. package/_cjs/errors/request.js.map +1 -1
  16. package/_cjs/errors/version.js +1 -1
  17. package/_cjs/utils/errors/getContractError.js +7 -3
  18. package/_cjs/utils/errors/getContractError.js.map +1 -1
  19. package/_esm/account-abstraction/errors/bundler.js +8 -1
  20. package/_esm/account-abstraction/errors/bundler.js.map +1 -1
  21. package/_esm/account-abstraction/utils/errors/getBundlerError.js +1 -0
  22. package/_esm/account-abstraction/utils/errors/getBundlerError.js.map +1 -1
  23. package/_esm/chains/definitions/alephZero.js +25 -0
  24. package/_esm/chains/definitions/alephZero.js.map +1 -0
  25. package/_esm/chains/definitions/neoxMainnet.js +22 -0
  26. package/_esm/chains/definitions/neoxMainnet.js.map +1 -0
  27. package/_esm/chains/definitions/neoxT4.js +19 -0
  28. package/_esm/chains/definitions/neoxT4.js.map +1 -0
  29. package/_esm/chains/index.js +3 -0
  30. package/_esm/chains/index.js.map +1 -1
  31. package/_esm/errors/request.js +7 -0
  32. package/_esm/errors/request.js.map +1 -1
  33. package/_esm/errors/version.js +1 -1
  34. package/_esm/utils/errors/getContractError.js +7 -3
  35. package/_esm/utils/errors/getContractError.js.map +1 -1
  36. package/_types/account-abstraction/errors/bundler.d.ts +8 -2
  37. package/_types/account-abstraction/errors/bundler.d.ts.map +1 -1
  38. package/_types/account-abstraction/utils/errors/getBundlerError.d.ts.map +1 -1
  39. package/_types/chains/definitions/alephZero.d.ts +34 -0
  40. package/_types/chains/definitions/alephZero.d.ts.map +1 -0
  41. package/_types/chains/definitions/neoxMainnet.d.ts +37 -0
  42. package/_types/chains/definitions/neoxMainnet.d.ts.map +1 -0
  43. package/_types/chains/definitions/neoxT4.d.ts +37 -0
  44. package/_types/chains/definitions/neoxT4.d.ts.map +1 -0
  45. package/_types/chains/index.d.ts +3 -0
  46. package/_types/chains/index.d.ts.map +1 -1
  47. package/_types/errors/request.d.ts +2 -0
  48. package/_types/errors/request.d.ts.map +1 -1
  49. package/_types/errors/version.d.ts +1 -1
  50. package/_types/utils/errors/getContractError.d.ts.map +1 -1
  51. package/account-abstraction/errors/bundler.ts +10 -1
  52. package/account-abstraction/utils/errors/getBundlerError.ts +2 -1
  53. package/chains/definitions/alephZero.ts +25 -0
  54. package/chains/definitions/neoxMainnet.ts +22 -0
  55. package/chains/definitions/neoxT4.ts +19 -0
  56. package/chains/index.ts +3 -0
  57. package/errors/request.ts +3 -1
  58. package/errors/version.ts +1 -1
  59. package/package.json +1 -1
  60. package/utils/errors/getContractError.ts +10 -4
@@ -1,2 +1,2 @@
1
- export declare const version = "2.21.56";
1
+ export declare const version = "2.21.57";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getContractError.d.ts","sourceRoot":"","sources":["../../../utils/errors/getContractError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAI3C,OAAO,EAEL,KAAK,kCAAkC,EAEvC,KAAK,iCAAiC,EAEtC,KAAK,iCAAiC,EAEvC,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAItD,MAAM,MAAM,0BAA0B,CAAC,KAAK,GAAG,SAAS,IAAI,IAAI,CAC9D,kCAAkC,EAClC,OAAO,CACR,GAAG;IACF,KAAK,EACD,KAAK,GACL,iCAAiC,GACjC,iCAAiC,CAAA;CACtC,CAAA;AAED,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,SAAS,CAAC,MAAM,CAAC,EAC5D,GAAG,EAAE,GAAG,EACR,EACE,GAAG,EACH,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,MAAM,GACP,EAAE;IACD,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,GAAG,CAAA;IACT,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC7B,GACA,0BAA0B,CAkC5B"}
1
+ {"version":3,"file":"getContractError.d.ts","sourceRoot":"","sources":["../../../utils/errors/getContractError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAI3C,OAAO,EAEL,KAAK,kCAAkC,EAEvC,KAAK,iCAAiC,EAEtC,KAAK,iCAAiC,EAEvC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAItD,MAAM,MAAM,0BAA0B,CAAC,KAAK,GAAG,SAAS,IAAI,IAAI,CAC9D,kCAAkC,EAClC,OAAO,CACR,GAAG;IACF,KAAK,EACD,KAAK,GACL,iCAAiC,GACjC,iCAAiC,CAAA;CACtC,CAAA;AAED,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,SAAS,CAAC,MAAM,CAAC,EAC5D,GAAG,EAAE,GAAG,EACR,EACE,GAAG,EACH,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,MAAM,GACP,EAAE;IACD,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,GAAG,CAAA;IACT,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC7B,GACA,0BAA0B,CAuC5B"}
@@ -32,10 +32,17 @@ export class ExecutionRevertedError extends BaseError {
32
32
  static code = -32521
33
33
  static message = /execution reverted/
34
34
 
35
+ data?: { revertData?: Hex } | undefined
36
+
35
37
  constructor({
36
38
  cause,
39
+ data,
37
40
  message,
38
- }: { cause?: BaseError | undefined; message?: string | undefined } = {}) {
41
+ }: {
42
+ cause?: BaseError | undefined
43
+ data?: { revertData?: Hex } | undefined
44
+ message?: string | undefined
45
+ } = {}) {
39
46
  const reason = message
40
47
  ?.replace('execution reverted: ', '')
41
48
  ?.replace('execution reverted', '')
@@ -48,6 +55,8 @@ export class ExecutionRevertedError extends BaseError {
48
55
  name: 'ExecutionRevertedError',
49
56
  },
50
57
  )
58
+
59
+ this.data = data
51
60
  }
52
61
  }
53
62
 
@@ -253,12 +253,13 @@ export function getBundlerError(
253
253
 
254
254
  const error = err.walk((e) =>
255
255
  bundlerErrors.some((error) => error.code === (e as { code: number }).code),
256
- ) as BaseError & { code: number }
256
+ ) as BaseError & { code: number; data: any }
257
257
 
258
258
  if (error) {
259
259
  if (error.code === ExecutionRevertedError.code)
260
260
  return new ExecutionRevertedError({
261
261
  cause: err,
262
+ data: error.data,
262
263
  message: error.details,
263
264
  }) as any
264
265
  if (error.code === InvalidFieldsError.code)
@@ -0,0 +1,25 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const alephZero = /*#__PURE__*/ defineChain({
4
+ id: 41_455,
5
+ name: 'Aleph Zero',
6
+ nativeCurrency: { name: 'Aleph Zero', symbol: 'AZERO', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://rpc.alephzero.raas.gelato.cloud'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'Aleph Zero EVM Explorer',
15
+ url: 'https://evm-explorer.alephzero.org',
16
+ apiUrl: 'https://evm-explorer.alephzero.org/api',
17
+ },
18
+ },
19
+ contracts: {
20
+ multicall3: {
21
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
22
+ blockCreated: 4603377,
23
+ },
24
+ },
25
+ })
@@ -0,0 +1,22 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const neoxMainnet = /*#__PURE__*/ defineChain({
4
+ id: 47763,
5
+ name: 'Neo X Mainnet',
6
+ nativeCurrency: { name: 'Gas', symbol: 'GAS', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: [
10
+ 'https://mainnet-1.rpc.banelabs.org',
11
+ 'https://mainnet-2.rpc.banelabs.org',
12
+ ],
13
+ },
14
+ },
15
+ blockExplorers: {
16
+ default: {
17
+ name: 'Neo X - Explorer',
18
+ url: 'https://xexplorer.neo.org',
19
+ },
20
+ },
21
+ testnet: false,
22
+ })
@@ -0,0 +1,19 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const neoxT4 = /*#__PURE__*/ defineChain({
4
+ id: 12227332,
5
+ name: 'Neo X Testnet T4',
6
+ nativeCurrency: { name: 'Gas', symbol: 'GAS', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://testnet.rpc.banelabs.org/'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'neox-scan',
15
+ url: 'https://xt4scan.ngd.network',
16
+ },
17
+ },
18
+ testnet: true,
19
+ })
package/chains/index.ts CHANGED
@@ -7,6 +7,7 @@ export { acala } from './definitions/acala.js'
7
7
  export { acria } from './definitions/acria.js'
8
8
  export { adf } from './definitions/adf.js'
9
9
  export { aioz } from './definitions/aioz.js'
10
+ export { alephZero } from './definitions/alephZero.js'
10
11
  export { alienx } from './definitions/alienX.js'
11
12
  export { alienxHalTestnet } from './definitions/alienXHalTestnet.js'
12
13
  export { ancient8 } from './definitions/ancient8.js'
@@ -290,6 +291,8 @@ export { nahmii } from './definitions/nahmii.js'
290
291
  export { nautilus } from './definitions/nautilus.js'
291
292
  export { neonDevnet } from './definitions/neonDevnet.js'
292
293
  export { neonMainnet } from './definitions/neonMainnet.js'
294
+ export { neoxMainnet } from './definitions/neoxMainnet.js'
295
+ export { neoxT4 } from './definitions/neoxT4.js'
293
296
  export { nexi } from './definitions/nexi.js'
294
297
  export { nexilix } from './definitions/nexilix.js'
295
298
  export { oasisTestnet } from './definitions/oasisTestnet.js'
package/errors/request.ts CHANGED
@@ -76,6 +76,7 @@ export type RpcRequestErrorType = RpcRequestError & {
76
76
  }
77
77
  export class RpcRequestError extends BaseError {
78
78
  code: number
79
+ data?: unknown
79
80
 
80
81
  constructor({
81
82
  body,
@@ -83,7 +84,7 @@ export class RpcRequestError extends BaseError {
83
84
  url,
84
85
  }: {
85
86
  body: { [x: string]: unknown } | { [y: string]: unknown }[]
86
- error: { code: number; message: string }
87
+ error: { code: number; data?: unknown; message: string }
87
88
  url: string
88
89
  }) {
89
90
  super('RPC Request failed.', {
@@ -93,6 +94,7 @@ export class RpcRequestError extends BaseError {
93
94
  name: 'RpcRequestError',
94
95
  })
95
96
  this.code = error.code
97
+ this.data = error.data
96
98
  }
97
99
  }
98
100
 
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.21.56'
1
+ export const version = '2.21.57'
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.56",
4
+ "version": "2.21.57",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -11,6 +11,7 @@ import {
11
11
  type ContractFunctionZeroDataErrorType,
12
12
  RawContractError,
13
13
  } from '../../errors/contract.js'
14
+ import { RpcRequestError } from '../../errors/request.js'
14
15
  import { InternalRpcError } from '../../errors/rpc.js'
15
16
  import type { ErrorType } from '../../errors/utils.js'
16
17
 
@@ -44,26 +45,31 @@ export function getContractError<err extends ErrorType<string>>(
44
45
  sender?: Address | undefined
45
46
  },
46
47
  ): GetContractErrorReturnType {
47
- const { code, data, message, shortMessage } = (
48
+ const error = (
48
49
  err instanceof RawContractError
49
50
  ? err
50
51
  : err instanceof BaseError
51
52
  ? err.walk((err) => 'data' in (err as Error)) || err.walk()
52
53
  : {}
53
- ) as RawContractError
54
+ ) as BaseError
55
+ const { code, data, details, message, shortMessage } =
56
+ error as RawContractError
54
57
 
55
58
  const cause = (() => {
56
59
  if (err instanceof AbiDecodingZeroDataError)
57
60
  return new ContractFunctionZeroDataError({ functionName })
58
61
  if (
59
62
  [EXECUTION_REVERTED_ERROR_CODE, InternalRpcError.code].includes(code) &&
60
- (data || message || shortMessage)
63
+ (data || details || message || shortMessage)
61
64
  ) {
62
65
  return new ContractFunctionRevertedError({
63
66
  abi,
64
67
  data: typeof data === 'object' ? data.data : data,
65
68
  functionName,
66
- message: shortMessage ?? message,
69
+ message:
70
+ error instanceof RpcRequestError
71
+ ? details
72
+ : (shortMessage ?? message),
67
73
  })
68
74
  }
69
75
  return err