viem 2.0.0-alpha.7 → 2.0.0-alpha.8
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/_cjs/actions/public/multicall.js.map +1 -1
- package/_cjs/chains/definitions/kroma.js +26 -0
- package/_cjs/chains/definitions/kroma.js.map +1 -0
- package/_cjs/chains/definitions/kromaSepolia.js +26 -0
- package/_cjs/chains/definitions/kromaSepolia.js.map +1 -0
- package/_cjs/chains/index.js +6 -2
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/node.js +11 -11
- package/_cjs/errors/node.js.map +1 -1
- package/_cjs/errors/rpc.js +18 -18
- package/_cjs/errors/rpc.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_esm/actions/public/multicall.js.map +1 -1
- package/_esm/chains/definitions/kroma.js +23 -0
- package/_esm/chains/definitions/kroma.js.map +1 -0
- package/_esm/chains/definitions/kromaSepolia.js +23 -0
- package/_esm/chains/definitions/kromaSepolia.js.map +1 -0
- package/_esm/chains/index.js +2 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/node.js +22 -11
- package/_esm/errors/node.js.map +1 -1
- package/_esm/errors/rpc.js +36 -18
- package/_esm/errors/rpc.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_types/chains/definitions/kroma.d.ts +29 -0
- package/_types/chains/definitions/kroma.d.ts.map +1 -0
- package/_types/chains/definitions/kromaSepolia.d.ts +29 -0
- package/_types/chains/definitions/kromaSepolia.d.ts.map +1 -0
- package/_types/chains/index.d.ts +2 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/types/multicall.d.ts +9 -3
- package/_types/types/multicall.d.ts.map +1 -1
- package/actions/public/multicall.ts +1 -1
- package/chains/definitions/kroma.ts +23 -0
- package/chains/definitions/kromaSepolia.ts +23 -0
- package/chains/index.ts +2 -0
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/types/multicall.ts +39 -7
@@ -22,9 +22,15 @@ export type MulticallResults<contracts extends readonly unknown[] = readonly Con
|
|
22
22
|
} = {
|
23
23
|
error: Error;
|
24
24
|
mutability: AbiStateMutability;
|
25
|
-
}> =
|
26
|
-
|
27
|
-
|
25
|
+
}, result extends any[] = []> = contracts extends 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 ? unknown[] : contracts extends readonly (infer contract extends ContractFunctionParameters)[] ? MulticallResponse<GetMulticallContractReturnType<contract, options['mutability']>, options['error'], allowFailure>[] : unknown[];
|
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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AAS;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
|
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.
|
1
|
+
export const version = '2.0.0-alpha.8'
|
package/package.json
CHANGED
package/types/multicall.ts
CHANGED
@@ -80,13 +80,45 @@ export type MulticallResults<
|
|
80
80
|
error?: Error
|
81
81
|
mutability: AbiStateMutability
|
82
82
|
} = { error: Error; mutability: AbiStateMutability },
|
83
|
-
|
84
|
-
[
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
///
|
84
|
+
result extends any[] = [],
|
85
|
+
> = contracts extends readonly [] // no contracts, return empty
|
86
|
+
? []
|
87
|
+
: contracts extends readonly [infer contract] // one contract left before returning `result`
|
88
|
+
? [
|
89
|
+
...result,
|
90
|
+
MulticallResponse<
|
91
|
+
GetMulticallContractReturnType<contract, options['mutability']>,
|
92
|
+
options['error'],
|
93
|
+
allowFailure
|
94
|
+
>,
|
95
|
+
]
|
96
|
+
: contracts extends readonly [infer contract, ...infer rest] // grab first contract and recurse through `rest`
|
97
|
+
? MulticallResults<
|
98
|
+
[...rest],
|
99
|
+
allowFailure,
|
100
|
+
options,
|
101
|
+
[
|
102
|
+
...result,
|
103
|
+
MulticallResponse<
|
104
|
+
GetMulticallContractReturnType<contract, options['mutability']>,
|
105
|
+
options['error'],
|
106
|
+
allowFailure
|
107
|
+
>,
|
108
|
+
]
|
109
|
+
>
|
110
|
+
: readonly unknown[] extends contracts
|
111
|
+
? unknown[]
|
112
|
+
: // If `contracts` is *some* array but we couldn't assign `unknown[]` to it, then it must hold some known/homogenous type!
|
113
|
+
// use this to infer the param types in the case of Array.map() argument
|
114
|
+
contracts extends readonly (infer contract extends ContractFunctionParameters)[]
|
115
|
+
? MulticallResponse<
|
116
|
+
GetMulticallContractReturnType<contract, options['mutability']>,
|
117
|
+
options['error'],
|
118
|
+
allowFailure
|
119
|
+
>[]
|
120
|
+
: // Fallback
|
121
|
+
unknown[]
|
90
122
|
|
91
123
|
export type MulticallResponse<
|
92
124
|
result = unknown,
|