viem 1.9.2 → 1.9.5
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/README.md +6 -0
- package/chains/dist/cjs/celo/formatters.js +57 -0
- package/chains/dist/cjs/celo/formatters.js.map +1 -0
- package/chains/dist/cjs/celo/parsers.js +72 -0
- package/chains/dist/cjs/celo/parsers.js.map +1 -0
- package/chains/dist/cjs/celo/serializers.js +75 -0
- package/chains/dist/cjs/celo/serializers.js.map +1 -0
- package/chains/dist/cjs/celo/types.js +3 -0
- package/chains/dist/cjs/celo/types.js.map +1 -0
- package/chains/dist/cjs/index.js +135 -0
- package/chains/dist/cjs/index.js.map +1 -0
- package/chains/dist/cjs/optimism/fees.js +7 -0
- package/chains/dist/cjs/optimism/fees.js.map +1 -0
- package/chains/dist/cjs/optimism/formatters.js +51 -0
- package/chains/dist/cjs/optimism/formatters.js.map +1 -0
- package/chains/dist/cjs/optimism/types.js +3 -0
- package/chains/dist/cjs/optimism/types.js.map +1 -0
- package/chains/dist/cjs/types.js +3 -0
- package/chains/dist/cjs/types.js.map +1 -0
- package/chains/dist/cjs/utils.js +23 -0
- package/chains/dist/cjs/utils.js.map +1 -0
- package/chains/dist/tsconfig.build.tsbuildinfo +1 -0
- package/chains/tsconfig.tsbuildinfo +1 -0
- package/dist/cjs/actions/public/call.js +1 -1
- package/dist/cjs/actions/public/call.js.map +1 -1
- package/dist/cjs/actions/public/multicall.js +54 -31
- package/dist/cjs/actions/public/multicall.js.map +1 -1
- package/dist/cjs/chains/definitions/sepolia.js +5 -0
- package/dist/cjs/chains/definitions/sepolia.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/utils/formatters/transaction.js +5 -5
- package/dist/cjs/utils/formatters/transaction.js.map +1 -1
- package/dist/cjs/utils/hash/getFunctionSelector.js.map +1 -1
- package/dist/cjs/utils/hash/hashFunction.js.map +1 -1
- package/dist/cjs/utils/signature/hexToSignature.js +1 -1
- package/dist/cjs/utils/signature/hexToSignature.js.map +1 -1
- package/dist/esm/actions/public/call.js +1 -1
- package/dist/esm/actions/public/call.js.map +1 -1
- package/dist/esm/actions/public/multicall.js +66 -31
- package/dist/esm/actions/public/multicall.js.map +1 -1
- package/dist/esm/chains/definitions/sepolia.js +5 -0
- package/dist/esm/chains/definitions/sepolia.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/utils/formatters/transaction.js +5 -5
- package/dist/esm/utils/formatters/transaction.js.map +1 -1
- package/dist/esm/utils/hash/getFunctionSelector.js.map +1 -1
- package/dist/esm/utils/hash/hashFunction.js.map +1 -1
- package/dist/esm/utils/signature/hexToSignature.js +1 -1
- package/dist/esm/utils/signature/hexToSignature.js.map +1 -1
- package/dist/types/actions/public/multicall.d.ts.map +1 -1
- package/dist/types/chains/definitions/sepolia.d.ts +7 -0
- package/dist/types/chains/definitions/sepolia.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/utils/hash/getEventSelector.d.ts +1 -1
- package/dist/types/utils/hash/getEventSelector.d.ts.map +1 -1
- package/dist/types/utils/hash/getFunctionSelector.d.ts.map +1 -1
- package/dist/types/utils/hash/hashFunction.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actions/public/call.ts +1 -1
- package/src/actions/public/multicall.ts +70 -31
- package/src/chains/definitions/sepolia.ts +5 -0
- package/src/errors/version.ts +1 -1
- package/src/utils/formatters/transaction.ts +5 -5
- package/src/utils/hash/getEventSelector.ts +1 -1
- package/src/utils/hash/getFunctionSelector.ts +1 -1
- package/src/utils/hash/hashFunction.ts +1 -1
- package/src/utils/signature/hexToSignature.ts +1 -1
@@ -4,7 +4,7 @@ import type { Client } from '../../clients/createClient.js'
|
|
4
4
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
5
5
|
import { multicall3Abi } from '../../constants/abis.js'
|
6
6
|
import { AbiDecodingZeroDataError } from '../../errors/abi.js'
|
7
|
-
import
|
7
|
+
import { BaseError } from '../../errors/base.js'
|
8
8
|
import { RawContractError } from '../../errors/contract.js'
|
9
9
|
import type { Chain } from '../../types/chain.js'
|
10
10
|
import type { ContractFunctionConfig } from '../../types/contract.js'
|
@@ -136,8 +136,16 @@ export async function multicall<
|
|
136
136
|
functionName,
|
137
137
|
} as unknown as EncodeFunctionDataParameters)
|
138
138
|
|
139
|
-
currentChunkSize += callData.length
|
140
|
-
if
|
139
|
+
currentChunkSize += (callData.length - 2) / 2
|
140
|
+
// Check to see if we need to create a new chunk.
|
141
|
+
if (
|
142
|
+
// Check if batching is enabled.
|
143
|
+
batchSize > 0 &&
|
144
|
+
// Check if the current size of the batch exceeds the size limit.
|
145
|
+
currentChunkSize > batchSize &&
|
146
|
+
// Check if the current chunk is not already empty.
|
147
|
+
chunkedCalls[currentChunk].length > 0
|
148
|
+
) {
|
141
149
|
currentChunk++
|
142
150
|
currentChunkSize = (callData.length - 2) / 2
|
143
151
|
chunkedCalls[currentChunk] = []
|
@@ -171,7 +179,7 @@ export async function multicall<
|
|
171
179
|
}
|
172
180
|
}
|
173
181
|
|
174
|
-
const
|
182
|
+
const aggregate3Results = await Promise.allSettled(
|
175
183
|
chunkedCalls.map((calls) =>
|
176
184
|
readContract(client, {
|
177
185
|
abi: multicall3Abi,
|
@@ -184,33 +192,64 @@ export async function multicall<
|
|
184
192
|
),
|
185
193
|
)
|
186
194
|
|
187
|
-
const
|
195
|
+
const results = []
|
196
|
+
for (let i = 0; i < aggregate3Results.length; i++) {
|
197
|
+
const result = aggregate3Results[i]
|
188
198
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
199
|
+
// If an error occurred in a `readContract` invocation (ie. network error),
|
200
|
+
// then append the failure reason to each contract result.
|
201
|
+
if (result.status === 'rejected') {
|
202
|
+
if (!allowFailure) throw result.reason
|
203
|
+
for (let j = 0; j < chunkedCalls[i].length; j++) {
|
204
|
+
results.push({
|
205
|
+
status: 'failure',
|
206
|
+
error: result.reason,
|
207
|
+
result: undefined,
|
208
|
+
})
|
209
|
+
}
|
210
|
+
continue
|
211
|
+
}
|
212
|
+
|
213
|
+
// If the `readContract` call was successful, then decode the results.
|
214
|
+
const aggregate3Result = result.value
|
215
|
+
for (let j = 0; j < aggregate3Result.length; j++) {
|
216
|
+
// Extract the response from `readContract`
|
217
|
+
const { returnData, success } = aggregate3Result[j]
|
218
|
+
|
219
|
+
// Extract the request call data from the original call.
|
220
|
+
const { callData } = chunkedCalls[i][j]
|
221
|
+
|
222
|
+
// Extract the contract config for this call from the `contracts` argument
|
223
|
+
// for decoding.
|
224
|
+
const { abi, address, functionName, args } = contracts[
|
225
|
+
results.length
|
226
|
+
] as ContractFunctionConfig
|
227
|
+
|
228
|
+
try {
|
229
|
+
if (callData === '0x') throw new AbiDecodingZeroDataError()
|
230
|
+
if (!success) throw new RawContractError({ data: returnData })
|
231
|
+
const result = decodeFunctionResult({
|
232
|
+
abi,
|
233
|
+
args,
|
234
|
+
data: returnData,
|
235
|
+
functionName,
|
236
|
+
})
|
237
|
+
results.push(allowFailure ? { result, status: 'success' } : result)
|
238
|
+
} catch (err) {
|
239
|
+
const error = getContractError(err as BaseError, {
|
240
|
+
abi,
|
241
|
+
address,
|
242
|
+
args,
|
243
|
+
docsPath: '/docs/contract/multicall',
|
244
|
+
functionName,
|
245
|
+
})
|
246
|
+
if (!allowFailure) throw error
|
247
|
+
results.push({ error, result: undefined, status: 'failure' })
|
248
|
+
}
|
214
249
|
}
|
215
|
-
}
|
250
|
+
}
|
251
|
+
|
252
|
+
if (results.length !== contracts.length)
|
253
|
+
throw new BaseError('multicall results mismatch')
|
254
|
+
return results as MulticallResults<TContracts, TAllowFailure>
|
216
255
|
}
|
@@ -36,6 +36,11 @@ export const sepolia = /*#__PURE__*/ defineChain({
|
|
36
36
|
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
37
37
|
blockCreated: 6507670,
|
38
38
|
},
|
39
|
+
ensRegistry: { address: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e' },
|
40
|
+
ensUniversalResolver: {
|
41
|
+
address: '0x21B000Fd62a880b2125A61e36a284BB757b76025',
|
42
|
+
blockCreated: 3914906,
|
43
|
+
},
|
39
44
|
},
|
40
45
|
testnet: true,
|
41
46
|
})
|
package/src/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '1.9.
|
1
|
+
export const version = '1.9.5'
|
@@ -68,13 +68,13 @@ export function formatTransaction(transaction: Partial<RpcTransaction>) {
|
|
68
68
|
}
|
69
69
|
|
70
70
|
if (transaction_.type === 'legacy') {
|
71
|
-
delete transaction_
|
72
|
-
delete transaction_
|
73
|
-
delete transaction_
|
71
|
+
delete transaction_.accessList
|
72
|
+
delete transaction_.maxFeePerGas
|
73
|
+
delete transaction_.maxPriorityFeePerGas
|
74
74
|
}
|
75
75
|
if (transaction_.type === 'eip2930') {
|
76
|
-
delete transaction_
|
77
|
-
delete transaction_
|
76
|
+
delete transaction_.maxFeePerGas
|
77
|
+
delete transaction_.maxPriorityFeePerGas
|
78
78
|
}
|
79
79
|
return transaction_ as Transaction
|
80
80
|
}
|
@@ -1,10 +1,10 @@
|
|
1
|
+
import type { AbiEvent, AbiFunction } from 'abitype'
|
1
2
|
import { formatAbiItem } from '../abi/formatAbiItem.js'
|
2
3
|
import {
|
3
4
|
extractFunctionName,
|
4
5
|
extractFunctionParams,
|
5
6
|
} from '../contract/extractFunctionParts.js'
|
6
7
|
import { toBytes } from '../encoding/toBytes.js'
|
7
|
-
import type { AbiEvent, AbiFunction } from 'abitype'
|
8
8
|
|
9
9
|
import { keccak256 } from './keccak256.js'
|
10
10
|
|
@@ -16,5 +16,5 @@ import { numberToHex } from '../../utils/encoding/toHex.js'
|
|
16
16
|
export function hexToSignature(signatureHex: Hex): Signature {
|
17
17
|
const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130))
|
18
18
|
const v = BigInt(`0x${signatureHex.slice(130)}`)
|
19
|
-
return { r: numberToHex(r), s: numberToHex(s), v }
|
19
|
+
return { r: numberToHex(r, { size: 32 }), s: numberToHex(s, { size: 32 }), v }
|
20
20
|
}
|