viem 0.0.1-alpha.4 → 0.0.1-alpha.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/dist/actions/index.js +3 -3
- package/dist/chains.js +2 -2
- package/dist/{chunk-ZGVHEFCJ.js → chunk-CI2RMCPH.js} +1 -1
- package/dist/{chunk-COHLCIQM.js → chunk-J7TAHE5G.js} +1 -1
- package/dist/{chunk-43X52QQL.js → chunk-L4ZEGSSO.js} +2 -2
- package/dist/{chunk-ROF2KQ2X.js → chunk-LM2GVIJG.js} +22 -1
- package/dist/clients/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -4
- package/dist/{parseGwei-a952d720.d.ts → parseGwei-f454ca76.d.ts} +22 -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-L4ZEGSSO.js";
|
62
|
+
import "../chunk-LM2GVIJG.js";
|
63
|
+
import "../chunk-J7TAHE5G.js";
|
64
64
|
export {
|
65
65
|
addChain,
|
66
66
|
call,
|
package/dist/chains.js
CHANGED
@@ -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.5",
|
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",
|
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
getAddress,
|
12
12
|
hexToNumber,
|
13
13
|
numberToHex
|
14
|
-
} from "./chunk-
|
14
|
+
} from "./chunk-LM2GVIJG.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-J7TAHE5G.js";
|
26
26
|
|
27
27
|
// src/actions/public/call.ts
|
28
28
|
async function call(client, {
|
@@ -17,7 +17,7 @@ import {
|
|
17
17
|
InvalidHexValueError,
|
18
18
|
OffsetOutOfBoundsError,
|
19
19
|
SizeExceedsPaddingSizeError
|
20
|
-
} from "./chunk-
|
20
|
+
} from "./chunk-J7TAHE5G.js";
|
21
21
|
|
22
22
|
// src/utils/data/concat.ts
|
23
23
|
function concat(values) {
|
@@ -977,6 +977,26 @@ function encodeFunctionData({
|
|
977
977
|
return concatHex([signature, data ?? "0x"]);
|
978
978
|
}
|
979
979
|
|
980
|
+
// src/utils/abi/encodeFunctionResult.ts
|
981
|
+
function encodeFunctionResult({
|
982
|
+
abi,
|
983
|
+
functionName,
|
984
|
+
result
|
985
|
+
}) {
|
986
|
+
const description = abi.find((x) => "name" in x && x.name === functionName);
|
987
|
+
if (!description)
|
988
|
+
throw new AbiFunctionNotFoundError(functionName);
|
989
|
+
if (!("outputs" in description))
|
990
|
+
throw new AbiFunctionOutputsNotFoundError(functionName);
|
991
|
+
let values = Array.isArray(result) ? result : [result];
|
992
|
+
if (description.outputs.length === 0 && !values[0])
|
993
|
+
values = [];
|
994
|
+
const data = encodeAbi({ params: description.outputs, values });
|
995
|
+
if (!data)
|
996
|
+
return "0x";
|
997
|
+
return data;
|
998
|
+
}
|
999
|
+
|
980
1000
|
// src/constants.ts
|
981
1001
|
var etherUnits = {
|
982
1002
|
gwei: 9,
|
@@ -1211,6 +1231,7 @@ export {
|
|
1211
1231
|
decodeFunctionData,
|
1212
1232
|
decodeFunctionResult,
|
1213
1233
|
encodeFunctionData,
|
1234
|
+
encodeFunctionResult,
|
1214
1235
|
etherUnits,
|
1215
1236
|
gweiUnits,
|
1216
1237
|
weiUnits,
|
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 decodeFunctionResult, n as decodeHex, o as decodeRlp, p as encodeAbi, q as encodeBytes, r as encodeFunctionData, s 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 encodeFunctionResult, t as encodeHex, u as encodeRlp, B as formatEther, U as formatGwei, V as formatUnit, v as getAddress, w as getContractAddress, y as getCreate2Address, x as getCreateAddress, z as getEventSignature, A as getFunctionSignature, I as hexToBigInt, J as hexToBool, K as hexToBytes, W as hexToNumber, L as hexToString, C as isAddress, D as isAddressEqual, F as isBytes, H as isHex, M as keccak256, N as numberToBytes, X as numberToHex, O as pad, P as padBytes, Q as padHex, R as parseEther, S as parseGwei, T as parseUnit, Y as size, Z as slice, _ as sliceBytes, $ as sliceHex, a0 as stringToBytes, a1 as stringToHex, a2 as trim } from './parseGwei-f454ca76.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-L4ZEGSSO.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-CI2RMCPH.js";
|
72
72
|
import {
|
73
73
|
boolToBytes,
|
74
74
|
boolToHex,
|
@@ -86,6 +86,7 @@ import {
|
|
86
86
|
encodeAbi,
|
87
87
|
encodeBytes,
|
88
88
|
encodeFunctionData,
|
89
|
+
encodeFunctionResult,
|
89
90
|
encodeHex,
|
90
91
|
encodeRlp,
|
91
92
|
etherUnits,
|
@@ -129,7 +130,7 @@ import {
|
|
129
130
|
transactionType,
|
130
131
|
trim,
|
131
132
|
weiUnits
|
132
|
-
} from "./chunk-
|
133
|
+
} from "./chunk-LM2GVIJG.js";
|
133
134
|
import {
|
134
135
|
AbiDecodingDataSizeInvalidError,
|
135
136
|
AbiEncodingArrayLengthMismatchError,
|
@@ -173,7 +174,7 @@ import {
|
|
173
174
|
UrlRequiredError,
|
174
175
|
WaitForTransactionReceiptTimeoutError,
|
175
176
|
WebSocketRequestError
|
176
|
-
} from "./chunk-
|
177
|
+
} from "./chunk-J7TAHE5G.js";
|
177
178
|
export {
|
178
179
|
AbiDecodingDataSizeInvalidError,
|
179
180
|
AbiEncodingArrayLengthMismatchError,
|
@@ -244,6 +245,7 @@ export {
|
|
244
245
|
encodeAbi,
|
245
246
|
encodeBytes,
|
246
247
|
encodeFunctionData,
|
248
|
+
encodeFunctionResult,
|
247
249
|
encodeHex,
|
248
250
|
encodeRlp,
|
249
251
|
estimateGas,
|
@@ -17,6 +17,22 @@ type ExtractArgsFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName ext
|
|
17
17
|
} : {
|
18
18
|
/** Arguments to pass contract method */ args: TArgs;
|
19
19
|
};
|
20
|
+
type ExtractResultFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiFunction extends AbiFunction & {
|
21
|
+
type: 'function';
|
22
|
+
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
|
23
|
+
type: 'function';
|
24
|
+
}, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['outputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
|
25
|
+
/**
|
26
|
+
* Arguments to pass contract method
|
27
|
+
*
|
28
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
29
|
+
*/
|
30
|
+
result?: readonly unknown[];
|
31
|
+
} : TArgs extends readonly [] ? {
|
32
|
+
result?: never;
|
33
|
+
} : {
|
34
|
+
/** Arguments to pass contract method */ result: TArgs;
|
35
|
+
};
|
20
36
|
|
21
37
|
declare function decodeAbi<TParams extends readonly AbiParameter[]>({ data, params, }: {
|
22
38
|
data: Hex;
|
@@ -50,6 +66,11 @@ declare function encodeFunctionData<TAbi extends Abi = Abi, TFunctionName extend
|
|
50
66
|
functionName: TFunctionName;
|
51
67
|
} & ExtractArgsFromAbi<TAbi, TFunctionName>): `0x${string}`;
|
52
68
|
|
69
|
+
declare function encodeFunctionResult<TAbi extends Abi = Abi, TFunctionName extends ExtractAbiFunctionNames<TAbi> = any>({ abi, functionName, result, }: {
|
70
|
+
abi: TAbi;
|
71
|
+
functionName: TFunctionName;
|
72
|
+
} & ExtractResultFromAbi<TAbi, TFunctionName>): `0x${string}`;
|
73
|
+
|
53
74
|
declare function getAddress(address: Address): `0x${string}`;
|
54
75
|
|
55
76
|
type GetCreateAddressOptions = {
|
@@ -251,4 +272,4 @@ declare function parseEther(ether: `${number}`, unit?: 'wei' | 'gwei'): bigint;
|
|
251
272
|
|
252
273
|
declare function parseGwei(ether: `${number}`, unit?: 'wei'): bigint;
|
253
274
|
|
254
|
-
export {
|
275
|
+
export { sliceHex as $, getFunctionSignature as A, formatEther as B, isAddress as C, isAddressEqual as D, EncodeRlpResponse as E, isBytes as F, GetContractAddressOptions as G, isHex as H, hexToBigInt as I, hexToBool as J, hexToBytes as K, hexToString as L, keccak256 as M, numberToBytes as N, pad as O, padBytes as P, padHex as Q, parseEther as R, parseGwei as S, parseUnit as T, formatGwei as U, formatUnit as V, hexToNumber as W, numberToHex as X, size as Y, slice as Z, sliceBytes as _, GetCreateAddressOptions as a, stringToBytes as a0, stringToHex as a1, trim as a2, 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, encodeFunctionResult as s, encodeHex as t, encodeRlp as u, getAddress as v, getContractAddress as w, getCreateAddress as x, getCreate2Address as y, getEventSignature 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 decodeFunctionResult, n as decodeHex, o as decodeRlp, p as encodeAbi, q as encodeBytes, r as encodeFunctionData, s 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 encodeFunctionResult, t as encodeHex, u as encodeRlp, B as formatEther, U as formatGwei, V as formatUnit, v as getAddress, w as getContractAddress, y as getCreate2Address, x as getCreateAddress, z as getEventSignature, A as getFunctionSignature, I as hexToBigInt, J as hexToBool, K as hexToBytes, W as hexToNumber, L as hexToString, C as isAddress, D as isAddressEqual, F as isBytes, H as isHex, M as keccak256, N as numberToBytes, X as numberToHex, O as pad, P as padBytes, Q as padHex, R as parseEther, S as parseGwei, T as parseUnit, Y as size, Z as slice, _ as sliceBytes, $ as sliceHex, a0 as stringToBytes, a1 as stringToHex, a2 as trim } from '../parseGwei-f454ca76.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
@@ -15,6 +15,7 @@ import {
|
|
15
15
|
encodeAbi,
|
16
16
|
encodeBytes,
|
17
17
|
encodeFunctionData,
|
18
|
+
encodeFunctionResult,
|
18
19
|
encodeHex,
|
19
20
|
encodeRlp,
|
20
21
|
extractFunctionName,
|
@@ -58,11 +59,11 @@ import {
|
|
58
59
|
stringToBytes,
|
59
60
|
stringToHex,
|
60
61
|
trim
|
61
|
-
} from "../chunk-
|
62
|
+
} from "../chunk-LM2GVIJG.js";
|
62
63
|
import {
|
63
64
|
buildRequest,
|
64
65
|
rpc
|
65
|
-
} from "../chunk-
|
66
|
+
} from "../chunk-J7TAHE5G.js";
|
66
67
|
export {
|
67
68
|
boolToBytes,
|
68
69
|
boolToHex,
|
@@ -81,6 +82,7 @@ export {
|
|
81
82
|
encodeAbi,
|
82
83
|
encodeBytes,
|
83
84
|
encodeFunctionData,
|
85
|
+
encodeFunctionResult,
|
84
86
|
encodeHex,
|
85
87
|
encodeRlp,
|
86
88
|
extractFunctionName,
|