viem 2.0.0-alpha.7 → 2.0.0-alpha.9

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 (40) hide show
  1. package/_cjs/actions/public/multicall.js.map +1 -1
  2. package/_cjs/chains/definitions/kroma.js +26 -0
  3. package/_cjs/chains/definitions/kroma.js.map +1 -0
  4. package/_cjs/chains/definitions/kromaSepolia.js +26 -0
  5. package/_cjs/chains/definitions/kromaSepolia.js.map +1 -0
  6. package/_cjs/chains/index.js +6 -2
  7. package/_cjs/chains/index.js.map +1 -1
  8. package/_cjs/errors/node.js +11 -11
  9. package/_cjs/errors/node.js.map +1 -1
  10. package/_cjs/errors/rpc.js +18 -18
  11. package/_cjs/errors/rpc.js.map +1 -1
  12. package/_cjs/errors/version.js +1 -1
  13. package/_esm/actions/public/multicall.js.map +1 -1
  14. package/_esm/chains/definitions/kroma.js +23 -0
  15. package/_esm/chains/definitions/kroma.js.map +1 -0
  16. package/_esm/chains/definitions/kromaSepolia.js +23 -0
  17. package/_esm/chains/definitions/kromaSepolia.js.map +1 -0
  18. package/_esm/chains/index.js +2 -0
  19. package/_esm/chains/index.js.map +1 -1
  20. package/_esm/errors/node.js +22 -11
  21. package/_esm/errors/node.js.map +1 -1
  22. package/_esm/errors/rpc.js +36 -18
  23. package/_esm/errors/rpc.js.map +1 -1
  24. package/_esm/errors/version.js +1 -1
  25. package/_types/chains/definitions/kroma.d.ts +29 -0
  26. package/_types/chains/definitions/kroma.d.ts.map +1 -0
  27. package/_types/chains/definitions/kromaSepolia.d.ts +29 -0
  28. package/_types/chains/definitions/kromaSepolia.d.ts.map +1 -0
  29. package/_types/chains/index.d.ts +2 -0
  30. package/_types/chains/index.d.ts.map +1 -1
  31. package/_types/errors/version.d.ts +1 -1
  32. package/_types/types/multicall.d.ts +10 -4
  33. package/_types/types/multicall.d.ts.map +1 -1
  34. package/actions/public/multicall.ts +1 -1
  35. package/chains/definitions/kroma.ts +23 -0
  36. package/chains/definitions/kromaSepolia.ts +23 -0
  37. package/chains/index.ts +2 -0
  38. package/errors/version.ts +1 -1
  39. package/package.json +1 -1
  40. package/types/multicall.ts +41 -22
