viem 0.0.1-alpha.19 → 0.0.1-alpha.20
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/{rpc-858670f1.d.ts → chain-32f56cfa.d.ts} +68 -18
- package/dist/chain-f12cdc7f.d.ts +5 -0
- package/dist/chains.d.ts +757 -170
- package/dist/chains.js +80 -86
- package/dist/chains.js.map +1 -1
- package/dist/chains.mjs +120 -126
- package/dist/chains.mjs.map +1 -1
- package/dist/{chunk-PHSAQQGZ.mjs → chunk-5Q6FSUU2.mjs} +75 -37
- package/dist/chunk-5Q6FSUU2.mjs.map +1 -0
- package/dist/{chunk-24EKKMUO.js → chunk-FHXXG7I6.js} +12 -12
- package/dist/chunk-FHXXG7I6.js.map +1 -0
- package/dist/{chunk-HRE6LYF3.js → chunk-IAQPMSGJ.js} +13 -13
- package/dist/chunk-IAQPMSGJ.js.map +1 -0
- package/dist/{chunk-IVWG22RQ.mjs → chunk-MYQNZSWD.mjs} +69 -12
- package/dist/chunk-MYQNZSWD.mjs.map +1 -0
- package/dist/{chunk-NYMS65YI.js → chunk-NHAKUPTF.js} +124 -67
- package/dist/chunk-NHAKUPTF.js.map +1 -0
- package/dist/{chunk-BZFF747V.js → chunk-SF4I2NKC.js} +81 -43
- package/dist/chunk-SF4I2NKC.js.map +1 -0
- package/dist/{chunk-VAT5CEF7.mjs → chunk-T7CBAKLI.mjs} +2 -2
- package/dist/chunk-T7CBAKLI.mjs.map +1 -0
- package/dist/{chunk-CTU4PQLY.js → chunk-YFKR74XG.js} +14 -14
- package/dist/{chunk-CTU4PQLY.js.map → chunk-YFKR74XG.js.map} +0 -0
- package/dist/{chunk-NSRORL3O.mjs → chunk-YODUQCHJ.mjs} +2 -2
- package/dist/{chunk-NSRORL3O.mjs.map → chunk-YODUQCHJ.mjs.map} +0 -0
- package/dist/{chunk-E7LH5H76.mjs → chunk-ZVGTYLKU.mjs} +2 -2
- package/dist/chunk-ZVGTYLKU.mjs.map +1 -0
- package/dist/clients/index.d.ts +7 -8
- package/dist/clients/index.js +3 -3
- package/dist/clients/index.mjs +2 -2
- package/dist/{transactionReceipt-aed524b4.d.ts → contract-9af4608b.d.ts} +30 -18
- package/dist/{createClient-03ba79e8.d.ts → createClient-5d316c7e.d.ts} +2 -2
- package/dist/{createPublicClient-818241ba.d.ts → createPublicClient-9d2b42e1.d.ts} +3 -3
- package/dist/{createTestClient-24eb7be8.d.ts → createTestClient-79498dab.d.ts} +3 -3
- package/dist/{createWalletClient-7cbd6ad1.d.ts → createWalletClient-f69a5230.d.ts} +3 -3
- package/dist/{eip1193-71d8e27d.d.ts → eip1193-6c485d63.d.ts} +1 -1
- package/dist/index.d.ts +45 -23
- package/dist/index.js +10 -6
- package/dist/index.mjs +9 -5
- package/dist/{parseGwei-dbd12305.d.ts → parseGwei-4308ad80.d.ts} +17 -4
- package/dist/public.d.ts +9 -10
- package/dist/public.js +4 -4
- package/dist/public.mjs +3 -3
- package/dist/{sendTransaction-d09961a7.d.ts → sendTransaction-1c8290a9.d.ts} +3 -4
- package/dist/{stopImpersonatingAccount-c8a00be7.d.ts → stopImpersonatingAccount-7781842a.d.ts} +2 -2
- package/dist/test.d.ts +5 -6
- package/dist/test.js +3 -3
- package/dist/test.mjs +2 -2
- package/dist/transactionRequest-341b6ed2.d.ts +15 -0
- package/dist/utils/index.d.ts +9 -8
- package/dist/utils/index.js +22 -2
- package/dist/utils/index.mjs +25 -5
- package/dist/wallet.d.ts +7 -8
- package/dist/wallet.js +3 -3
- package/dist/wallet.mjs +2 -2
- package/dist/{watchAsset-c39645b7.d.ts → watchAsset-afaad3c7.d.ts} +3 -4
- package/dist/{watchPendingTransactions-01e6be4f.d.ts → watchPendingTransactions-3b722547.d.ts} +21 -16
- package/dist/{webSocket-3a00015b.d.ts → webSocket-b180e679.d.ts} +2 -2
- package/dist/window.d.ts +3 -2
- package/package.json +3 -3
- package/src/_test/abis.ts +188 -0
- package/src/_test/constants.ts +0 -3
- package/src/_test/index.ts +5 -2
- package/src/actions/index.test.ts +2 -0
- package/src/actions/index.ts +6 -0
- package/src/actions/public/call.ts +2 -1
- package/src/actions/public/createContractEventFilter.test.ts +119 -0
- package/src/actions/public/createContractEventFilter.ts +69 -0
- package/src/actions/public/createEventFilter.ts +5 -8
- package/src/actions/public/deployContract.ts +1 -2
- package/src/actions/public/getBlock.test.ts +3 -3
- package/src/actions/public/getBlock.ts +1 -2
- package/src/actions/public/getBlockTransactionCount.ts +1 -2
- package/src/actions/public/getFilterChanges.test.ts +9 -7
- package/src/actions/public/getFilterLogs.test.ts +7 -5
- package/src/actions/public/getLogs.test.ts +7 -5
- package/src/actions/public/getLogs.ts +3 -2
- package/src/actions/public/getTransaction.ts +1 -2
- package/src/actions/public/getTransactionConfirmations.ts +1 -2
- package/src/actions/public/getTransactionReceipt.test.ts +24 -62
- package/src/actions/public/getTransactionReceipt.ts +1 -2
- package/src/actions/public/index.test.ts +4 -0
- package/src/actions/public/index.ts +18 -0
- package/src/actions/public/readContract.ts +1 -1
- package/src/actions/public/simulateContract.ts +1 -1
- package/src/actions/public/waitForTransactionReceipt.ts +1 -2
- package/src/actions/public/watchBlocks.test.ts +27 -2
- package/src/actions/public/watchBlocks.ts +33 -14
- package/src/actions/public/watchContractEvent.test.ts +301 -0
- package/src/actions/public/watchContractEvent.ts +108 -0
- package/src/actions/public/watchEvent.test.ts +190 -0
- package/src/actions/public/watchEvent.ts +95 -0
- package/src/actions/public/watchPendingTransactions.ts +1 -0
- package/src/actions/wallet/addChain.ts +1 -1
- package/src/actions/wallet/sendTransaction.ts +2 -1
- package/src/actions/wallet/switchChain.ts +1 -1
- package/src/actions/wallet/writeContract.ts +1 -1
- package/src/chains.test.ts +830 -52
- package/src/chains.ts +90 -158
- package/src/clients/createClient.ts +1 -1
- package/src/clients/createPublicClient.ts +1 -1
- package/src/clients/createTestClient.ts +1 -1
- package/src/clients/createWalletClient.ts +1 -1
- package/src/clients/transports/createTransport.ts +1 -1
- package/src/index.test.ts +2 -0
- package/src/index.ts +10 -2
- package/src/types/chain.ts +6 -0
- package/src/types/contract.ts +17 -2
- package/src/types/formatter.ts +23 -0
- package/src/types/index.ts +6 -0
- package/src/types/transaction.ts +1 -1
- package/src/utils/abi/decodeErrorResult.ts +2 -2
- package/src/utils/abi/decodeFunctionData.ts +2 -2
- package/src/utils/abi/encodeErrorResult.ts +2 -2
- package/src/utils/abi/encodeEventTopics.ts +4 -4
- package/src/utils/abi/encodeFunctionData.ts +2 -2
- package/src/utils/abi/{formatAbiItemWithParams.test.ts → formatAbiItem.test.ts} +11 -11
- package/src/utils/abi/{formatAbiItemWithParams.ts → formatAbiItem.ts} +1 -1
- package/src/utils/abi/index.test.ts +1 -1
- package/src/utils/abi/index.ts +1 -1
- package/src/utils/chain.test.ts +43 -0
- package/src/utils/chain.ts +8 -0
- package/src/utils/contract/getContractError.ts +2 -6
- package/src/utils/formatters/block.ts +4 -3
- package/src/utils/formatters/extract.ts +1 -1
- package/src/utils/formatters/format.ts +39 -2
- package/src/utils/formatters/index.test.ts +10 -0
- package/src/utils/formatters/index.ts +15 -5
- package/src/utils/formatters/transaction.ts +16 -4
- package/src/utils/formatters/transactionReceipt.ts +13 -4
- package/src/utils/formatters/transactionRequest.ts +12 -3
- package/src/utils/hash/getEventSignature.ts +2 -2
- package/src/utils/index.test.ts +24 -1
- package/src/utils/index.ts +12 -1
- package/src/{constants.test.ts → utils/unit/constants.test.ts} +0 -5
- package/src/{constants.ts → utils/unit/constants.ts} +0 -6
- package/src/utils/unit/formatEther.ts +1 -1
- package/src/utils/unit/formatGwei.ts +1 -1
- package/src/utils/unit/index.test.ts +12 -0
- package/src/utils/unit/index.ts +1 -0
- package/src/utils/unit/parseEther.ts +1 -1
- package/src/utils/unit/parseGwei.ts +1 -1
- package/dist/chunk-24EKKMUO.js.map +0 -1
- package/dist/chunk-BZFF747V.js.map +0 -1
- package/dist/chunk-E7LH5H76.mjs.map +0 -1
- package/dist/chunk-HRE6LYF3.js.map +0 -1
- package/dist/chunk-IVWG22RQ.mjs.map +0 -1
- package/dist/chunk-NYMS65YI.js.map +0 -1
- package/dist/chunk-PHSAQQGZ.mjs.map +0 -1
- package/dist/chunk-VAT5CEF7.mjs.map +0 -1
- package/dist/transactionRequest-8e970b0e.d.ts +0 -33
@@ -1,20 +1,4 @@
|
|
1
|
-
|
2
|
-
gwei: number;
|
3
|
-
wei: number;
|
4
|
-
};
|
5
|
-
declare const gweiUnits: {
|
6
|
-
ether: number;
|
7
|
-
wei: number;
|
8
|
-
};
|
9
|
-
declare const weiUnits: {
|
10
|
-
ether: number;
|
11
|
-
gwei: number;
|
12
|
-
};
|
13
|
-
declare const transactionType: {
|
14
|
-
readonly '0x0': "legacy";
|
15
|
-
readonly '0x1': "eip2930";
|
16
|
-
readonly '0x2': "eip1559";
|
17
|
-
};
|
1
|
+
import { Chain as Chain$1 } from '@wagmi/chains';
|
18
2
|
|
19
3
|
type Address = `0x${string}`;
|
20
4
|
type ByteArray = Uint8Array;
|
@@ -22,6 +6,58 @@ type Hex = `0x${string}`;
|
|
22
6
|
type Hash = `0x${string}`;
|
23
7
|
type LogTopic = Hex | Hex[] | null;
|
24
8
|
|
9
|
+
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;
|
10
|
+
type FormatOptions<TSource, TTarget> = {
|
11
|
+
formatter: Formatter<TSource, TTarget>;
|
12
|
+
};
|
13
|
+
/**
|
14
|
+
* Creates a type that is the result of applying `TFormatter` to `TSource`.
|
15
|
+
*
|
16
|
+
* @example
|
17
|
+
* Formatted<() => { a: undefined, b: bigint }, { a: bigint }>
|
18
|
+
* => { a: undefined, b: bigint }
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* Formatted<() => {}, { a: bigint }>
|
22
|
+
* => { a: bigint }
|
23
|
+
*
|
24
|
+
* @example
|
25
|
+
* Formatted<() => { a: bigint | undefined, b: bigint }, { a: bigint, b: bigint }, true>
|
26
|
+
* => { a?: bigint | undefined, b: bigint }
|
27
|
+
*/
|
28
|
+
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;
|
29
|
+
/**
|
30
|
+
* @description Formats a data object using the given replacer and an optional formatter.
|
31
|
+
*/
|
32
|
+
declare function format<TFormatter, TSource extends Record<string, any>, TTarget>(data: TSource, { formatter }: FormatOptions<TSource, TTarget>): Formatted<TFormatter, TTarget, false>;
|
33
|
+
declare function defineFormatter<TSource extends Record<string, unknown>, TFormatted>({ format, }: {
|
34
|
+
format: (data: TSource) => TFormatted;
|
35
|
+
}): <TFormat extends Formatter<TSource, Partial<TFormatted> & {
|
36
|
+
[key: string]: unknown;
|
37
|
+
}>, TExclude extends (keyof TSource)[] = []>({ exclude, format: formatOverride, }: {
|
38
|
+
exclude?: TExclude | undefined;
|
39
|
+
format?: TFormat | undefined;
|
40
|
+
}) => (data: TSource & {
|
41
|
+
[key: string]: unknown;
|
42
|
+
}) => TFormatted & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
|
43
|
+
|
44
|
+
type TransactionFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transaction', NonNullable<Formatters['transaction']>>;
|
45
|
+
type FormattedTransaction<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, Transaction>;
|
46
|
+
declare const transactionType: {
|
47
|
+
readonly '0x0': "legacy";
|
48
|
+
readonly '0x1': "eip2930";
|
49
|
+
readonly '0x2': "eip1559";
|
50
|
+
};
|
51
|
+
declare function formatTransaction(transaction: Partial<RpcTransaction>): Transaction<bigint, number>;
|
52
|
+
declare const defineTransaction: <TFormat extends Formatter<Partial<RpcTransaction>, Partial<Transaction<bigint, number>> & {
|
53
|
+
[key: string]: unknown;
|
54
|
+
}>, TExclude extends ("type" | "blockHash" | "blockNumber" | "hash" | "value" | "gas" | "from" | "input" | "nonce" | "r" | "s" | "to" | "transactionIndex" | "v" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "accessList")[] = []>({ exclude, format: formatOverride, }: {
|
55
|
+
exclude?: TExclude | undefined;
|
56
|
+
format?: TFormat | undefined;
|
57
|
+
}) => (data: Partial<RpcTransaction> & {
|
58
|
+
[key: string]: unknown;
|
59
|
+
}) => Transaction<bigint, number> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
|
60
|
+
|
25
61
|
type EstimateGasParameters<TQuantity = bigint> = {
|
26
62
|
/** Contract code or a hashed method call with encoded args */
|
27
63
|
data?: Hex;
|
@@ -300,4 +336,18 @@ type RpcTransactionReceipt = TransactionReceipt<Quantity, Index, Status, Transac
|
|
300
336
|
type RpcTransactionRequest = TransactionRequest<Quantity, Index>;
|
301
337
|
type RpcTransaction = TransactionLegacy<Quantity, Index, '0x0'> | TransactionEIP2930<Quantity, Index, '0x1'> | TransactionEIP1559<Quantity, Index, '0x2'>;
|
302
338
|
|
303
|
-
|
339
|
+
type Formatter<TSource = any, TTarget = any> = (value: TSource & {
|
340
|
+
[key: string]: unknown;
|
341
|
+
}) => TTarget;
|
342
|
+
type Formatters = {
|
343
|
+
block?: Formatter<RpcBlock, Block>;
|
344
|
+
transaction?: Formatter<RpcTransaction, Transaction>;
|
345
|
+
transactionReceipt?: Formatter<RpcTransactionReceipt, TransactionReceipt>;
|
346
|
+
transactionRequest?: Formatter<TransactionRequest, RpcTransactionRequest>;
|
347
|
+
};
|
348
|
+
|
349
|
+
type Chain<TFormatters extends Formatters = Formatters> = Chain$1 & {
|
350
|
+
formatters?: TFormatters;
|
351
|
+
};
|
352
|
+
|
353
|
+
export { defineTransaction as $, Address as A, BlockNumber as B, TransactionEIP2930 as C, TransactionLegacy as D, FormattedTransaction as E, FeeHistory as F, formatTransaction as G, Hash as H, transactionType as I, Chain as J, Formatter as K, Log as L, MergeIntersectionProperties as M, Formatted as N, EstimateGasParameters as O, TransactionFormatter as P, ExtractFormatter as Q, RpcBlock as R, TransactionType$1 as S, TransactionReceipt as T, Uncle as U, Formatters as V, Trim as W, Quantity as X, RpcEstimateGasParameters as Y, LogTopic as Z, defineFormatter as _, BlockTag as a, format as a0, Hex as b, ByteArray as c, AccessList as d, Block as e, BlockIdentifier as f, FeeValues as g, FeeValuesEIP1559 as h, FeeValuesLegacy as i, RpcBlockIdentifier as j, RpcBlockNumber as k, RpcFeeHistory as l, RpcFeeValues as m, RpcLog as n, RpcTransaction as o, RpcTransactionReceipt as p, RpcTransactionRequest as q, RpcUncle as r, TransactionRequest as s, TransactionRequestBase as t, TransactionRequestEIP1559 as u, TransactionRequestEIP2930 as v, TransactionRequestLegacy as w, Transaction as x, TransactionBase as y, TransactionEIP1559 as z };
|