viem 0.0.1-alpha.7 → 0.0.1-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/dist/actions/index.js +3 -3
- package/dist/chains.d.ts +1 -1
- package/dist/chains.js +2 -2
- package/dist/{chunk-TKAGJYBH.js → chunk-4Z43OTO6.js} +62 -6
- package/dist/{chunk-3N57H2YM.js → chunk-ALVD6MNU.js} +56 -1
- package/dist/{chunk-26LBGCAV.js → chunk-BIQ5KSX5.js} +1 -1
- package/dist/{chunk-6NVPLWQM.js → chunk-N6PIT2C5.js} +2 -2
- package/dist/clients/index.js +2 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +18 -4
- package/dist/{parseGwei-9cc6638c.d.ts → parseGwei-14f716fc.d.ts} +53 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +6 -2
- package/package.json +1 -1
package/dist/actions/index.js
CHANGED
@@ -58,9 +58,9 @@ import {
|
|
58
58
|
watchBlockNumber,
|
59
59
|
watchBlocks,
|
60
60
|
watchPendingTransactions
|
61
|
-
} from "../chunk-
|
62
|
-
import "../chunk-
|
63
|
-
import "../chunk-
|
61
|
+
} from "../chunk-N6PIT2C5.js";
|
62
|
+
import "../chunk-4Z43OTO6.js";
|
63
|
+
import "../chunk-ALVD6MNU.js";
|
64
64
|
export {
|
65
65
|
addChain,
|
66
66
|
call,
|
package/dist/chains.d.ts
CHANGED
@@ -24,7 +24,7 @@ declare const defineBlock: <TFormat extends Formatter<Partial<RpcBlock>, Partial
|
|
24
24
|
}) => Block<bigint, Transaction<bigint, number>> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
|
25
25
|
declare const defineTransaction: <TFormat extends Formatter<Partial<RpcTransaction>, Partial<Transaction<bigint, number>> & {
|
26
26
|
[key: string]: unknown;
|
27
|
-
}>, TExclude extends ("
|
27
|
+
}>, TExclude extends ("type" | "gas" | "blockHash" | "blockNumber" | "hash" | "value" | "from" | "input" | "nonce" | "r" | "s" | "to" | "transactionIndex" | "v" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "accessList")[] = []>({ exclude, format: formatOverride, }: {
|
28
28
|
exclude?: TExclude | undefined;
|
29
29
|
format?: TFormat | undefined;
|
30
30
|
}) => (data: Partial<RpcTransaction> & {
|
package/dist/chains.js
CHANGED
@@ -4,12 +4,16 @@ import {
|
|
4
4
|
AbiDecodingDataSizeInvalidError,
|
5
5
|
AbiEncodingArrayLengthMismatchError,
|
6
6
|
AbiEncodingLengthMismatchError,
|
7
|
+
AbiErrorInputsNotFoundError,
|
8
|
+
AbiErrorNotFoundError,
|
7
9
|
AbiErrorSignatureNotFoundError,
|
10
|
+
AbiEventNotFoundError,
|
8
11
|
AbiFunctionNotFoundError,
|
9
12
|
AbiFunctionOutputsNotFoundError,
|
10
13
|
AbiFunctionSignatureNotFoundError,
|
11
14
|
DataLengthTooLongError,
|
12
15
|
DataLengthTooShortError,
|
16
|
+
FilterTypeNotSupportedError,
|
13
17
|
InvalidAbiDecodingTypeError,
|
14
18
|
InvalidAbiEncodingTypeError,
|
15
19
|
InvalidAddressError,
|
@@ -20,7 +24,7 @@ import {
|
|
20
24
|
InvalidHexValueError,
|
21
25
|
OffsetOutOfBoundsError,
|
22
26
|
SizeExceedsPaddingSizeError
|
23
|
-
} from "./chunk-
|
27
|
+
} from "./chunk-ALVD6MNU.js";
|
24
28
|
|
25
29
|
// src/utils/data/concat.ts
|
26
30
|
function concat(values) {
|
@@ -556,7 +560,7 @@ function encodeAbi({
|
|
556
560
|
const preparedParams = prepareParams({ params, values });
|
557
561
|
const data = encodeParams(preparedParams);
|
558
562
|
if (data.length === 0)
|
559
|
-
return
|
563
|
+
return "0x";
|
560
564
|
return data;
|
561
565
|
}
|
562
566
|
function prepareParams({
|
@@ -998,6 +1002,59 @@ function encodeDeployData({
|
|
998
1002
|
return concatHex([bytecode, data]);
|
999
1003
|
}
|
1000
1004
|
|
1005
|
+
// src/utils/abi/encodeErrorResult.ts
|
1006
|
+
function encodeErrorResult({
|
1007
|
+
abi,
|
1008
|
+
errorName,
|
1009
|
+
args
|
1010
|
+
}) {
|
1011
|
+
const description = abi.find((x) => "name" in x && x.name === errorName);
|
1012
|
+
if (!description)
|
1013
|
+
throw new AbiErrorNotFoundError(errorName);
|
1014
|
+
const definition = getDefinition(description);
|
1015
|
+
const signature = getFunctionSignature(definition);
|
1016
|
+
let data = "0x";
|
1017
|
+
if (args && args.length > 0) {
|
1018
|
+
if (!("inputs" in description && description.inputs))
|
1019
|
+
throw new AbiErrorInputsNotFoundError(errorName);
|
1020
|
+
data = encodeAbi({ params: description.inputs, values: args });
|
1021
|
+
}
|
1022
|
+
return concatHex([signature, data]);
|
1023
|
+
}
|
1024
|
+
|
1025
|
+
// src/utils/abi/encodeEventTopics.ts
|
1026
|
+
function encodeEventTopics({
|
1027
|
+
abi,
|
1028
|
+
eventName,
|
1029
|
+
args
|
1030
|
+
}) {
|
1031
|
+
const description = abi.find((x) => "name" in x && x.name === eventName);
|
1032
|
+
if (!description)
|
1033
|
+
throw new AbiEventNotFoundError(eventName);
|
1034
|
+
const definition = getDefinition(description);
|
1035
|
+
const signature = getEventSignature(definition);
|
1036
|
+
let topics = [];
|
1037
|
+
if (args && "inputs" in description) {
|
1038
|
+
const args_ = Array.isArray(args) ? args : description.inputs?.map((x) => args[x.name]) ?? [];
|
1039
|
+
topics = description.inputs?.filter((param) => "indexed" in param && param.indexed).map(
|
1040
|
+
(param, i) => Array.isArray(args_[i]) ? args_[i].map(
|
1041
|
+
(_, j) => encodeArg({ param, value: args_[i][j] })
|
1042
|
+
) : args_[i] ? encodeArg({ param, value: args_[i] }) : null
|
1043
|
+
) ?? [];
|
1044
|
+
}
|
1045
|
+
return [signature, ...topics];
|
1046
|
+
}
|
1047
|
+
function encodeArg({
|
1048
|
+
param,
|
1049
|
+
value
|
1050
|
+
}) {
|
1051
|
+
if (param.type === "string" || param.type === "bytes")
|
1052
|
+
return keccak256(encodeBytes(value));
|
1053
|
+
if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
|
1054
|
+
throw new FilterTypeNotSupportedError(param.type);
|
1055
|
+
return encodeAbi({ params: [param], values: [value] });
|
1056
|
+
}
|
1057
|
+
|
1001
1058
|
// src/utils/abi/encodeFunctionData.ts
|
1002
1059
|
function encodeFunctionData({
|
1003
1060
|
abi,
|
@@ -1030,10 +1087,7 @@ function encodeFunctionResult({
|
|
1030
1087
|
let values = Array.isArray(result) ? result : [result];
|
1031
1088
|
if (description.outputs.length === 0 && !values[0])
|
1032
1089
|
values = [];
|
1033
|
-
|
1034
|
-
if (!data)
|
1035
|
-
return "0x";
|
1036
|
-
return data;
|
1090
|
+
return encodeAbi({ params: description.outputs, values });
|
1037
1091
|
}
|
1038
1092
|
|
1039
1093
|
// src/constants.ts
|
@@ -1271,6 +1325,8 @@ export {
|
|
1271
1325
|
decodeFunctionData,
|
1272
1326
|
decodeFunctionResult,
|
1273
1327
|
encodeDeployData,
|
1328
|
+
encodeErrorResult,
|
1329
|
+
encodeEventTopics,
|
1274
1330
|
encodeFunctionData,
|
1275
1331
|
encodeFunctionResult,
|
1276
1332
|
etherUnits,
|
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
|
|
9
9
|
var package_default = {
|
10
10
|
name: "viem",
|
11
11
|
description: "TypeScript (& JavaScript) Interface for Ethereum",
|
12
|
-
version: "0.0.1-alpha.
|
12
|
+
version: "0.0.1-alpha.8",
|
13
13
|
scripts: {
|
14
14
|
anvil: "source .env && anvil --fork-url $ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
15
15
|
bench: "vitest bench --no-threads",
|
@@ -227,6 +227,35 @@ var AbiEncodingLengthMismatchError = class extends BaseError {
|
|
227
227
|
__publicField(this, "name", "AbiEncodingLengthMismatchError");
|
228
228
|
}
|
229
229
|
};
|
230
|
+
var AbiErrorInputsNotFoundError = class extends BaseError {
|
231
|
+
constructor(errorName) {
|
232
|
+
super(
|
233
|
+
[
|
234
|
+
`Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
|
235
|
+
"Cannot encode error result without knowing what the parameter types are.",
|
236
|
+
"Make sure you are using the correct ABI and that the inputs exist on it."
|
237
|
+
].join("\n"),
|
238
|
+
{
|
239
|
+
docsPath: "/docs/contract/encodeErrorResult"
|
240
|
+
}
|
241
|
+
);
|
242
|
+
__publicField(this, "name", "AbiErrorInputsNotFoundError");
|
243
|
+
}
|
244
|
+
};
|
245
|
+
var AbiErrorNotFoundError = class extends BaseError {
|
246
|
+
constructor(errorName) {
|
247
|
+
super(
|
248
|
+
[
|
249
|
+
`Error "${errorName}" not found on ABI.`,
|
250
|
+
"Make sure you are using the correct ABI and that the error exists on it."
|
251
|
+
].join("\n"),
|
252
|
+
{
|
253
|
+
docsPath: "/docs/contract/encodeErrorResult"
|
254
|
+
}
|
255
|
+
);
|
256
|
+
__publicField(this, "name", "AbiErrorNotFoundError");
|
257
|
+
}
|
258
|
+
};
|
230
259
|
var AbiErrorSignatureNotFoundError = class extends BaseError {
|
231
260
|
constructor(signature) {
|
232
261
|
super(
|
@@ -242,6 +271,20 @@ var AbiErrorSignatureNotFoundError = class extends BaseError {
|
|
242
271
|
__publicField(this, "name", "AbiErrorSignatureNotFoundError");
|
243
272
|
}
|
244
273
|
};
|
274
|
+
var AbiEventNotFoundError = class extends BaseError {
|
275
|
+
constructor(eventName) {
|
276
|
+
super(
|
277
|
+
[
|
278
|
+
`Event "${eventName}" not found on ABI.`,
|
279
|
+
"Make sure you are using the correct ABI and that the event exists on it."
|
280
|
+
].join("\n"),
|
281
|
+
{
|
282
|
+
docsPath: "/docs/contract/encodeEventTopics"
|
283
|
+
}
|
284
|
+
);
|
285
|
+
__publicField(this, "name", "AbiEventNotFoundError");
|
286
|
+
}
|
287
|
+
};
|
245
288
|
var AbiFunctionNotFoundError = class extends BaseError {
|
246
289
|
constructor(functionName) {
|
247
290
|
super(
|
@@ -419,6 +462,14 @@ var OffsetOutOfBoundsError = class extends BaseError {
|
|
419
462
|
}
|
420
463
|
};
|
421
464
|
|
465
|
+
// src/errors/log.ts
|
466
|
+
var FilterTypeNotSupportedError = class extends BaseError {
|
467
|
+
constructor(type) {
|
468
|
+
super(`Filter type "${type}" is not supported.`);
|
469
|
+
__publicField(this, "name", "FilterTypeNotSupportedError");
|
470
|
+
}
|
471
|
+
};
|
472
|
+
|
422
473
|
// src/errors/request.ts
|
423
474
|
var RequestError = class extends BaseError {
|
424
475
|
constructor(err, { docsPath, humanMessage }) {
|
@@ -1008,7 +1059,10 @@ export {
|
|
1008
1059
|
AbiDecodingDataSizeInvalidError,
|
1009
1060
|
AbiEncodingArrayLengthMismatchError,
|
1010
1061
|
AbiEncodingLengthMismatchError,
|
1062
|
+
AbiErrorInputsNotFoundError,
|
1063
|
+
AbiErrorNotFoundError,
|
1011
1064
|
AbiErrorSignatureNotFoundError,
|
1065
|
+
AbiEventNotFoundError,
|
1012
1066
|
AbiFunctionNotFoundError,
|
1013
1067
|
AbiFunctionOutputsNotFoundError,
|
1014
1068
|
AbiFunctionSignatureNotFoundError,
|
@@ -1025,6 +1079,7 @@ export {
|
|
1025
1079
|
InvalidHexBooleanError,
|
1026
1080
|
InvalidHexValueError,
|
1027
1081
|
OffsetOutOfBoundsError,
|
1082
|
+
FilterTypeNotSupportedError,
|
1028
1083
|
RequestError,
|
1029
1084
|
RpcRequestError,
|
1030
1085
|
ParseRpcError,
|
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
getAddress,
|
12
12
|
hexToNumber,
|
13
13
|
numberToHex
|
14
|
-
} from "./chunk-
|
14
|
+
} from "./chunk-4Z43OTO6.js";
|
15
15
|
import {
|
16
16
|
BaseError,
|
17
17
|
BlockNotFoundError,
|
@@ -22,7 +22,7 @@ import {
|
|
22
22
|
getCache,
|
23
23
|
wait,
|
24
24
|
withCache
|
25
|
-
} from "./chunk-
|
25
|
+
} from "./chunk-ALVD6MNU.js";
|
26
26
|
|
27
27
|
// src/actions/public/call.ts
|
28
28
|
async function call(client, {
|
package/dist/clients/index.js
CHANGED
package/dist/index.d.ts
CHANGED
@@ -3,7 +3,7 @@ export { C as Client, a as ClientConfig, P as PublicClient, b as PublicClientCon
|
|
3
3
|
export { C as CustomTransport, a as CustomTransportConfig, F as FallbackTransport, b as FallbackTransportConfig, H as HttpTransport, c as HttpTransportConfig, W as WebSocketTransport, d as WebSocketTransportConfig, e as custom, f as fallback, h as http, w as webSocket } from './webSocket-f4abf66c.js';
|
4
4
|
import { H as Hex, A as Address, a as Hash, B as ByteArray, b as BlockTag } from './rpc-b77c5aee.js';
|
5
5
|
export { c as AccessList, A as Address, d as Block, f as BlockIdentifier, h as BlockNumber, b as BlockTag, B as ByteArray, F as FeeHistory, i as FeeValues, j as FeeValuesEIP1559, k as FeeValuesLegacy, a as Hash, H as Hex, L as Log, R as RpcBlock, l as RpcBlockIdentifier, m as RpcBlockNumber, n as RpcFeeHistory, o as RpcFeeValues, p as RpcLog, q as RpcTransaction, r as RpcTransactionReceipt, s as RpcTransactionRequest, u as RpcUncle, D as Transaction, E as TransactionBase, G as TransactionEIP1559, I as TransactionEIP2930, J as TransactionLegacy, T as TransactionReceipt, v as TransactionRequest, x as TransactionRequestBase, y as TransactionRequestEIP1559, z as TransactionRequestEIP2930, C as TransactionRequestLegacy, U as Uncle, e as etherUnits, g as gweiUnits, t as transactionType, w as weiUnits } from './rpc-b77c5aee.js';
|
6
|
-
export { E as EncodeRlpResponse, G as GetContractAddressOptions, b as GetCreate2AddressOptions, a as GetCreateAddressOptions, e as boolToBytes, f as boolToHex, g as bytesToBigint, h as bytesToBool, c as bytesToHex, i as bytesToNumber, d as bytesToString, j as decodeAbi, k as decodeBytes, l as decodeErrorResult, m as decodeFunctionData, n as decodeFunctionResult, o as decodeHex, p as decodeRlp, q as encodeAbi, r as encodeBytes, s as encodeDeployData, t as
|
6
|
+
export { E as EncodeRlpResponse, G as GetContractAddressOptions, b as GetCreate2AddressOptions, a as GetCreateAddressOptions, e as boolToBytes, f as boolToHex, g as bytesToBigint, h as bytesToBool, c as bytesToHex, i as bytesToNumber, d as bytesToString, j as decodeAbi, k as decodeBytes, l as decodeErrorResult, m as decodeFunctionData, n as decodeFunctionResult, o as decodeHex, p as decodeRlp, q as encodeAbi, r as encodeBytes, s as encodeDeployData, t as encodeErrorResult, u as encodeEventTopics, v as encodeFunctionData, w as encodeFunctionResult, x as encodeHex, y as encodeRlp, H as formatEther, Y as formatGwei, Z as formatUnit, z as getAddress, A as getContractAddress, C as getCreate2Address, B as getCreateAddress, D as getEventSignature, F as getFunctionSignature, M as hexToBigInt, N as hexToBool, O as hexToBytes, _ as hexToNumber, P as hexToString, I as isAddress, J as isAddressEqual, K as isBytes, L as isHex, Q as keccak256, R as numberToBytes, $ as numberToHex, S as pad, T as padBytes, U as padHex, V as parseEther, W as parseGwei, X as parseUnit, a0 as size, a1 as slice, a2 as sliceBytes, a3 as sliceHex, a4 as stringToBytes, a5 as stringToHex, a6 as trim } from './parseGwei-14f716fc.js';
|
7
7
|
export { F as FormattedBlock, a as FormattedTransaction, b as FormattedTransactionRequest, f as formatBlock, c as formatTransaction, d as formatTransactionRequest } from './transactionRequest-3e463099.js';
|
8
8
|
import './chains.js';
|
9
9
|
import '@wagmi/chains';
|
@@ -55,6 +55,22 @@ declare class AbiEncodingLengthMismatchError extends BaseError {
|
|
55
55
|
givenLength: number;
|
56
56
|
});
|
57
57
|
}
|
58
|
+
declare class AbiErrorInputsNotFoundError extends BaseError {
|
59
|
+
name: string;
|
60
|
+
constructor(errorName: string);
|
61
|
+
}
|
62
|
+
declare class AbiErrorNotFoundError extends BaseError {
|
63
|
+
name: string;
|
64
|
+
constructor(errorName: string);
|
65
|
+
}
|
66
|
+
declare class AbiErrorSignatureNotFoundError extends BaseError {
|
67
|
+
name: string;
|
68
|
+
constructor(signature: Hex);
|
69
|
+
}
|
70
|
+
declare class AbiEventNotFoundError extends BaseError {
|
71
|
+
name: string;
|
72
|
+
constructor(eventName: string);
|
73
|
+
}
|
58
74
|
declare class AbiFunctionNotFoundError extends BaseError {
|
59
75
|
name: string;
|
60
76
|
constructor(functionName: string);
|
@@ -142,6 +158,11 @@ declare class OffsetOutOfBoundsError extends BaseError {
|
|
142
158
|
});
|
143
159
|
}
|
144
160
|
|
161
|
+
declare class FilterTypeNotSupportedError extends BaseError {
|
162
|
+
name: string;
|
163
|
+
constructor(type: string);
|
164
|
+
}
|
165
|
+
|
145
166
|
declare class HttpRequestError extends BaseError {
|
146
167
|
name: string;
|
147
168
|
status: number;
|
@@ -297,4 +318,4 @@ declare class UrlRequiredError extends BaseError {
|
|
297
318
|
constructor();
|
298
319
|
}
|
299
320
|
|
300
|
-
export { AbiConstructorNotFoundError, AbiConstructorParamsNotFoundError, AbiDecodingDataSizeInvalidError, AbiEncodingArrayLengthMismatchError, AbiEncodingLengthMismatchError, AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, AbiFunctionSignatureNotFoundError, BaseError, BlockNotFoundError, DataLengthTooLongError, DataLengthTooShortError, HttpRequestError, InternalRpcError, InvalidAbiDecodingTypeError, InvalidAbiEncodingTypeError, InvalidAddressError, InvalidArrayError, InvalidBytesBooleanError, InvalidDefinitionTypeError, InvalidGasArgumentsError, InvalidHexBooleanError, InvalidHexValueError, InvalidInputRpcError, InvalidParamsRpcError, InvalidRequestRpcError, JsonRpcVersionUnsupportedError, LimitExceededRpcError, MethodNotFoundRpcError, MethodNotSupportedRpcError, OffsetOutOfBoundsError, ParseRpcError, RequestError, ResourceNotFoundRpcError, ResourceUnavailableRpcError, RpcError, RpcRequestError, SizeExceedsPaddingSizeError, TimeoutError, TransactionNotFoundError, TransactionReceiptNotFoundError, TransactionRejectedRpcError, UnknownRpcError, UrlRequiredError, WaitForTransactionReceiptTimeoutError, WebSocketRequestError };
|
321
|
+
export { AbiConstructorNotFoundError, AbiConstructorParamsNotFoundError, AbiDecodingDataSizeInvalidError, AbiEncodingArrayLengthMismatchError, AbiEncodingLengthMismatchError, AbiErrorInputsNotFoundError, AbiErrorNotFoundError, AbiErrorSignatureNotFoundError, AbiEventNotFoundError, AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, AbiFunctionSignatureNotFoundError, BaseError, BlockNotFoundError, DataLengthTooLongError, DataLengthTooShortError, FilterTypeNotSupportedError, HttpRequestError, InternalRpcError, InvalidAbiDecodingTypeError, InvalidAbiEncodingTypeError, InvalidAddressError, InvalidArrayError, InvalidBytesBooleanError, InvalidDefinitionTypeError, InvalidGasArgumentsError, InvalidHexBooleanError, InvalidHexValueError, InvalidInputRpcError, InvalidParamsRpcError, InvalidRequestRpcError, JsonRpcVersionUnsupportedError, LimitExceededRpcError, MethodNotFoundRpcError, MethodNotSupportedRpcError, OffsetOutOfBoundsError, ParseRpcError, RequestError, ResourceNotFoundRpcError, ResourceUnavailableRpcError, RpcError, RpcRequestError, SizeExceedsPaddingSizeError, TimeoutError, TransactionNotFoundError, TransactionReceiptNotFoundError, TransactionRejectedRpcError, UnknownRpcError, UrlRequiredError, WaitForTransactionReceiptTimeoutError, WebSocketRequestError };
|
package/dist/index.js
CHANGED
@@ -57,7 +57,7 @@ import {
|
|
57
57
|
watchBlockNumber,
|
58
58
|
watchBlocks,
|
59
59
|
watchPendingTransactions
|
60
|
-
} from "./chunk-
|
60
|
+
} from "./chunk-N6PIT2C5.js";
|
61
61
|
import {
|
62
62
|
createClient,
|
63
63
|
createPublicClient,
|
@@ -68,7 +68,7 @@ import {
|
|
68
68
|
fallback,
|
69
69
|
http,
|
70
70
|
webSocket
|
71
|
-
} from "./chunk-
|
71
|
+
} from "./chunk-BIQ5KSX5.js";
|
72
72
|
import {
|
73
73
|
boolToBytes,
|
74
74
|
boolToHex,
|
@@ -87,6 +87,8 @@ import {
|
|
87
87
|
encodeAbi,
|
88
88
|
encodeBytes,
|
89
89
|
encodeDeployData,
|
90
|
+
encodeErrorResult,
|
91
|
+
encodeEventTopics,
|
90
92
|
encodeFunctionData,
|
91
93
|
encodeFunctionResult,
|
92
94
|
encodeHex,
|
@@ -132,13 +134,17 @@ import {
|
|
132
134
|
transactionType,
|
133
135
|
trim,
|
134
136
|
weiUnits
|
135
|
-
} from "./chunk-
|
137
|
+
} from "./chunk-4Z43OTO6.js";
|
136
138
|
import {
|
137
139
|
AbiConstructorNotFoundError,
|
138
140
|
AbiConstructorParamsNotFoundError,
|
139
141
|
AbiDecodingDataSizeInvalidError,
|
140
142
|
AbiEncodingArrayLengthMismatchError,
|
141
143
|
AbiEncodingLengthMismatchError,
|
144
|
+
AbiErrorInputsNotFoundError,
|
145
|
+
AbiErrorNotFoundError,
|
146
|
+
AbiErrorSignatureNotFoundError,
|
147
|
+
AbiEventNotFoundError,
|
142
148
|
AbiFunctionNotFoundError,
|
143
149
|
AbiFunctionOutputsNotFoundError,
|
144
150
|
AbiFunctionSignatureNotFoundError,
|
@@ -146,6 +152,7 @@ import {
|
|
146
152
|
BlockNotFoundError,
|
147
153
|
DataLengthTooLongError,
|
148
154
|
DataLengthTooShortError,
|
155
|
+
FilterTypeNotSupportedError,
|
149
156
|
HttpRequestError,
|
150
157
|
InternalRpcError,
|
151
158
|
InvalidAbiDecodingTypeError,
|
@@ -180,13 +187,17 @@ import {
|
|
180
187
|
UrlRequiredError,
|
181
188
|
WaitForTransactionReceiptTimeoutError,
|
182
189
|
WebSocketRequestError
|
183
|
-
} from "./chunk-
|
190
|
+
} from "./chunk-ALVD6MNU.js";
|
184
191
|
export {
|
185
192
|
AbiConstructorNotFoundError,
|
186
193
|
AbiConstructorParamsNotFoundError,
|
187
194
|
AbiDecodingDataSizeInvalidError,
|
188
195
|
AbiEncodingArrayLengthMismatchError,
|
189
196
|
AbiEncodingLengthMismatchError,
|
197
|
+
AbiErrorInputsNotFoundError,
|
198
|
+
AbiErrorNotFoundError,
|
199
|
+
AbiErrorSignatureNotFoundError,
|
200
|
+
AbiEventNotFoundError,
|
190
201
|
AbiFunctionNotFoundError,
|
191
202
|
AbiFunctionOutputsNotFoundError,
|
192
203
|
AbiFunctionSignatureNotFoundError,
|
@@ -194,6 +205,7 @@ export {
|
|
194
205
|
BlockNotFoundError,
|
195
206
|
DataLengthTooLongError,
|
196
207
|
DataLengthTooShortError,
|
208
|
+
FilterTypeNotSupportedError,
|
197
209
|
HttpRequestError,
|
198
210
|
InternalRpcError,
|
199
211
|
InvalidAbiDecodingTypeError,
|
@@ -256,6 +268,8 @@ export {
|
|
256
268
|
encodeAbi,
|
257
269
|
encodeBytes,
|
258
270
|
encodeDeployData,
|
271
|
+
encodeErrorResult,
|
272
|
+
encodeEventTopics,
|
259
273
|
encodeFunctionData,
|
260
274
|
encodeFunctionResult,
|
261
275
|
encodeHex,
|
@@ -1,6 +1,18 @@
|
|
1
|
-
import { Abi, AbiFunction, ExtractAbiFunction, AbiParametersToPrimitiveTypes, AbiParameter, ExtractAbiFunctionNames } from 'abitype';
|
1
|
+
import { Abi, AbiFunction, ExtractAbiFunction, AbiParametersToPrimitiveTypes, AbiError, ExtractAbiError, AbiEvent, ExtractAbiEvent, AbiParameter, AbiParameterToPrimitiveType, ExtractAbiFunctionNames, ExtractAbiErrorNames, ExtractAbiEventNames } from 'abitype';
|
2
2
|
import { H as Hex, A as Address, B as ByteArray } from './rpc-b77c5aee.js';
|
3
3
|
|
4
|
+
type AbiEventParametersToPrimitiveTypes<TAbiParameters extends readonly AbiParameter[], TBase = TAbiParameters[0] extends {
|
5
|
+
name: string;
|
6
|
+
} ? {} : []> = TAbiParameters extends readonly [infer Head, ...infer Tail] ? Head extends {
|
7
|
+
indexed: true;
|
8
|
+
} ? Head extends AbiParameter ? Head extends {
|
9
|
+
name: infer Name;
|
10
|
+
} ? Name extends string ? {
|
11
|
+
[name in Name]?: AbiParameterToPrimitiveType<Head> | AbiParameterToPrimitiveType<Head>[] | null;
|
12
|
+
} & (Tail extends readonly [] ? {} : Tail extends readonly AbiParameter[] ? AbiEventParametersToPrimitiveTypes<Tail> : {}) : never : [
|
13
|
+
(AbiParameterToPrimitiveType<Head> | AbiParameterToPrimitiveType<Head>[] | null),
|
14
|
+
...(Tail extends readonly [] ? [] : Tail extends readonly AbiParameter[] ? AbiEventParametersToPrimitiveTypes<Tail> : [])
|
15
|
+
] : TBase : TBase : TBase;
|
4
16
|
type ExtractArgsFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiFunction extends AbiFunction & {
|
5
17
|
type: 'function';
|
6
18
|
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
|
@@ -35,6 +47,18 @@ type ExtractConstructorArgsFromAbi<TAbi extends Abi | readonly unknown[], TAbiFu
|
|
35
47
|
} : {
|
36
48
|
/** Arguments to pass contract method */ args: TArgs;
|
37
49
|
};
|
50
|
+
type ExtractErrorArgsFromAbi<TAbi extends Abi | readonly unknown[], TErrorName extends string, TAbiError extends AbiError = TAbi extends Abi ? ExtractAbiError<TAbi, TErrorName> : AbiError, TArgs = AbiParametersToPrimitiveTypes<TAbiError['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
|
51
|
+
/**
|
52
|
+
* Arguments to pass contract method
|
53
|
+
*
|
54
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
55
|
+
*/
|
56
|
+
args?: readonly unknown[];
|
57
|
+
} : TArgs extends readonly [] ? {
|
58
|
+
args?: never;
|
59
|
+
} : {
|
60
|
+
/** Arguments to pass contract method */ args: TArgs;
|
61
|
+
};
|
38
62
|
type ExtractResultFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiFunction extends AbiFunction & {
|
39
63
|
type: 'function';
|
40
64
|
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
|
@@ -51,6 +75,22 @@ type ExtractResultFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName e
|
|
51
75
|
} : {
|
52
76
|
/** Arguments to pass contract method */ result: TArgs;
|
53
77
|
};
|
78
|
+
type ExtractEventArgsFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiEvent extends AbiEvent & {
|
79
|
+
type: 'event';
|
80
|
+
} = TAbi extends Abi ? ExtractAbiEvent<TAbi, TFunctionName> : AbiEvent & {
|
81
|
+
type: 'event';
|
82
|
+
}, TArgs = AbiEventParametersToPrimitiveTypes<TAbiEvent['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
|
83
|
+
/**
|
84
|
+
* Arguments to pass contract method
|
85
|
+
*
|
86
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
87
|
+
*/
|
88
|
+
args?: readonly unknown[];
|
89
|
+
} : TArgs extends readonly [] ? {
|
90
|
+
args?: never;
|
91
|
+
} : {
|
92
|
+
args?: TArgs;
|
93
|
+
};
|
54
94
|
|
55
95
|
declare function decodeAbi<TParams extends readonly AbiParameter[]>({ data, params, }: {
|
56
96
|
data: Hex;
|
@@ -85,13 +125,23 @@ declare function decodeFunctionResult<TAbi extends Abi = Abi, TFunctionName exte
|
|
85
125
|
declare function encodeAbi<TParams extends readonly AbiParameter[]>({ params, values, }: {
|
86
126
|
params: TParams;
|
87
127
|
values: AbiParametersToPrimitiveTypes<TParams>;
|
88
|
-
}): `0x${string}
|
128
|
+
}): `0x${string}`;
|
89
129
|
|
90
130
|
declare function encodeDeployData<TAbi extends Abi = Abi>({ abi, args, bytecode, }: {
|
91
131
|
abi: TAbi;
|
92
132
|
bytecode: Hex;
|
93
133
|
} & ExtractConstructorArgsFromAbi<TAbi>): `0x${string}`;
|
94
134
|
|
135
|
+
declare function encodeErrorResult<TAbi extends Abi = Abi, TErrorName extends ExtractAbiErrorNames<TAbi> = any>({ abi, errorName, args, }: {
|
136
|
+
abi: TAbi;
|
137
|
+
errorName: TErrorName;
|
138
|
+
} & ExtractErrorArgsFromAbi<TAbi, TErrorName>): `0x${string}`;
|
139
|
+
|
140
|
+
declare function encodeEventTopics<TAbi extends Abi = Abi, TEventName extends ExtractAbiEventNames<TAbi> = any>({ abi, eventName, args, }: {
|
141
|
+
abi: TAbi;
|
142
|
+
eventName: TEventName;
|
143
|
+
} & ExtractEventArgsFromAbi<TAbi, TEventName>): `0x${string}`[];
|
144
|
+
|
95
145
|
declare function encodeFunctionData<TAbi extends Abi = Abi, TFunctionName extends ExtractAbiFunctionNames<TAbi> = any>({ abi, args, functionName, }: {
|
96
146
|
abi: TAbi;
|
97
147
|
functionName: TFunctionName;
|
@@ -303,4 +353,4 @@ declare function parseEther(ether: `${number}`, unit?: 'wei' | 'gwei'): bigint;
|
|
303
353
|
|
304
354
|
declare function parseGwei(ether: `${number}`, unit?: 'wei'): bigint;
|
305
355
|
|
306
|
-
export {
|
356
|
+
export { numberToHex as $, getContractAddress as A, getCreateAddress as B, getCreate2Address as C, getEventSignature as D, EncodeRlpResponse as E, getFunctionSignature as F, GetContractAddressOptions as G, formatEther as H, isAddress as I, isAddressEqual as J, isBytes as K, isHex as L, hexToBigInt as M, hexToBool as N, hexToBytes as O, hexToString as P, keccak256 as Q, numberToBytes as R, pad as S, padBytes as T, padHex as U, parseEther as V, parseGwei as W, parseUnit as X, formatGwei as Y, formatUnit as Z, hexToNumber as _, GetCreateAddressOptions as a, size as a0, slice as a1, sliceBytes as a2, sliceHex as a3, stringToBytes as a4, stringToHex as a5, trim as a6, GetCreate2AddressOptions as b, bytesToHex as c, bytesToString as d, boolToBytes as e, boolToHex as f, bytesToBigint as g, bytesToBool as h, bytesToNumber as i, decodeAbi as j, decodeBytes as k, decodeErrorResult as l, decodeFunctionData as m, decodeFunctionResult as n, decodeHex as o, decodeRlp as p, encodeAbi as q, encodeBytes as r, encodeDeployData as s, encodeErrorResult as t, encodeEventTopics as u, encodeFunctionData as v, encodeFunctionResult as w, encodeHex as x, encodeRlp as y, getAddress as z };
|
package/dist/utils/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { E as EncodeRlpResponse, G as GetContractAddressOptions, b as GetCreate2AddressOptions, a as GetCreateAddressOptions, e as boolToBytes, f as boolToHex, g as bytesToBigint, h as bytesToBool, c as bytesToHex, i as bytesToNumber, d as bytesToString, j as decodeAbi, k as decodeBytes, l as decodeErrorResult, m as decodeFunctionData, n as decodeFunctionResult, o as decodeHex, p as decodeRlp, q as encodeAbi, r as encodeBytes, s as encodeDeployData, t as
|
1
|
+
export { E as EncodeRlpResponse, G as GetContractAddressOptions, b as GetCreate2AddressOptions, a as GetCreateAddressOptions, e as boolToBytes, f as boolToHex, g as bytesToBigint, h as bytesToBool, c as bytesToHex, i as bytesToNumber, d as bytesToString, j as decodeAbi, k as decodeBytes, l as decodeErrorResult, m as decodeFunctionData, n as decodeFunctionResult, o as decodeHex, p as decodeRlp, q as encodeAbi, r as encodeBytes, s as encodeDeployData, t as encodeErrorResult, u as encodeEventTopics, v as encodeFunctionData, w as encodeFunctionResult, x as encodeHex, y as encodeRlp, H as formatEther, Y as formatGwei, Z as formatUnit, z as getAddress, A as getContractAddress, C as getCreate2Address, B as getCreateAddress, D as getEventSignature, F as getFunctionSignature, M as hexToBigInt, N as hexToBool, O as hexToBytes, _ as hexToNumber, P as hexToString, I as isAddress, J as isAddressEqual, K as isBytes, L as isHex, Q as keccak256, R as numberToBytes, $ as numberToHex, S as pad, T as padBytes, U as padHex, V as parseEther, W as parseGwei, X as parseUnit, a0 as size, a1 as slice, a2 as sliceBytes, a3 as sliceHex, a4 as stringToBytes, a5 as stringToHex, a6 as trim } from '../parseGwei-14f716fc.js';
|
2
2
|
export { B as BlockFormatter, E as ExtractFormatter, e as Formatted, F as FormattedBlock, a as FormattedTransaction, h as FormattedTransactionReceipt, b as FormattedTransactionRequest, g as TransactionFormatter, i as TransactionReceiptFormatter, T as TransactionRequestFormatter, j as format, f as formatBlock, c as formatTransaction, d as formatTransactionRequest } from '../transactionRequest-3e463099.js';
|
3
3
|
export { r as rpc } from '../rpc-26932bae.js';
|
4
4
|
import 'abitype';
|
package/dist/utils/index.js
CHANGED
@@ -16,6 +16,8 @@ import {
|
|
16
16
|
encodeAbi,
|
17
17
|
encodeBytes,
|
18
18
|
encodeDeployData,
|
19
|
+
encodeErrorResult,
|
20
|
+
encodeEventTopics,
|
19
21
|
encodeFunctionData,
|
20
22
|
encodeFunctionResult,
|
21
23
|
encodeHex,
|
@@ -61,11 +63,11 @@ import {
|
|
61
63
|
stringToBytes,
|
62
64
|
stringToHex,
|
63
65
|
trim
|
64
|
-
} from "../chunk-
|
66
|
+
} from "../chunk-4Z43OTO6.js";
|
65
67
|
import {
|
66
68
|
buildRequest,
|
67
69
|
rpc
|
68
|
-
} from "../chunk-
|
70
|
+
} from "../chunk-ALVD6MNU.js";
|
69
71
|
export {
|
70
72
|
boolToBytes,
|
71
73
|
boolToHex,
|
@@ -85,6 +87,8 @@ export {
|
|
85
87
|
encodeAbi,
|
86
88
|
encodeBytes,
|
87
89
|
encodeDeployData,
|
90
|
+
encodeErrorResult,
|
91
|
+
encodeEventTopics,
|
88
92
|
encodeFunctionData,
|
89
93
|
encodeFunctionResult,
|
90
94
|
encodeHex,
|