viem 0.0.1-alpha.14 → 0.0.1-alpha.15
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 +5 -5
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-KB6CBNKW.mjs → chunk-2HENAFQN.mjs} +16 -6
- package/dist/{chunk-E7IQYTLV.js → chunk-EMQSYKNY.js} +11 -11
- package/dist/{chunk-VUNR7KGG.js → chunk-HTYEJEWI.js} +145 -531
- package/dist/chunk-IMYI7Z6M.js +255 -0
- package/dist/chunk-KGXH5DYI.js +152 -0
- package/dist/chunk-NYXBQHNJ.mjs +255 -0
- package/dist/chunk-PHAG5KUF.mjs +152 -0
- package/dist/{chunk-DUNJAMH5.mjs → chunk-PPDHFNFM.mjs} +94 -480
- package/dist/{chunk-6Z62LPKB.js → chunk-QMLDI5JU.js} +16 -6
- package/dist/{chunk-5TCPFLFT.mjs → chunk-SX7GPOCZ.mjs} +1 -1
- package/dist/clients/index.d.ts +6 -3
- package/dist/clients/index.js +3 -3
- package/dist/clients/index.mjs +2 -2
- package/dist/createClient-cd948138.d.ts +62 -0
- package/dist/createPublicClient-989a0556.d.ts +19 -0
- package/dist/createTestClient-81507f58.d.ts +34 -0
- package/dist/createWalletClient-43f801b9.d.ts +30 -0
- package/dist/{eip1193-c001fcd5.d.ts → eip1193-4330b722.d.ts} +1 -1
- package/dist/index.d.ts +13 -6
- package/dist/index.js +8 -4
- package/dist/index.mjs +33 -29
- package/dist/{parseGwei-21f98a29.d.ts → parseGwei-f2d23de6.d.ts} +1 -1
- package/dist/public.d.ts +12 -0
- package/dist/public.js +58 -0
- package/dist/public.mjs +58 -0
- package/dist/sendTransaction-7a9d241a.d.ts +13 -0
- package/dist/stopImpersonatingAccount-8113150e.d.ts +156 -0
- package/dist/test.d.ts +7 -0
- package/dist/test.js +59 -0
- package/dist/test.mjs +59 -0
- package/dist/{transactionRequest-1d4e4385.d.ts → transactionReceipt-5d332aab.d.ts} +4 -32
- package/dist/transactionRequest-327eb7c2.d.ts +33 -0
- package/dist/utils/index.d.ts +4 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/wallet.d.ts +9 -0
- package/dist/wallet.js +23 -0
- package/dist/wallet.mjs +23 -0
- package/dist/watchAsset-0088384c.d.ts +39 -0
- package/dist/{stopImpersonatingAccount-fcc5a678.d.ts → watchPendingTransactions-670a7ca3.d.ts} +7 -197
- package/dist/{webSocket-3385e295.d.ts → webSocket-9a3b0b26.d.ts} +1 -1
- package/dist/window.d.ts +1 -1
- package/package.json +16 -6
- package/actions/package.json +0 -4
- package/dist/actions/index.d.ts +0 -8
- package/dist/actions/index.js +0 -129
- package/dist/actions/index.mjs +0 -129
- package/dist/createWalletClient-3f9fa8b6.d.ts +0 -130
@@ -1,15 +1,15 @@
|
|
1
1
|
import {
|
2
|
-
|
2
|
+
sendTransaction
|
3
|
+
} from "./chunk-PHAG5KUF.mjs";
|
4
|
+
import {
|
3
5
|
BlockNotFoundError,
|
4
6
|
InvalidGasArgumentsError,
|
5
7
|
TransactionNotFoundError,
|
6
8
|
TransactionReceiptNotFoundError,
|
7
9
|
WaitForTransactionReceiptTimeoutError,
|
8
|
-
checksumAddress,
|
9
10
|
decodeFunctionResult,
|
10
11
|
encodeDeployData,
|
11
12
|
encodeFunctionData,
|
12
|
-
encodeHex,
|
13
13
|
extract,
|
14
14
|
format,
|
15
15
|
formatBlock,
|
@@ -18,14 +18,13 @@ import {
|
|
18
18
|
formatTransaction,
|
19
19
|
formatTransactionReceipt,
|
20
20
|
formatTransactionRequest,
|
21
|
-
getAddress,
|
22
21
|
getCache,
|
23
22
|
getContractError,
|
24
23
|
hexToNumber,
|
25
24
|
numberToHex,
|
26
25
|
wait,
|
27
26
|
withCache
|
28
|
-
} from "./chunk-
|
27
|
+
} from "./chunk-2HENAFQN.mjs";
|
29
28
|
|
30
29
|
// src/actions/public/call.ts
|
31
30
|
async function call(client, {
|
@@ -126,135 +125,6 @@ async function createBlockFilter(client) {
|
|
126
125
|
return { id, type: "block" };
|
127
126
|
}
|
128
127
|
|
129
|
-
// src/actions/wallet/addChain.ts
|
130
|
-
async function addChain(client, chain) {
|
131
|
-
const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
132
|
-
await client.request({
|
133
|
-
method: "wallet_addEthereumChain",
|
134
|
-
params: [
|
135
|
-
{
|
136
|
-
chainId: numberToHex(id),
|
137
|
-
chainName: name,
|
138
|
-
nativeCurrency,
|
139
|
-
rpcUrls: rpcUrls.default.http,
|
140
|
-
blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
|
141
|
-
}
|
142
|
-
]
|
143
|
-
});
|
144
|
-
}
|
145
|
-
|
146
|
-
// src/actions/wallet/getAccounts.ts
|
147
|
-
async function getAccounts(client) {
|
148
|
-
const addresses = await client.request({ method: "eth_accounts" });
|
149
|
-
return addresses.map((address) => checksumAddress(address));
|
150
|
-
}
|
151
|
-
|
152
|
-
// src/actions/wallet/getPermissions.ts
|
153
|
-
async function getPermissions(client) {
|
154
|
-
const permissions = await client.request({ method: "wallet_getPermissions" });
|
155
|
-
return permissions;
|
156
|
-
}
|
157
|
-
|
158
|
-
// src/actions/wallet/requestAccounts.ts
|
159
|
-
async function requestAccounts(client) {
|
160
|
-
const addresses = await client.request({ method: "eth_requestAccounts" });
|
161
|
-
return addresses.map((address) => getAddress(address));
|
162
|
-
}
|
163
|
-
|
164
|
-
// src/actions/wallet/requestPermissions.ts
|
165
|
-
async function requestPermissions(client, permissions) {
|
166
|
-
return client.request({
|
167
|
-
method: "wallet_requestPermissions",
|
168
|
-
params: [permissions]
|
169
|
-
});
|
170
|
-
}
|
171
|
-
|
172
|
-
// src/actions/wallet/sendTransaction.ts
|
173
|
-
async function sendTransaction(client, {
|
174
|
-
chain,
|
175
|
-
from,
|
176
|
-
accessList,
|
177
|
-
data,
|
178
|
-
gas,
|
179
|
-
gasPrice,
|
180
|
-
maxFeePerGas,
|
181
|
-
maxPriorityFeePerGas,
|
182
|
-
nonce,
|
183
|
-
to,
|
184
|
-
value,
|
185
|
-
...rest
|
186
|
-
}) {
|
187
|
-
if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
|
188
|
-
throw new InvalidGasArgumentsError();
|
189
|
-
const formatter = chain?.formatters?.transactionRequest;
|
190
|
-
const request_ = format(
|
191
|
-
{
|
192
|
-
from,
|
193
|
-
accessList,
|
194
|
-
data,
|
195
|
-
gas,
|
196
|
-
gasPrice,
|
197
|
-
maxFeePerGas,
|
198
|
-
maxPriorityFeePerGas,
|
199
|
-
nonce,
|
200
|
-
to,
|
201
|
-
value,
|
202
|
-
...extract(rest, { formatter })
|
203
|
-
},
|
204
|
-
{
|
205
|
-
formatter: formatter || formatTransactionRequest
|
206
|
-
}
|
207
|
-
);
|
208
|
-
const hash = await client.request({
|
209
|
-
method: "eth_sendTransaction",
|
210
|
-
params: [request_]
|
211
|
-
});
|
212
|
-
return hash;
|
213
|
-
}
|
214
|
-
|
215
|
-
// src/actions/wallet/signMessage.ts
|
216
|
-
async function signMessage(client, { from, data: data_ }) {
|
217
|
-
let data;
|
218
|
-
if (typeof data_ === "string") {
|
219
|
-
if (!data_.startsWith("0x"))
|
220
|
-
throw new BaseError(
|
221
|
-
`data ("${data_}") must be a hex value. Encode it first to a hex with the \`encodeHex\` util.`,
|
222
|
-
{
|
223
|
-
docsPath: "/TODO"
|
224
|
-
}
|
225
|
-
);
|
226
|
-
data = data_;
|
227
|
-
} else {
|
228
|
-
data = encodeHex(data_);
|
229
|
-
}
|
230
|
-
const signed = await client.request({
|
231
|
-
method: "personal_sign",
|
232
|
-
params: [data, from]
|
233
|
-
});
|
234
|
-
return signed;
|
235
|
-
}
|
236
|
-
|
237
|
-
// src/actions/wallet/switchChain.ts
|
238
|
-
async function switchChain(client, { id }) {
|
239
|
-
await client.request({
|
240
|
-
method: "wallet_switchEthereumChain",
|
241
|
-
params: [
|
242
|
-
{
|
243
|
-
chainId: numberToHex(id)
|
244
|
-
}
|
245
|
-
]
|
246
|
-
});
|
247
|
-
}
|
248
|
-
|
249
|
-
// src/actions/wallet/watchAsset.ts
|
250
|
-
async function watchAsset(client, params) {
|
251
|
-
const added = await client.request({
|
252
|
-
method: "wallet_watchAsset",
|
253
|
-
params: [params]
|
254
|
-
});
|
255
|
-
return added;
|
256
|
-
}
|
257
|
-
|
258
128
|
// src/actions/public/deployContract.ts
|
259
129
|
function deployContract(walletClient, { abi, args, bytecode, ...request }) {
|
260
130
|
const calldata = encodeDeployData({
|
@@ -561,98 +431,6 @@ function observe(observerId, callbacks, fn) {
|
|
561
431
|
return unwatch;
|
562
432
|
}
|
563
433
|
|
564
|
-
// src/actions/public/waitForTransactionReceipt.ts
|
565
|
-
async function waitForTransactionReceipt(client, {
|
566
|
-
confirmations = 1,
|
567
|
-
hash,
|
568
|
-
onReplaced,
|
569
|
-
pollingInterval = client.pollingInterval,
|
570
|
-
timeout
|
571
|
-
}) {
|
572
|
-
const observerId = JSON.stringify([
|
573
|
-
"waitForTransactionReceipt",
|
574
|
-
client.uid,
|
575
|
-
hash
|
576
|
-
]);
|
577
|
-
let transaction;
|
578
|
-
let replacedTransaction;
|
579
|
-
let receipt;
|
580
|
-
return new Promise((resolve, reject) => {
|
581
|
-
if (timeout)
|
582
|
-
setTimeout(
|
583
|
-
() => reject(new WaitForTransactionReceiptTimeoutError({ hash })),
|
584
|
-
timeout
|
585
|
-
);
|
586
|
-
const unobserve = observe(
|
587
|
-
observerId,
|
588
|
-
{ onReplaced, resolve, reject },
|
589
|
-
(emit) => {
|
590
|
-
const unwatch = watchBlockNumber(client, {
|
591
|
-
emitMissed: true,
|
592
|
-
emitOnBegin: true,
|
593
|
-
pollingInterval,
|
594
|
-
async onBlockNumber(blockNumber) {
|
595
|
-
const done = async (fn) => {
|
596
|
-
unwatch();
|
597
|
-
fn();
|
598
|
-
unobserve();
|
599
|
-
};
|
600
|
-
try {
|
601
|
-
if (receipt) {
|
602
|
-
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
603
|
-
return;
|
604
|
-
done(() => emit.resolve(receipt));
|
605
|
-
return;
|
606
|
-
}
|
607
|
-
transaction = await getTransaction(client, { hash });
|
608
|
-
receipt = await getTransactionReceipt(client, { hash });
|
609
|
-
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
610
|
-
return;
|
611
|
-
done(() => emit.resolve(receipt));
|
612
|
-
} catch (err) {
|
613
|
-
if (transaction && (err instanceof TransactionNotFoundError || err instanceof TransactionReceiptNotFoundError)) {
|
614
|
-
replacedTransaction = transaction;
|
615
|
-
const block = await getBlock(client, {
|
616
|
-
blockNumber,
|
617
|
-
includeTransactions: true
|
618
|
-
});
|
619
|
-
const replacementTransaction = block.transactions.find(
|
620
|
-
({ from, nonce }) => from === replacedTransaction.from && nonce === replacedTransaction.nonce
|
621
|
-
);
|
622
|
-
if (!replacementTransaction)
|
623
|
-
return;
|
624
|
-
receipt = await getTransactionReceipt(client, {
|
625
|
-
hash: replacementTransaction.hash
|
626
|
-
});
|
627
|
-
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
628
|
-
return;
|
629
|
-
let reason = "replaced";
|
630
|
-
if (replacementTransaction.to === replacedTransaction.to && replacementTransaction.value === replacedTransaction.value) {
|
631
|
-
reason = "repriced";
|
632
|
-
} else if (replacementTransaction.from === replacementTransaction.to && replacementTransaction.value === 0n) {
|
633
|
-
reason = "cancelled";
|
634
|
-
}
|
635
|
-
done(() => {
|
636
|
-
emit.onReplaced?.({
|
637
|
-
reason,
|
638
|
-
replacedTransaction,
|
639
|
-
transaction: replacementTransaction,
|
640
|
-
transactionReceipt: receipt
|
641
|
-
});
|
642
|
-
emit.resolve(receipt);
|
643
|
-
});
|
644
|
-
} else {
|
645
|
-
done(() => emit.reject(err));
|
646
|
-
}
|
647
|
-
}
|
648
|
-
}
|
649
|
-
});
|
650
|
-
return unwatch;
|
651
|
-
}
|
652
|
-
);
|
653
|
-
});
|
654
|
-
}
|
655
|
-
|
656
434
|
// src/utils/poll.ts
|
657
435
|
function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
658
436
|
let active = true;
|
@@ -829,223 +607,95 @@ function watchPendingTransactions(client, {
|
|
829
607
|
});
|
830
608
|
}
|
831
609
|
|
832
|
-
// src/actions/
|
833
|
-
async function
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
}
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
}
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
}
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
}
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
const request_ = formatTransactionRequest(request);
|
922
|
-
const hash = await client.request({
|
923
|
-
method: "eth_sendUnsignedTransaction",
|
924
|
-
params: [request_]
|
925
|
-
});
|
926
|
-
return hash;
|
927
|
-
}
|
928
|
-
|
929
|
-
// src/actions/test/setAutomine.ts
|
930
|
-
async function setAutomine(client, enabled) {
|
931
|
-
return await client.request({
|
932
|
-
method: "evm_setAutomine",
|
933
|
-
params: [enabled]
|
934
|
-
});
|
935
|
-
}
|
936
|
-
|
937
|
-
// src/actions/test/setBalance.ts
|
938
|
-
async function setBalance(client, { address, value }) {
|
939
|
-
return await client.request({
|
940
|
-
method: `${client.mode}_setBalance`,
|
941
|
-
params: [address, numberToHex(value)]
|
942
|
-
});
|
943
|
-
}
|
944
|
-
|
945
|
-
// src/actions/test/setBlockGasLimit.ts
|
946
|
-
async function setBlockGasLimit(client, { gasLimit }) {
|
947
|
-
return await client.request({
|
948
|
-
method: "evm_setBlockGasLimit",
|
949
|
-
params: [numberToHex(gasLimit)]
|
950
|
-
});
|
951
|
-
}
|
952
|
-
|
953
|
-
// src/actions/test/setBlockTimestampInterval.ts
|
954
|
-
async function setBlockTimestampInterval(client, { interval }) {
|
955
|
-
return await client.request({
|
956
|
-
method: `${client.mode}_setBlockTimestampInterval`,
|
957
|
-
params: [interval]
|
958
|
-
});
|
959
|
-
}
|
960
|
-
|
961
|
-
// src/actions/test/setCode.ts
|
962
|
-
async function setCode(client, { address, bytecode }) {
|
963
|
-
return await client.request({
|
964
|
-
method: `${client.mode}_setCode`,
|
965
|
-
params: [address, bytecode]
|
966
|
-
});
|
967
|
-
}
|
968
|
-
|
969
|
-
// src/actions/test/setCoinbase.ts
|
970
|
-
async function setCoinbase(client, { address }) {
|
971
|
-
return await client.request({
|
972
|
-
method: `${client.mode}_setCoinbase`,
|
973
|
-
params: [address]
|
974
|
-
});
|
975
|
-
}
|
976
|
-
|
977
|
-
// src/actions/test/setIntervalMining.ts
|
978
|
-
async function setIntervalMining(client, { interval }) {
|
979
|
-
return await client.request({
|
980
|
-
method: "evm_setIntervalMining",
|
981
|
-
params: [interval]
|
982
|
-
});
|
983
|
-
}
|
984
|
-
|
985
|
-
// src/actions/test/setLoggingEnabled.ts
|
986
|
-
async function setLoggingEnabled(client, enabled) {
|
987
|
-
return await client.request({
|
988
|
-
method: `${client.mode}_setLoggingEnabled`,
|
989
|
-
params: [enabled]
|
990
|
-
});
|
991
|
-
}
|
992
|
-
|
993
|
-
// src/actions/test/setMinGasPrice.ts
|
994
|
-
async function setMinGasPrice(client, { gasPrice }) {
|
995
|
-
return await client.request({
|
996
|
-
method: `${client.mode}_setMinGasPrice`,
|
997
|
-
params: [numberToHex(gasPrice)]
|
998
|
-
});
|
999
|
-
}
|
1000
|
-
|
1001
|
-
// src/actions/test/setNextBlockBaseFeePerGas.ts
|
1002
|
-
async function setNextBlockBaseFeePerGas(client, { baseFeePerGas }) {
|
1003
|
-
return await client.request({
|
1004
|
-
method: `${client.mode}_setNextBlockBaseFeePerGas`,
|
1005
|
-
params: [numberToHex(baseFeePerGas)]
|
1006
|
-
});
|
1007
|
-
}
|
1008
|
-
|
1009
|
-
// src/actions/test/setNextBlockTimestamp.ts
|
1010
|
-
async function setNextBlockTimestamp(client, { timestamp }) {
|
1011
|
-
return await client.request({
|
1012
|
-
method: "evm_setNextBlockTimestamp",
|
1013
|
-
params: [numberToHex(timestamp)]
|
1014
|
-
});
|
1015
|
-
}
|
1016
|
-
|
1017
|
-
// src/actions/test/setNonce.ts
|
1018
|
-
async function setNonce(client, { address, nonce }) {
|
1019
|
-
return await client.request({
|
1020
|
-
method: `${client.mode}_setNonce`,
|
1021
|
-
params: [address, numberToHex(nonce)]
|
1022
|
-
});
|
1023
|
-
}
|
1024
|
-
|
1025
|
-
// src/actions/test/setStorageAt.ts
|
1026
|
-
async function setStorageAt(client, { address, index, value }) {
|
1027
|
-
return await client.request({
|
1028
|
-
method: `${client.mode}_setStorageAt`,
|
1029
|
-
params: [
|
1030
|
-
address,
|
1031
|
-
typeof index === "number" ? numberToHex(index) : index,
|
1032
|
-
value
|
1033
|
-
]
|
1034
|
-
});
|
1035
|
-
}
|
1036
|
-
|
1037
|
-
// src/actions/test/snapshot.ts
|
1038
|
-
async function snapshot(client) {
|
1039
|
-
return await client.request({
|
1040
|
-
method: "evm_snapshot"
|
1041
|
-
});
|
1042
|
-
}
|
1043
|
-
|
1044
|
-
// src/actions/test/stopImpersonatingAccount.ts
|
1045
|
-
async function stopImpersonatingAccount(client, { address }) {
|
1046
|
-
return await client.request({
|
1047
|
-
method: `${client.mode}_stopImpersonatingAccount`,
|
1048
|
-
params: [address]
|
610
|
+
// src/actions/public/waitForTransactionReceipt.ts
|
611
|
+
async function waitForTransactionReceipt(client, {
|
612
|
+
confirmations = 1,
|
613
|
+
hash,
|
614
|
+
onReplaced,
|
615
|
+
pollingInterval = client.pollingInterval,
|
616
|
+
timeout
|
617
|
+
}) {
|
618
|
+
const observerId = JSON.stringify([
|
619
|
+
"waitForTransactionReceipt",
|
620
|
+
client.uid,
|
621
|
+
hash
|
622
|
+
]);
|
623
|
+
let transaction;
|
624
|
+
let replacedTransaction;
|
625
|
+
let receipt;
|
626
|
+
return new Promise((resolve, reject) => {
|
627
|
+
if (timeout)
|
628
|
+
setTimeout(
|
629
|
+
() => reject(new WaitForTransactionReceiptTimeoutError({ hash })),
|
630
|
+
timeout
|
631
|
+
);
|
632
|
+
const unobserve = observe(
|
633
|
+
observerId,
|
634
|
+
{ onReplaced, resolve, reject },
|
635
|
+
(emit) => {
|
636
|
+
const unwatch = watchBlockNumber(client, {
|
637
|
+
emitMissed: true,
|
638
|
+
emitOnBegin: true,
|
639
|
+
pollingInterval,
|
640
|
+
async onBlockNumber(blockNumber) {
|
641
|
+
const done = async (fn) => {
|
642
|
+
unwatch();
|
643
|
+
fn();
|
644
|
+
unobserve();
|
645
|
+
};
|
646
|
+
try {
|
647
|
+
if (receipt) {
|
648
|
+
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
649
|
+
return;
|
650
|
+
done(() => emit.resolve(receipt));
|
651
|
+
return;
|
652
|
+
}
|
653
|
+
transaction = await getTransaction(client, { hash });
|
654
|
+
receipt = await getTransactionReceipt(client, { hash });
|
655
|
+
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
656
|
+
return;
|
657
|
+
done(() => emit.resolve(receipt));
|
658
|
+
} catch (err) {
|
659
|
+
if (transaction && (err instanceof TransactionNotFoundError || err instanceof TransactionReceiptNotFoundError)) {
|
660
|
+
replacedTransaction = transaction;
|
661
|
+
const block = await getBlock(client, {
|
662
|
+
blockNumber,
|
663
|
+
includeTransactions: true
|
664
|
+
});
|
665
|
+
const replacementTransaction = block.transactions.find(
|
666
|
+
({ from, nonce }) => from === replacedTransaction.from && nonce === replacedTransaction.nonce
|
667
|
+
);
|
668
|
+
if (!replacementTransaction)
|
669
|
+
return;
|
670
|
+
receipt = await getTransactionReceipt(client, {
|
671
|
+
hash: replacementTransaction.hash
|
672
|
+
});
|
673
|
+
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
674
|
+
return;
|
675
|
+
let reason = "replaced";
|
676
|
+
if (replacementTransaction.to === replacedTransaction.to && replacementTransaction.value === replacedTransaction.value) {
|
677
|
+
reason = "repriced";
|
678
|
+
} else if (replacementTransaction.from === replacementTransaction.to && replacementTransaction.value === 0n) {
|
679
|
+
reason = "cancelled";
|
680
|
+
}
|
681
|
+
done(() => {
|
682
|
+
emit.onReplaced?.({
|
683
|
+
reason,
|
684
|
+
replacedTransaction,
|
685
|
+
transaction: replacementTransaction,
|
686
|
+
transactionReceipt: receipt
|
687
|
+
});
|
688
|
+
emit.resolve(receipt);
|
689
|
+
});
|
690
|
+
} else {
|
691
|
+
done(() => emit.reject(err));
|
692
|
+
}
|
693
|
+
}
|
694
|
+
}
|
695
|
+
});
|
696
|
+
return unwatch;
|
697
|
+
}
|
698
|
+
);
|
1049
699
|
});
|
1050
700
|
}
|
1051
701
|
|
@@ -1054,15 +704,6 @@ export {
|
|
1054
704
|
callContract,
|
1055
705
|
createPendingTransactionFilter,
|
1056
706
|
createBlockFilter,
|
1057
|
-
addChain,
|
1058
|
-
getAccounts,
|
1059
|
-
getPermissions,
|
1060
|
-
requestAccounts,
|
1061
|
-
requestPermissions,
|
1062
|
-
sendTransaction,
|
1063
|
-
signMessage,
|
1064
|
-
switchChain,
|
1065
|
-
watchAsset,
|
1066
707
|
deployContract,
|
1067
708
|
estimateGas,
|
1068
709
|
getBalance,
|
@@ -1084,32 +725,5 @@ export {
|
|
1084
725
|
waitForTransactionReceipt,
|
1085
726
|
watchBlockNumber,
|
1086
727
|
watchBlocks,
|
1087
|
-
watchPendingTransactions
|
1088
|
-
dropTransaction,
|
1089
|
-
getAutomine,
|
1090
|
-
getTxpoolContent,
|
1091
|
-
getTxpoolStatus,
|
1092
|
-
impersonateAccount,
|
1093
|
-
increaseTime,
|
1094
|
-
inspectTxpool,
|
1095
|
-
mine,
|
1096
|
-
removeBlockTimestampInterval,
|
1097
|
-
reset,
|
1098
|
-
revert,
|
1099
|
-
sendUnsignedTransaction,
|
1100
|
-
setAutomine,
|
1101
|
-
setBalance,
|
1102
|
-
setBlockGasLimit,
|
1103
|
-
setBlockTimestampInterval,
|
1104
|
-
setCode,
|
1105
|
-
setCoinbase,
|
1106
|
-
setIntervalMining,
|
1107
|
-
setLoggingEnabled,
|
1108
|
-
setMinGasPrice,
|
1109
|
-
setNextBlockBaseFeePerGas,
|
1110
|
-
setNextBlockTimestamp,
|
1111
|
-
setNonce,
|
1112
|
-
setStorageAt,
|
1113
|
-
snapshot,
|
1114
|
-
stopImpersonatingAccount
|
728
|
+
watchPendingTransactions
|
1115
729
|
};
|
@@ -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.15",
|
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",
|
@@ -50,11 +50,6 @@ var package_default = {
|
|
50
50
|
module: "./dist/index.mjs",
|
51
51
|
default: "./dist/index.js"
|
52
52
|
},
|
53
|
-
"./actions": {
|
54
|
-
types: "./dist/actions/index.d.ts",
|
55
|
-
module: "./dist/actions/index.mjs",
|
56
|
-
default: "./dist/actions/index.js"
|
57
|
-
},
|
58
53
|
"./chains": {
|
59
54
|
types: "./dist/chains.d.ts",
|
60
55
|
module: "./dist/chains.mjs",
|
@@ -65,11 +60,26 @@ var package_default = {
|
|
65
60
|
module: "./dist/clients/index.mjs",
|
66
61
|
default: "./dist/clients/index.js"
|
67
62
|
},
|
63
|
+
"./public": {
|
64
|
+
types: "./dist/public.d.ts",
|
65
|
+
module: "./dist/public.mjs",
|
66
|
+
default: "./dist/public.js"
|
67
|
+
},
|
68
|
+
"./test": {
|
69
|
+
types: "./dist/test.d.ts",
|
70
|
+
module: "./dist/test.mjs",
|
71
|
+
default: "./dist/test.js"
|
72
|
+
},
|
68
73
|
"./utils": {
|
69
74
|
types: "./dist/utils/index.d.ts",
|
70
75
|
module: "./dist/utils/index.mjs",
|
71
76
|
default: "./dist/utils/index.js"
|
72
77
|
},
|
78
|
+
"./wallet": {
|
79
|
+
types: "./dist/wallet.d.ts",
|
80
|
+
module: "./dist/wallet.mjs",
|
81
|
+
default: "./dist/wallet.js"
|
82
|
+
},
|
73
83
|
"./window": {
|
74
84
|
types: "./dist/window.d.ts",
|
75
85
|
module: "./dist/window.mjs",
|