viem 0.0.1-alpha.0 → 0.0.1-alpha.10
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/README.md +16 -0
- package/dist/actions/index.d.ts +6 -10
- package/dist/actions/index.js +6 -2
- package/dist/chains.d.ts +3 -3
- package/dist/chains.js +1 -1
- package/dist/{chunk-OPR6LKYX.js → chunk-3TSTZHVO.js} +57 -50
- package/dist/{chunk-GI67STNV.js → chunk-6GAKRM5P.js} +1499 -355
- package/dist/{chunk-JSYJDK4W.js → chunk-NMN4TFDP.js} +248 -196
- package/dist/clients/index.d.ts +5 -6
- package/dist/clients/index.js +6 -6
- package/dist/{createWalletClient-c40fef16.d.ts → createWalletClient-d612fe08.d.ts} +6 -6
- package/dist/{eip1193-8f7c22ce.d.ts → eip1193-020a6f13.d.ts} +2 -2
- package/dist/index.d.ts +341 -9
- package/dist/index.js +102 -6
- package/dist/{parseGwei-a7d0bcb2.d.ts → parseGwei-7c87ff41.d.ts} +90 -87
- package/dist/{rpc-3c0e3985.d.ts → rpc-26932bae.d.ts} +1 -38
- package/dist/{rpc-655c0ba4.d.ts → rpc-b77c5aee.d.ts} +1 -1
- package/dist/transactionRequest-08d30731.d.ts +132 -0
- package/dist/utils/index.d.ts +41 -6
- package/dist/utils/index.js +33 -35
- package/dist/{watchAsset-bb30848d.d.ts → watchAsset-bc6373f4.d.ts} +35 -36
- package/dist/{webSocket-14584a7e.d.ts → webSocket-7f88e9e0.d.ts} +27 -21
- package/dist/window.d.ts +2 -2
- package/package.json +64 -10
- package/dist/BaseError-7688f84e.d.ts +0 -18
- package/dist/transactionRequest-ade896ac.d.ts +0 -44
@@ -1,7 +1,13 @@
|
|
1
1
|
import {
|
2
2
|
BaseError,
|
3
|
-
|
3
|
+
BlockNotFoundError,
|
4
|
+
InvalidGasArgumentsError,
|
5
|
+
TransactionNotFoundError,
|
6
|
+
TransactionReceiptNotFoundError,
|
7
|
+
WaitForTransactionReceiptTimeoutError,
|
4
8
|
checksumAddress,
|
9
|
+
decodeFunctionResult,
|
10
|
+
encodeFunctionData,
|
5
11
|
encodeHex,
|
6
12
|
format,
|
7
13
|
formatBlock,
|
@@ -12,133 +18,93 @@ import {
|
|
12
18
|
formatTransactionRequest,
|
13
19
|
getAddress,
|
14
20
|
getCache,
|
21
|
+
getContractError,
|
15
22
|
hexToNumber,
|
16
23
|
numberToHex,
|
17
24
|
wait,
|
18
25
|
withCache
|
19
|
-
} from "./chunk-
|
20
|
-
|
21
|
-
// src/actions/wallet/addChain.ts
|
22
|
-
async function addChain(client, chain) {
|
23
|
-
const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
24
|
-
await client.request({
|
25
|
-
method: "wallet_addEthereumChain",
|
26
|
-
params: [
|
27
|
-
{
|
28
|
-
chainId: numberToHex(id),
|
29
|
-
chainName: name,
|
30
|
-
nativeCurrency,
|
31
|
-
rpcUrls: rpcUrls.default.http,
|
32
|
-
blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
|
33
|
-
}
|
34
|
-
]
|
35
|
-
});
|
36
|
-
}
|
37
|
-
|
38
|
-
// src/actions/wallet/getAccounts.ts
|
39
|
-
async function getAccounts(client) {
|
40
|
-
const addresses = await client.request({ method: "eth_accounts" });
|
41
|
-
return addresses.map((address) => checksumAddress(address));
|
42
|
-
}
|
43
|
-
|
44
|
-
// src/actions/wallet/getPermissions.ts
|
45
|
-
async function getPermissions(client) {
|
46
|
-
const permissions = await client.request({ method: "wallet_getPermissions" });
|
47
|
-
return permissions;
|
48
|
-
}
|
49
|
-
|
50
|
-
// src/actions/wallet/requestAccounts.ts
|
51
|
-
async function requestAccounts(client) {
|
52
|
-
const addresses = await client.request({ method: "eth_requestAccounts" });
|
53
|
-
return addresses.map((address) => getAddress(address));
|
54
|
-
}
|
55
|
-
|
56
|
-
// src/actions/wallet/requestPermissions.ts
|
57
|
-
async function requestPermissions(client, permissions) {
|
58
|
-
return client.request({
|
59
|
-
method: "wallet_requestPermissions",
|
60
|
-
params: [permissions]
|
61
|
-
});
|
62
|
-
}
|
63
|
-
|
64
|
-
// src/actions/wallet/sendTransaction.ts
|
65
|
-
async function sendTransaction(client, { chain, request }) {
|
66
|
-
if (request.maxFeePerGas !== void 0 && request.maxPriorityFeePerGas !== void 0 && request.maxFeePerGas < request.maxPriorityFeePerGas)
|
67
|
-
throw new InvalidGasArgumentsError();
|
68
|
-
const request_ = format(request, {
|
69
|
-
formatter: chain?.formatters?.transactionRequest || formatTransactionRequest
|
70
|
-
});
|
71
|
-
const hash = await client.request({
|
72
|
-
method: "eth_sendTransaction",
|
73
|
-
params: [request_]
|
74
|
-
});
|
75
|
-
return { hash };
|
76
|
-
}
|
77
|
-
var InvalidGasArgumentsError = class extends BaseError {
|
78
|
-
constructor() {
|
79
|
-
super("`maxFeePerGas` cannot be less than `maxPriorityFeePerGas`");
|
80
|
-
__publicField(this, "name", "InvalidGasArgumentsError");
|
81
|
-
}
|
82
|
-
};
|
83
|
-
|
84
|
-
// src/actions/wallet/signMessage.ts
|
85
|
-
async function signMessage(client, { from, data: data_ }) {
|
86
|
-
let data;
|
87
|
-
if (typeof data_ === "string") {
|
88
|
-
if (!data_.startsWith("0x"))
|
89
|
-
throw new BaseError(
|
90
|
-
`data ("${data_}") must be a hex value. Encode it first to a hex with the \`encodeHex\` util.`,
|
91
|
-
{
|
92
|
-
docsPath: "/TODO"
|
93
|
-
}
|
94
|
-
);
|
95
|
-
data = data_;
|
96
|
-
} else {
|
97
|
-
data = encodeHex(data_);
|
98
|
-
}
|
99
|
-
const signed = await client.request({
|
100
|
-
method: "personal_sign",
|
101
|
-
params: [data, from]
|
102
|
-
});
|
103
|
-
return signed;
|
104
|
-
}
|
105
|
-
|
106
|
-
// src/actions/wallet/switchChain.ts
|
107
|
-
async function switchChain(client, { id }) {
|
108
|
-
await client.request({
|
109
|
-
method: "wallet_switchEthereumChain",
|
110
|
-
params: [
|
111
|
-
{
|
112
|
-
chainId: numberToHex(id)
|
113
|
-
}
|
114
|
-
]
|
115
|
-
});
|
116
|
-
}
|
117
|
-
|
118
|
-
// src/actions/wallet/watchAsset.ts
|
119
|
-
async function watchAsset(client, params) {
|
120
|
-
const added = await client.request({
|
121
|
-
method: "wallet_watchAsset",
|
122
|
-
params: [params]
|
123
|
-
});
|
124
|
-
return added;
|
125
|
-
}
|
26
|
+
} from "./chunk-6GAKRM5P.js";
|
126
27
|
|
127
28
|
// src/actions/public/call.ts
|
128
|
-
async function call(client, {
|
129
|
-
|
29
|
+
async function call(client, {
|
30
|
+
blockNumber,
|
31
|
+
blockTag = "latest",
|
32
|
+
chain,
|
33
|
+
from,
|
34
|
+
accessList,
|
35
|
+
data,
|
36
|
+
gas,
|
37
|
+
gasPrice,
|
38
|
+
maxFeePerGas,
|
39
|
+
maxPriorityFeePerGas,
|
40
|
+
nonce,
|
41
|
+
to,
|
42
|
+
value,
|
43
|
+
...rest
|
44
|
+
}) {
|
45
|
+
if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
|
130
46
|
throw new InvalidGasArgumentsError();
|
131
47
|
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
132
|
-
const request_ = format(
|
133
|
-
|
134
|
-
|
135
|
-
|
48
|
+
const request_ = format(
|
49
|
+
{
|
50
|
+
from,
|
51
|
+
accessList,
|
52
|
+
data,
|
53
|
+
gas,
|
54
|
+
gasPrice,
|
55
|
+
maxFeePerGas,
|
56
|
+
maxPriorityFeePerGas,
|
57
|
+
nonce,
|
58
|
+
to,
|
59
|
+
value,
|
60
|
+
...rest
|
61
|
+
},
|
62
|
+
{
|
63
|
+
formatter: chain?.formatters?.transactionRequest || formatTransactionRequest
|
64
|
+
}
|
65
|
+
);
|
66
|
+
const response = await client.request({
|
136
67
|
method: "eth_call",
|
137
68
|
params: [request_, blockNumberHex || blockTag]
|
138
69
|
});
|
139
|
-
if (
|
70
|
+
if (response === "0x")
|
140
71
|
return { data: void 0 };
|
141
|
-
return { data };
|
72
|
+
return { data: response };
|
73
|
+
}
|
74
|
+
|
75
|
+
// src/actions/public/callContract.ts
|
76
|
+
async function callContract(client, {
|
77
|
+
abi,
|
78
|
+
address,
|
79
|
+
args,
|
80
|
+
functionName,
|
81
|
+
...callRequest
|
82
|
+
}) {
|
83
|
+
const calldata = encodeFunctionData({
|
84
|
+
abi,
|
85
|
+
args,
|
86
|
+
functionName
|
87
|
+
});
|
88
|
+
try {
|
89
|
+
const { data } = await call(client, {
|
90
|
+
data: calldata,
|
91
|
+
to: address,
|
92
|
+
...callRequest
|
93
|
+
});
|
94
|
+
return decodeFunctionResult({
|
95
|
+
abi,
|
96
|
+
functionName,
|
97
|
+
data: data || "0x"
|
98
|
+
});
|
99
|
+
} catch (err) {
|
100
|
+
throw getContractError(err, {
|
101
|
+
abi,
|
102
|
+
address,
|
103
|
+
args,
|
104
|
+
functionName,
|
105
|
+
sender: callRequest.from
|
106
|
+
});
|
107
|
+
}
|
142
108
|
}
|
143
109
|
|
144
110
|
// src/actions/public/createPendingTransactionFilter.ts
|
@@ -161,16 +127,14 @@ async function createBlockFilter(client) {
|
|
161
127
|
async function estimateGas(client, {
|
162
128
|
blockNumber,
|
163
129
|
blockTag = "latest",
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
value
|
173
|
-
}
|
130
|
+
data,
|
131
|
+
from,
|
132
|
+
gas,
|
133
|
+
gasPrice,
|
134
|
+
maxFeePerGas,
|
135
|
+
maxPriorityFeePerGas,
|
136
|
+
to,
|
137
|
+
value
|
174
138
|
}) {
|
175
139
|
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
176
140
|
const parameters = {
|
@@ -226,20 +190,6 @@ async function getBlock(client, {
|
|
226
190
|
formatter: client.chain?.formatters?.block || formatBlock
|
227
191
|
});
|
228
192
|
}
|
229
|
-
var BlockNotFoundError = class extends BaseError {
|
230
|
-
constructor({
|
231
|
-
blockHash,
|
232
|
-
blockNumber
|
233
|
-
}) {
|
234
|
-
let identifier = "Block";
|
235
|
-
if (blockHash)
|
236
|
-
identifier = `Block at hash "${blockHash}"`;
|
237
|
-
if (blockNumber)
|
238
|
-
identifier = `Block at number "${blockNumber}"`;
|
239
|
-
super(`${identifier} could not be found.`);
|
240
|
-
__publicField(this, "name", "BlockNotFoundError");
|
241
|
-
}
|
242
|
-
};
|
243
193
|
|
244
194
|
// src/actions/public/getBlockNumber.ts
|
245
195
|
var cacheKey = (id) => `blockNumber.${id}`;
|
@@ -314,6 +264,15 @@ async function getFilterChanges(client, { filter }) {
|
|
314
264
|
);
|
315
265
|
}
|
316
266
|
|
267
|
+
// src/actions/public/getFilterLogs.ts
|
268
|
+
async function getFilterLogs(client, { filter }) {
|
269
|
+
const logs = await client.request({
|
270
|
+
method: "eth_getFilterLogs",
|
271
|
+
params: [filter.id]
|
272
|
+
});
|
273
|
+
return logs.map(formatLog);
|
274
|
+
}
|
275
|
+
|
317
276
|
// src/actions/public/getGasPrice.ts
|
318
277
|
async function getGasPrice(client) {
|
319
278
|
const gasPrice = await client.request({
|
@@ -360,27 +319,6 @@ async function getTransaction(client, {
|
|
360
319
|
formatter: client.chain?.formatters?.transaction || formatTransaction
|
361
320
|
});
|
362
321
|
}
|
363
|
-
var TransactionNotFoundError = class extends BaseError {
|
364
|
-
constructor({
|
365
|
-
blockHash,
|
366
|
-
blockNumber,
|
367
|
-
blockTag,
|
368
|
-
hash,
|
369
|
-
index
|
370
|
-
}) {
|
371
|
-
let identifier = "Transaction";
|
372
|
-
if (blockTag && index !== void 0)
|
373
|
-
identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
|
374
|
-
if (blockHash && index !== void 0)
|
375
|
-
identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
|
376
|
-
if (blockNumber && index !== void 0)
|
377
|
-
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
|
378
|
-
if (hash)
|
379
|
-
identifier = `Transaction with hash "${hash}"`;
|
380
|
-
super(`${identifier} could not be found.`);
|
381
|
-
__publicField(this, "name", "TransactionNotFoundError");
|
382
|
-
}
|
383
|
-
};
|
384
322
|
|
385
323
|
// src/actions/public/getTransactionConfirmations.ts
|
386
324
|
async function getTransactionConfirmations(client, { hash, transactionReceipt }) {
|
@@ -400,7 +338,7 @@ async function getTransactionCount(client, { address, blockTag = "latest", block
|
|
400
338
|
method: "eth_getTransactionCount",
|
401
339
|
params: [address, blockNumber ? numberToHex(blockNumber) : blockTag]
|
402
340
|
});
|
403
|
-
return hexToNumber(count
|
341
|
+
return hexToNumber(count);
|
404
342
|
}
|
405
343
|
|
406
344
|
// src/actions/public/getTransactionReceipt.ts
|
@@ -415,14 +353,6 @@ async function getTransactionReceipt(client, { hash }) {
|
|
415
353
|
formatter: client.chain?.formatters?.transactionReceipt || formatTransactionReceipt
|
416
354
|
});
|
417
355
|
}
|
418
|
-
var TransactionReceiptNotFoundError = class extends BaseError {
|
419
|
-
constructor({ hash }) {
|
420
|
-
super(
|
421
|
-
`Transaction receipt with hash "${hash}" could not be found. The Transaction may not be processed on a block yet.`
|
422
|
-
);
|
423
|
-
__publicField(this, "name", "TransactionReceiptNotFoundError");
|
424
|
-
}
|
425
|
-
};
|
426
356
|
|
427
357
|
// src/actions/public/uninstallFilter.ts
|
428
358
|
async function uninstallFilter(client, { filter }) {
|
@@ -565,14 +495,6 @@ async function waitForTransactionReceipt(client, {
|
|
565
495
|
);
|
566
496
|
});
|
567
497
|
}
|
568
|
-
var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
569
|
-
constructor({ hash }) {
|
570
|
-
super(
|
571
|
-
`Timed out while waiting for transaction with hash "${hash}" to be confirmed.`
|
572
|
-
);
|
573
|
-
__publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
|
574
|
-
}
|
575
|
-
};
|
576
498
|
|
577
499
|
// src/utils/poll.ts
|
578
500
|
function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
@@ -768,14 +690,14 @@ async function getAutomine(client) {
|
|
768
690
|
// src/actions/test/getTxpoolContent.ts
|
769
691
|
async function getTxpoolContent(client) {
|
770
692
|
return await client.request({
|
771
|
-
method:
|
693
|
+
method: "txpool_content"
|
772
694
|
});
|
773
695
|
}
|
774
696
|
|
775
697
|
// src/actions/test/getTxpoolStatus.ts
|
776
698
|
async function getTxpoolStatus(client) {
|
777
699
|
const { pending, queued } = await client.request({
|
778
|
-
method:
|
700
|
+
method: "txpool_status"
|
779
701
|
});
|
780
702
|
return {
|
781
703
|
pending: hexToNumber(pending),
|
@@ -802,7 +724,7 @@ async function increaseTime(client, { seconds }) {
|
|
802
724
|
// src/actions/test/inspectTxpool.ts
|
803
725
|
async function inspectTxpool(client) {
|
804
726
|
return await client.request({
|
805
|
-
method:
|
727
|
+
method: "txpool_inspect"
|
806
728
|
});
|
807
729
|
}
|
808
730
|
|
@@ -832,19 +754,19 @@ async function reset(client, { blockNumber, jsonRpcUrl } = {}) {
|
|
832
754
|
// src/actions/test/revert.ts
|
833
755
|
async function revert(client, { id }) {
|
834
756
|
return await client.request({
|
835
|
-
method:
|
757
|
+
method: "evm_revert",
|
836
758
|
params: [id]
|
837
759
|
});
|
838
760
|
}
|
839
761
|
|
840
762
|
// src/actions/test/sendUnsignedTransaction.ts
|
841
|
-
async function sendUnsignedTransaction(client,
|
763
|
+
async function sendUnsignedTransaction(client, request) {
|
842
764
|
const request_ = formatTransactionRequest(request);
|
843
765
|
const hash = await client.request({
|
844
766
|
method: "eth_sendUnsignedTransaction",
|
845
767
|
params: [request_]
|
846
768
|
});
|
847
|
-
return
|
769
|
+
return hash;
|
848
770
|
}
|
849
771
|
|
850
772
|
// src/actions/test/setAutomine.ts
|
@@ -930,7 +852,7 @@ async function setNextBlockBaseFeePerGas(client, { baseFeePerGas }) {
|
|
930
852
|
// src/actions/test/setNextBlockTimestamp.ts
|
931
853
|
async function setNextBlockTimestamp(client, { timestamp }) {
|
932
854
|
return await client.request({
|
933
|
-
method:
|
855
|
+
method: "evm_setNextBlockTimestamp",
|
934
856
|
params: [numberToHex(timestamp)]
|
935
857
|
});
|
936
858
|
}
|
@@ -958,7 +880,7 @@ async function setStorageAt(client, { address, index, value }) {
|
|
958
880
|
// src/actions/test/snapshot.ts
|
959
881
|
async function snapshot(client) {
|
960
882
|
return await client.request({
|
961
|
-
method:
|
883
|
+
method: "evm_snapshot"
|
962
884
|
});
|
963
885
|
}
|
964
886
|
|
@@ -970,17 +892,137 @@ async function stopImpersonatingAccount(client, { address }) {
|
|
970
892
|
});
|
971
893
|
}
|
972
894
|
|
895
|
+
// src/actions/wallet/addChain.ts
|
896
|
+
async function addChain(client, chain) {
|
897
|
+
const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
898
|
+
await client.request({
|
899
|
+
method: "wallet_addEthereumChain",
|
900
|
+
params: [
|
901
|
+
{
|
902
|
+
chainId: numberToHex(id),
|
903
|
+
chainName: name,
|
904
|
+
nativeCurrency,
|
905
|
+
rpcUrls: rpcUrls.default.http,
|
906
|
+
blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
|
907
|
+
}
|
908
|
+
]
|
909
|
+
});
|
910
|
+
}
|
911
|
+
|
912
|
+
// src/actions/wallet/getAccounts.ts
|
913
|
+
async function getAccounts(client) {
|
914
|
+
const addresses = await client.request({ method: "eth_accounts" });
|
915
|
+
return addresses.map((address) => checksumAddress(address));
|
916
|
+
}
|
917
|
+
|
918
|
+
// src/actions/wallet/getPermissions.ts
|
919
|
+
async function getPermissions(client) {
|
920
|
+
const permissions = await client.request({ method: "wallet_getPermissions" });
|
921
|
+
return permissions;
|
922
|
+
}
|
923
|
+
|
924
|
+
// src/actions/wallet/requestAccounts.ts
|
925
|
+
async function requestAccounts(client) {
|
926
|
+
const addresses = await client.request({ method: "eth_requestAccounts" });
|
927
|
+
return addresses.map((address) => getAddress(address));
|
928
|
+
}
|
929
|
+
|
930
|
+
// src/actions/wallet/requestPermissions.ts
|
931
|
+
async function requestPermissions(client, permissions) {
|
932
|
+
return client.request({
|
933
|
+
method: "wallet_requestPermissions",
|
934
|
+
params: [permissions]
|
935
|
+
});
|
936
|
+
}
|
937
|
+
|
938
|
+
// src/actions/wallet/sendTransaction.ts
|
939
|
+
async function sendTransaction(client, {
|
940
|
+
chain,
|
941
|
+
from,
|
942
|
+
accessList,
|
943
|
+
data,
|
944
|
+
gas,
|
945
|
+
gasPrice,
|
946
|
+
maxFeePerGas,
|
947
|
+
maxPriorityFeePerGas,
|
948
|
+
nonce,
|
949
|
+
to,
|
950
|
+
value,
|
951
|
+
...rest
|
952
|
+
}) {
|
953
|
+
if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
|
954
|
+
throw new InvalidGasArgumentsError();
|
955
|
+
const request_ = format(
|
956
|
+
{
|
957
|
+
from,
|
958
|
+
accessList,
|
959
|
+
data,
|
960
|
+
gas,
|
961
|
+
gasPrice,
|
962
|
+
maxFeePerGas,
|
963
|
+
maxPriorityFeePerGas,
|
964
|
+
nonce,
|
965
|
+
to,
|
966
|
+
value,
|
967
|
+
...rest
|
968
|
+
},
|
969
|
+
{
|
970
|
+
formatter: chain?.formatters?.transactionRequest || formatTransactionRequest
|
971
|
+
}
|
972
|
+
);
|
973
|
+
const hash = await client.request({
|
974
|
+
method: "eth_sendTransaction",
|
975
|
+
params: [request_]
|
976
|
+
});
|
977
|
+
return hash;
|
978
|
+
}
|
979
|
+
|
980
|
+
// src/actions/wallet/signMessage.ts
|
981
|
+
async function signMessage(client, { from, data: data_ }) {
|
982
|
+
let data;
|
983
|
+
if (typeof data_ === "string") {
|
984
|
+
if (!data_.startsWith("0x"))
|
985
|
+
throw new BaseError(
|
986
|
+
`data ("${data_}") must be a hex value. Encode it first to a hex with the \`encodeHex\` util.`,
|
987
|
+
{
|
988
|
+
docsPath: "/TODO"
|
989
|
+
}
|
990
|
+
);
|
991
|
+
data = data_;
|
992
|
+
} else {
|
993
|
+
data = encodeHex(data_);
|
994
|
+
}
|
995
|
+
const signed = await client.request({
|
996
|
+
method: "personal_sign",
|
997
|
+
params: [data, from]
|
998
|
+
});
|
999
|
+
return signed;
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
// src/actions/wallet/switchChain.ts
|
1003
|
+
async function switchChain(client, { id }) {
|
1004
|
+
await client.request({
|
1005
|
+
method: "wallet_switchEthereumChain",
|
1006
|
+
params: [
|
1007
|
+
{
|
1008
|
+
chainId: numberToHex(id)
|
1009
|
+
}
|
1010
|
+
]
|
1011
|
+
});
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
// src/actions/wallet/watchAsset.ts
|
1015
|
+
async function watchAsset(client, params) {
|
1016
|
+
const added = await client.request({
|
1017
|
+
method: "wallet_watchAsset",
|
1018
|
+
params: [params]
|
1019
|
+
});
|
1020
|
+
return added;
|
1021
|
+
}
|
1022
|
+
|
973
1023
|
export {
|
974
|
-
addChain,
|
975
|
-
getAccounts,
|
976
|
-
getPermissions,
|
977
|
-
requestAccounts,
|
978
|
-
requestPermissions,
|
979
|
-
sendTransaction,
|
980
|
-
signMessage,
|
981
|
-
switchChain,
|
982
|
-
watchAsset,
|
983
1024
|
call,
|
1025
|
+
callContract,
|
984
1026
|
createPendingTransactionFilter,
|
985
1027
|
createBlockFilter,
|
986
1028
|
estimateGas,
|
@@ -992,6 +1034,7 @@ export {
|
|
992
1034
|
getChainId,
|
993
1035
|
getFeeHistory,
|
994
1036
|
getFilterChanges,
|
1037
|
+
getFilterLogs,
|
995
1038
|
getGasPrice,
|
996
1039
|
getTransaction,
|
997
1040
|
getTransactionConfirmations,
|
@@ -1028,5 +1071,14 @@ export {
|
|
1028
1071
|
setNonce,
|
1029
1072
|
setStorageAt,
|
1030
1073
|
snapshot,
|
1031
|
-
stopImpersonatingAccount
|
1074
|
+
stopImpersonatingAccount,
|
1075
|
+
addChain,
|
1076
|
+
getAccounts,
|
1077
|
+
getPermissions,
|
1078
|
+
requestAccounts,
|
1079
|
+
requestPermissions,
|
1080
|
+
sendTransaction,
|
1081
|
+
signMessage,
|
1082
|
+
switchChain,
|
1083
|
+
watchAsset
|
1032
1084
|
};
|
package/dist/clients/index.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
export { C as Client, a as ClientConfig, P as PublicClient, b as PublicClientConfig, T as TestClient, c as TestClientConfig, d as Transport, e as TransportConfig, W as WalletClient, f as WalletClientConfig, g as createClient, h as createPublicClient, i as createTestClient, j as createTransport, k as createWalletClient } from '../createWalletClient-
|
2
|
-
export {
|
1
|
+
export { C as Client, a as ClientConfig, P as PublicClient, b as PublicClientConfig, T as TestClient, c as TestClientConfig, d as Transport, e as TransportConfig, W as WalletClient, f as WalletClientConfig, g as createClient, h as createPublicClient, i as createTestClient, j as createTransport, k as createWalletClient } from '../createWalletClient-d612fe08.js';
|
2
|
+
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-7f88e9e0.js';
|
3
3
|
import '../chains.js';
|
4
|
-
import '../rpc-
|
4
|
+
import '../rpc-b77c5aee.js';
|
5
5
|
import '@wagmi/chains';
|
6
|
-
import '../eip1193-
|
7
|
-
import '../
|
8
|
-
import '../rpc-3c0e3985.js';
|
6
|
+
import '../eip1193-020a6f13.js';
|
7
|
+
import '../rpc-26932bae.js';
|
package/dist/clients/index.js
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
import {
|
2
|
-
UrlRequiredError,
|
3
2
|
createClient,
|
4
3
|
createPublicClient,
|
5
4
|
createTestClient,
|
6
5
|
createTransport,
|
7
6
|
createWalletClient,
|
8
|
-
|
7
|
+
custom,
|
8
|
+
fallback,
|
9
9
|
http,
|
10
10
|
webSocket
|
11
|
-
} from "../chunk-
|
12
|
-
import "../chunk-
|
11
|
+
} from "../chunk-3TSTZHVO.js";
|
12
|
+
import "../chunk-6GAKRM5P.js";
|
13
13
|
export {
|
14
|
-
UrlRequiredError,
|
15
14
|
createClient,
|
16
15
|
createPublicClient,
|
17
16
|
createTestClient,
|
18
17
|
createTransport,
|
19
18
|
createWalletClient,
|
20
|
-
|
19
|
+
custom,
|
20
|
+
fallback,
|
21
21
|
http,
|
22
22
|
webSocket
|
23
23
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Chain } from './chains.js';
|
2
|
-
import { R as Requests, P as PublicRequests, T as TestRequests, S as SignableRequests, b as WalletRequests } from './eip1193-
|
2
|
+
import { R as Requests, P as PublicRequests, T as TestRequests, S as SignableRequests, b as WalletRequests } from './eip1193-020a6f13.js';
|
3
3
|
|
4
4
|
type BaseRpcRequests = {
|
5
5
|
request(...args: any): Promise<any>;
|
@@ -36,7 +36,7 @@ type Client<TTransport extends Transport = Transport, TChain extends Chain = Cha
|
|
36
36
|
pollingInterval: number;
|
37
37
|
/** Request function wrapped with friendly error handling */
|
38
38
|
request: TRequests['request'];
|
39
|
-
/** The RPC transport (http, webSocket,
|
39
|
+
/** The RPC transport (http, webSocket, custom, etc) */
|
40
40
|
transport: ReturnType<TTransport>['config'] & ReturnType<TTransport>['value'];
|
41
41
|
/** The type of client. */
|
42
42
|
type: string;
|
@@ -96,9 +96,9 @@ type TestClient<TTransport extends Transport = Transport, TChain extends Chain =
|
|
96
96
|
* `evm_mine`, etc).
|
97
97
|
*
|
98
98
|
* @example
|
99
|
+
* import { createTestClient, http } from 'viem'
|
99
100
|
* import { local } from 'viem/chains'
|
100
|
-
*
|
101
|
-
* const client = createTestClient(http({ chain: local }), { mode: 'anvil' })
|
101
|
+
* const client = createTestClient({ chain: local, mode: 'anvil', transport: http() })
|
102
102
|
*/
|
103
103
|
declare function createTestClient<TTransport extends Transport, TChain extends Chain, TMode extends TestClientModes>({ chain, key, name, mode, pollingInterval, transport, }: TestClientConfig<TTransport, TChain, TMode>): TestClient<TTransport, TChain, TMode>;
|
104
104
|
|
@@ -120,9 +120,9 @@ type WalletClient<TTransport extends Transport = Transport, TChain extends Chain
|
|
120
120
|
* (ie. `eth_sendTransaction`, `eth_requestAccounts`, etc).
|
121
121
|
*
|
122
122
|
* @example
|
123
|
-
* import { createWalletClient,
|
123
|
+
* import { createWalletClient, custom } from 'viem'
|
124
124
|
* const client = createWalletClient(
|
125
|
-
*
|
125
|
+
* custom(window.ethereum)
|
126
126
|
* )
|
127
127
|
*/
|
128
128
|
declare function createWalletClient<TTransport extends Transport, TChain extends Chain>({ transport, key, name, pollingInterval, }: WalletClientConfig<TTransport, TChain>): WalletClient<TTransport, TChain>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { A as Address,
|
1
|
+
import { A as Address, a as Hash, Q as Quantity, s as RpcTransactionRequest, m as RpcBlockNumber, b as BlockTag, l as RpcBlockIdentifier, H as Hex, P as RpcEstimateGasParameters, n as RpcFeeHistory, R as RpcBlock, p as RpcLog, q as RpcTransaction, r as RpcTransactionReceipt, u as RpcUncle } from './rpc-b77c5aee.js';
|
2
2
|
|
3
3
|
declare class RpcError extends Error {
|
4
4
|
code: number;
|
@@ -405,7 +405,7 @@ type PublicRequests = {
|
|
405
405
|
* */
|
406
406
|
method: 'eth_getTransactionCount';
|
407
407
|
params: [address: Address, block: RpcBlockNumber | BlockTag | RpcBlockIdentifier];
|
408
|
-
}): Promise<Quantity
|
408
|
+
}): Promise<Quantity>;
|
409
409
|
request(args: {
|
410
410
|
/**
|
411
411
|
* @description Returns the receipt of a transaction specified by hash
|