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.
@@ -1,9 +1,9 @@
1
+ import { Abi } from 'abitype';
1
2
  import { Chain, Formatter } from './chains.js';
2
- import { H as Hex, d as BlockTag, M as MergeIntersectionProperties, v as TransactionRequest, K as EstimateGasParameters, A as Address, k as Hash, F as FeeHistory, L as Log, r as RpcTransactionReceipt, T as TransactionReceipt, N as TransactionType, D as Transaction, q as RpcTransaction, Q as Quantity, f as ByteArray } from './rpc-655c0ba4.js';
3
- import { T as TransactionRequestFormatter, e as Formatted, F as FormattedBlock, B as BlockFormatter, a as FormattedTransaction, g as TransactionFormatter, h as FormattedTransactionReceipt, i as TransactionReceiptFormatter, E as ExtractFormatter } from './transactionRequest-ade896ac.js';
4
- import { P as PublicClient, T as TestClient, W as WalletClient } from './createWalletClient-c40fef16.js';
5
- import { B as BaseError } from './BaseError-7688f84e.js';
6
- import { W as WalletPermission, a as WatchAssetParams } from './eip1193-8f7c22ce.js';
3
+ import { H as Hex, A as Address, b as BlockTag, M as MergeIntersectionProperties, v as TransactionRequest, K as EstimateGasParameters, a as Hash, F as FeeHistory, L as Log, r as RpcTransactionReceipt, T as TransactionReceipt, N as TransactionType, D as Transaction, q as RpcTransaction, Q as Quantity, B as ByteArray } from './rpc-b77c5aee.js';
4
+ import { T as TransactionRequestFormatter, e as Formatted, E as ExtractFunctionNameFromAbi, G as GetValue, g as ExtractArgsFromAbi, h as ExtractResultFromAbi, F as FormattedBlock, B as BlockFormatter, a as FormattedTransaction, i as TransactionFormatter, j as FormattedTransactionReceipt, k as TransactionReceiptFormatter, l as ExtractFormatter } from './transactionRequest-08d30731.js';
5
+ import { P as PublicClient, T as TestClient, W as WalletClient } from './createWalletClient-d612fe08.js';
6
+ import { W as WalletPermission, a as WatchAssetParams } from './eip1193-020a6f13.js';
7
7
 
8
8
  type FilterType = 'transaction' | 'block' | 'event';
