viem 0.0.1-alpha.3 → 0.0.1-alpha.4
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.js +2 -2
- package/dist/{chunk-YZEQFYZ3.js → chunk-43X52QQL.js} +2 -2
- package/dist/{chunk-WZITKXV3.js → chunk-COHLCIQM.js} +17 -1
- package/dist/{chunk-SRDTRROA.js → chunk-ROF2KQ2X.js} +18 -1
- package/dist/{chunk-TLEMV4T3.js → chunk-ZGVHEFCJ.js} +1 -1
- package/dist/clients/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -4
- package/dist/{parseGwei-0f85e8ca.d.ts → parseGwei-a952d720.d.ts} +7 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +4 -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-43X52QQL.js";
|
62
|
+
import "../chunk-ROF2KQ2X.js";
|
63
|
+
import "../chunk-COHLCIQM.js";
|
64
64
|
export {
|
65
65
|
addChain,
|
66
66
|
call,
|
package/dist/chains.js
CHANGED
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
getAddress,
|
12
12
|
hexToNumber,
|
13
13
|
numberToHex
|
14
|
-
} from "./chunk-
|
14
|
+
} from "./chunk-ROF2KQ2X.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-COHLCIQM.js";
|
26
26
|
|
27
27
|
// src/actions/public/call.ts
|
28
28
|
async function call(client, {
|
@@ -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.4",
|
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",
|
@@ -213,6 +213,21 @@ var AbiFunctionNotFoundError = class extends BaseError {
|
|
213
213
|
__publicField(this, "name", "AbiFunctionNotFoundError");
|
214
214
|
}
|
215
215
|
};
|
216
|
+
var AbiFunctionOutputsNotFoundError = class extends BaseError {
|
217
|
+
constructor(functionName) {
|
218
|
+
super(
|
219
|
+
[
|
220
|
+
`Function "${functionName}" does not contain any \`outputs\` on ABI.`,
|
221
|
+
"Cannot decode function result without knowing what the parameter types are.",
|
222
|
+
"Make sure you are using the correct ABI and that the function exists on it."
|
223
|
+
].join("\n"),
|
224
|
+
{
|
225
|
+
docsPath: "/docs/contract/decodeFunctionResult"
|
226
|
+
}
|
227
|
+
);
|
228
|
+
__publicField(this, "name", "AbiFunctionOutputsNotFoundError");
|
229
|
+
}
|
230
|
+
};
|
216
231
|
var AbiFunctionSignatureNotFoundError = class extends BaseError {
|
217
232
|
constructor(signature) {
|
218
233
|
super(
|
@@ -949,6 +964,7 @@ export {
|
|
949
964
|
AbiEncodingArrayLengthMismatchError,
|
950
965
|
AbiEncodingLengthMismatchError,
|
951
966
|
AbiFunctionNotFoundError,
|
967
|
+
AbiFunctionOutputsNotFoundError,
|
952
968
|
AbiFunctionSignatureNotFoundError,
|
953
969
|
InvalidAbiEncodingTypeError,
|
954
970
|
InvalidAbiDecodingTypeError,
|
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
AbiEncodingArrayLengthMismatchError,
|
4
4
|
AbiEncodingLengthMismatchError,
|
5
5
|
AbiFunctionNotFoundError,
|
6
|
+
AbiFunctionOutputsNotFoundError,
|
6
7
|
AbiFunctionSignatureNotFoundError,
|
7
8
|
DataLengthTooLongError,
|
8
9
|
DataLengthTooShortError,
|
@@ -16,7 +17,7 @@ import {
|
|
16
17
|
InvalidHexValueError,
|
17
18
|
OffsetOutOfBoundsError,
|
18
19
|
SizeExceedsPaddingSizeError
|
19
|
-
} from "./chunk-
|
20
|
+
} from "./chunk-COHLCIQM.js";
|
20
21
|
|
21
22
|
// src/utils/data/concat.ts
|
22
23
|
function concat(values) {
|
@@ -943,6 +944,21 @@ function decodeFunctionData({ abi, data }) {
|
|
943
944
|
};
|
944
945
|
}
|
945
946
|
|
947
|
+
// src/utils/abi/decodeFunctionResult.ts
|
948
|
+
function decodeFunctionResult({
|
949
|
+
abi,
|
950
|
+
functionName,
|
951
|
+
data
|
952
|
+
}) {
|
953
|
+
const description = abi.find((x) => "name" in x && x.name === functionName);
|
954
|
+
if (!description)
|
955
|
+
throw new AbiFunctionNotFoundError(functionName);
|
956
|
+
if (!("outputs" in description))
|
957
|
+
throw new AbiFunctionOutputsNotFoundError(functionName);
|
958
|
+
const values = decodeAbi({ data, params: description.outputs });
|
959
|
+
return values.length > 1 ? values : values.length === 1 ? values[0] : void 0;
|
960
|
+
}
|
961
|
+
|
946
962
|
// src/utils/abi/encodeFunctionData.ts
|
947
963
|
function encodeFunctionData({
|
948
964
|
abi,
|
@@ -1193,6 +1209,7 @@ export {
|
|
1193
1209
|
encodeAbi,
|
1194
1210
|
decodeAbi,
|
1195
1211
|
decodeFunctionData,
|
1212
|
+
decodeFunctionResult,
|
1196
1213
|
encodeFunctionData,
|
1197
1214
|
etherUnits,
|
1198
1215
|
gweiUnits,
|
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-b55b0951.js';
|
4
4
|
import { A as Address, H as Hash, B as ByteArray, a as Hex, b as BlockTag } from './rpc-15b85963.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, H as Hash, a 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-15b85963.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 decodeFunctionData, m 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 decodeFunctionData, m as decodeFunctionResult, n as decodeHex, o as decodeRlp, p as encodeAbi, q as encodeBytes, r as encodeFunctionData, s as encodeHex, t as encodeRlp, A as formatEther, T as formatGwei, U as formatUnit, u as getAddress, v as getContractAddress, x as getCreate2Address, w as getCreateAddress, y as getEventSignature, z as getFunctionSignature, H as hexToBigInt, I as hexToBool, J as hexToBytes, V as hexToNumber, K as hexToString, B as isAddress, C as isAddressEqual, D as isBytes, F as isHex, L as keccak256, M as numberToBytes, W as numberToHex, N as pad, O as padBytes, P as padHex, Q as parseEther, R as parseGwei, S as parseUnit, X as size, Y as slice, Z as sliceBytes, _ as sliceHex, $ as stringToBytes, a0 as stringToHex, a1 as trim } from './parseGwei-a952d720.js';
|
7
7
|
export { F as FormattedBlock, a as FormattedTransaction, b as FormattedTransactionRequest, f as formatBlock, c as formatTransaction, d as formatTransactionRequest } from './transactionRequest-f538ea86.js';
|
8
8
|
import './chains.js';
|
9
9
|
import '@wagmi/chains';
|
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-43X52QQL.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-ZGVHEFCJ.js";
|
72
72
|
import {
|
73
73
|
boolToBytes,
|
74
74
|
boolToHex,
|
@@ -80,6 +80,7 @@ import {
|
|
80
80
|
decodeAbi,
|
81
81
|
decodeBytes,
|
82
82
|
decodeFunctionData,
|
83
|
+
decodeFunctionResult,
|
83
84
|
decodeHex,
|
84
85
|
decodeRlp,
|
85
86
|
encodeAbi,
|
@@ -128,7 +129,7 @@ import {
|
|
128
129
|
transactionType,
|
129
130
|
trim,
|
130
131
|
weiUnits
|
131
|
-
} from "./chunk-
|
132
|
+
} from "./chunk-ROF2KQ2X.js";
|
132
133
|
import {
|
133
134
|
AbiDecodingDataSizeInvalidError,
|
134
135
|
AbiEncodingArrayLengthMismatchError,
|
@@ -172,7 +173,7 @@ import {
|
|
172
173
|
UrlRequiredError,
|
173
174
|
WaitForTransactionReceiptTimeoutError,
|
174
175
|
WebSocketRequestError
|
175
|
-
} from "./chunk-
|
176
|
+
} from "./chunk-COHLCIQM.js";
|
176
177
|
export {
|
177
178
|
AbiDecodingDataSizeInvalidError,
|
178
179
|
AbiEncodingArrayLengthMismatchError,
|
@@ -236,6 +237,7 @@ export {
|
|
236
237
|
decodeAbi,
|
237
238
|
decodeBytes,
|
238
239
|
decodeFunctionData,
|
240
|
+
decodeFunctionResult,
|
239
241
|
decodeHex,
|
240
242
|
decodeRlp,
|
241
243
|
dropTransaction,
|
@@ -31,6 +31,12 @@ declare function decodeFunctionData({ abi, data }: {
|
|
31
31
|
args: readonly unknown[] | undefined;
|
32
32
|
};
|
33
33
|
|
34
|
+
declare function decodeFunctionResult<TAbi extends Abi = Abi, TFunctionName extends ExtractAbiFunctionNames<TAbi> = any>({ abi, functionName, data, }: {
|
35
|
+
abi: TAbi;
|
36
|
+
functionName: TFunctionName;
|
37
|
+
data: Hex;
|
38
|
+
}): unknown;
|
39
|
+
|
34
40
|
/**
|
35
41
|
* @description Encodes a list of primitive values into an ABI-encoded hex value.
|
36
42
|
*/
|
@@ -245,4 +251,4 @@ declare function parseEther(ether: `${number}`, unit?: 'wei' | 'gwei'): bigint;
|
|
245
251
|
|
246
252
|
declare function parseGwei(ether: `${number}`, unit?: 'wei'): bigint;
|
247
253
|
|
248
|
-
export {
|
254
|
+
export { stringToBytes as $, formatEther as A, isAddress as B, isAddressEqual as C, isBytes as D, EncodeRlpResponse as E, isHex as F, GetContractAddressOptions as G, hexToBigInt as H, hexToBool as I, hexToBytes as J, hexToString as K, keccak256 as L, numberToBytes as M, pad as N, padBytes as O, padHex as P, parseEther as Q, parseGwei as R, parseUnit as S, formatGwei as T, formatUnit as U, hexToNumber as V, numberToHex as W, size as X, slice as Y, sliceBytes as Z, sliceHex as _, GetCreateAddressOptions as a, stringToHex as a0, trim as a1, 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, decodeFunctionData as l, decodeFunctionResult as m, decodeHex as n, decodeRlp as o, encodeAbi as p, encodeBytes as q, encodeFunctionData as r, encodeHex as s, encodeRlp as t, getAddress as u, getContractAddress as v, getCreateAddress as w, getCreate2Address as x, getEventSignature as y, getFunctionSignature 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 decodeFunctionData, m 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 decodeFunctionData, m as decodeFunctionResult, n as decodeHex, o as decodeRlp, p as encodeAbi, q as encodeBytes, r as encodeFunctionData, s as encodeHex, t as encodeRlp, A as formatEther, T as formatGwei, U as formatUnit, u as getAddress, v as getContractAddress, x as getCreate2Address, w as getCreateAddress, y as getEventSignature, z as getFunctionSignature, H as hexToBigInt, I as hexToBool, J as hexToBytes, V as hexToNumber, K as hexToString, B as isAddress, C as isAddressEqual, D as isBytes, F as isHex, L as keccak256, M as numberToBytes, W as numberToHex, N as pad, O as padBytes, P as padHex, Q as parseEther, R as parseGwei, S as parseUnit, X as size, Y as slice, Z as sliceBytes, _ as sliceHex, $ as stringToBytes, a0 as stringToHex, a1 as trim } from '../parseGwei-a952d720.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-f538ea86.js';
|
3
3
|
export { r as rpc } from '../rpc-26932bae.js';
|
4
4
|
import 'abitype';
|
package/dist/utils/index.js
CHANGED
@@ -9,6 +9,7 @@ import {
|
|
9
9
|
decodeAbi,
|
10
10
|
decodeBytes,
|
11
11
|
decodeFunctionData,
|
12
|
+
decodeFunctionResult,
|
12
13
|
decodeHex,
|
13
14
|
decodeRlp,
|
14
15
|
encodeAbi,
|
@@ -57,11 +58,11 @@ import {
|
|
57
58
|
stringToBytes,
|
58
59
|
stringToHex,
|
59
60
|
trim
|
60
|
-
} from "../chunk-
|
61
|
+
} from "../chunk-ROF2KQ2X.js";
|
61
62
|
import {
|
62
63
|
buildRequest,
|
63
64
|
rpc
|
64
|
-
} from "../chunk-
|
65
|
+
} from "../chunk-COHLCIQM.js";
|
65
66
|
export {
|
66
67
|
boolToBytes,
|
67
68
|
boolToHex,
|
@@ -74,6 +75,7 @@ export {
|
|
74
75
|
decodeAbi,
|
75
76
|
decodeBytes,
|
76
77
|
decodeFunctionData,
|
78
|
+
decodeFunctionResult,
|
77
79
|
decodeHex,
|
78
80
|
decodeRlp,
|
79
81
|
encodeAbi,
|