viem 2.0.3 → 2.0.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/CHANGELOG.md +20 -0
- package/_cjs/actions/wallet/writeContract.js.map +1 -1
- package/_cjs/chains/definitions/taikoJolnir.js +7 -0
- package/_cjs/chains/definitions/taikoJolnir.js.map +1 -1
- package/_cjs/chains/definitions/taikoKatla.js +25 -0
- package/_cjs/chains/definitions/taikoKatla.js.map +1 -0
- package/_cjs/chains/index.js +3 -1
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/transports/http.js +1 -1
- package/_cjs/clients/transports/http.js.map +1 -1
- package/_cjs/errors/abi.js +13 -1
- package/_cjs/errors/abi.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +5 -3
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/abi/decodeAbiParameters.js +2 -0
- package/_cjs/utils/abi/decodeAbiParameters.js.map +1 -1
- package/_esm/actions/wallet/writeContract.js.map +1 -1
- package/_esm/chains/definitions/taikoJolnir.js +7 -0
- package/_esm/chains/definitions/taikoJolnir.js.map +1 -1
- package/_esm/chains/definitions/taikoKatla.js +22 -0
- package/_esm/chains/definitions/taikoKatla.js.map +1 -0
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/transports/http.js +1 -1
- package/_esm/clients/transports/http.js.map +1 -1
- package/_esm/errors/abi.js +11 -0
- package/_esm/errors/abi.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/utils/abi/decodeAbiParameters.js +3 -1
- package/_esm/utils/abi/decodeAbiParameters.js.map +1 -1
- package/_types/actions/wallet/writeContract.d.ts +1 -1
- package/_types/actions/wallet/writeContract.d.ts.map +1 -1
- package/_types/chains/definitions/taikoJolnir.d.ts +7 -9
- package/_types/chains/definitions/taikoJolnir.d.ts.map +1 -1
- package/_types/chains/definitions/taikoKatla.d.ts +38 -0
- package/_types/chains/definitions/taikoKatla.d.ts.map +1 -0
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/abi.d.ts +10 -0
- package/_types/errors/abi.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +1 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/types/contract.d.ts +2 -1
- package/_types/types/contract.d.ts.map +1 -1
- package/_types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
- package/actions/wallet/writeContract.ts +5 -1
- package/chains/definitions/taikoJolnir.ts +7 -0
- package/chains/definitions/taikoKatla.ts +22 -0
- package/chains/index.ts +1 -0
- package/clients/transports/http.ts +1 -1
- package/errors/abi.ts +13 -0
- package/errors/version.ts +1 -1
- package/index.ts +6 -0
- package/package.json +1 -1
- package/types/contract.ts +13 -12
- package/utils/abi/decodeAbiParameters.ts +4 -0
package/errors/abi.ts
CHANGED
@@ -95,6 +95,19 @@ export class AbiDecodingDataSizeTooSmallError extends BaseError {
|
|
95
95
|
}
|
96
96
|
}
|
97
97
|
|
98
|
+
export type AbiDecodingOffsetOutOfBoundsErrorType =
|
99
|
+
AbiDecodingOffsetOutOfBoundsError & {
|
100
|
+
name: 'AbiDecodingOffsetOutOfBoundsError'
|
101
|
+
}
|
102
|
+
export class AbiDecodingOffsetOutOfBoundsError extends BaseError {
|
103
|
+
override name = 'AbiDecodingOffsetOutOfBoundsError'
|
104
|
+
constructor({ offset, position }: { offset: number; position: number }) {
|
105
|
+
super(
|
106
|
+
`Offset at "${offset}" is out-of-bounds (current position: "${position}").`,
|
107
|
+
)
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
98
111
|
export type AbiDecodingZeroDataErrorType = AbiDecodingZeroDataError & {
|
99
112
|
name: 'AbiDecodingZeroDataError'
|
100
113
|
}
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.0.
|
1
|
+
export const version = '2.0.5'
|
package/index.ts
CHANGED
@@ -1046,6 +1046,12 @@ export {
|
|
1046
1046
|
type EncodeFunctionResultReturnType,
|
1047
1047
|
encodeFunctionResult,
|
1048
1048
|
} from './utils/abi/encodeFunctionResult.js'
|
1049
|
+
export {
|
1050
|
+
type ParseEventLogsErrorType,
|
1051
|
+
type ParseEventLogsParameters,
|
1052
|
+
type ParseEventLogsReturnType,
|
1053
|
+
parseEventLogs,
|
1054
|
+
} from './utils/abi/parseEventLogs.js'
|
1049
1055
|
export {
|
1050
1056
|
type FormattedTransaction,
|
1051
1057
|
defineTransaction,
|
package/package.json
CHANGED
package/types/contract.ts
CHANGED
@@ -168,21 +168,22 @@ export type ExtractAbiFunctionForArgs<
|
|
168
168
|
? IsUnion<abiFunction> extends true // narrow overloads using `args` by converting to tuple and filtering out overloads that don't match
|
169
169
|
? UnionToTuple<abiFunction> extends infer abiFunctions extends
|
170
170
|
readonly AbiFunction[]
|
171
|
-
?
|
172
|
-
|
173
|
-
readonly [] extends args
|
174
|
-
? readonly [] // fallback to `readonly []` if `args` has no value (e.g. `args` property not provided)
|
175
|
-
: args
|
176
|
-
) extends AbiParametersToPrimitiveTypes<
|
177
|
-
abiFunctions[k]['inputs'],
|
178
|
-
'inputs'
|
179
|
-
>
|
180
|
-
? abiFunctions[k]
|
181
|
-
: never
|
182
|
-
}[number] // convert back to union (removes `never` tuple entries: `['foo', never, 'bar'][number]` => `'foo' | 'bar'`)
|
171
|
+
? // convert back to union (removes `never` tuple entries)
|
172
|
+
{ [k in keyof abiFunctions]: CheckArgs<abiFunctions[k], args> }[number]
|
183
173
|
: never
|
184
174
|
: abiFunction
|
185
175
|
: never
|
176
|
+
type CheckArgs<
|
177
|
+
abiFunction extends AbiFunction,
|
178
|
+
args,
|
179
|
+
///
|
180
|
+
targetArgs extends AbiParametersToPrimitiveTypes<
|
181
|
+
abiFunction['inputs'],
|
182
|
+
'inputs'
|
183
|
+
> = AbiParametersToPrimitiveTypes<abiFunction['inputs'], 'inputs'>,
|
184
|
+
> = (readonly [] extends args ? readonly [] : args) extends targetArgs // fallback to `readonly []` if `args` has no value (e.g. `args` property not provided)
|
185
|
+
? abiFunction
|
186
|
+
: never
|
186
187
|
|
187
188
|
export type ContractFunctionParameters<
|
188
189
|
abi extends Abi | readonly unknown[] = Abi,
|
@@ -7,6 +7,7 @@ import type {
|
|
7
7
|
import {
|
8
8
|
AbiDecodingDataSizeTooSmallError,
|
9
9
|
type AbiDecodingDataSizeTooSmallErrorType,
|
10
|
+
AbiDecodingOffsetOutOfBoundsError,
|
10
11
|
AbiDecodingZeroDataError,
|
11
12
|
type AbiDecodingZeroDataErrorType,
|
12
13
|
InvalidAbiDecodingTypeError,
|
@@ -185,6 +186,9 @@ function decodeArray<const TParam extends AbiParameter>(
|
|
185
186
|
const offset = hexToNumber(
|
186
187
|
slice(data, position, position + 32, { strict: true }),
|
187
188
|
)
|
189
|
+
if (offset < position)
|
190
|
+
throw new AbiDecodingOffsetOutOfBoundsError({ offset, position })
|
191
|
+
|
188
192
|
// Get the length of the array from the offset.
|
189
193
|
const length = hexToNumber(
|
190
194
|
slice(data, offset, offset + 32, { strict: true }),
|