9
9
  type Filter<TFilterType extends FilterType = 'event'> = {
@@ -12,9 +12,9 @@ type Filter<TFilterType extends FilterType = 'event'> = {
12
12
  };
13
13
 
14
14
  type FormattedCall<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Formatted<TFormatter, TransactionRequest, true>, TransactionRequest>;
15
- type CallArgs<TChain extends Chain = Chain> = {
15
+ type CallArgs<TChain extends Chain = Chain> = FormattedCall<TransactionRequestFormatter<TChain>> & {
16
16
  chain?: TChain;
17
- request: FormattedCall<TransactionRequestFormatter<TChain>>;
17
+ from?: Address;
18
18
  } & ({
19
19
  /** The balance of the account at a block number. */
20
20
  blockNumber?: bigint;
@@ -27,7 +27,17 @@ type CallArgs<TChain extends Chain = Chain> = {
27
27
  type CallResponse = {
28
28
  data: Hex | undefined;
29
29
  };
30
- declare function call<TChain extends Chain>(client: PublicClient, { blockNumber, blockTag, chain, request }: CallArgs<TChain>): Promise<CallResponse>;
30
+ declare function call<TChain extends Chain>(client: PublicClient, { blockNumber, blockTag, chain, from, accessList, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, ...rest }: CallArgs<TChain>): Promise<CallResponse>;
31
+
32
+ type CallContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any> = Omit<CallArgs<TChain>, 'from' | 'to' | 'data' | 'value'> & {
33
+ address: Address;
34
+ abi: TAbi;
35
+ from?: Address;
36
+ functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName>;
37
+ value?: GetValue<TAbi, TFunctionName, CallArgs<TChain>['value']>;
38
+ } & ExtractArgsFromAbi<TAbi, TFunctionName>;
39
+ type CallContractResponse<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = ExtractResultFromAbi<TAbi, TFunctionName>;
40
+ declare function callContract<TChain extends Chain, TAbi extends Abi = Abi, TFunctionName extends string = any>(client: PublicClient, { abi, address, args, functionName, ...callRequest }: CallContractArgs<TChain, TAbi, TFunctionName>): Promise<CallContractResponse<TAbi, TFunctionName>>;
31
41
 
32
42
  type CreatePendingTransactionFilterResponse = Filter<'transaction'>;
33
43
  declare function createPendingTransactionFilter(client: PublicClient): Promise<CreatePendingTransactionFilterResponse>;
@@ -35,9 +45,7 @@ declare function createPendingTransactionFilter(client: PublicClient): Promise<C
35
45
  type CreateBlockFilterResponse = Filter<'block'>;
36
46
  declare function createBlockFilter(client: PublicClient): Promise<CreateBlockFilterResponse>;
37
47
 
38
- type EstimateGasArgs = {
39
- request: EstimateGasParameters;
40
- } & ({
48
+ type EstimateGasArgs = EstimateGasParameters & ({
41
49
  /** The balance of the account at a block number. */
42
50
  blockNumber?: bigint;
43
51
  blockTag?: never;
@@ -50,7 +58,7 @@ type EstimateGasResponse = bigint;
50
58
  /**
51
59
  * @description Estimates the gas necessary to complete a transaction without submitting it to the network.
52
60
  */
53
- declare function estimateGas(client: PublicClient, { blockNumber, blockTag, request: { data, from, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to, value, }, }: EstimateGasArgs): Promise<EstimateGasResponse>;
61
+ declare function estimateGas(client: PublicClient, { blockNumber, blockTag, data, from, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to, value, }: EstimateGasArgs): Promise<EstimateGasResponse>;
54
62
 
55
63
  type GetBalanceArgs = {
56
64
  /** The address of the account. */
@@ -167,6 +175,12 @@ type GetFilterChangesArgs<TFilterType extends FilterType> = {
167
175
  type GetFilterChangesResponse<TFilterType extends FilterType> = TFilterType extends 'event' ? Log[] : Hash[];
168
176
  declare function getFilterChanges<TFilterType extends FilterType>(client: PublicClient, { filter }: GetFilterChangesArgs<TFilterType>): Promise<GetFilterChangesResponse<TFilterType>>;
169
177
 
178
+ type GetFilterLogsArgs = {
179
+ filter: Filter<'event'>;
180
+ };
181
+ type GetFilterLogsResponse = Log[];
182
+ declare function getFilterLogs<TFilterType extends FilterType>(client: PublicClient, { filter }: GetFilterLogsArgs): Promise<GetFilterLogsResponse>;
183
+
170
184
  type GetGasPriceResponse = bigint;
171
185
  /**
172
186
  * @description Returns the current price of gas (in wei).
@@ -272,12 +286,6 @@ type WaitForTransactionReceiptArgs<TChain extends Chain = Chain> = {
272
286
  timeout?: number;
273
287
  };
274
288
  declare function waitForTransactionReceipt<TChain extends Chain>(client: PublicClient<any, TChain>, { confirmations, hash, onReplaced, pollingInterval, timeout, }: WaitForTransactionReceiptArgs<TChain>): Promise<WaitForTransactionReceiptResponse<TChain>>;
275
- declare class WaitForTransactionReceiptTimeoutError extends BaseError {
276
- name: string;
277
- constructor({ hash }: {
278
- hash: Hash;
279
- });
280
- }
281
289
 
282
290
  type OnBlockNumberResponse = GetBlockNumberResponse;
283
291
  type OnBlockNumber = (blockNumber: OnBlockNumberResponse, prevBlockNumber: OnBlockNumberResponse | undefined) => void;
@@ -391,13 +399,9 @@ type RevertArgs = {
391
399
  };
392
400
  declare function revert(client: TestClient, { id }: RevertArgs): Promise<void>;
393
401
 
394
- type SendUnsignedTransactionArgs = {
395
- request: TransactionRequest;
396
- };
397
- type SendUnsignedTransactionResponse = {
398
- hash: `0x${string}`;
399
- };
400
- declare function sendUnsignedTransaction(client: TestClient, { request }: SendUnsignedTransactionArgs): Promise<SendUnsignedTransactionResponse>;
402
+ type SendUnsignedTransactionArgs = TransactionRequest;
403
+ type SendUnsignedTransactionResponse = Hash;
404
+ declare function sendUnsignedTransaction(client: TestClient, request: SendUnsignedTransactionArgs): Promise<SendUnsignedTransactionResponse>;
401
405
 
402
406
  declare function setAutomine(client: TestClient, enabled: boolean): Promise<void>;
403
407
 
@@ -489,6 +493,8 @@ declare function stopImpersonatingAccount(client: TestClient, { address }: StopI
489
493
 
490
494
  declare function addChain(client: WalletClient, chain: Chain): Promise<void>;
491
495
 
496
+ declare function getAccounts(client: WalletClient): Promise<`0x${string}`[]>;
497
+
492
498
  type GetPermissionsResponse = WalletPermission[];
493
499
  declare function getPermissions(client: WalletClient): Promise<WalletPermission[]>;
494
500
 
@@ -503,18 +509,11 @@ type RequestPermissionsResponse = WalletPermission[];
503
509
  declare function requestPermissions(client: WalletClient, permissions: RequestPermissionsArgs): Promise<WalletPermission[]>;
504
510
 
505
511
  type FormattedTransactionRequest<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Formatted<TFormatter, TransactionRequest, true>, TransactionRequest>;
506
- type SendTransactionArgs<TChain extends Chain = Chain> = {
512
+ type SendTransactionArgs<TChain extends Chain = Chain> = FormattedTransactionRequest<TransactionRequestFormatter<TChain>> & {
507
513
  chain?: TChain;
508
- request: FormattedTransactionRequest<TransactionRequestFormatter<TChain>>;
509
- };
510
- type SendTransactionResponse = {
511
- hash: `0x${string}`;
512
514
  };
513
- declare function sendTransaction<TChain extends Chain>(client: WalletClient, { chain, request }: SendTransactionArgs<TChain>): Promise<SendTransactionResponse>;
514
- declare class InvalidGasArgumentsError extends BaseError {
515
- name: string;
516
- constructor();
517
- }
515
+ type SendTransactionResponse = Hash;
516
+ declare function sendTransaction<TChain extends Chain>(client: WalletClient, { chain, from, accessList, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, ...rest }: SendTransactionArgs<TChain>): Promise<SendTransactionResponse>;
518
517
 
519
518
  type SignMessageArgs = {
520
519
  from: Address;
@@ -532,4 +531,4 @@ type WatchAssetArgs = WatchAssetParams;
532
531
  type WatchAssetResponse = boolean;
533
532
  declare function watchAsset(client: WalletClient, params: WatchAssetParams): Promise<WatchAssetResponse>;
534
533
 
535
- export { SetNextBlockBaseFeePerGasArgs as $, OnBlockNumber as A, OnBlockNumberResponse as B, CallArgs as C, DropTransactionArgs as D, EstimateGasArgs as E, OnBlockResponse as F, GetBalanceArgs as G, OnTransactions as H, ImpersonateAccountArgs as I, OnTransactionsResponse as J, RequestPermissionsResponse as K, RevertArgs as L, MineArgs as M, SendTransactionResponse as N, OnBlock as O, SendUnsignedTransactionArgs as P, SendUnsignedTransactionResponse as Q, ResetArgs as R, SendTransactionArgs as S, SetBalanceArgs as T, SetBlockGasLimitArgs as U, SetCodeArgs as V, SetCoinbaseArgs as W, SetIntervalMiningArgs as X, SetMinGasPriceArgs as Y, SetBlockTimestampIntervalArgs as Z, SetNextBlockTimestampArgs as _, CallResponse as a, switchChain as a$, SetNonceArgs as a0, SetStorageAtArgs as a1, SignMessageArgs as a2, SignMessageResponse as a3, StopImpersonatingAccountArgs as a4, SwitchChainArgs as a5, UninstallFilterArgs as a6, UninstallFilterResponse as a7, WaitForTransactionReceiptArgs as a8, WaitForTransactionReceiptResponse as a9, impersonateAccount as aA, increaseTime as aB, inspectTxpool as aC, mine as aD, removeBlockTimestampInterval as aE, reset as aF, requestAccounts as aG, requestPermissions as aH, revert as aI, sendTransaction as aJ, sendUnsignedTransaction as aK, setAutomine as aL, setBalance as aM, setBlockGasLimit as aN, setBlockTimestampInterval as aO, setCode as aP, setCoinbase as aQ, setIntervalMining as aR, setLoggingEnabled as aS, setMinGasPrice as aT, setNextBlockBaseFeePerGas as aU, setNextBlockTimestamp as aV, setNonce as aW, setStorageAt as aX, signMessage as aY, snapshot as aZ, stopImpersonatingAccount as a_, WatchAssetArgs as aa, WatchAssetResponse as ab, WatchBlockNumberArgs as ac, WatchBlocksArgs as ad, WatchPendingTransactionsArgs as ae, addChain as af, call as ag, createBlockFilter as ah, createPendingTransactionFilter as ai, estimateGas as aj, dropTransaction as ak, getAutomine as al, getBalance as am, getBlock as an, getBlockNumber as ao, getBlockTransactionCount as ap, getChainId as aq, getFeeHistory as ar, getGasPrice as as, getPermissions as at, getTransaction as au, getTransactionConfirmations as av, getTransactionCount as aw, getTransactionReceipt as ax, getTxpoolContent as ay, getTxpoolStatus as az, CreateBlockFilterResponse as b, uninstallFilter as b0, waitForTransactionReceipt as b1, watchAsset as b2, watchBlockNumber as b3, watchBlocks as b4, watchPendingTransactions as b5, getBlockNumberCache as b6, getFilterChanges as b7, ReplacementReason as b8, ReplacementResponse as b9, WaitForTransactionReceiptTimeoutError as ba, FormattedTransactionRequest as bb, InvalidGasArgumentsError as bc, CreatePendingTransactionFilterResponse as c, EstimateGasResponse as d, GetBalanceResponse as e, GetBlockArgs as f, GetBlockNumberArgs as g, GetBlockNumberResponse as h, GetBlockResponse as i, GetBlockTransactionCountArgs as j, GetBlockTransactionCountResponse as k, GetFeeHistoryArgs as l, GetFeeHistoryResponse as m, GetFilterChangesArgs as n, GetFilterChangesResponse as o, GetGasPriceResponse as p, GetPermissionsResponse as q, GetTransactionArgs as r, GetTransactionConfirmationsArgs as s, GetTransactionConfirmationsResponse as t, GetTransactionCountArgs as u, GetTransactionCountResponse as v, GetTransactionResponse as w, GetTransactionReceiptArgs as x, GetTransactionReceiptResponse as y, IncreaseTimeArgs as z };
534
+ export { SetIntervalMiningArgs as $, GetTransactionResponse as A, GetTransactionReceiptArgs as B, CallArgs as C, DropTransactionArgs as D, EstimateGasArgs as E, GetTransactionReceiptResponse as F, GetBalanceArgs as G, IncreaseTimeArgs as H, ImpersonateAccountArgs as I, OnBlockNumber as J, OnBlockNumberResponse as K, OnBlockResponse as L, MineArgs as M, OnTransactions as N, OnBlock as O, OnTransactionsResponse as P, RequestPermissionsResponse as Q, ResetArgs as R, RevertArgs as S, SendTransactionArgs as T, SendTransactionResponse as U, SendUnsignedTransactionArgs as V, SendUnsignedTransactionResponse as W, SetBalanceArgs as X, SetBlockGasLimitArgs as Y, SetCodeArgs as Z, SetCoinbaseArgs as _, CallContractArgs as a, setMinGasPrice as a$, SetMinGasPriceArgs as a0, SetBlockTimestampIntervalArgs as a1, SetNextBlockTimestampArgs as a2, SetNextBlockBaseFeePerGasArgs as a3, SetNonceArgs as a4, SetStorageAtArgs as a5, SignMessageArgs as a6, SignMessageResponse as a7, StopImpersonatingAccountArgs as a8, SwitchChainArgs as a9, getGasPrice as aA, getPermissions as aB, getTransaction as aC, getTransactionConfirmations as aD, getTransactionCount as aE, getTransactionReceipt as aF, getTxpoolContent as aG, getTxpoolStatus as aH, impersonateAccount as aI, increaseTime as aJ, inspectTxpool as aK, mine as aL, removeBlockTimestampInterval as aM, reset as aN, requestAccounts as aO, requestPermissions as aP, revert as aQ, sendTransaction as aR, sendUnsignedTransaction as aS, setAutomine as aT, setBalance as aU, setBlockGasLimit as aV, setBlockTimestampInterval as aW, setCode as aX, setCoinbase as aY, setIntervalMining as aZ, setLoggingEnabled as a_, UninstallFilterArgs as aa, UninstallFilterResponse as ab, WaitForTransactionReceiptArgs as ac, WaitForTransactionReceiptResponse as ad, WatchAssetArgs as ae, WatchAssetResponse as af, WatchBlockNumberArgs as ag, WatchBlocksArgs as ah, WatchPendingTransactionsArgs as ai, addChain as aj, call as ak, callContract as al, createBlockFilter as am, createPendingTransactionFilter as an, estimateGas as ao, dropTransaction as ap, getAccounts as aq, getAutomine as ar, getBalance as as, getBlock as at, getBlockNumber as au, getBlockTransactionCount as av, getChainId as aw, getFeeHistory as ax, getFilterChanges as ay, getFilterLogs as az, CallContractResponse as b, setNextBlockBaseFeePerGas as b0, setNextBlockTimestamp as b1, setNonce as b2, setStorageAt as b3, signMessage as b4, snapshot as b5, stopImpersonatingAccount as b6, switchChain as b7, uninstallFilter as b8, waitForTransactionReceipt as b9, watchAsset as ba, watchBlockNumber as bb, watchBlocks as bc, watchPendingTransactions as bd, getBlockNumberCache as be, ReplacementReason as bf, ReplacementResponse as bg, FormattedTransactionRequest as bh, CallResponse as c, CreateBlockFilterResponse as d, CreatePendingTransactionFilterResponse as e, EstimateGasResponse as f, GetBalanceResponse as g, GetBlockArgs as h, GetBlockNumberArgs as i, GetBlockNumberResponse as j, GetBlockResponse as k, GetBlockTransactionCountArgs as l, GetBlockTransactionCountResponse as m, GetFeeHistoryArgs as n, GetFeeHistoryResponse as o, GetFilterChangesArgs as p, GetFilterChangesResponse as q, GetFilterLogsArgs as r, GetFilterLogsResponse as s, GetGasPriceResponse as t, GetPermissionsResponse as u, GetTransactionArgs as v, GetTransactionConfirmationsArgs as w, GetTransactionConfirmationsResponse as x, GetTransactionCountArgs as y, GetTransactionCountResponse as z };
@@ -1,36 +1,40 @@
1
- import { B as BaseError } from './BaseError-7688f84e.js';
2
- import { e as TransportConfig, d as Transport, B as BaseRpcRequests } from './createWalletClient-c40fef16.js';
3
- import { k as Hash } from './rpc-655c0ba4.js';
4
- import { a as RpcResponse } from './rpc-3c0e3985.js';
5
-
6
- declare class UrlRequiredError extends BaseError {
7
- constructor();
8
- }
1
+ import { e as TransportConfig, d as Transport, B as BaseRpcRequests } from './createWalletClient-d612fe08.js';
2
+ import { a as Hash } from './rpc-b77c5aee.js';
3
+ import { R as RpcResponse } from './rpc-26932bae.js';
9
4
 
10
5
  type EthereumProvider = {
11
6
  request: BaseRpcRequests['request'];
12
7
  };
13
- type EthereumProviderTransportConfig<TProvider> = {
8
+ type CustomTransportConfig = {
14
9
  /** The key of the transport. */
15
10
  key?: TransportConfig['key'];
16
11
  /** The name of the transport. */
17
12
  name?: TransportConfig['name'];
18
- /** An EIP-1193 or equivalent provider with a "request" function. */
19
- provider: TProvider;
20
13
  };
21
- type EthereumProviderTransport = Transport<'ethereumProvider', EthereumProvider['request']>;
14
+ type CustomTransport = Transport<'custom', EthereumProvider['request']>;
22
15
  /**
23
- * @description Creates a transport based on an EIP-1193 provider (eg. `window.ethereum`).
16
+ * @description Creates a custom transport given an EIP-1193 compliant `request` attribute.
24
17
  */
25
- declare function ethereumProvider<TProvider extends EthereumProvider>({ key, name, provider, }: EthereumProviderTransportConfig<TProvider>): EthereumProviderTransport;
18
+ declare function custom<TProvider extends EthereumProvider>(
19
+ /** An Ethereum provider with an EIP-1193 "request" attribute. */
20
+ provider: TProvider, { key, name }?: CustomTransportConfig): CustomTransport;
21
+
22
+ type FallbackTransportConfig = {
23
+ /** The key of the Fallback transport. */
24
+ key?: TransportConfig['key'];
25
+ /** The name of the Fallback transport. */
26
+ name?: TransportConfig['name'];
27
+ };
28
+ type FallbackTransport = Transport<'fallback', {
29
+ transports: Transport[];
30
+ }>;
31
+ declare function fallback(transports: Transport[], { key, name }?: FallbackTransportConfig): FallbackTransport;
26
32
 
27
33
  type HttpTransportConfig = {
28
34
  /** The key of the HTTP transport. */
29
35
  key?: TransportConfig['key'];
30
36
  /** The name of the HTTP transport. */
31
37
  name?: TransportConfig['name'];
32
- /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
33
- url?: string;
34
38
  };
35
39
  type HttpTransport = Transport<'http', {
36
40
  url?: string;
@@ -38,7 +42,9 @@ type HttpTransport = Transport<'http', {
38
42
  /**
39
43
  * @description Creates a HTTP transport that connects to a JSON-RPC API.
40
44
  */
41
- declare function http({ key, name, url, }?: HttpTransportConfig): HttpTransport;
45
+ declare function http(
46
+ /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
47
+ url?: string, { key, name }?: HttpTransportConfig): HttpTransport;
42
48
 
43
49
  type WebSocketTransportSubscribeArgs = {
44
50
  onData: (data: RpcResponse) => void;
@@ -62,8 +68,6 @@ type WebSocketTransportConfig = {
62
68
  key?: TransportConfig['key'];
63
69
  /** The name of the WebSocket transport. */
64
70
  name?: TransportConfig['name'];
65
- /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
66
- url?: string;
67
71
  };
68
72
  type WebSocketTransport = Transport<'webSocket', {
69
73
  getSocket(): Promise<WebSocket>;
@@ -72,6 +76,8 @@ type WebSocketTransport = Transport<'webSocket', {
72
76
  /**
73
77
  * @description Creates a WebSocket transport that connects to a JSON-RPC API.
74
78
  */
75
- declare function webSocket({ key, name, url, }?: WebSocketTransportConfig): WebSocketTransport;
79
+ declare function webSocket(
80
+ /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
81
+ url?: string, { key, name, }?: WebSocketTransportConfig): WebSocketTransport;
76
82
 
77
- export { EthereumProviderTransport as E, HttpTransport as H, UrlRequiredError as U, WebSocketTransport as W, EthereumProviderTransportConfig as a, HttpTransportConfig as b, WebSocketTransportConfig as c, ethereumProvider as e, http as h, webSocket as w };
83
+ export { CustomTransport as C, FallbackTransport as F, HttpTransport as H, WebSocketTransport as W, CustomTransportConfig as a, FallbackTransportConfig as b, HttpTransportConfig as c, WebSocketTransportConfig as d, custom as e, fallback as f, http as h, webSocket as w };
package/dist/window.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Requests, E as Events } from './eip1193-8f7c22ce.js';
2
- import './rpc-655c0ba4.js';
1
+ import { R as Requests, E as Events } from './eip1193-020a6f13.js';
2
+ import './rpc-b77c5aee.js';
3
3
 
4
4
  type WindowProvider = Requests & Events;
5
5
  declare global {
package/package.json CHANGED
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript (& JavaScript) Interface for Ethereum",
4
- "version": "0.0.1-alpha.0",
5
- "dependencies": {
6
- "@noble/hashes": "^1.1.2",
7
- "@wagmi/chains": "^0.1.0",
8
- "abitype": "^0.2.5"
9
- },
4
+ "version": "0.0.1-alpha.10",
10
5
  "files": [
11
6
  "/actions",
12
7
  "/chains",
@@ -47,10 +42,45 @@
47
42
  "main": "dist/index.js",
48
43
  "types": "dist/index.d.ts",
49
44
  "sideEffects": false,
50
- "license": "WAGMIT",
45
+ "dependencies": {
46
+ "@noble/hashes": "^1.1.2",
47
+ "@wagmi/chains": "^0.1.0",
48
+ "abitype": "^0.2.5"
49
+ },
50
+ "devDependencies": {
51
+ "@actions/core": "^1.10.0",
52
+ "@actions/github": "^5.1.1",
53
+ "@changesets/changelog-github": "^0.4.5",
54
+ "@changesets/cli": "^2.23.2",
55
+ "@testing-library/jest-dom": "^5.16.5",
56
+ "@types/dedent": "^0.7.0",
57
+ "@types/fs-extra": "^9.0.13",
58
+ "@types/node": "^17.0.45",
59
+ "@vitest/coverage-c8": "^0.24.3",
60
+ "@vitest/ui": "^0.19.1",
61
+ "bundlewatch": "^0.3.3",
62
+ "dedent": "^0.7.0",
63
+ "esbuild": "^0.16.12",
64
+ "esbuild-register": "^3.4.2",
65
+ "essential-eth": "^0.6.2",
66
+ "ethers": "^5.7.2",
67
+ "execa": "^6.1.0",
68
+ "fs-extra": "^10.1.0",
69
+ "jsdom": "^20.0.0",
70
+ "rome": "^11.0.0",
71
+ "simple-git-hooks": "^2.8.1",
72
+ "tsup": "^6.5.0",
73
+ "typescript": "^4.9.3",
74
+ "vite": "^3.0.4",
75
+ "vitest": "^0.25.2",
76
+ "web3": "^1.8.1"
77
+ },
78
+ "license": "MIT",
51
79
  "repository": "wagmi-dev/viem",
52
- "author": "moxey.eth",
53
- "ethereum": "moxey.eth",
80
+ "authors": [
81
+ "awkweb.eth",
82
+ "jxom.eth"
83
+ ],
54
84
  "keywords": [
55
85
  "eth",
56
86
  "ethereum",
@@ -58,8 +88,32 @@
58
88
  "wallet",
59
89
  "web3"
60
90
  ],
91
+ "engines": {
92
+ "node": ">=18"
93
+ },
94
+ "simple-git-hooks": {
95
+ "pre-commit": "pnpm format & pnpm lint:fix"
96
+ },
61
97
  "scripts": {
98
+ "anvil": "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
99
+ "bench": "vitest bench --no-threads",
100
+ "bench:ci": "CI=true vitest bench --no-threads",
62
101
  "build": "tsup",
63
- "dev": "DEV=true tsup"
102
+ "changeset": "changeset",
103
+ "changeset:release": "pnpm build && changeset publish",
104
+ "changeset:version": "changeset version && pnpm install --lockfile-only",
105
+ "dev": "DEV=true tsup",
106
+ "dev:docs": "pnpm -r --filter site dev",
107
+ "format": "rome format src/ test/ --write",
108
+ "lint": "rome check .",
109
+ "lint:fix": "pnpm lint --apply-suggested",
110
+ "playground": "pnpm --filter playground-dev dev",
111
+ "playground:benchmark": "pnpm --filter playground-benchmark dev",
112
+ "postinstall": "pnpm dev",
113
+ "preinstall": "npx only-allow pnpm",
114
+ "test": "vitest dev --coverage --no-threads",
115
+ "test:ci": "CI=true vitest --coverage --no-threads",
116
+ "test:ui": "vitest dev --ui --no-threads",
117
+ "typecheck": "tsc --noEmit"
64
118
  }
65
119
  }
@@ -1,18 +0,0 @@
1
- type BaseErrorArgs = {
2
- docsPath?: string;
3
- } & ({
4
- cause?: never;
5
- details?: string;
6
- } | {
7
- cause: BaseError | Error;
8
- details?: never;
9
- });
10
- declare class BaseError extends Error {
11
- humanMessage: string;
12
- details: string;
13
- docsPath?: string;
14
- name: string;
15
- constructor(humanMessage: string, args?: BaseErrorArgs);
16
- }
17
-
18
- export { BaseError as B };
@@ -1,44 +0,0 @@
1
- import { O as OptionalNullable, B as Block, R as RpcBlock, D as Transaction, q as RpcTransaction, T as TransactionReceipt, s as RpcTransactionRequest, v as TransactionRequest } from './rpc-655c0ba4.js';
2
- import { Chain, Formatter, Formatters } from './chains.js';
3
-
4
- type ExtractFormatter<TChain extends Chain, TKey extends keyof NonNullable<TChain['formatters']>, TFallbackFormatter extends Formatter = Formatter> = NonNullable<TChain['formatters']>[TKey] extends NonNullable<unknown> ? NonNullable<TChain['formatters']>[TKey] : TFallbackFormatter;
5
- type FormatOptions<TSource, TTarget> = {
6
- formatter: Formatter<TSource, TTarget>;
7
- };
8
- /**
9
- * Creates a type that is the result of applying `TFormatter` to `TSource`.
10
- *
11
- * @example
12
- * Formatted<() => { a: undefined, b: bigint }, { a: bigint }>
13
- * => { a: undefined, b: bigint }
14
- *
15
- * @example
16
- * Formatted<() => {}, { a: bigint }>
17
- * => { a: bigint }
18
- *
19
- * @example
20
- * Formatted<() => { a: bigint | undefined, b: bigint }, { a: bigint, b: bigint }, true>
21
- * => { a?: bigint | undefined, b: bigint }
22
- */
23
- type Formatted<TFormatter, TFallback, TAllowOptional = false> = TFormatter extends Formatter ? ReturnType<TFormatter> extends Record<string, never> ? TFallback : TAllowOptional extends true ? OptionalNullable<ReturnType<TFormatter>> : ReturnType<TFormatter> : never;
24
- /**
25
- * @description Formats a data object using the given replacer and an optional formatter.
26
- */
27
- declare function format<TFormatter, TSource extends Record<string, any>, TTarget>(data: TSource, { formatter }: FormatOptions<TSource, TTarget>): Formatted<TFormatter, TTarget, false>;
28
-
29
- type BlockFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'block', NonNullable<Formatters['block']>>;
30
- type FormattedBlock<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, Block>;
31
- declare function formatBlock(block: Partial<RpcBlock>): Block<bigint, Transaction<bigint, number>>;
32
-
33
- type TransactionFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transaction', NonNullable<Formatters['transaction']>>;
34
- type FormattedTransaction<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, Transaction>;
35
- declare function formatTransaction(transaction: Partial<RpcTransaction>): Transaction<bigint, number>;
36
-
37
- type TransactionReceiptFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transactionReceipt', NonNullable<Formatters['transactionReceipt']>>;
38
- type FormattedTransactionReceipt<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, TransactionReceipt>;
39
-
40
- type TransactionRequestFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transactionRequest', NonNullable<Formatters['transactionRequest']>>;
41
- type FormattedTransactionRequest<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, RpcTransactionRequest>;
42
- declare function formatTransactionRequest(transactionRequest: Partial<TransactionRequest>): RpcTransactionRequest;
43
-
44
- export { BlockFormatter as B, ExtractFormatter as E, FormattedBlock as F, TransactionRequestFormatter as T, FormattedTransaction as a, FormattedTransactionRequest as b, formatTransaction as c, formatTransactionRequest as d, Formatted as e, formatBlock as f, TransactionFormatter as g, FormattedTransactionReceipt as h, TransactionReceiptFormatter as i, format as j };