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
package/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<picture>
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/wagmi-dev/viem/blob/main/.github/viem-dark.svg">
|
4
|
+
<img alt="wagmi logo" src="https://github.com/wagmi-dev/viem/blob/main/.github/viem-light.svg" width="auto" height="60">
|
5
|
+
</picture>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p align="center">
|
9
|
+
TypeScript Interface for Ethereum
|
10
|
+
<p>
|
11
|
+
|
12
|
+
<p align="center">
|
13
|
+
<a href="https://codecov.io/github/wagmi-dev/viem" >
|
14
|
+
<img src="https://codecov.io/github/wagmi-dev/viem/branch/main/graph/badge.svg?token=iUTN9R4Qfg"/>
|
15
|
+
</a>
|
16
|
+
</p>
|
package/dist/actions/index.d.ts
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
export { C as CallArgs, a as
|
2
|
-
import
|
1
|
+
export { C as CallArgs, a as CallContractArgs, b as CallContractResponse, c as CallResponse, d as CreateBlockFilterResponse, e as CreatePendingTransactionFilterResponse, D as DropTransactionArgs, E as EstimateGasArgs, f as EstimateGasResponse, bh as FormattedTransactionRequest, G as GetBalanceArgs, g as GetBalanceResponse, h as GetBlockArgs, i as GetBlockNumberArgs, j as GetBlockNumberResponse, k as GetBlockResponse, l as GetBlockTransactionCountArgs, m as GetBlockTransactionCountResponse, n as GetFeeHistoryArgs, o as GetFeeHistoryResponse, p as GetFilterChangesArgs, q as GetFilterChangesResponse, r as GetFilterLogsArgs, s as GetFilterLogsResponse, t as GetGasPriceResponse, u as GetPermissionsResponse, v as GetTransactionArgs, w as GetTransactionConfirmationsArgs, x as GetTransactionConfirmationsResponse, y as GetTransactionCountArgs, z as GetTransactionCountResponse, B as GetTransactionReceiptArgs, F as GetTransactionReceiptResponse, A as GetTransactionResponse, I as ImpersonateAccountArgs, H as IncreaseTimeArgs, M as MineArgs, O as OnBlock, J as OnBlockNumber, K as OnBlockNumberResponse, L as OnBlockResponse, N as OnTransactions, P as OnTransactionsResponse, bf as ReplacementReason, bg as ReplacementResponse, Q as RequestPermissionsResponse, R as ResetArgs, S as RevertArgs, T as SendTransactionArgs, U as SendTransactionResponse, V as SendUnsignedTransactionArgs, W as SendUnsignedTransactionResponse, X as SetBalanceArgs, Y as SetBlockGasLimitArgs, a1 as SetBlockTimestampIntervalArgs, Z as SetCodeArgs, _ as SetCoinbaseArgs, $ as SetIntervalMiningArgs, a0 as SetMinGasPriceArgs, a3 as SetNextBlockBaseFeePerGasArgs, a2 as SetNextBlockTimestampArgs, a4 as SetNonceArgs, a5 as SetStorageAtArgs, a6 as SignMessageArgs, a7 as SignMessageResponse, a8 as StopImpersonatingAccountArgs, a9 as SwitchChainArgs, aa as UninstallFilterArgs, ab as UninstallFilterResponse, ac as WaitForTransactionReceiptArgs, ad as WaitForTransactionReceiptResponse, ae as WatchAssetArgs, af as WatchAssetResponse, ag as WatchBlockNumberArgs, ah as WatchBlocksArgs, ai as WatchPendingTransactionsArgs, aj as addChain, ak as call, al as callContract, am as createBlockFilter, an as createPendingTransactionFilter, ap as dropTransaction, ao as estimateGas, aq as getAccounts, ar as getAutomine, as as getBalance, at as getBlock, au as getBlockNumber, be as getBlockNumberCache, av as getBlockTransactionCount, aw as getChainId, ax as getFeeHistory, ay as getFilterChanges, az as getFilterLogs, aA as getGasPrice, aB as getPermissions, aC as getTransaction, aD as getTransactionConfirmations, aE as getTransactionCount, aF as getTransactionReceipt, aG as getTxpoolContent, aH as getTxpoolStatus, aI as impersonateAccount, aJ as increaseTime, aK as inspectTxpool, aL as mine, aM as removeBlockTimestampInterval, aO as requestAccounts, aP as requestPermissions, aN as reset, aQ as revert, aR as sendTransaction, aS as sendUnsignedTransaction, aT as setAutomine, aU as setBalance, aV as setBlockGasLimit, aW as setBlockTimestampInterval, aX as setCode, aY as setCoinbase, aZ as setIntervalMining, a_ as setLoggingEnabled, a$ as setMinGasPrice, b0 as setNextBlockBaseFeePerGas, b1 as setNextBlockTimestamp, b2 as setNonce, b3 as setStorageAt, b4 as signMessage, b5 as snapshot, b6 as stopImpersonatingAccount, b7 as switchChain, b8 as uninstallFilter, b9 as waitForTransactionReceipt, ba as watchAsset, bb as watchBlockNumber, bc as watchBlocks, bd as watchPendingTransactions } from '../watchAsset-bc6373f4.js';
|
2
|
+
import 'abitype';
|
3
3
|
import '../chains.js';
|
4
|
-
import '../rpc-
|
4
|
+
import '../rpc-b77c5aee.js';
|
5
5
|
import '@wagmi/chains';
|
6
|
-
import '../transactionRequest-
|
7
|
-
import '../
|
8
|
-
import '../eip1193-
|
9
|
-
|
10
|
-
declare function getAccounts(client: WalletClient): Promise<`0x${string}`[]>;
|
11
|
-
|
12
|
-
export { getAccounts };
|
6
|
+
import '../transactionRequest-08d30731.js';
|
7
|
+
import '../createWalletClient-d612fe08.js';
|
8
|
+
import '../eip1193-020a6f13.js';
|
package/dist/actions/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
addChain,
|
3
3
|
call,
|
4
|
+
callContract,
|
4
5
|
createBlockFilter,
|
5
6
|
createPendingTransactionFilter,
|
6
7
|
dropTransaction,
|
@@ -15,6 +16,7 @@ import {
|
|
15
16
|
getChainId,
|
16
17
|
getFeeHistory,
|
17
18
|
getFilterChanges,
|
19
|
+
getFilterLogs,
|
18
20
|
getGasPrice,
|
19
21
|
getPermissions,
|
20
22
|
getTransaction,
|
@@ -57,11 +59,12 @@ import {
|
|
57
59
|
watchBlockNumber,
|
58
60
|
watchBlocks,
|
59
61
|
watchPendingTransactions
|
60
|
-
} from "../chunk-
|
61
|
-
import "../chunk-
|
62
|
+
} from "../chunk-NMN4TFDP.js";
|
63
|
+
import "../chunk-6GAKRM5P.js";
|
62
64
|
export {
|
63
65
|
addChain,
|
64
66
|
call,
|
67
|
+
callContract,
|
65
68
|
createBlockFilter,
|
66
69
|
createPendingTransactionFilter,
|
67
70
|
dropTransaction,
|
@@ -76,6 +79,7 @@ export {
|
|
76
79
|
getChainId,
|
77
80
|
getFeeHistory,
|
78
81
|
getFilterChanges,
|
82
|
+
getFilterLogs,
|
79
83
|
getGasPrice,
|
80
84
|
getPermissions,
|
81
85
|
getTransaction,
|
package/dist/chains.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { R as RpcBlock,
|
1
|
+
import { R as RpcBlock, d as Block, q as RpcTransaction, D as Transaction, r as RpcTransactionReceipt, T as TransactionReceipt, v as TransactionRequest, s as RpcTransactionRequest, N as TransactionType, H as Hex } from './rpc-b77c5aee.js';
|
2
2
|
import { Chain as Chain$1 } from '@wagmi/chains';
|
3
3
|
|
4
4
|
type Formatter<TSource = any, TTarget = any> = (value: TSource & {
|
@@ -24,7 +24,7 @@ declare const defineBlock: <TFormat extends Formatter<Partial<RpcBlock>, Partial
|
|
24
24
|
}) => Block<bigint, Transaction<bigint, number>> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
|
25
25
|
declare const defineTransaction: <TFormat extends Formatter<Partial<RpcTransaction>, Partial<Transaction<bigint, number>> & {
|
26
26
|
[key: string]: unknown;
|
27
|
-
}>, TExclude extends ("type" | "
|
27
|
+
}>, TExclude extends ("type" | "gas" | "value" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "blockHash" | "blockNumber" | "hash" | "from" | "input" | "nonce" | "r" | "s" | "to" | "transactionIndex" | "v" | "accessList")[] = []>({ exclude, format: formatOverride, }: {
|
28
28
|
exclude?: TExclude | undefined;
|
29
29
|
format?: TFormat | undefined;
|
30
30
|
}) => (data: Partial<RpcTransaction> & {
|
@@ -32,7 +32,7 @@ declare const defineTransaction: <TFormat extends Formatter<Partial<RpcTransacti
|
|
32
32
|
}) => Transaction<bigint, number> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
|
33
33
|
declare const defineTransactionRequest: <TFormat extends Formatter<Partial<TransactionRequest<bigint, number>>, Partial<RpcTransactionRequest> & {
|
34
34
|
[key: string]: unknown;
|
35
|
-
}>, TExclude extends ("
|
35
|
+
}>, TExclude extends ("gas" | "value" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "data" | "from" | "nonce" | "to" | "accessList")[] = []>({ exclude, format: formatOverride, }: {
|
36
36
|
exclude?: TExclude | undefined;
|
37
37
|
format?: TFormat | undefined;
|
38
38
|
}) => (data: Partial<TransactionRequest<bigint, number>> & {
|
package/dist/chains.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import {
|
2
|
-
|
2
|
+
UrlRequiredError,
|
3
3
|
buildRequest,
|
4
4
|
getSocket,
|
5
5
|
rpc
|
6
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-6GAKRM5P.js";
|
7
7
|
|
8
8
|
// src/clients/transports/createTransport.ts
|
9
9
|
function createTransport(config, value) {
|
@@ -13,38 +13,50 @@ function createTransport(config, value) {
|
|
13
13
|
};
|
14
14
|
}
|
15
15
|
|
16
|
-
// src/clients/transports/
|
17
|
-
|
18
|
-
constructor() {
|
19
|
-
super(
|
20
|
-
"No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",
|
21
|
-
{
|
22
|
-
docsPath: "/TODO"
|
23
|
-
}
|
24
|
-
);
|
25
|
-
}
|
26
|
-
};
|
27
|
-
|
28
|
-
// src/clients/transports/ethereumProvider.ts
|
29
|
-
function ethereumProvider({
|
30
|
-
key = "ethereumProvider",
|
31
|
-
name = "Ethereum Provider",
|
32
|
-
provider
|
33
|
-
}) {
|
16
|
+
// src/clients/transports/custom.ts
|
17
|
+
function custom(provider, { key = "custom", name = "Custom Provider" } = {}) {
|
34
18
|
return () => createTransport({
|
35
19
|
key,
|
36
20
|
name,
|
37
21
|
request: provider.request.bind(provider),
|
38
|
-
type: "
|
22
|
+
type: "custom"
|
39
23
|
});
|
40
24
|
}
|
41
25
|
|
26
|
+
// src/clients/transports/fallback.ts
|
27
|
+
function fallback(transports, { key = "fallback", name = "Fallback" } = {}) {
|
28
|
+
return ({ chain }) => createTransport(
|
29
|
+
{
|
30
|
+
key,
|
31
|
+
name,
|
32
|
+
async request({ method, params }) {
|
33
|
+
const fetch = async (i = 0) => {
|
34
|
+
const transport = transports[i]({ chain });
|
35
|
+
try {
|
36
|
+
return await transport.config.request({
|
37
|
+
method,
|
38
|
+
params
|
39
|
+
});
|
40
|
+
} catch (err) {
|
41
|
+
if (i < transports.length - 1)
|
42
|
+
return fetch(i + 1);
|
43
|
+
throw err;
|
44
|
+
}
|
45
|
+
};
|
46
|
+
return fetch();
|
47
|
+
},
|
48
|
+
type: "fallback"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
transports: transports.map(
|
52
|
+
(fn) => fn({ chain })
|
53
|
+
)
|
54
|
+
}
|
55
|
+
);
|
56
|
+
}
|
57
|
+
|
42
58
|
// src/clients/transports/http.ts
|
43
|
-
function http({
|
44
|
-
key = "http",
|
45
|
-
name = "HTTP JSON-RPC",
|
46
|
-
url
|
47
|
-
} = {}) {
|
59
|
+
function http(url, { key = "http", name = "HTTP JSON-RPC" } = {}) {
|
48
60
|
return ({ chain }) => {
|
49
61
|
const url_ = url || chain?.rpcUrls.default.http[0];
|
50
62
|
if (!url_)
|
@@ -72,10 +84,9 @@ function http({
|
|
72
84
|
}
|
73
85
|
|
74
86
|
// src/clients/transports/webSocket.ts
|
75
|
-
function webSocket({
|
87
|
+
function webSocket(url, {
|
76
88
|
key = "webSocket",
|
77
|
-
name = "WebSocket JSON-RPC"
|
78
|
-
url
|
89
|
+
name = "WebSocket JSON-RPC"
|
79
90
|
} = {}) {
|
80
91
|
return ({ chain }) => {
|
81
92
|
const url_ = url || chain?.rpcUrls.default.webSocket?.[0];
|
@@ -186,16 +197,14 @@ function createPublicClient({
|
|
186
197
|
pollingInterval
|
187
198
|
}) {
|
188
199
|
chain;
|
189
|
-
return {
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
})
|
198
|
-
};
|
200
|
+
return createClient({
|
201
|
+
chain,
|
202
|
+
key,
|
203
|
+
name,
|
204
|
+
pollingInterval,
|
205
|
+
transport,
|
206
|
+
type: "publicClient"
|
207
|
+
});
|
199
208
|
}
|
200
209
|
|
201
210
|
// src/clients/createTestClient.ts
|
@@ -227,21 +236,19 @@ function createWalletClient({
|
|
227
236
|
name = "Wallet Client",
|
228
237
|
pollingInterval
|
229
238
|
}) {
|
230
|
-
return {
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
})
|
238
|
-
};
|
239
|
+
return createClient({
|
240
|
+
key,
|
241
|
+
name,
|
242
|
+
pollingInterval,
|
243
|
+
transport,
|
244
|
+
type: "walletClient"
|
245
|
+
});
|
239
246
|
}
|
240
247
|
|
241
248
|
export {
|
242
249
|
createTransport,
|
243
|
-
|
244
|
-
|
250
|
+
custom,
|
251
|
+
fallback,
|
245
252
|
http,
|
246
253
|
webSocket,
|
247
254
|
createClient,
|