@@ -15,16 +15,22 @@ export type MulticallContracts<contracts extends readonly unknown[], options ext
15
15
  ], options, [
16
16
  ...result,
17
17
  MaybePartial<Prettify<GetMulticallContractParameters<contract, options['mutability']> & options['properties']>, options['optional']>
18
- ]> : readonly unknown[] extends contracts ? contracts : contracts extends readonly ContractFunctionParameters<infer abi, infer _, infer functionName, infer args>[] ? readonly MaybePartial<Prettify<ContractFunctionParameters<abi, options['mutability'], functionName, args> & options['properties']>, options['optional']>[] : readonly MaybePartial<Prettify<ContractFunctionParameters & options['properties']>, options['optional']>[];
18
+ ]> : readonly unknown[] extends contracts ? contracts : contracts extends readonly (infer contract extends ContractFunctionParameters)[] ? readonly MaybePartial<Prettify<contract & options['properties']>, options['optional']>[] : readonly MaybePartial<Prettify<ContractFunctionParameters & options['properties']>, options['optional']>[];
19
19
  export type MulticallResults<contracts extends readonly unknown[] = readonly ContractFunctionParameters[], allowFailure extends boolean = true, options extends {
20
20
  error?: Error;
21
21
  mutability: AbiStateMutability;
22
22
  } = {
23
23
  error: Error;
24
24
  mutability: AbiStateMutability;
25
- }> = {
26
- [index in keyof contracts]: MulticallResponse<GetMulticallContractReturnType<contracts[index], options['mutability']>, options['error'], allowFailure>;
27
- };
25
+ }, result extends any[] = []> = contracts extends readonly [] ? readonly [] : contracts extends readonly [infer contract] ? [
26
+ ...result,
27
+ MulticallResponse<GetMulticallContractReturnType<contract, options['mutability']>, options['error'], allowFailure>
28
+ ] : contracts extends readonly [infer contract, ...infer rest] ? MulticallResults<[
29
+ ...rest
30
+ ], allowFailure, options, [
31
+ ...result,
32
+ MulticallResponse<GetMulticallContractReturnType<contract, options['mutability']>, options['error'], allowFailure>
33
+ ]> : readonly unknown[] extends contracts ? MulticallResponse<unknown, options['error'], allowFailure>[] : contracts extends readonly (infer contract extends ContractFunctionParameters)[] ? MulticallResponse<GetMulticallContractReturnType<contract, options['mutability']>, options['error'], allowFailure>[] : MulticallResponse<unknown, options['error'], allowFailure>[];
28
34
  export type MulticallResponse<result = unknown, error = unknown, allowFailure extends boolean = true> = allowFailure extends true ? {
29
35
  error?: undefined;
30
36
  result: result;
@@ -1 +1 @@
1
- {"version":3,"file":"multicall.d.ts","sourceRoot":"","sources":["../../types/multicall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAExD,MAAM,MAAM,kBAAkB,CAC5B,SAAS,SAAS,SAAS,OAAO,EAAE,EACpC,OAAO,SAAS;IACd,UAAU,EAAE,kBAAkB,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACjC,GAAG;IAAE,UAAU,EAAE,kBAAkB,CAAA;CAAE,EAEtC,MAAM,SAAS,SAAS,GAAG,EAAE,GAAG,EAAE,IAChC,SAAS,SAAS,SAAS,EAAE,GAC7B,SAAS,EAAE,GACX,SAAS,SAAS,SAAS,CAAC,MAAM,QAAQ,CAAC,GAC3C,SAAS;IACP,GAAG,MAAM;IACT,YAAY,CACV,QAAQ,CACN,8BAA8B,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,GAC7D,OAAO,CAAC,YAAY,CAAC,CACxB,EACD,OAAO,CAAC,UAAU,CAAC,CACpB;CACF,GACD,SAAS,SAAS,SAAS,CAAC,MAAM,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,GAC1D,kBAAkB,CAChB;IAAC,GAAG,IAAI;CA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C,QAAQ,SAAS;IACf,YAAY,EAAE,MAAM,YAAY,SAAS,oBAAoB,CAC3D,GAAG,EACH,UAAU,CACX,CAAA;CACF,GAEC,QAAQ,SAAS;IACf,IAAI,EAAE,MAAM,IAAI,SAAS,oBAAoB,CAC3C,GAAG,EACH,UAAU,EACV,YAAY,CACb,CAAA;CACF,GACC,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,GAC/D,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,GAE7D,GAAG,SAAS,GAAG,GACb,0BAA0B,GAE1B,0BAA0B,CAAC,GAAG,EAAE,UAAU,CAAC,GAC7C,0BAA0B,CAAC,SAAS,OAAO,EAAE,CAAC,CAAA;AAElD,KAAK,8BAA8B,CACjC,QAAQ,EACR,UAAU,SAAS,kBAAkB,IACnC,QAAQ,SAAS;IAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,CAAA;CAAE,GAE/C,QAAQ,SAAS;IACf,YAAY,EAAE,MAAM,YAAY,SAAS,oBAAoB,CAC3D,GAAG,EACH,UAAU,CACX,CAAA;CACF,GAEC,QAAQ,SAAS;IACf,IAAI,EAAE,MAAM,IAAI,SAAS,oBAAoB,CAC3C,GAAG,EACH,UAAU,EACV,YAAY,CACb,CAAA;CACF,GACC,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,GAC/D,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,GAC3D,0BAA0B,CAAC,GAAG,EAAE,UAAU,CAAC,GAC7C,0BAA0B,CAAA"}
@@ -254,5 +254,5 @@ export async function multicall<
254
254
 
255
255
  if (results.length !== contracts.length)
256
256
  throw new BaseError('multicall results mismatch')
257
- return results as MulticallResults<contracts, allowFailure>
257
+ return results as MulticallReturnType<contracts, allowFailure>
258
258
  }
@@ -0,0 +1,23 @@
1
+ import { defineChain } from '../../utils/chain.js'
2
+
3
+ export const kroma = /*#__PURE__*/ defineChain({
4
+ id: 255,
5
+ network: 'kroma',
6
+ name: 'Kroma',
7
+ nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 },
8
+ rpcUrls: {
9
+ default: {
10
+ http: ['https://api.kroma.network'],
11
+ },
12
+ public: {
13
+ http: ['https://api.kroma.network'],
14
+ },
15
+ },
16
+ blockExplorers: {
17
+ default: {
18
+ name: 'Kroma Explorer',
19
+ url: 'https://blockscout.kroma.network',
20
+ },
21
+ },
22
+ testnet: false,
23
+ })
@@ -0,0 +1,23 @@
1
+ import { defineChain } from '../../utils/chain.js'
2
+
3
+ export const kromaSepolia = /*#__PURE__*/ defineChain({
4
+ id: 2358,
5
+ network: 'kroma-sepolia',
6
+ name: 'Kroma Sepolia',
7
+ nativeCurrency: { name: 'Sepolia Ether', symbol: 'ETH', decimals: 18 },
8
+ rpcUrls: {
9
+ default: {
10
+ http: ['https://api.sepolia.kroma.network'],
11
+ },
12
+ public: {
13
+ http: ['https://api.sepolia.kroma.network'],
14
+ },
15
+ },
16
+ blockExplorers: {
17
+ default: {
18
+ name: 'Kroma Sepolia Explorer',
19
+ url: 'https://blockscout.sepolia.kroma.network',
20
+ },
21
+ },
22
+ testnet: true,
23
+ })
package/chains/index.ts CHANGED
@@ -63,6 +63,8 @@ export { haqqMainnet } from './definitions/haqqMainnet.js'
63
63
  export { haqqTestedge2 } from './definitions/haqqTestedge2.js'
