viem 0.0.1-alpha.0 → 0.0.1-alpha.2
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 +3 -7
- package/dist/actions/index.js +4 -2
- package/dist/chains.d.ts +2 -2
- package/dist/chains.js +1 -1
- package/dist/{chunk-GI67STNV.js → chunk-3EOU525X.js} +603 -26
- package/dist/{chunk-JSYJDK4W.js → chunk-4HNVS7AM.js} +99 -33
- package/dist/{chunk-OPR6LKYX.js → chunk-YQRTXQ2G.js} +56 -36
- package/dist/clients/index.d.ts +2 -2
- package/dist/clients/index.js +6 -4
- package/dist/{createWalletClient-c40fef16.d.ts → createWalletClient-915223f3.d.ts} +5 -5
- package/dist/index.d.ts +5 -4
- package/dist/index.js +19 -5
- package/dist/{parseGwei-a7d0bcb2.d.ts → parseGwei-fd7a0f7d.d.ts} +83 -10
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +7 -1
- package/dist/{watchAsset-bb30848d.d.ts → watchAsset-04ab8db5.d.ts} +20 -22
- package/dist/{webSocket-14584a7e.d.ts → webSocket-c6e0d26f.d.ts} +25 -14
- package/package.json +61 -10
@@ -1,7 +1,74 @@
|
|
1
|
-
import {
|
1
|
+
import { Abi, AbiFunction, ExtractAbiFunction, AbiParametersToPrimitiveTypes, AbiParameter, ExtractAbiFunctionNames } from 'abitype';
|
2
|
+
import { H as Hex, A as Address, f as ByteArray } from './rpc-655c0ba4.js';
|
2
3
|
import { B as BaseError } from './BaseError-7688f84e.js';
|
3
4
|
import { R as RpcError } from './rpc-3c0e3985.js';
|
4
5
|
|
6
|
+
type ExtractArgsFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiFunction extends AbiFunction & {
|
7
|
+
type: 'function';
|
8
|
+
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
|
9
|
+
type: 'function';
|
10
|
+
}, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
|
11
|
+
/**
|
12
|
+
* Arguments to pass contract method
|
13
|
+
*
|
14
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
15
|
+
*/
|
16
|
+
args?: readonly unknown[];
|
17
|
+
} : TArgs extends readonly [] ? {
|
18
|
+
args?: never;
|
19
|
+
} : {
|
20
|
+
/** Arguments to pass contract method */ args: TArgs;
|
21
|
+
};
|
22
|
+
|
23
|
+
declare function decodeAbi<TParams extends readonly AbiParameter[]>({ data, params, }: {
|
24
|
+
data: Hex;
|
25
|
+
params: TParams;
|
26
|
+
}): AbiParametersToPrimitiveTypes<TParams>;
|
27
|
+
declare class AbiDecodingDataSizeInvalidError extends BaseError {
|
28
|
+
name: string;
|
29
|
+
constructor(size: number);
|
30
|
+
}
|
31
|
+
declare class InvalidAbiDecodingTypeError extends BaseError {
|
32
|
+
name: string;
|
33
|
+
constructor(type: string);
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* @description Encodes a list of primitive values into an ABI-encoded hex value.
|
38
|
+
*/
|
39
|
+
declare function encodeAbi<TParams extends readonly AbiParameter[]>({ params, values, }: {
|
40
|
+
params: TParams;
|
41
|
+
values: AbiParametersToPrimitiveTypes<TParams>;
|
42
|
+
}): `0x${string}` | undefined;
|
43
|
+
declare class AbiEncodingArrayLengthMismatchError extends BaseError {
|
44
|
+
name: string;
|
45
|
+
constructor({ expectedLength, givenLength, type, }: {
|
46
|
+
expectedLength: number;
|
47
|
+
givenLength: number;
|
48
|
+
type: string;
|
49
|
+
});
|
50
|
+
}
|
51
|
+
declare class AbiEncodingLengthMismatchError extends BaseError {
|
52
|
+
name: string;
|
53
|
+
constructor({ expectedLength, givenLength, }: {
|
54
|
+
expectedLength: number;
|
55
|
+
givenLength: number;
|
56
|
+
});
|
57
|
+
}
|
58
|
+
declare class InvalidAbiEncodingTypeError extends BaseError {
|
59
|
+
name: string;
|
60
|
+
constructor(type: string);
|
61
|
+
}
|
62
|
+
declare class InvalidArrayError extends BaseError {
|
63
|
+
name: string;
|
64
|
+
constructor(value: unknown);
|
65
|
+
}
|
66
|
+
|
67
|
+
declare function encodeFunctionParams<TAbi extends Abi = Abi, TFunctionName extends ExtractAbiFunctionNames<TAbi> = any>({ abi, args, functionName, }: {
|
68
|
+
abi: TAbi;
|
69
|
+
functionName: TFunctionName;
|
70
|
+
} & ExtractArgsFromAbi<TAbi, TFunctionName>): `0x${string}`;
|
71
|
+
|
5
72
|
declare function getAddress(address: Address): `0x${string}`;
|
6
73
|
|
7
74
|
type GetCreateAddressOptions = {
|
@@ -109,14 +176,16 @@ type PadOptions = {
|
|
109
176
|
dir?: 'left' | 'right';
|
110
177
|
size?: number;
|
111
178
|
};
|
112
|
-
|
179
|
+
type PadResult<TValue extends ByteArray | Hex> = TValue extends Hex ? Hex : ByteArray;
|
180
|
+
declare function pad<TValue extends ByteArray | Hex>(hexOrBytes: TValue, { dir, size }?: PadOptions): PadResult<TValue>;
|
113
181
|
declare function padHex(hex_: Hex, { dir, size }?: PadOptions): `0x${string}`;
|
114
182
|
declare function padBytes(bytes: ByteArray, { dir, size }?: PadOptions): Uint8Array;
|
115
183
|
|
116
184
|
type TrimOptions = {
|
117
185
|
dir?: 'left' | 'right';
|
118
186
|
};
|
119
|
-
|
187
|
+
type TrimResult<TValue extends ByteArray | Hex> = TValue extends Hex ? Hex : ByteArray;
|
188
|
+
declare function trim<TValue extends ByteArray | Hex>(hexOrBytes: TValue, { dir }?: TrimOptions): TrimResult<TValue>;
|
120
189
|
|
121
190
|
/**
|
122
191
|
* @description Retrieves the size of the value (in bytes).
|
@@ -164,7 +233,7 @@ declare function bytesToHex(value: ByteArray): Hex;
|
|
164
233
|
* @description Encodes a string, number, bigint, or ByteArray into a hex string
|
165
234
|
*/
|
166
235
|
declare function encodeHex(value: string | number | bigint | boolean | ByteArray): Hex;
|
167
|
-
type NumberToHexOpts = {
|
236
|
+
type NumberToHexOpts$1 = {
|
168
237
|
signed?: boolean;
|
169
238
|
size: number;
|
170
239
|
} | {
|
@@ -174,7 +243,7 @@ type NumberToHexOpts = {
|
|
174
243
|
/**
|
175
244
|
* @description Encodes a number or bigint into a hex string
|
176
245
|
*/
|
177
|
-
declare function numberToHex(value_: number | bigint, opts?: NumberToHexOpts): Hex;
|
246
|
+
declare function numberToHex(value_: number | bigint, opts?: NumberToHexOpts$1): Hex;
|
178
247
|
/**
|
179
248
|
* @description Encodes a UTF-8 string into a hex string
|
180
249
|
*/
|
@@ -193,7 +262,7 @@ declare function hexToBytes(hex_: Hex): ByteArray;
|
|
193
262
|
/**
|
194
263
|
* @description Encodes a number into a byte array.
|
195
264
|
*/
|
196
|
-
declare function numberToBytes(value: bigint | number, opts?: NumberToHexOpts): Uint8Array;
|
265
|
+
declare function numberToBytes(value: bigint | number, opts?: NumberToHexOpts$1): Uint8Array;
|
197
266
|
/**
|
198
267
|
* @description Encodes a UTF-8 string into a byte array.
|
199
268
|
*/
|
@@ -232,18 +301,22 @@ type DecodeHexResponse<TTo> = TTo extends 'string' ? string : TTo extends 'bigin
|
|
232
301
|
* @description Decodes a hex string into a string, number, bigint, boolean, or bytes32 array.
|
233
302
|
*/
|
234
303
|
declare function decodeHex<TTo extends 'string' | 'bigint' | 'number' | 'bytes' | 'boolean'>(hex: Hex, to: TTo): DecodeHexResponse<TTo>;
|
304
|
+
type HexToBigIntOpts = {
|
305
|
+
signed?: boolean;
|
306
|
+
};
|
235
307
|
/**
|
236
308
|
* @description Decodes a hex string into a bigint.
|
237
309
|
*/
|
238
|
-
declare function hexToBigInt(hex: Hex): bigint;
|
310
|
+
declare function hexToBigInt(hex: Hex, opts?: HexToBigIntOpts): bigint;
|
239
311
|
/**
|
240
312
|
* @description Decodes a hex string into a boolean.
|
241
313
|
*/
|
242
314
|
declare function hexToBool(hex: Hex): boolean;
|
315
|
+
type NumberToHexOpts = HexToBigIntOpts;
|
243
316
|
/**
|
244
317
|
* @description Decodes a hex string into a number.
|
245
318
|
*/
|
246
|
-
declare function hexToNumber(hex: Hex): number;
|
319
|
+
declare function hexToNumber(hex: Hex, opts?: NumberToHexOpts): number;
|
247
320
|
/**
|
248
321
|
* @description Decodes a hex string into a UTF-8 string.
|
249
322
|
*/
|
@@ -254,7 +327,7 @@ declare function decodeRlp<TTo extends 'bytes' | 'hex'>(value: ByteArray | Hex,
|
|
254
327
|
|
255
328
|
declare const getEventSignature: (event: `${string}(${string})`) => `0x${string}`;
|
256
329
|
|
257
|
-
declare const getFunctionSignature: (fn: string) => string
|
330
|
+
declare const getFunctionSignature: (fn: string) => `0x${string}`;
|
258
331
|
|
259
332
|
type To = 'hex' | 'bytes';
|
260
333
|
type Keccak256Hash<TTo extends To> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
|
@@ -272,4 +345,4 @@ declare function parseEther(ether: `${number}`, unit?: 'wei' | 'gwei'): bigint;
|
|
272
345
|
|
273
346
|
declare function parseGwei(ether: `${number}`, unit?: 'wei'): bigint;
|
274
347
|
|
275
|
-
export {
|
348
|
+
export { hexToString as $, AbiDecodingDataSizeInvalidError as A, encodeFunctionParams as B, encodeHex as C, encodeRlp as D, EncodeRlpResponse as E, getAddress as F, GetContractAddressOptions as G, getContractAddress as H, InvalidAbiDecodingTypeError as I, JsonRpcVersionUnsupportedError as J, getCreateAddress as K, LimitExceededRpcError as L, MethodNotFoundRpcError as M, getCreate2Address as N, getEventSignature as O, ParseRpcError as P, getFunctionSignature as Q, ResourceNotFoundRpcError as R, formatEther as S, TransactionRejectedRpcError as T, isAddress as U, isAddressEqual as V, isBytes as W, isHex as X, hexToBigInt as Y, hexToBool as Z, hexToBytes as _, AbiEncodingArrayLengthMismatchError as a, keccak256 as a0, numberToBytes as a1, pad as a2, padBytes as a3, padHex as a4, parseEther as a5, parseGwei as a6, parseUnit as a7, formatGwei as a8, formatUnit as a9, hexToNumber as aa, numberToHex as ab, size as ac, slice as ad, sliceBytes as ae, sliceHex as af, stringToBytes as ag, stringToHex as ah, trim as ai, buildRequest as aj, AbiEncodingLengthMismatchError as b, GetCreateAddressOptions as c, GetCreate2AddressOptions as d, InvalidAbiEncodingTypeError as e, InvalidArrayError as f, InternalRpcError as g, InvalidInputRpcError as h, InvalidParamsRpcError as i, InvalidRequestRpcError as j, MethodNotSupportedRpcError as k, ResourceUnavailableRpcError as l, RpcRequestError as m, bytesToHex as n, bytesToString as o, boolToBytes as p, boolToHex as q, bytesToBigint as r, bytesToBool as s, bytesToNumber as t, decodeAbi as u, decodeBytes as v, decodeHex as w, decodeRlp as x, encodeAbi as y, encodeBytes as z };
|
package/dist/utils/index.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
export { E as EncodeRlpResponse, G as GetContractAddressOptions,
|
1
|
+
export { A as AbiDecodingDataSizeInvalidError, a as AbiEncodingArrayLengthMismatchError, b as AbiEncodingLengthMismatchError, E as EncodeRlpResponse, G as GetContractAddressOptions, d as GetCreate2AddressOptions, c as GetCreateAddressOptions, g as InternalRpcError, I as InvalidAbiDecodingTypeError, e as InvalidAbiEncodingTypeError, f as InvalidArrayError, h as InvalidInputRpcError, i as InvalidParamsRpcError, j as InvalidRequestRpcError, J as JsonRpcVersionUnsupportedError, L as LimitExceededRpcError, M as MethodNotFoundRpcError, k as MethodNotSupportedRpcError, P as ParseRpcError, R as ResourceNotFoundRpcError, l as ResourceUnavailableRpcError, m as RpcRequestError, T as TransactionRejectedRpcError, p as boolToBytes, q as boolToHex, aj as buildRequest, r as bytesToBigint, s as bytesToBool, n as bytesToHex, t as bytesToNumber, o as bytesToString, u as decodeAbi, v as decodeBytes, w as decodeHex, x as decodeRlp, y as encodeAbi, z as encodeBytes, B as encodeFunctionParams, C as encodeHex, D as encodeRlp, S as formatEther, a8 as formatGwei, a9 as formatUnit, F as getAddress, H as getContractAddress, N as getCreate2Address, K as getCreateAddress, O as getEventSignature, Q as getFunctionSignature, Y as hexToBigInt, Z as hexToBool, _ as hexToBytes, aa as hexToNumber, $ as hexToString, U as isAddress, V as isAddressEqual, W as isBytes, X as isHex, a0 as keccak256, a1 as numberToBytes, ab as numberToHex, a2 as pad, a3 as padBytes, a4 as padHex, a5 as parseEther, a6 as parseGwei, a7 as parseUnit, ac as size, ad as slice, ae as sliceBytes, af as sliceHex, ag as stringToBytes, ah as stringToHex, ai as trim } from '../parseGwei-fd7a0f7d.js';
|
2
2
|
export { B as BaseError } from '../BaseError-7688f84e.js';
|
3
3
|
export { B as BlockFormatter, E as ExtractFormatter, e as Formatted, F as FormattedBlock, a as FormattedTransaction, h as FormattedTransactionReceipt, b as FormattedTransactionRequest, g as TransactionFormatter, i as TransactionReceiptFormatter, T as TransactionRequestFormatter, j as format, f as formatBlock, c as formatTransaction, d as formatTransactionRequest } from '../transactionRequest-ade896ac.js';
|
4
4
|
export { H as HttpRequestError, R as RpcError, T as TimeoutError, r as rpc } from '../rpc-3c0e3985.js';
|
5
|
+
import 'abitype';
|
5
6
|
import '../rpc-655c0ba4.js';
|
6
7
|
import '../chains.js';
|
7
8
|
import '@wagmi/chains';
|
package/dist/utils/index.js
CHANGED
@@ -24,10 +24,13 @@ import {
|
|
24
24
|
bytesToHex,
|
25
25
|
bytesToNumber,
|
26
26
|
bytesToString,
|
27
|
+
decodeAbi,
|
27
28
|
decodeBytes,
|
28
29
|
decodeHex,
|
29
30
|
decodeRlp,
|
31
|
+
encodeAbi,
|
30
32
|
encodeBytes,
|
33
|
+
encodeFunctionParams,
|
31
34
|
encodeHex,
|
32
35
|
encodeRlp,
|
33
36
|
extractFunctionName,
|
@@ -72,7 +75,7 @@ import {
|
|
72
75
|
stringToBytes,
|
73
76
|
stringToHex,
|
74
77
|
trim
|
75
|
-
} from "../chunk-
|
78
|
+
} from "../chunk-3EOU525X.js";
|
76
79
|
export {
|
77
80
|
BaseError,
|
78
81
|
HttpRequestError,
|
@@ -99,10 +102,13 @@ export {
|
|
99
102
|
bytesToHex,
|
100
103
|
bytesToNumber,
|
101
104
|
bytesToString,
|
105
|
+
decodeAbi,
|
102
106
|
decodeBytes,
|
103
107
|
decodeHex,
|
104
108
|
decodeRlp,
|
109
|
+
encodeAbi,
|
105
110
|
encodeBytes,
|
111
|
+
encodeFunctionParams,
|
106
112
|
encodeHex,
|
107
113
|
encodeRlp,
|
108
114
|
extractFunctionName,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Chain, Formatter } from './chains.js';
|
2
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
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-
|
4
|
+
import { P as PublicClient, T as TestClient, W as WalletClient } from './createWalletClient-915223f3.js';
|
5
5
|
import { B as BaseError } from './BaseError-7688f84e.js';
|
6
6
|
import { W as WalletPermission, a as WatchAssetParams } from './eip1193-8f7c22ce.js';
|
7
7
|
|
@@ -12,9 +12,8 @@ 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>>;
|
18
17
|
} & ({
|
19
18
|
/** The balance of the account at a block number. */
|
20
19
|
blockNumber?: bigint;
|
@@ -27,7 +26,7 @@ type CallArgs<TChain extends Chain = Chain> = {
|
|
27
26
|
type CallResponse = {
|
28
27
|
data: Hex | undefined;
|
29
28
|
};
|
30
|
-
declare function call<TChain extends Chain>(client: PublicClient, { blockNumber, blockTag, chain,
|
29
|
+
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
30
|
|
32
31
|
type CreatePendingTransactionFilterResponse = Filter<'transaction'>;
|
33
32
|
declare function createPendingTransactionFilter(client: PublicClient): Promise<CreatePendingTransactionFilterResponse>;
|
@@ -35,9 +34,7 @@ declare function createPendingTransactionFilter(client: PublicClient): Promise<C
|
|
35
34
|
type CreateBlockFilterResponse = Filter<'block'>;
|
36
35
|
declare function createBlockFilter(client: PublicClient): Promise<CreateBlockFilterResponse>;
|
37
36
|
|
38
|
-
type EstimateGasArgs = {
|
39
|
-
request: EstimateGasParameters;
|
40
|
-
} & ({
|
37
|
+
type EstimateGasArgs = EstimateGasParameters & ({
|
41
38
|
/** The balance of the account at a block number. */
|
42
39
|
blockNumber?: bigint;
|
43
40
|
blockTag?: never;
|
@@ -50,7 +47,7 @@ type EstimateGasResponse = bigint;
|
|
50
47
|
/**
|
51
48
|
* @description Estimates the gas necessary to complete a transaction without submitting it to the network.
|
52
49
|
*/
|
53
|
-
declare function estimateGas(client: PublicClient, { blockNumber, blockTag,
|
50
|
+
declare function estimateGas(client: PublicClient, { blockNumber, blockTag, data, from, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to, value, }: EstimateGasArgs): Promise<EstimateGasResponse>;
|
54
51
|
|
55
52
|
type GetBalanceArgs = {
|
56
53
|
/** The address of the account. */
|
@@ -167,6 +164,12 @@ type GetFilterChangesArgs<TFilterType extends FilterType> = {
|
|
167
164
|
type GetFilterChangesResponse<TFilterType extends FilterType> = TFilterType extends 'event' ? Log[] : Hash[];
|
168
165
|
declare function getFilterChanges<TFilterType extends FilterType>(client: PublicClient, { filter }: GetFilterChangesArgs<TFilterType>): Promise<GetFilterChangesResponse<TFilterType>>;
|
169
166
|
|
167
|
+
type GetFilterLogsArgs = {
|
168
|
+
filter: Filter<'event'>;
|
169
|
+
};
|
170
|
+
type GetFilterLogsResponse = Log[];
|
171
|
+
declare function getFilterLogs<TFilterType extends FilterType>(client: PublicClient, { filter }: GetFilterLogsArgs): Promise<GetFilterLogsResponse>;
|
172
|
+
|
170
173
|
type GetGasPriceResponse = bigint;
|
171
174
|
/**
|
172
175
|
* @description Returns the current price of gas (in wei).
|
@@ -391,13 +394,9 @@ type RevertArgs = {
|
|
391
394
|
};
|
392
395
|
declare function revert(client: TestClient, { id }: RevertArgs): Promise<void>;
|
393
396
|
|
394
|
-
type SendUnsignedTransactionArgs =
|
395
|
-
|
396
|
-
|
397
|
-
type SendUnsignedTransactionResponse = {
|
398
|
-
hash: `0x${string}`;
|
399
|
-
};
|
400
|
-
declare function sendUnsignedTransaction(client: TestClient, { request }: SendUnsignedTransactionArgs): Promise<SendUnsignedTransactionResponse>;
|
397
|
+
type SendUnsignedTransactionArgs = TransactionRequest;
|
398
|
+
type SendUnsignedTransactionResponse = Hash;
|
399
|
+
declare function sendUnsignedTransaction(client: TestClient, request: SendUnsignedTransactionArgs): Promise<SendUnsignedTransactionResponse>;
|
401
400
|
|
402
401
|
declare function setAutomine(client: TestClient, enabled: boolean): Promise<void>;
|
403
402
|
|
@@ -489,6 +488,8 @@ declare function stopImpersonatingAccount(client: TestClient, { address }: StopI
|
|
489
488
|
|
490
489
|
declare function addChain(client: WalletClient, chain: Chain): Promise<void>;
|
491
490
|
|
491
|
+
declare function getAccounts(client: WalletClient): Promise<`0x${string}`[]>;
|
492
|
+
|
492
493
|
type GetPermissionsResponse = WalletPermission[];
|
493
494
|
declare function getPermissions(client: WalletClient): Promise<WalletPermission[]>;
|
494
495
|
|
@@ -503,14 +504,11 @@ type RequestPermissionsResponse = WalletPermission[];
|
|
503
504
|
declare function requestPermissions(client: WalletClient, permissions: RequestPermissionsArgs): Promise<WalletPermission[]>;
|
504
505
|
|
505
506
|
type FormattedTransactionRequest<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Formatted<TFormatter, TransactionRequest, true>, TransactionRequest>;
|
506
|
-
type SendTransactionArgs<TChain extends Chain = Chain> = {
|
507
|
+
type SendTransactionArgs<TChain extends Chain = Chain> = FormattedTransactionRequest<TransactionRequestFormatter<TChain>> & {
|
507
508
|
chain?: TChain;
|
508
|
-
request: FormattedTransactionRequest<TransactionRequestFormatter<TChain>>;
|
509
|
-
};
|
510
|
-
type SendTransactionResponse = {
|
511
|
-
hash: `0x${string}`;
|
512
509
|
};
|
513
|
-
|
510
|
+
type SendTransactionResponse = Hash;
|
511
|
+
declare function sendTransaction<TChain extends Chain>(client: WalletClient, { chain, from, accessList, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, ...rest }: SendTransactionArgs<TChain>): Promise<SendTransactionResponse>;
|
514
512
|
declare class InvalidGasArgumentsError extends BaseError {
|
515
513
|
name: string;
|
516
514
|
constructor();
|
@@ -532,4 +530,4 @@ type WatchAssetArgs = WatchAssetParams;
|
|
532
530
|
type WatchAssetResponse = boolean;
|
533
531
|
declare function watchAsset(client: WalletClient, params: WatchAssetParams): Promise<WatchAssetResponse>;
|
534
532
|
|
535
|
-
export {
|
533
|
+
export { SetBlockTimestampIntervalArgs as $, GetTransactionReceiptResponse as A, IncreaseTimeArgs as B, CallArgs as C, DropTransactionArgs as D, EstimateGasArgs as E, OnBlockNumber as F, GetBalanceArgs as G, OnBlockNumberResponse as H, ImpersonateAccountArgs as I, OnBlockResponse as J, OnTransactions as K, OnTransactionsResponse as L, MineArgs as M, RequestPermissionsResponse as N, OnBlock as O, RevertArgs as P, SendTransactionResponse as Q, ResetArgs as R, SendTransactionArgs as S, SendUnsignedTransactionArgs as T, SendUnsignedTransactionResponse as U, SetBalanceArgs as V, SetBlockGasLimitArgs as W, SetCodeArgs as X, SetCoinbaseArgs as Y, SetIntervalMiningArgs as Z, SetMinGasPriceArgs as _, CallResponse as a, setNonce as a$, SetNextBlockTimestampArgs as a0, SetNextBlockBaseFeePerGasArgs as a1, SetNonceArgs as a2, SetStorageAtArgs as a3, SignMessageArgs as a4, SignMessageResponse as a5, StopImpersonatingAccountArgs as a6, SwitchChainArgs as a7, UninstallFilterArgs as a8, UninstallFilterResponse as a9, getTransactionConfirmations as aA, getTransactionCount as aB, getTransactionReceipt as aC, getTxpoolContent as aD, getTxpoolStatus as aE, impersonateAccount as aF, increaseTime as aG, inspectTxpool as aH, mine as aI, removeBlockTimestampInterval as aJ, reset as aK, requestAccounts as aL, requestPermissions as aM, revert as aN, sendTransaction as aO, sendUnsignedTransaction as aP, setAutomine as aQ, setBalance as aR, setBlockGasLimit as aS, setBlockTimestampInterval as aT, setCode as aU, setCoinbase as aV, setIntervalMining as aW, setLoggingEnabled as aX, setMinGasPrice as aY, setNextBlockBaseFeePerGas as aZ, setNextBlockTimestamp as a_, WaitForTransactionReceiptArgs as aa, WaitForTransactionReceiptResponse as ab, WatchAssetArgs as ac, WatchAssetResponse as ad, WatchBlockNumberArgs as ae, WatchBlocksArgs as af, WatchPendingTransactionsArgs as ag, addChain as ah, call as ai, createBlockFilter as aj, createPendingTransactionFilter as ak, estimateGas as al, dropTransaction as am, getAccounts as an, getAutomine as ao, getBalance as ap, getBlock as aq, getBlockNumber as ar, getBlockTransactionCount as as, getChainId as at, getFeeHistory as au, getFilterChanges as av, getFilterLogs as aw, getGasPrice as ax, getPermissions as ay, getTransaction as az, CreateBlockFilterResponse as b, setStorageAt as b0, signMessage as b1, snapshot as b2, stopImpersonatingAccount as b3, switchChain as b4, uninstallFilter as b5, waitForTransactionReceipt as b6, watchAsset as b7, watchBlockNumber as b8, watchBlocks as b9, watchPendingTransactions as ba, getBlockNumberCache as bb, ReplacementReason as bc, ReplacementResponse as bd, WaitForTransactionReceiptTimeoutError as be, FormattedTransactionRequest as bf, InvalidGasArgumentsError as bg, 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, GetFilterLogsArgs as p, GetFilterLogsResponse as q, GetGasPriceResponse as r, GetPermissionsResponse as s, GetTransactionArgs as t, GetTransactionConfirmationsArgs as u, GetTransactionConfirmationsResponse as v, GetTransactionCountArgs as w, GetTransactionCountResponse as x, GetTransactionResponse as y, GetTransactionReceiptArgs as z };
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { B as BaseError } from './BaseError-7688f84e.js';
|
2
|
-
import { e as TransportConfig, d as Transport, B as BaseRpcRequests } from './createWalletClient-
|
2
|
+
import { e as TransportConfig, d as Transport, B as BaseRpcRequests } from './createWalletClient-915223f3.js';
|
3
3
|
import { k as Hash } from './rpc-655c0ba4.js';
|
4
4
|
import { a as RpcResponse } from './rpc-3c0e3985.js';
|
5
5
|
|
@@ -10,27 +10,36 @@ declare class UrlRequiredError extends BaseError {
|
|
10
10
|
type EthereumProvider = {
|
11
11
|
request: BaseRpcRequests['request'];
|
12
12
|
};
|
13
|
-
type
|
13
|
+
type CustomTransportConfig = {
|
14
14
|
/** The key of the transport. */
|
15
15
|
key?: TransportConfig['key'];
|
16
16
|
/** The name of the transport. */
|
17
17
|
name?: TransportConfig['name'];
|
18
|
-
/** An EIP-1193 or equivalent provider with a "request" function. */
|
19
|
-
provider: TProvider;
|
20
18
|
};
|
21
|
-
type
|
19
|
+
type CustomTransport = Transport<'custom', EthereumProvider['request']>;
|
22
20
|
/**
|
23
|
-
* @description Creates a transport
|
21
|
+
* @description Creates a custom transport given an EIP-1193 compliant `request` attribute.
|
24
22
|
*/
|
25
|
-
declare function
|
23
|
+
declare function custom<TProvider extends EthereumProvider>(
|
24
|
+
/** An Ethereum provider with an EIP-1193 "request" attribute. */
|
25
|
+
provider: TProvider, { key, name }?: CustomTransportConfig): CustomTransport;
|
26
|
+
|
27
|
+
type FallbackTransportConfig = {
|
28
|
+
/** The key of the Fallback transport. */
|
29
|
+
key?: TransportConfig['key'];
|
30
|
+
/** The name of the Fallback transport. */
|
31
|
+
name?: TransportConfig['name'];
|
32
|
+
};
|
33
|
+
type FallbackTransport = Transport<'fallback', {
|
34
|
+
transports: Transport[];
|
35
|
+
}>;
|
36
|
+
declare function fallback(transports: Transport[], { key, name }?: FallbackTransportConfig): FallbackTransport;
|
26
37
|
|
27
38
|
type HttpTransportConfig = {
|
28
39
|
/** The key of the HTTP transport. */
|
29
40
|
key?: TransportConfig['key'];
|
30
41
|
/** The name of the HTTP transport. */
|
31
42
|
name?: TransportConfig['name'];
|
32
|
-
/** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
|
33
|
-
url?: string;
|
34
43
|
};
|
35
44
|
type HttpTransport = Transport<'http', {
|
36
45
|
url?: string;
|
@@ -38,7 +47,9 @@ type HttpTransport = Transport<'http', {
|
|
38
47
|
/**
|
39
48
|
* @description Creates a HTTP transport that connects to a JSON-RPC API.
|
40
49
|
*/
|
41
|
-
declare function http(
|
50
|
+
declare function http(
|
51
|
+
/** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
|
52
|
+
url?: string, { key, name }?: HttpTransportConfig): HttpTransport;
|
42
53
|
|
43
54
|
type WebSocketTransportSubscribeArgs = {
|
44
55
|
onData: (data: RpcResponse) => void;
|
@@ -62,8 +73,6 @@ type WebSocketTransportConfig = {
|
|
62
73
|
key?: TransportConfig['key'];
|
63
74
|
/** The name of the WebSocket transport. */
|
64
75
|
name?: TransportConfig['name'];
|
65
|
-
/** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
|
66
|
-
url?: string;
|
67
76
|
};
|
68
77
|
type WebSocketTransport = Transport<'webSocket', {
|
69
78
|
getSocket(): Promise<WebSocket>;
|
@@ -72,6 +81,8 @@ type WebSocketTransport = Transport<'webSocket', {
|
|
72
81
|
/**
|
73
82
|
* @description Creates a WebSocket transport that connects to a JSON-RPC API.
|
74
83
|
*/
|
75
|
-
declare function webSocket(
|
84
|
+
declare function webSocket(
|
85
|
+
/** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
|
86
|
+
url?: string, { key, name, }?: WebSocketTransportConfig): WebSocketTransport;
|
76
87
|
|
77
|
-
export {
|
88
|
+
export { CustomTransport as C, FallbackTransport as F, HttpTransport as H, UrlRequiredError as U, 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/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.
|
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.2",
|
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
|
-
"
|
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
|
-
"
|
53
|
-
|
80
|
+
"authors": [
|
81
|
+
"awkweb.eth",
|
82
|
+
"jxom.eth"
|
83
|
+
],
|
54
84
|
"keywords": [
|
55
85
|
"eth",
|
56
86
|
"ethereum",
|
@@ -58,8 +88,29 @@
|
|
58
88
|
"wallet",
|
59
89
|
"web3"
|
60
90
|
],
|
91
|
+
"simple-git-hooks": {
|
92
|
+
"pre-commit": "pnpm format & pnpm lint:fix"
|
93
|
+
},
|
61
94
|
"scripts": {
|
95
|
+
"anvil": "source .env && anvil --fork-url $ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
96
|
+
"bench": "vitest bench --no-threads",
|
97
|
+
"bench:ci": "CI=true vitest bench --no-threads",
|
62
98
|
"build": "tsup",
|
63
|
-
"
|
99
|
+
"changeset": "changeset",
|
100
|
+
"changeset:release": "pnpm build && changeset publish",
|
101
|
+
"changeset:version": "changeset version && pnpm install --lockfile-only",
|
102
|
+
"dev": "DEV=true tsup",
|
103
|
+
"dev:docs": "pnpm -r --filter site dev",
|
104
|
+
"format": "rome format src/ test/ --write",
|
105
|
+
"lint": "rome check .",
|
106
|
+
"lint:fix": "pnpm lint --apply-suggested",
|
107
|
+
"playground": "pnpm --filter playground-dev dev",
|
108
|
+
"playground:benchmark": "pnpm --filter playground-benchmark dev",
|
109
|
+
"postinstall": "pnpm dev",
|
110
|
+
"preinstall": "npx only-allow pnpm",
|
111
|
+
"test": "vitest dev --coverage --no-threads",
|
112
|
+
"test:ci": "CI=true vitest --coverage --no-threads",
|
113
|
+
"test:ui": "vitest dev --ui --no-threads",
|
114
|
+
"typecheck": "tsc --noEmit"
|
64
115
|
}
|
65
116
|
}
|