viem 0.0.1-alpha.31 → 0.0.1-alpha.32
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/chains.js +46 -46
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-NCPBWOQA.js → chunk-4TDJALZ6.js} +75 -75
- package/dist/{chunk-J7QHQ26Y.js → chunk-DEF2SWG2.js} +36 -10
- package/dist/chunk-DEF2SWG2.js.map +1 -0
- package/dist/{chunk-IBWRBL2I.mjs → chunk-HJBIOX2W.mjs} +2 -2
- package/dist/{chunk-UUULPQHV.js → chunk-K3Q7U5IY.js} +15 -15
- package/dist/{chunk-MYFKW55L.js → chunk-NZUM6QVJ.js} +22 -22
- package/dist/{chunk-6ZFIUYGC.mjs → chunk-P76FCR36.mjs} +35 -9
- package/dist/chunk-P76FCR36.mjs.map +1 -0
- package/dist/{chunk-QBB3DFIB.mjs → chunk-QPXAI2W5.mjs} +2 -2
- package/dist/{chunk-5STAX3WF.js → chunk-S3HZ74MN.js} +14 -14
- package/dist/{chunk-C54QK7K3.mjs → chunk-ZIH5V7HU.mjs} +3 -3
- package/dist/{chunk-APXHGB76.mjs → chunk-ZZWYDER3.mjs} +2 -2
- package/dist/contract.d.ts +1 -1
- package/dist/contract.js +4 -4
- package/dist/contract.mjs +3 -3
- package/dist/{createPublicClient-99be385b.d.ts → createPublicClient-2187596f.d.ts} +1 -1
- package/dist/ens.d.ts +1 -1
- package/dist/ens.js +4 -4
- package/dist/ens.mjs +3 -3
- package/dist/index.d.ts +14 -4
- package/dist/index.js +95 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{parseGwei-8af7a0a6.d.ts → parseGwei-308eada9.d.ts} +2 -2
- package/dist/public.d.ts +2 -2
- package/dist/public.js +3 -3
- package/dist/public.mjs +2 -2
- package/dist/test.js +3 -3
- package/dist/test.mjs +2 -2
- 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.js +3 -3
- package/dist/wallet.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-6ZFIUYGC.mjs.map +0 -1
- package/dist/chunk-J7QHQ26Y.js.map +0 -1
- /package/dist/{chunk-NCPBWOQA.js.map → chunk-4TDJALZ6.js.map} +0 -0
- /package/dist/{chunk-IBWRBL2I.mjs.map → chunk-HJBIOX2W.mjs.map} +0 -0
- /package/dist/{chunk-UUULPQHV.js.map → chunk-K3Q7U5IY.js.map} +0 -0
- /package/dist/{chunk-MYFKW55L.js.map → chunk-NZUM6QVJ.js.map} +0 -0
- /package/dist/{chunk-QBB3DFIB.mjs.map → chunk-QPXAI2W5.mjs.map} +0 -0
- /package/dist/{chunk-5STAX3WF.js.map → chunk-S3HZ74MN.js.map} +0 -0
- /package/dist/{chunk-C54QK7K3.mjs.map → chunk-ZIH5V7HU.mjs.map} +0 -0
- /package/dist/{chunk-APXHGB76.mjs.map → chunk-ZZWYDER3.mjs.map} +0 -0
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
|
14
|
-
var
|
14
|
+
var _chunkDEF2SWG2js = require('./chunk-DEF2SWG2.js');
|
15
15
|
|
16
16
|
// src/actions/wallet/addChain.ts
|
17
17
|
async function addChain(client, { chain }) {
|
@@ -20,7 +20,7 @@ async function addChain(client, { chain }) {
|
|
20
20
|
method: "wallet_addEthereumChain",
|
21
21
|
params: [
|
22
22
|
{
|
23
|
-
chainId:
|
23
|
+
chainId: _chunkDEF2SWG2js.numberToHex.call(void 0, id),
|
24
24
|
chainName: name,
|
25
25
|
nativeCurrency,
|
26
26
|
rpcUrls: rpcUrls.default.http,
|
@@ -33,7 +33,7 @@ async function addChain(client, { chain }) {
|
|
33
33
|
// src/actions/wallet/getAccounts.ts
|
34
34
|
async function getAccounts(client) {
|
35
35
|
const addresses = await client.request({ method: "eth_accounts" });
|
36
|
-
return addresses.map((address) =>
|
36
|
+
return addresses.map((address) => _chunkDEF2SWG2js.checksumAddress.call(void 0, address));
|
37
37
|
}
|
38
38
|
|
39
39
|
// src/actions/wallet/getPermissions.ts
|
@@ -45,7 +45,7 @@ async function getPermissions(client) {
|
|
45
45
|
// src/actions/wallet/requestAccounts.ts
|
46
46
|
async function requestAccounts(client) {
|
47
47
|
const addresses = await client.request({ method: "eth_requestAccounts" });
|
48
|
-
return addresses.map((address) =>
|
48
|
+
return addresses.map((address) => _chunkDEF2SWG2js.getAddress.call(void 0, address));
|
49
49
|
}
|
50
50
|
|
51
51
|
// src/actions/wallet/requestPermissions.ts
|
@@ -73,9 +73,9 @@ async function sendTransaction(client, args) {
|
|
73
73
|
...rest
|
74
74
|
} = args;
|
75
75
|
try {
|
76
|
-
|
76
|
+
_chunkDEF2SWG2js.assertRequest.call(void 0, args);
|
77
77
|
const formatter = _optionalChain([chain, 'optionalAccess', _ => _.formatters, 'optionalAccess', _2 => _2.transactionRequest]);
|
78
|
-
const request_ =
|
78
|
+
const request_ = _chunkDEF2SWG2js.format.call(void 0,
|
79
79
|
{
|
80
80
|
from,
|
81
81
|
accessList,
|
@@ -88,10 +88,10 @@ async function sendTransaction(client, args) {
|
|
88
88
|
to,
|
89
89
|
value,
|
90
90
|
// Pick out extra data that might exist on the chain's transaction request type.
|
91
|
-
...
|
91
|
+
..._chunkDEF2SWG2js.extract.call(void 0, rest, { formatter })
|
92
92
|
},
|
93
93
|
{
|
94
|
-
formatter: formatter ||
|
94
|
+
formatter: formatter || _chunkDEF2SWG2js.formatTransactionRequest
|
95
95
|
}
|
96
96
|
);
|
97
97
|
const hash = await client.request({
|
@@ -100,7 +100,7 @@ async function sendTransaction(client, args) {
|
|
100
100
|
});
|
101
101
|
return hash;
|
102
102
|
} catch (err) {
|
103
|
-
throw
|
103
|
+
throw _chunkDEF2SWG2js.getTransactionError.call(void 0, err, args);
|
104
104
|
}
|
105
105
|
}
|
106
106
|
|
@@ -109,7 +109,7 @@ async function signMessage(client, { from, data: data_ }) {
|
|
109
109
|
let data;
|
110
110
|
if (typeof data_ === "string") {
|
111
111
|
if (!data_.startsWith("0x"))
|
112
|
-
throw new (0,
|
112
|
+
throw new (0, _chunkDEF2SWG2js.BaseError)(
|
113
113
|
`data ("${data_}") must be a hex value. Encode it first to a hex with the \`toHex\` util.`,
|
114
114
|
{
|
115
115
|
docsPath: "/TODO"
|
@@ -117,7 +117,7 @@ async function signMessage(client, { from, data: data_ }) {
|
|
117
117
|
);
|
118
118
|
data = data_;
|
119
119
|
} else {
|
120
|
-
data =
|
120
|
+
data = _chunkDEF2SWG2js.toHex.call(void 0, data_);
|
121
121
|
}
|
122
122
|
const signed = await client.request({
|
123
123
|
method: "personal_sign",
|
@@ -132,7 +132,7 @@ async function switchChain(client, { id }) {
|
|
132
132
|
method: "wallet_switchEthereumChain",
|
133
133
|
params: [
|
134
134
|
{
|
135
|
-
chainId:
|
135
|
+
chainId: _chunkDEF2SWG2js.numberToHex.call(void 0, id)
|
136
136
|
}
|
137
137
|
]
|
138
138
|
});
|
@@ -155,7 +155,7 @@ async function writeContract(client, {
|
|
155
155
|
functionName,
|
156
156
|
...request
|
157
157
|
}) {
|
158
|
-
const data =
|
158
|
+
const data = _chunkDEF2SWG2js.encodeFunctionData.call(void 0, {
|
159
159
|
abi,
|
160
160
|
args,
|
161
161
|
functionName
|
@@ -170,7 +170,7 @@ async function writeContract(client, {
|
|
170
170
|
|
171
171
|
// src/actions/wallet/deployContract.ts
|
172
172
|
function deployContract(walletClient, { abi, args, bytecode, ...request }) {
|
173
|
-
const calldata =
|
173
|
+
const calldata = _chunkDEF2SWG2js.encodeDeployData.call(void 0, {
|
174
174
|
abi,
|
175
175
|
args,
|
176
176
|
bytecode
|
@@ -194,4 +194,4 @@ function deployContract(walletClient, { abi, args, bytecode, ...request }) {
|
|
194
194
|
|
195
195
|
|
196
196
|
exports.addChain = addChain; exports.deployContract = deployContract; exports.getAccounts = getAccounts; exports.getPermissions = getPermissions; exports.requestAccounts = requestAccounts; exports.requestPermissions = requestPermissions; exports.sendTransaction = sendTransaction; exports.signMessage = signMessage; exports.switchChain = switchChain; exports.watchAsset = watchAsset; exports.writeContract = writeContract;
|
197
|
-
//# sourceMappingURL=chunk-
|
197
|
+
//# sourceMappingURL=chunk-K3Q7U5IY.js.map
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
2
2
|
|
3
|
-
var
|
3
|
+
var _chunk4TDJALZ6js = require('./chunk-4TDJALZ6.js');
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -13,27 +13,27 @@ var _chunkNCPBWOQAjs = require('./chunk-NCPBWOQA.js');
|
|
13
13
|
|
14
14
|
|
15
15
|
|
16
|
-
var
|
16
|
+
var _chunkDEF2SWG2js = require('./chunk-DEF2SWG2.js');
|
17
17
|
|
18
18
|
// src/utils/ens/labelhash.ts
|
19
19
|
function labelhash(label) {
|
20
20
|
let result = new Uint8Array(32).fill(0);
|
21
21
|
if (!label)
|
22
|
-
return
|
23
|
-
return
|
22
|
+
return _chunkDEF2SWG2js.bytesToHex.call(void 0, result);
|
23
|
+
return _chunkDEF2SWG2js.keccak256.call(void 0, _chunkDEF2SWG2js.stringToBytes.call(void 0, label));
|
24
24
|
}
|
25
25
|
|
26
26
|
// src/utils/ens/namehash.ts
|
27
27
|
function namehash(name) {
|
28
28
|
let result = new Uint8Array(32).fill(0);
|
29
29
|
if (!name)
|
30
|
-
return
|
30
|
+
return _chunkDEF2SWG2js.bytesToHex.call(void 0, result);
|
31
31
|
const labels = name.split(".");
|
32
32
|
for (let i = labels.length - 1; i >= 0; i -= 1) {
|
33
|
-
const hashed =
|
34
|
-
result =
|
33
|
+
const hashed = _chunkDEF2SWG2js.keccak256.call(void 0, _chunkDEF2SWG2js.stringToBytes.call(void 0, labels[i]), "bytes");
|
34
|
+
result = _chunkDEF2SWG2js.keccak256.call(void 0, _chunkDEF2SWG2js.concat.call(void 0, [result, hashed]), "bytes");
|
35
35
|
}
|
36
|
-
return
|
36
|
+
return _chunkDEF2SWG2js.bytesToHex.call(void 0, result);
|
37
37
|
}
|
38
38
|
|
39
39
|
// src/utils/ens/packetToBytes.ts
|
@@ -41,7 +41,7 @@ function packetToBytes(packet) {
|
|
41
41
|
function length(value2) {
|
42
42
|
if (value2 === "." || value2 === "..")
|
43
43
|
return 1;
|
44
|
-
return
|
44
|
+
return _chunkDEF2SWG2js.toBytes.call(void 0, value2.replace(/^\.|\.$/gm, "")).length + 2;
|
45
45
|
}
|
46
46
|
const bytes = new Uint8Array(length(packet));
|
47
47
|
const value = packet.replace(/^\.|\.$/gm, "");
|
@@ -50,7 +50,7 @@ function packetToBytes(packet) {
|
|
50
50
|
let offset = 0;
|
51
51
|
const list = value.split(".");
|
52
52
|
for (let i = 0; i < list.length; i++) {
|
53
|
-
const encoded =
|
53
|
+
const encoded = _chunkDEF2SWG2js.toBytes.call(void 0, list[i]);
|
54
54
|
bytes[offset] = encoded.length;
|
55
55
|
bytes.set(encoded, offset + 1);
|
56
56
|
offset += encoded.length + 1;
|
@@ -73,12 +73,12 @@ async function getEnsAddress(client, {
|
|
73
73
|
);
|
74
74
|
const contract = _optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.contracts, 'optionalAccess', _3 => _3.ensUniversalResolver]);
|
75
75
|
if (!contract)
|
76
|
-
throw new (0,
|
76
|
+
throw new (0, _chunkDEF2SWG2js.ChainDoesNotSupportContract)({
|
77
77
|
chain: client.chain,
|
78
78
|
contract: { name: "ensUniversalResolver" }
|
79
79
|
});
|
80
80
|
if (blockNumber && contract.blockCreated && contract.blockCreated > blockNumber)
|
81
|
-
throw new (0,
|
81
|
+
throw new (0, _chunkDEF2SWG2js.ChainDoesNotSupportContract)({
|
82
82
|
blockNumber,
|
83
83
|
chain: client.chain,
|
84
84
|
contract: {
|
@@ -88,7 +88,7 @@ async function getEnsAddress(client, {
|
|
88
88
|
});
|
89
89
|
universalResolverAddress = contract.address;
|
90
90
|
}
|
91
|
-
const res = await
|
91
|
+
const res = await _chunk4TDJALZ6js.readContract.call(void 0, client, {
|
92
92
|
address: universalResolverAddress,
|
93
93
|
abi: [
|
94
94
|
{
|
@@ -107,8 +107,8 @@ async function getEnsAddress(client, {
|
|
107
107
|
],
|
108
108
|
functionName: "resolve",
|
109
109
|
args: [
|
110
|
-
|
111
|
-
|
110
|
+
_chunkDEF2SWG2js.toHex.call(void 0, packetToBytes(name)),
|
111
|
+
_chunkDEF2SWG2js.encodeFunctionData.call(void 0, {
|
112
112
|
abi: [
|
113
113
|
{
|
114
114
|
name: "addr",
|
@@ -125,7 +125,7 @@ async function getEnsAddress(client, {
|
|
125
125
|
blockNumber,
|
126
126
|
blockTag
|
127
127
|
});
|
128
|
-
return
|
128
|
+
return _chunkDEF2SWG2js.decodeFunctionResult.call(void 0, {
|
129
129
|
abi: [
|
130
130
|
{
|
131
131
|
name: "addr",
|
@@ -155,12 +155,12 @@ async function getEnsName(client, {
|
|
155
155
|
);
|
156
156
|
const contract = _optionalChain([client, 'access', _4 => _4.chain, 'optionalAccess', _5 => _5.contracts, 'optionalAccess', _6 => _6.ensUniversalResolver]);
|
157
157
|
if (!contract)
|
158
|
-
throw new (0,
|
158
|
+
throw new (0, _chunkDEF2SWG2js.ChainDoesNotSupportContract)({
|
159
159
|
chain: client.chain,
|
160
160
|
contract: { name: "ensUniversalResolver" }
|
161
161
|
});
|
162
162
|
if (blockNumber && contract.blockCreated && contract.blockCreated > blockNumber)
|
163
|
-
throw new (0,
|
163
|
+
throw new (0, _chunkDEF2SWG2js.ChainDoesNotSupportContract)({
|
164
164
|
blockNumber,
|
165
165
|
chain: client.chain,
|
166
166
|
contract: {
|
@@ -172,7 +172,7 @@ async function getEnsName(client, {
|
|
172
172
|
}
|
173
173
|
const reverseNode = `${address.toLowerCase().substring(2)}.addr.reverse`;
|
174
174
|
try {
|
175
|
-
const res = await
|
175
|
+
const res = await _chunk4TDJALZ6js.readContract.call(void 0, client, {
|
176
176
|
address: universalResolverAddress,
|
177
177
|
abi: [
|
178
178
|
{
|
@@ -189,13 +189,13 @@ async function getEnsName(client, {
|
|
189
189
|
}
|
190
190
|
],
|
191
191
|
functionName: "reverse",
|
192
|
-
args: [
|
192
|
+
args: [_chunkDEF2SWG2js.toHex.call(void 0, packetToBytes(reverseNode))],
|
193
193
|
blockNumber,
|
194
194
|
blockTag
|
195
195
|
});
|
196
196
|
return res[0];
|
197
197
|
} catch (error) {
|
198
|
-
if (error instanceof
|
198
|
+
if (error instanceof _chunkDEF2SWG2js.ContractFunctionExecutionError && error.cause.reason === _chunkDEF2SWG2js.panicReasons[50])
|
199
199
|
return null;
|
200
200
|
throw error;
|
201
201
|
}
|
@@ -207,4 +207,4 @@ async function getEnsName(client, {
|
|
207
207
|
|
208
208
|
|
209
209
|
exports.labelhash = labelhash; exports.namehash = namehash; exports.getEnsAddress = getEnsAddress; exports.getEnsName = getEnsName;
|
210
|
-
//# sourceMappingURL=chunk-
|
210
|
+
//# sourceMappingURL=chunk-NZUM6QVJ.js.map
|
@@ -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.32",
|
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",
|
@@ -1219,6 +1219,24 @@ var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
|
1219
1219
|
__publicField(this, "code", -32006);
|
1220
1220
|
}
|
1221
1221
|
};
|
1222
|
+
var UserRejectedRequestError = class extends RpcRequestError {
|
1223
|
+
constructor(err) {
|
1224
|
+
super(err, {
|
1225
|
+
shortMessage: "User rejected the request."
|
1226
|
+
});
|
1227
|
+
__publicField(this, "name", "UserRejectedRequestError");
|
1228
|
+
__publicField(this, "code", 4001);
|
1229
|
+
}
|
1230
|
+
};
|
1231
|
+
var SwitchChainError = class extends RpcRequestError {
|
1232
|
+
constructor(err) {
|
1233
|
+
super(err, {
|
1234
|
+
shortMessage: "An error occurred when attempting to switch chain."
|
1235
|
+
});
|
1236
|
+
__publicField(this, "name", "SwitchChainError");
|
1237
|
+
__publicField(this, "code", 4902);
|
1238
|
+
}
|
1239
|
+
};
|
1222
1240
|
var UnknownRpcError = class extends RequestError {
|
1223
1241
|
constructor(err) {
|
1224
1242
|
super(err, {
|
@@ -2710,6 +2728,10 @@ function buildRequest(request, {
|
|
2710
2728
|
throw new LimitExceededRpcError(err);
|
2711
2729
|
if (err.code === -32006)
|
2712
2730
|
throw new JsonRpcVersionUnsupportedError(err);
|
2731
|
+
if (err.code === 4001)
|
2732
|
+
throw new UserRejectedRequestError(err);
|
2733
|
+
if (err.code === 4902)
|
2734
|
+
throw new SwitchChainError(err);
|
2713
2735
|
if (err_ instanceof BaseError)
|
2714
2736
|
throw err_;
|
2715
2737
|
throw new UnknownRpcError(err);
|
@@ -3022,12 +3044,14 @@ function getTransactionError(err, {
|
|
3022
3044
|
import WebSocket from "isomorphic-ws";
|
3023
3045
|
|
3024
3046
|
// src/utils/stringify.ts
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
}
|
3047
|
+
var stringify = (value, replacer, space) => JSON.stringify(
|
3048
|
+
value,
|
3049
|
+
(key, value_) => {
|
3050
|
+
const value2 = typeof value_ === "bigint" ? value_.toString() : value_;
|
3051
|
+
return typeof replacer === "function" ? replacer(key, value2) : value2;
|
3052
|
+
},
|
3053
|
+
space
|
3054
|
+
);
|
3031
3055
|
|
3032
3056
|
// src/utils/rpc.ts
|
3033
3057
|
var id = 0;
|
@@ -3206,11 +3230,11 @@ function formatUnit(value, decimals) {
|
|
3206
3230
|
const negative = display.startsWith("-");
|
3207
3231
|
if (negative)
|
3208
3232
|
display = display.slice(1);
|
3233
|
+
display = display.padStart(decimals, "0");
|
3209
3234
|
let [integer, fraction] = [
|
3210
3235
|
display.slice(0, display.length - decimals),
|
3211
3236
|
display.slice(display.length - decimals)
|
3212
3237
|
];
|
3213
|
-
fraction = fraction.padStart(decimals, "0");
|
3214
3238
|
fraction = fraction.replace(/(0+)$/, "");
|
3215
3239
|
return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
|
3216
3240
|
}
|
@@ -3326,6 +3350,8 @@ export {
|
|
3326
3350
|
MethodNotSupportedRpcError,
|
3327
3351
|
LimitExceededRpcError,
|
3328
3352
|
JsonRpcVersionUnsupportedError,
|
3353
|
+
UserRejectedRequestError,
|
3354
|
+
SwitchChainError,
|
3329
3355
|
UnknownRpcError,
|
3330
3356
|
HttpRequestError,
|
3331
3357
|
WebSocketRequestError,
|
@@ -3433,4 +3459,4 @@ export {
|
|
3433
3459
|
parseEther,
|
3434
3460
|
parseGwei
|
3435
3461
|
};
|
3436
|
-
//# sourceMappingURL=chunk-
|
3462
|
+
//# sourceMappingURL=chunk-P76FCR36.mjs.map
|