64
64
  export { holesky } from './definitions/holesky.js'
65
65
  export { klaytn } from './definitions/klaytn.js'
66
+ export { kroma } from './definitions/kroma.js'
67
+ export { kromaSepolia } from './definitions/kromaSepolia.js'
66
68
  export { linea } from './definitions/linea.js'
67
69
  export { lineaTestnet } from './definitions/lineaTestnet.js'
68
70
  export { localhost } from './definitions/localhost.js'
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.0.0-alpha.7'
1
+ export const version = '2.0.0-alpha.9'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.0.0-alpha.7",
4
+ "version": "2.0.0-alpha.9",
5
5
  "type": "module",
6
6
  "main": "./_cjs/index.js",
7
7
  "module": "./_esm/index.js",
@@ -49,22 +49,9 @@ export type MulticallContracts<
49
49
  ? contracts
50
50
  : // If `contracts` is *some* array but we couldn't assign `unknown[]` to it, then it must hold some known/homogenous type!
51
51
  // use this to infer the param types in the case of Array.map() argument
52
- contracts extends readonly ContractFunctionParameters<
53
- infer abi,
54
- infer _,
55
- infer functionName,
56
- infer args
57
- >[]
52
+ contracts extends readonly (infer contract extends ContractFunctionParameters)[]
58
53
  ? readonly MaybePartial<
59
- Prettify<
60
- ContractFunctionParameters<
61
- abi,
62
- options['mutability'],
63
- functionName,
64
- args
65
- > &
66
- options['properties']
67
- >,
54
+ Prettify<contract & options['properties']>,
68
55
  options['optional']
69
56
  >[]
70
57
  : // Fallback
@@ -80,13 +67,45 @@ export type MulticallResults<
80
67
  error?: Error
81
68
  mutability: AbiStateMutability
82
69
  } = { error: Error; mutability: AbiStateMutability },
83
- > = {
84
- [index in keyof contracts]: MulticallResponse<
85
- GetMulticallContractReturnType<contracts[index], options['mutability']>,
86
- options['error'],
87
- allowFailure
88
- >
89
- }
70
+ ///
71
+ result extends any[] = [],
72
+ > = contracts extends readonly [] // no contracts, return empty
73
+ ? readonly []
74
+ : contracts extends readonly [infer contract] // one contract left before returning `result`
75
+ ? [
76
+ ...result,
77
+ MulticallResponse<
78
+ GetMulticallContractReturnType<contract, options['mutability']>,
79
+ options['error'],
80
+ allowFailure
81
+ >,
82
+ ]
83
+ : contracts extends readonly [infer contract, ...infer rest] // grab first contract and recurse through `rest`
84
+ ? MulticallResults<
85
+ [...rest],
86
+ allowFailure,
87
+ options,
88
+ [
89
+ ...result,
90
+ MulticallResponse<
91
+ GetMulticallContractReturnType<contract, options['mutability']>,
92
+ options['error'],
93
+ allowFailure
94
+ >,
95
+ ]
96
+ >
97
+ : readonly unknown[] extends contracts
98
+ ? MulticallResponse<unknown, options['error'], allowFailure>[]
99
+ : // If `contracts` is *some* array but we couldn't assign `unknown[]` to it, then it must hold some known/homogenous type!
100
+ // use this to infer the param types in the case of Array.map() argument
101
+ contracts extends readonly (infer contract extends ContractFunctionParameters)[]
102
+ ? MulticallResponse<
103
+ GetMulticallContractReturnType<contract, options['mutability']>,
104
+ options['error'],
105
+ allowFailure
106
+ >[]
107
+ : // Fallback
108
+ MulticallResponse<unknown, options['error'], allowFailure>[]
90
109
 
91
110
  export type MulticallResponse<
92
111
  result = unknown,