viem 0.0.1-alpha.27 → 0.0.1-alpha.29
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/chain-4d46a747.d.ts +543 -0
- package/dist/{chain-b0cfb141.d.ts → chain-c7c44165.d.ts} +1 -1
- package/dist/chains.d.ts +5 -3
- package/dist/chains.js +46 -46
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-JY7JGKSA.js → chunk-4VQKZYE2.js} +219 -157
- package/dist/chunk-4VQKZYE2.js.map +1 -0
- package/dist/{chunk-2DSFM32P.js → chunk-CKYH337I.js} +15 -15
- package/dist/{chunk-2DSFM32P.js.map → chunk-CKYH337I.js.map} +1 -1
- package/dist/{chunk-W7KWIGWO.js → chunk-EYORBAD4.js} +45 -44
- package/dist/chunk-EYORBAD4.js.map +1 -0
- package/dist/{chunk-LF6P33WQ.mjs → chunk-HPUQL3IM.mjs} +3 -3
- package/dist/chunk-HPUQL3IM.mjs.map +1 -0
- package/dist/chunk-OJ7H3CQF.js +265 -0
- package/dist/chunk-OJ7H3CQF.js.map +1 -0
- package/dist/chunk-Q67VUTW3.mjs +210 -0
- package/dist/chunk-Q67VUTW3.mjs.map +1 -0
- package/dist/{chunk-AKGXRZDN.mjs → chunk-RR4MGS6O.mjs} +27 -26
- package/dist/chunk-RR4MGS6O.mjs.map +1 -0
- package/dist/chunk-S252SZEL.mjs +265 -0
- package/dist/chunk-S252SZEL.mjs.map +1 -0
- package/dist/chunk-SEIPUKZE.js +210 -0
- package/dist/chunk-SEIPUKZE.js.map +1 -0
- package/dist/{chunk-BJJH7RYH.mjs → chunk-TQC7KZ24.mjs} +164 -102
- package/dist/chunk-TQC7KZ24.mjs.map +1 -0
- package/dist/contract.d.ts +12 -128
- package/dist/contract.js +6 -4
- package/dist/contract.mjs +5 -3
- package/dist/{createClient-6689596e.d.ts → createClient-5d5c14d6.d.ts} +5 -3
- package/dist/createPublicClient-2b4afeac.d.ts +629 -0
- package/dist/{eip1193-617a05ae.d.ts → eip1193-f09a55af.d.ts} +2 -2
- package/dist/ens.d.ts +10 -68
- package/dist/ens.js +5 -199
- package/dist/ens.js.map +1 -1
- package/dist/ens.mjs +7 -201
- package/dist/ens.mjs.map +1 -1
- package/dist/formatAbiItem-d231fef2.d.ts +14 -0
- package/dist/{getAbiItem-d2e8bd76.d.ts → getAbiItem-0e085959.d.ts} +15 -15
- package/dist/index.d.ts +22 -13
- package/dist/index.js +368 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +358 -16
- package/dist/index.mjs.map +1 -1
- package/dist/namehash-88f4639d.d.ts +22 -0
- package/dist/parseGwei-4d0b0d73.d.ts +344 -0
- package/dist/public.d.ts +11 -334
- package/dist/public.js +5 -3
- package/dist/public.mjs +4 -2
- package/dist/test-b9208949.d.ts +213 -0
- package/dist/test.d.ts +8 -149
- package/dist/test.js +20 -222
- package/dist/test.js.map +1 -1
- package/dist/test.mjs +30 -232
- package/dist/test.mjs.map +1 -1
- package/dist/{transactionReceipt-44dbf122.d.ts → transactionReceipt-84fc92e1.d.ts} +1 -1
- package/dist/{transactionRequest-f437b4ba.d.ts → transactionRequest-44c539b4.d.ts} +1 -1
- package/dist/utils/index.d.ts +12 -238
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/wallet-9b1c6905.d.ts +104 -0
- package/dist/wallet.d.ts +7 -41
- package/dist/wallet.js +3 -3
- package/dist/wallet.mjs +2 -2
- package/dist/window.d.ts +4 -2
- package/package.json +1 -1
- package/dist/call-3476b8ee.d.ts +0 -22
- package/dist/chain-42de87e5.d.ts +0 -359
- package/dist/chunk-AKGXRZDN.mjs.map +0 -1
- package/dist/chunk-BJJH7RYH.mjs.map +0 -1
- package/dist/chunk-JY7JGKSA.js.map +0 -1
- package/dist/chunk-LF6P33WQ.mjs.map +0 -1
- package/dist/chunk-W7KWIGWO.js.map +0 -1
- package/dist/contract-9dd2f98b.d.ts +0 -166
- package/dist/createPublicClient-fd558574.d.ts +0 -19
- package/dist/createTestClient-bc1d9028.d.ts +0 -34
- package/dist/createWalletClient-4df88244.d.ts +0 -30
- package/dist/decodeErrorResult-ac835649.d.ts +0 -16
- package/dist/readContract-c460f23a.d.ts +0 -10
- package/dist/rpc-8c10fc98.d.ts +0 -119
- package/dist/sendTransaction-7ce442c0.d.ts +0 -12
- package/dist/watchEvent-569c9976.d.ts +0 -41
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
|
|
9
9
|
var package_default = {
|
10
10
|
name: "viem",
|
11
11
|
description: "TypeScript Interface for Ethereum",
|
12
|
-
version: "0.0.1-alpha.
|
12
|
+
version: "0.0.1-alpha.29",
|
13
13
|
scripts: {
|
14
14
|
anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
15
15
|
bench: "vitest bench --no-threads",
|
@@ -1051,6 +1051,8 @@ function isBytes(value) {
|
|
1051
1051
|
return false;
|
1052
1052
|
if (typeof value !== "object")
|
1053
1053
|
return false;
|
1054
|
+
if (!("BYTES_PER_ELEMENT" in value))
|
1055
|
+
return false;
|
1054
1056
|
return value.BYTES_PER_ELEMENT === 1 && value.constructor.name === "Uint8Array";
|
1055
1057
|
}
|
1056
1058
|
|
@@ -1502,14 +1504,19 @@ var getEventSignature = (event) => hashFunction(event);
|
|
1502
1504
|
// src/utils/hash/getFunctionSignature.ts
|
1503
1505
|
var getFunctionSignature = (fn) => slice(hashFunction(fn), 0, 4);
|
1504
1506
|
|
1507
|
+
// src/utils/address/isAddress.ts
|
1508
|
+
var addressRegex = /^0x[a-fA-F0-9]{40}$/;
|
1509
|
+
function isAddress(address) {
|
1510
|
+
return addressRegex.test(address);
|
1511
|
+
}
|
1512
|
+
|
1505
1513
|
// src/utils/address/getAddress.ts
|
1506
|
-
var addressRegex = /^(0x)?[a-fA-F0-9]{40}$/;
|
1507
1514
|
function checksumAddress(address_) {
|
1508
1515
|
const hexAddress = address_.substring(2).toLowerCase();
|
1509
1516
|
const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
|
1510
1517
|
let address = hexAddress.split("");
|
1511
1518
|
for (let i = 0; i < 40; i += 2) {
|
1512
|
-
if (hash2
|
1519
|
+
if (hash2[i >> 1] >> 4 >= 8 && address[i]) {
|
1513
1520
|
address[i] = address[i].toUpperCase();
|
1514
1521
|
}
|
1515
1522
|
if ((hash2[i >> 1] & 15) >= 8 && address[i + 1]) {
|
@@ -1519,7 +1526,7 @@ function checksumAddress(address_) {
|
|
1519
1526
|
return `0x${address.join("")}`;
|
1520
1527
|
}
|
1521
1528
|
function getAddress(address) {
|
1522
|
-
if (!
|
1529
|
+
if (!isAddress(address))
|
1523
1530
|
throw new InvalidAddressError({ address });
|
1524
1531
|
return checksumAddress(address);
|
1525
1532
|
}
|
@@ -1554,18 +1561,13 @@ function getCreate2Address(opts) {
|
|
1554
1561
|
);
|
1555
1562
|
}
|
1556
1563
|
|
1557
|
-
// src/utils/address/isAddress.ts
|
1558
|
-
function isAddress(address) {
|
1559
|
-
try {
|
1560
|
-
return Boolean(getAddress(address));
|
1561
|
-
} catch {
|
1562
|
-
return false;
|
1563
|
-
}
|
1564
|
-
}
|
1565
|
-
|
1566
1564
|
// src/utils/address/isAddressEqual.ts
|
1567
1565
|
function isAddressEqual(a, b) {
|
1568
|
-
|
1566
|
+
if (!isAddress(a))
|
1567
|
+
throw new InvalidAddressError({ address: a });
|
1568
|
+
if (!isAddress(b))
|
1569
|
+
throw new InvalidAddressError({ address: b });
|
1570
|
+
return a.toLowerCase() === b.toLowerCase();
|
1569
1571
|
}
|
1570
1572
|
|
1571
1573
|
// src/utils/abi/encodeAbi.ts
|
@@ -2027,7 +2029,7 @@ function decodeEventLog({
|
|
2027
2029
|
args[param.name || i] = decodeTopic({ param, value: topic });
|
2028
2030
|
}
|
2029
2031
|
}
|
2030
|
-
if (data) {
|
2032
|
+
if (data && data !== "0x") {
|
2031
2033
|
const params = inputs.filter((x) => !("indexed" in x && x.indexed));
|
2032
2034
|
const decodedData = decodeAbi({ params, data });
|
2033
2035
|
if (decodedData) {
|
@@ -2409,13 +2411,11 @@ function withTimeout(fn, {
|
|
2409
2411
|
|
2410
2412
|
// src/utils/buildRequest.ts
|
2411
2413
|
var isDeterministicError = (error) => {
|
2412
|
-
if (error instanceof UnknownRpcError)
|
2413
|
-
return false;
|
2414
2414
|
if ("code" in error)
|
2415
2415
|
return error.code !== -32603 && error.code !== -32005;
|
2416
2416
|
if (error instanceof HttpRequestError && error.status)
|
2417
|
-
return error.status !== 408 && error.status !== 413 && error.status !== 429 && error.status !== 500;
|
2418
|
-
return
|
2417
|
+
return error.status !== 408 && error.status !== 413 && error.status !== 429 && error.status !== 500 && error.status !== 502 && error.status !== 503 && error.status !== 504;
|
2418
|
+
return false;
|
2419
2419
|
};
|
2420
2420
|
function buildRequest(request, {
|
2421
2421
|
retryDelay = 150,
|
@@ -2582,12 +2582,13 @@ function formatFeeHistory(feeHistory) {
|
|
2582
2582
|
}
|
2583
2583
|
|
2584
2584
|
// src/utils/formatters/log.ts
|
2585
|
-
function formatLog(log) {
|
2585
|
+
function formatLog(log, { args, eventName } = {}) {
|
2586
2586
|
return {
|
2587
2587
|
...log,
|
2588
2588
|
blockNumber: log.blockNumber ? BigInt(log.blockNumber) : null,
|
2589
2589
|
logIndex: log.logIndex ? BigInt(log.logIndex) : null,
|
2590
|
-
transactionIndex: log.transactionIndex ? BigInt(log.transactionIndex) : null
|
2590
|
+
transactionIndex: log.transactionIndex ? BigInt(log.transactionIndex) : null,
|
2591
|
+
...eventName ? { args, eventName } : {}
|
2591
2592
|
};
|
2592
2593
|
}
|
2593
2594
|
|
@@ -2603,7 +2604,7 @@ function formatTransactionReceipt(transactionReceipt) {
|
|
2603
2604
|
cumulativeGasUsed: transactionReceipt.cumulativeGasUsed ? BigInt(transactionReceipt.cumulativeGasUsed) : null,
|
2604
2605
|
effectiveGasPrice: transactionReceipt.effectiveGasPrice ? BigInt(transactionReceipt.effectiveGasPrice) : null,
|
2605
2606
|
gasUsed: transactionReceipt.gasUsed ? BigInt(transactionReceipt.gasUsed) : null,
|
2606
|
-
logs: transactionReceipt.logs ? transactionReceipt.logs.map(formatLog) : null,
|
2607
|
+
logs: transactionReceipt.logs ? transactionReceipt.logs.map((log) => formatLog(log)) : null,
|
2607
2608
|
transactionIndex: transactionReceipt.transactionIndex ? hexToNumber(transactionReceipt.transactionIndex) : null,
|
2608
2609
|
status: transactionReceipt.status ? statuses[transactionReceipt.status] : null,
|
2609
2610
|
type: transactionReceipt.type ? transactionType[transactionReceipt.type] : null
|
@@ -2644,7 +2645,7 @@ function stringify(value) {
|
|
2644
2645
|
var id = 0;
|
2645
2646
|
async function http(url, {
|
2646
2647
|
body,
|
2647
|
-
timeout =
|
2648
|
+
timeout = 1e4
|
2648
2649
|
}) {
|
2649
2650
|
try {
|
2650
2651
|
const response = await withTimeout(
|
@@ -2775,7 +2776,7 @@ function webSocket(socket, {
|
|
2775
2776
|
}
|
2776
2777
|
async function webSocketAsync(socket, {
|
2777
2778
|
body,
|
2778
|
-
timeout =
|
2779
|
+
timeout = 1e4
|
2779
2780
|
}) {
|
2780
2781
|
return withTimeout(
|
2781
2782
|
() => new Promise(
|
@@ -2969,12 +2970,12 @@ export {
|
|
2969
2970
|
keccak256,
|
2970
2971
|
getEventSignature,
|
2971
2972
|
getFunctionSignature,
|
2973
|
+
isAddress,
|
2972
2974
|
checksumAddress,
|
2973
2975
|
getAddress,
|
2974
2976
|
getContractAddress2 as getContractAddress,
|
2975
2977
|
getCreateAddress,
|
2976
2978
|
getCreate2Address,
|
2977
|
-
isAddress,
|
2978
2979
|
isAddressEqual,
|
2979
2980
|
encodeAbi,
|
2980
2981
|
decodeAbi,
|
@@ -3023,4 +3024,4 @@ export {
|
|
3023
3024
|
parseEther,
|
3024
3025
|
parseGwei
|
3025
3026
|
};
|
3026
|
-
//# sourceMappingURL=chunk-
|
3027
|
+
//# sourceMappingURL=chunk-RR4MGS6O.mjs.map
|