viem 0.2.2 → 0.2.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/abi.js +2 -2
- package/dist/abi.mjs +1 -1
- package/dist/accounts/index.js +17 -17
- package/dist/accounts/index.mjs +2 -2
- package/dist/chains.js +89 -89
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-EP6BQLGR.js → chunk-NNNKKACJ.js} +6 -6
- package/dist/{chunk-IGFTD4HW.js → chunk-QISMTRQF.js} +22 -17
- package/dist/chunk-QISMTRQF.js.map +1 -0
- package/dist/{chunk-ZXUGY7ZA.mjs → chunk-VOEF3A53.mjs} +2 -2
- package/dist/{chunk-GJGV3W5S.mjs → chunk-ZEA2O6V2.mjs} +22 -17
- package/dist/chunk-ZEA2O6V2.mjs.map +1 -0
- package/dist/contract.d.ts +1 -1
- package/dist/contract.js +2 -2
- package/dist/contract.mjs +1 -1
- package/dist/ens.d.ts +1 -1
- package/dist/ens.js +2 -2
- package/dist/ens.mjs +1 -1
- package/dist/ethers.js +4 -4
- package/dist/ethers.mjs +2 -2
- package/dist/{getEnsResolver-9e26c596.d.ts → getEnsResolver-ce85735b.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +94 -94
- package/dist/index.mjs +1 -1
- package/dist/{parseGwei-d2147f8b.d.ts → parseGwei-280a3ff7.d.ts} +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/public.js +2 -2
- package/dist/public.mjs +1 -1
- package/dist/test.js +2 -2
- package/dist/test.mjs +1 -1
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/wallet.d.ts +1 -1
- package/dist/wallet.js +2 -2
- package/dist/wallet.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-GJGV3W5S.mjs.map +0 -1
- package/dist/chunk-IGFTD4HW.js.map +0 -1
- /package/dist/{chunk-EP6BQLGR.js.map → chunk-NNNKKACJ.js.map} +0 -0
- /package/dist/{chunk-ZXUGY7ZA.mjs.map → chunk-VOEF3A53.mjs.map} +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
InvalidAddressError,
|
3
3
|
isAddress
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-ZEA2O6V2.mjs";
|
5
5
|
|
6
6
|
// src/accounts/toAccount.ts
|
7
7
|
function toAccount(source) {
|
@@ -28,4 +28,4 @@ function toAccount(source) {
|
|
28
28
|
export {
|
29
29
|
toAccount
|
30
30
|
};
|
31
|
-
//# sourceMappingURL=chunk-
|
31
|
+
//# sourceMappingURL=chunk-VOEF3A53.mjs.map
|
@@ -20,7 +20,7 @@ import "abitype";
|
|
20
20
|
var package_default = {
|
21
21
|
name: "viem",
|
22
22
|
description: "TypeScript Interface for Ethereum",
|
23
|
-
version: "0.2.
|
23
|
+
version: "0.2.4",
|
24
24
|
scripts: {
|
25
25
|
anvil: "dotenv -- sh -c 'anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME'",
|
26
26
|
bench: "vitest bench --no-threads",
|
@@ -1657,6 +1657,15 @@ var UrlRequiredError = class extends BaseError {
|
|
1657
1657
|
}
|
1658
1658
|
};
|
1659
1659
|
|
1660
|
+
// src/utils/data/isHex.ts
|
1661
|
+
function isHex(value) {
|
1662
|
+
if (!value)
|
1663
|
+
return false;
|
1664
|
+
if (typeof value !== "string")
|
1665
|
+
return false;
|
1666
|
+
return /^0x[0-9a-fA-F]*$/.test(value);
|
1667
|
+
}
|
1668
|
+
|
1660
1669
|
// src/utils/data/concat.ts
|
1661
1670
|
function concat(values) {
|
1662
1671
|
if (typeof values[0] === "string")
|
@@ -1694,15 +1703,6 @@ function isBytes(value) {
|
|
1694
1703
|
return value.BYTES_PER_ELEMENT === 1 && value.constructor.name === "Uint8Array";
|
1695
1704
|
}
|
1696
1705
|
|
1697
|
-
// src/utils/data/isHex.ts
|
1698
|
-
function isHex(value) {
|
1699
|
-
if (!value)
|
1700
|
-
return false;
|
1701
|
-
if (typeof value !== "string")
|
1702
|
-
return false;
|
1703
|
-
return /^0x[0-9a-fA-F]*$/.test(value);
|
1704
|
-
}
|
1705
|
-
|
1706
1706
|
// src/utils/data/pad.ts
|
1707
1707
|
function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
|
1708
1708
|
if (typeof hexOrBytes === "string")
|
@@ -1857,7 +1857,7 @@ function toBytes(value) {
|
|
1857
1857
|
return numberToBytes(value);
|
1858
1858
|
if (typeof value === "boolean")
|
1859
1859
|
return boolToBytes(value);
|
1860
|
-
if (value
|
1860
|
+
if (isHex(value))
|
1861
1861
|
return hexToBytes(value);
|
1862
1862
|
return stringToBytes(value);
|
1863
1863
|
}
|
@@ -2118,7 +2118,7 @@ var getFunctionSelector = (fn) => slice(hashFunction(fn), 0, 4);
|
|
2118
2118
|
|
2119
2119
|
// src/utils/hash/isHash.ts
|
2120
2120
|
function isHash(hash2) {
|
2121
|
-
return hash2
|
2121
|
+
return isHex(hash2) && size(hash2) === 32;
|
2122
2122
|
}
|
2123
2123
|
|
2124
2124
|
// src/utils/address/isAddress.ts
|
@@ -4286,7 +4286,7 @@ function packetToBytes(packet) {
|
|
4286
4286
|
function length(value2) {
|
4287
4287
|
if (value2 === "." || value2 === "..")
|
4288
4288
|
return 1;
|
4289
|
-
return
|
4289
|
+
return stringToBytes(value2.replace(/^\.|\.$/gm, "")).length + 2;
|
4290
4290
|
}
|
4291
4291
|
const bytes = new Uint8Array(length(packet));
|
4292
4292
|
const value = packet.replace(/^\.|\.$/gm, "");
|
@@ -4295,7 +4295,7 @@ function packetToBytes(packet) {
|
|
4295
4295
|
let offset = 0;
|
4296
4296
|
const list = value.split(".");
|
4297
4297
|
for (let i = 0; i < list.length; i++) {
|
4298
|
-
const encoded =
|
4298
|
+
const encoded = stringToBytes(list[i]);
|
4299
4299
|
bytes[offset] = encoded.length;
|
4300
4300
|
bytes.set(encoded, offset + 1);
|
4301
4301
|
offset += encoded.length + 1;
|
@@ -5614,11 +5614,14 @@ async function getEnsAddress(client, {
|
|
5614
5614
|
blockNumber,
|
5615
5615
|
blockTag
|
5616
5616
|
});
|
5617
|
-
|
5617
|
+
if (res[0] === "0x")
|
5618
|
+
return null;
|
5619
|
+
const address = decodeFunctionResult({
|
5618
5620
|
abi: singleAddressResolverAbi,
|
5619
5621
|
functionName: "addr",
|
5620
5622
|
data: res[0]
|
5621
5623
|
});
|
5624
|
+
return trim(address) === "0x0" ? null : address;
|
5622
5625
|
}
|
5623
5626
|
|
5624
5627
|
// src/actions/ens/getEnsText.ts
|
@@ -5656,6 +5659,8 @@ async function getEnsText(client, {
|
|
5656
5659
|
blockNumber,
|
5657
5660
|
blockTag
|
5658
5661
|
});
|
5662
|
+
if (res[0] === "0x")
|
5663
|
+
return null;
|
5659
5664
|
const record = decodeFunctionResult({
|
5660
5665
|
abi: textResolverAbi,
|
5661
5666
|
functionName: "text",
|
@@ -7015,11 +7020,11 @@ export {
|
|
7015
7020
|
RpcError,
|
7016
7021
|
TimeoutError,
|
7017
7022
|
UrlRequiredError,
|
7023
|
+
isHex,
|
7018
7024
|
concat,
|
7019
7025
|
concatBytes,
|
7020
7026
|
concatHex,
|
7021
7027
|
isBytes,
|
7022
|
-
isHex,
|
7023
7028
|
pad,
|
7024
7029
|
padHex,
|
7025
7030
|
padBytes,
|
@@ -7219,4 +7224,4 @@ export {
|
|
7219
7224
|
writeContract,
|
7220
7225
|
getContract
|
7221
7226
|
};
|
7222
|
-
//# sourceMappingURL=chunk-
|
7227
|
+
//# sourceMappingURL=chunk-ZEA2O6V2.mjs.map
|