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
@@ -1,6 +1,78 @@
|
|
1
|
-
import {
|
2
|
-
import { B as
|
3
|
-
import {
|
1
|
+
import { AbiParameter, AbiParametersToPrimitiveTypes, Abi, ExtractAbiErrorNames, ExtractAbiEventNames } from 'abitype';
|
2
|
+
import { H as Hex, A as Address, B as ByteArray } from './rpc-b77c5aee.js';
|
3
|
+
import { E as ExtractFunctionNameFromAbi, h as ExtractResultFromAbi, m as ExtractConstructorArgsFromAbi, n as ExtractErrorArgsFromAbi, o as ExtractEventArgsFromAbi, g as ExtractArgsFromAbi } from './transactionRequest-08d30731.js';
|
4
|
+
|
5
|
+
type DecodeAbiArgs<TParams extends readonly AbiParameter[]> = {
|
6
|
+
data: Hex;
|
7
|
+
params: TParams;
|
8
|
+
};
|
9
|
+
declare function decodeAbi<TParams extends readonly AbiParameter[]>({ data, params, }: DecodeAbiArgs<TParams>): AbiParametersToPrimitiveTypes<TParams> | undefined;
|
10
|
+
|
11
|
+
type DecodeErrorResultArgs = {
|
12
|
+
abi: Abi;
|
13
|
+
data: Hex;
|
14
|
+
};
|
15
|
+
declare function decodeErrorResult({ abi, data }: DecodeErrorResultArgs): {
|
16
|
+
errorName: string;
|
17
|
+
args: readonly unknown[] | undefined;
|
18
|
+
};
|
19
|
+
|
20
|
+
type DecodeFunctionDataArgs = {
|
21
|
+
abi: Abi;
|
22
|
+
data: Hex;
|
23
|
+
};
|
24
|
+
declare function decodeFunctionData({ abi, data }: DecodeFunctionDataArgs): {
|
25
|
+
functionName: string;
|
26
|
+
args: readonly unknown[] | undefined;
|
27
|
+
};
|
28
|
+
|
29
|
+
type DecodeFunctionResultArgs<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any> = {
|
30
|
+
abi: TAbi;
|
31
|
+
functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName>;
|
32
|
+
data: Hex;
|
33
|
+
};
|
34
|
+
type DecodeFunctionResultResponse<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any> = ExtractResultFromAbi<TAbi, TFunctionName>;
|
35
|
+
declare function decodeFunctionResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any>({ abi, functionName, data, }: DecodeFunctionResultArgs<TAbi, TFunctionName>): DecodeFunctionResultResponse<TAbi, TFunctionName>;
|
36
|
+
|
37
|
+
type EncodeAbiArgs<TParams extends readonly AbiParameter[]> = {
|
38
|
+
params: TParams;
|
39
|
+
values: AbiParametersToPrimitiveTypes<TParams>;
|
40
|
+
};
|
41
|
+
/**
|
42
|
+
* @description Encodes a list of primitive values into an ABI-encoded hex value.
|
43
|
+
*/
|
44
|
+
declare function encodeAbi<TParams extends readonly AbiParameter[]>({ params, values, }: EncodeAbiArgs<TParams>): `0x${string}`;
|
45
|
+
|
46
|
+
type EncodeDeployDataArgs<TAbi extends Abi = Abi> = {
|
47
|
+
abi: TAbi;
|
48
|
+
bytecode: Hex;
|
49
|
+
} & ExtractConstructorArgsFromAbi<TAbi>;
|
50
|
+
declare function encodeDeployData<TAbi extends Abi = Abi>({ abi, args, bytecode, }: EncodeDeployDataArgs<TAbi>): `0x${string}`;
|
51
|
+
|
52
|
+
type EncodeErrorResultArgs<TAbi extends Abi = Abi, TErrorName extends ExtractAbiErrorNames<TAbi> = any> = {
|
53
|
+
abi: TAbi;
|
54
|
+
errorName: TErrorName;
|
55
|
+
} & ExtractErrorArgsFromAbi<TAbi, TErrorName>;
|
56
|
+
declare function encodeErrorResult<TAbi extends Abi = Abi, TErrorName extends ExtractAbiErrorNames<TAbi> = any>({ abi, errorName, args }: EncodeErrorResultArgs<TAbi, TErrorName>): `0x${string}`;
|
57
|
+
|
58
|
+
type EncodeEventTopicsArgs<TAbi extends Abi = Abi, TEventName extends ExtractAbiEventNames<TAbi> = any> = {
|
59
|
+
abi: TAbi;
|
60
|
+
eventName: TEventName;
|
61
|
+
} & ExtractEventArgsFromAbi<TAbi, TEventName>;
|
62
|
+
declare function encodeEventTopics<TAbi extends Abi = Abi, TEventName extends ExtractAbiEventNames<TAbi> = any>({ abi, eventName, args }: EncodeEventTopicsArgs<TAbi, TEventName>): `0x${string}`[];
|
63
|
+
|
64
|
+
type EncodeFunctionDataArgs<TAbi extends Abi = Abi, TFunctionName extends string = any> = {
|
65
|
+
abi: TAbi;
|
66
|
+
functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName>;
|
67
|
+
} & ExtractArgsFromAbi<TAbi, TFunctionName>;
|
68
|
+
declare function encodeFunctionData<TAbi extends Abi = Abi, TFunctionName extends string = any>({ abi, args, functionName }: EncodeFunctionDataArgs<TAbi, TFunctionName>): `0x${string}`;
|
69
|
+
|
70
|
+
type EncodeFunctionResultArgs<TAbi extends Abi = Abi, TFunctionName extends string = any> = {
|
71
|
+
abi: TAbi;
|
72
|
+
functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName>;
|
73
|
+
result?: ExtractResultFromAbi<TAbi, TFunctionName>;
|
74
|
+
};
|
75
|
+
declare function encodeFunctionResult<TAbi extends Abi = Abi, TFunctionName extends string = any>({ abi, functionName, result, }: EncodeFunctionResultArgs<TAbi, TFunctionName>): `0x${string}`;
|
4
76
|
|
5
77
|
declare function getAddress(address: Address): `0x${string}`;
|
6
78
|
|
@@ -26,81 +98,6 @@ declare function isAddress(address: Address): boolean;
|
|
26
98
|
|
27
99
|
declare function isAddressEqual(a: Address, b: Address): boolean;
|
28
100
|
|
29
|
-
declare function buildRequest<TRequest extends (args: any) => Promise<any>>(request: TRequest): TRequest;
|
30
|
-
declare class RequestError extends BaseError {
|
31
|
-
constructor(err: Error, { docsPath, humanMessage }: {
|
32
|
-
docsPath?: string;
|
33
|
-
humanMessage: string;
|
34
|
-
});
|
35
|
-
}
|
36
|
-
declare class RpcRequestError extends RequestError {
|
37
|
-
code: number;
|
38
|
-
constructor(err: RpcError, { docsPath, humanMessage }: {
|
39
|
-
docsPath?: string;
|
40
|
-
humanMessage: string;
|
41
|
-
});
|
42
|
-
}
|
43
|
-
declare class ParseRpcError extends RpcRequestError {
|
44
|
-
name: string;
|
45
|
-
code: number;
|
46
|
-
constructor(err: RpcError);
|
47
|
-
}
|
48
|
-
declare class InvalidRequestRpcError extends RpcRequestError {
|
49
|
-
name: string;
|
50
|
-
code: number;
|
51
|
-
constructor(err: RpcError);
|
52
|
-
}
|
53
|
-
declare class MethodNotFoundRpcError extends RpcRequestError {
|
54
|
-
name: string;
|
55
|
-
code: number;
|
56
|
-
constructor(err: RpcError);
|
57
|
-
}
|
58
|
-
declare class InvalidParamsRpcError extends RpcRequestError {
|
59
|
-
name: string;
|
60
|
-
code: number;
|
61
|
-
constructor(err: RpcError);
|
62
|
-
}
|
63
|
-
declare class InternalRpcError extends RpcRequestError {
|
64
|
-
name: string;
|
65
|
-
code: number;
|
66
|
-
constructor(err: RpcError);
|
67
|
-
}
|
68
|
-
declare class InvalidInputRpcError extends RpcRequestError {
|
69
|
-
name: string;
|
70
|
-
code: number;
|
71
|
-
constructor(err: RpcError);
|
72
|
-
}
|
73
|
-
declare class ResourceNotFoundRpcError extends RpcRequestError {
|
74
|
-
name: string;
|
75
|
-
code: number;
|
76
|
-
constructor(err: RpcError);
|
77
|
-
}
|
78
|
-
declare class ResourceUnavailableRpcError extends RpcRequestError {
|
79
|
-
name: string;
|
80
|
-
code: number;
|
81
|
-
constructor(err: RpcError);
|
82
|
-
}
|
83
|
-
declare class TransactionRejectedRpcError extends RpcRequestError {
|
84
|
-
name: string;
|
85
|
-
code: number;
|
86
|
-
constructor(err: RpcError);
|
87
|
-
}
|
88
|
-
declare class MethodNotSupportedRpcError extends RpcRequestError {
|
89
|
-
name: string;
|
90
|
-
code: number;
|
91
|
-
constructor(err: RpcError);
|
92
|
-
}
|
93
|
-
declare class LimitExceededRpcError extends RpcRequestError {
|
94
|
-
name: string;
|
95
|
-
code: number;
|
96
|
-
constructor(err: RpcError);
|
97
|
-
}
|
98
|
-
declare class JsonRpcVersionUnsupportedError extends RpcRequestError {
|
99
|
-
name: string;
|
100
|
-
code: number;
|
101
|
-
constructor(err: RpcError);
|
102
|
-
}
|
103
|
-
|
104
101
|
declare function isBytes(value: any): boolean;
|
105
102
|
|
106
103
|
declare function isHex(value: any): boolean;
|
@@ -109,14 +106,16 @@ type PadOptions = {
|
|
109
106
|
dir?: 'left' | 'right';
|
110
107
|
size?: number;
|
111
108
|
};
|
112
|
-
|
109
|
+
type PadResult<TValue extends ByteArray | Hex> = TValue extends Hex ? Hex : ByteArray;
|
110
|
+
declare function pad<TValue extends ByteArray | Hex>(hexOrBytes: TValue, { dir, size }?: PadOptions): PadResult<TValue>;
|
113
111
|
declare function padHex(hex_: Hex, { dir, size }?: PadOptions): `0x${string}`;
|
114
112
|
declare function padBytes(bytes: ByteArray, { dir, size }?: PadOptions): Uint8Array;
|
115
113
|
|
116
114
|
type TrimOptions = {
|
117
115
|
dir?: 'left' | 'right';
|
118
116
|
};
|
119
|
-
|
117
|
+
type TrimResult<TValue extends ByteArray | Hex> = TValue extends Hex ? Hex : ByteArray;
|
118
|
+
declare function trim<TValue extends ByteArray | Hex>(hexOrBytes: TValue, { dir }?: TrimOptions): TrimResult<TValue>;
|
120
119
|
|
121
120
|
/**
|
122
121
|
* @description Retrieves the size of the value (in bytes).
|
@@ -164,7 +163,7 @@ declare function bytesToHex(value: ByteArray): Hex;
|
|
164
163
|
* @description Encodes a string, number, bigint, or ByteArray into a hex string
|
165
164
|
*/
|
166
165
|
declare function encodeHex(value: string | number | bigint | boolean | ByteArray): Hex;
|
167
|
-
type NumberToHexOpts = {
|
166
|
+
type NumberToHexOpts$1 = {
|
168
167
|
signed?: boolean;
|
169
168
|
size: number;
|
170
169
|
} | {
|
@@ -174,7 +173,7 @@ type NumberToHexOpts = {
|
|
174
173
|
/**
|
175
174
|
* @description Encodes a number or bigint into a hex string
|
176
175
|
*/
|
177
|
-
declare function numberToHex(value_: number | bigint, opts?: NumberToHexOpts): Hex;
|
176
|
+
declare function numberToHex(value_: number | bigint, opts?: NumberToHexOpts$1): Hex;
|
178
177
|
/**
|
179
178
|
* @description Encodes a UTF-8 string into a hex string
|
180
179
|
*/
|
@@ -193,7 +192,7 @@ declare function hexToBytes(hex_: Hex): ByteArray;
|
|
193
192
|
/**
|
194
193
|
* @description Encodes a number into a byte array.
|
195
194
|
*/
|
196
|
-
declare function numberToBytes(value: bigint | number, opts?: NumberToHexOpts): Uint8Array;
|
195
|
+
declare function numberToBytes(value: bigint | number, opts?: NumberToHexOpts$1): Uint8Array;
|
197
196
|
/**
|
198
197
|
* @description Encodes a UTF-8 string into a byte array.
|
199
198
|
*/
|
@@ -232,18 +231,22 @@ type DecodeHexResponse<TTo> = TTo extends 'string' ? string : TTo extends 'bigin
|
|
232
231
|
* @description Decodes a hex string into a string, number, bigint, boolean, or bytes32 array.
|
233
232
|
*/
|
234
233
|
declare function decodeHex<TTo extends 'string' | 'bigint' | 'number' | 'bytes' | 'boolean'>(hex: Hex, to: TTo): DecodeHexResponse<TTo>;
|
234
|
+
type HexToBigIntOpts = {
|
235
|
+
signed?: boolean;
|
236
|
+
};
|
235
237
|
/**
|
236
238
|
* @description Decodes a hex string into a bigint.
|
237
239
|
*/
|
238
|
-
declare function hexToBigInt(hex: Hex): bigint;
|
240
|
+
declare function hexToBigInt(hex: Hex, opts?: HexToBigIntOpts): bigint;
|
239
241
|
/**
|
240
242
|
* @description Decodes a hex string into a boolean.
|
241
243
|
*/
|
242
244
|
declare function hexToBool(hex: Hex): boolean;
|
245
|
+
type NumberToHexOpts = HexToBigIntOpts;
|
243
246
|
/**
|
244
247
|
* @description Decodes a hex string into a number.
|
245
248
|
*/
|
246
|
-
declare function hexToNumber(hex: Hex): number;
|
249
|
+
declare function hexToNumber(hex: Hex, opts?: NumberToHexOpts): number;
|
247
250
|
/**
|
248
251
|
* @description Decodes a hex string into a UTF-8 string.
|
249
252
|
*/
|
@@ -254,7 +257,7 @@ declare function decodeRlp<TTo extends 'bytes' | 'hex'>(value: ByteArray | Hex,
|
|
254
257
|
|
255
258
|
declare const getEventSignature: (event: `${string}(${string})`) => `0x${string}`;
|
256
259
|
|
257
|
-
declare const getFunctionSignature: (fn: string) => string
|
260
|
+
declare const getFunctionSignature: (fn: string) => `0x${string}`;
|
258
261
|
|
259
262
|
type To = 'hex' | 'bytes';
|
260
263
|
type Keccak256Hash<TTo extends To> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
|
@@ -272,4 +275,4 @@ declare function parseEther(ether: `${number}`, unit?: 'wei' | 'gwei'): bigint;
|
|
272
275
|
|
273
276
|
declare function parseGwei(ether: `${number}`, unit?: 'wei'): bigint;
|
274
277
|
|
275
|
-
export {
|
278
|
+
export { keccak256 as $, encodeAbi as A, encodeBytes as B, encodeDeployData as C, DecodeAbiArgs as D, EncodeAbiArgs as E, encodeErrorResult as F, GetContractAddressOptions as G, encodeEventTopics as H, encodeFunctionData as I, encodeFunctionResult as J, encodeHex as K, encodeRlp as L, getAddress as M, getContractAddress as N, getCreateAddress as O, getCreate2Address as P, getEventSignature as Q, getFunctionSignature as R, formatEther as S, isAddress as T, isAddressEqual as U, isBytes as V, isHex as W, hexToBigInt as X, hexToBool as Y, hexToBytes as Z, hexToString as _, DecodeErrorResultArgs as a, numberToBytes as a0, pad as a1, padBytes as a2, padHex as a3, parseEther as a4, parseGwei as a5, parseUnit as a6, formatGwei as a7, formatUnit as a8, hexToNumber as a9, numberToHex as aa, size as ab, slice as ac, sliceBytes as ad, sliceHex as ae, stringToBytes as af, stringToHex as ag, trim as ah, DecodeFunctionDataArgs as b, DecodeFunctionResultArgs as c, DecodeFunctionResultResponse as d, EncodeDeployDataArgs as e, EncodeErrorResultArgs as f, EncodeEventTopicsArgs as g, EncodeFunctionDataArgs as h, EncodeFunctionResultArgs as i, GetCreateAddressOptions as j, GetCreate2AddressOptions as k, EncodeRlpResponse as l, bytesToHex as m, bytesToString as n, boolToBytes as o, boolToHex as p, bytesToBigint as q, bytesToBool as r, bytesToNumber as s, decodeAbi as t, decodeBytes as u, decodeErrorResult as v, decodeFunctionData as w, decodeFunctionResult as x, decodeHex as y, decodeRlp as z };
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import { B as BaseError } from './BaseError-7688f84e.js';
|
2
|
-
|
3
1
|
type SuccessResult<T> = {
|
4
2
|
method?: never;
|
5
3
|
result: T;
|
@@ -59,40 +57,5 @@ declare const rpc: {
|
|
59
57
|
webSocket: typeof webSocket;
|
60
58
|
webSocketAsync: typeof webSocketAsync;
|
61
59
|
};
|
62
|
-
declare class HttpRequestError extends BaseError {
|
63
|
-
name: string;
|
64
|
-
status: number;
|
65
|
-
constructor({ body, details, status, url, }: {
|
66
|
-
body: {
|
67
|
-
[key: string]: unknown;
|
68
|
-
};
|
69
|
-
details: string;
|
70
|
-
status: number;
|
71
|
-
url: string;
|
72
|
-
});
|
73
|
-
}
|
74
|
-
declare class RpcError extends BaseError {
|
75
|
-
code: number;
|
76
|
-
name: string;
|
77
|
-
constructor({ body, error, url, }: {
|
78
|
-
body: {
|
79
|
-
[key: string]: unknown;
|
80
|
-
};
|
81
|
-
error: {
|
82
|
-
code: number;
|
83
|
-
message: string;
|
84
|
-
};
|
85
|
-
url: string;
|
86
|
-
});
|
87
|
-
}
|
88
|
-
declare class TimeoutError extends BaseError {
|
89
|
-
name: string;
|
90
|
-
constructor({ body, url, }: {
|
91
|
-
body: {
|
92
|
-
[key: string]: unknown;
|
93
|
-
};
|
94
|
-
url: string;
|
95
|
-
});
|
96
|
-
}
|
97
60
|
|
98
|
-
export {
|
61
|
+
export { RpcResponse as R, rpc as r };
|
@@ -289,4 +289,4 @@ type RpcTransactionReceipt = TransactionReceipt<Quantity, Index, Status, Transac
|
|
289
289
|
type RpcTransactionRequest = TransactionRequest<Quantity, Index>;
|
290
290
|
type RpcTransaction = TransactionLegacy<Quantity, Index, '0x0'> | TransactionEIP2930<Quantity, Index, '0x1'> | TransactionEIP1559<Quantity, Index, '0x2'>;
|
291
291
|
|
292
|
-
export { Address as A,
|
292
|
+
export { Address as A, ByteArray as B, TransactionRequestLegacy as C, Transaction as D, TransactionBase as E, FeeHistory as F, TransactionEIP1559 as G, Hex as H, TransactionEIP2930 as I, TransactionLegacy as J, EstimateGasParameters as K, Log as L, MergeIntersectionProperties as M, TransactionType$1 as N, OptionalNullable as O, RpcEstimateGasParameters as P, Quantity as Q, RpcBlock as R, TransactionReceipt as T, Uncle as U, Hash as a, BlockTag as b, AccessList as c, Block as d, etherUnits as e, BlockIdentifier as f, gweiUnits as g, BlockNumber as h, FeeValues as i, FeeValuesEIP1559 as j, FeeValuesLegacy as k, RpcBlockIdentifier as l, RpcBlockNumber as m, RpcFeeHistory as n, RpcFeeValues as o, RpcLog as p, RpcTransaction as q, RpcTransactionReceipt as r, RpcTransactionRequest as s, transactionType as t, RpcUncle as u, TransactionRequest as v, weiUnits as w, TransactionRequestBase as x, TransactionRequestEIP1559 as y, TransactionRequestEIP2930 as z };
|
@@ -0,0 +1,132 @@
|
|
1
|
+
import { Abi, AbiFunction, ExtractAbiFunction, AbiParametersToPrimitiveTypes, AbiError, ExtractAbiError, AbiEvent, ExtractAbiEvent, AbiStateMutability, ExtractAbiFunctionNames, AbiParameter, AbiParameterToPrimitiveType } from 'abitype';
|
2
|
+
import { v as TransactionRequest, O as OptionalNullable, d as Block, R as RpcBlock, D as Transaction, q as RpcTransaction, T as TransactionReceipt, s as RpcTransactionRequest } from './rpc-b77c5aee.js';
|
3
|
+
import { Chain, Formatter, Formatters } from './chains.js';
|
4
|
+
|
5
|
+
type AbiItem = Abi[number];
|
6
|
+
type AbiEventParametersToPrimitiveTypes<TAbiParameters extends readonly AbiParameter[], TBase = TAbiParameters[0] extends {
|
7
|
+
name: string;
|
8
|
+
} ? {} : []> = TAbiParameters extends readonly [infer Head, ...infer Tail] ? Head extends {
|
9
|
+
indexed: true;
|
10
|
+
} ? Head extends AbiParameter ? Head extends {
|
11
|
+
name: infer Name;
|
12
|
+
} ? Name extends string ? {
|
13
|
+
[name in Name]?: AbiParameterToPrimitiveType<Head> | AbiParameterToPrimitiveType<Head>[] | null;
|
14
|
+
} & (Tail extends readonly [] ? {} : Tail extends readonly AbiParameter[] ? AbiEventParametersToPrimitiveTypes<Tail> : {}) : never : [
|
15
|
+
(AbiParameterToPrimitiveType<Head> | AbiParameterToPrimitiveType<Head>[] | null),
|
16
|
+
...(Tail extends readonly [] ? [] : Tail extends readonly AbiParameter[] ? AbiEventParametersToPrimitiveTypes<Tail> : [])
|
17
|
+
] : TBase : TBase : TBase;
|
18
|
+
type ExtractArgsFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiFunction extends AbiFunction & {
|
19
|
+
type: 'function';
|
20
|
+
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
|
21
|
+
type: 'function';
|
22
|
+
}, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
|
23
|
+
/**
|
24
|
+
* Arguments to pass contract method
|
25
|
+
*
|
26
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
27
|
+
*/
|
28
|
+
args?: readonly unknown[];
|
29
|
+
} : TArgs extends readonly [] ? {
|
30
|
+
args?: never;
|
31
|
+
} : {
|
32
|
+
/** Arguments to pass contract method */ args: TArgs;
|
33
|
+
};
|
34
|
+
type ExtractConstructorArgsFromAbi<TAbi extends Abi | readonly unknown[], TAbiFunction extends AbiFunction & {
|
35
|
+
type: 'constructor';
|
36
|
+
} = TAbi extends Abi ? Extract<TAbi[number], {
|
37
|
+
type: 'constructor';
|
38
|
+
}> : AbiFunction & {
|
39
|
+
type: 'constructor';
|
40
|
+
}, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
|
41
|
+
/**
|
42
|
+
* Arguments to pass contract method
|
43
|
+
*
|
44
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
45
|
+
*/
|
46
|
+
args?: readonly unknown[];
|
47
|
+
} : TArgs extends readonly [] ? {
|
48
|
+
args?: never;
|
49
|
+
} : {
|
50
|
+
/** Arguments to pass contract method */ args: TArgs;
|
51
|
+
};
|
52
|
+
type ExtractErrorArgsFromAbi<TAbi extends Abi | readonly unknown[], TErrorName extends string, TAbiError extends AbiError = TAbi extends Abi ? ExtractAbiError<TAbi, TErrorName> : AbiError, TArgs = AbiParametersToPrimitiveTypes<TAbiError['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
|
53
|
+
/**
|
54
|
+
* Arguments to pass contract method
|
55
|
+
*
|
56
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
57
|
+
*/
|
58
|
+
args?: readonly unknown[];
|
59
|
+
} : TArgs extends readonly [] ? {
|
60
|
+
args?: never;
|
61
|
+
} : {
|
62
|
+
/** Arguments to pass contract method */ args: TArgs;
|
63
|
+
};
|
64
|
+
type ExtractEventArgsFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiEvent extends AbiEvent & {
|
65
|
+
type: 'event';
|
66
|
+
} = TAbi extends Abi ? ExtractAbiEvent<TAbi, TFunctionName> : AbiEvent & {
|
67
|
+
type: 'event';
|
68
|
+
}, TArgs = AbiEventParametersToPrimitiveTypes<TAbiEvent['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
|
69
|
+
/**
|
70
|
+
* Arguments to pass contract method
|
71
|
+
*
|
72
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
73
|
+
*/
|
74
|
+
args?: readonly unknown[];
|
75
|
+
} : TArgs extends readonly [] ? {
|
76
|
+
args?: never;
|
77
|
+
} : {
|
78
|
+
args?: TArgs;
|
79
|
+
};
|
80
|
+
type ExtractFunctionNameFromAbi<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiStateMutability extends AbiStateMutability = AbiStateMutability> = TAbi extends Abi ? ExtractAbiFunctionNames<TAbi, TAbiStateMutability> extends infer AbiFunctionNames ? AbiFunctionNames | (TFunctionName extends AbiFunctionNames ? TFunctionName : never) | (Abi extends TAbi ? string : never) : never : TFunctionName;
|
81
|
+
type ExtractResultFromAbi<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiFunction extends AbiFunction & {
|
82
|
+
type: 'function';
|
83
|
+
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
|
84
|
+
type: 'function';
|
85
|
+
}, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['outputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? unknown : TArgs extends readonly [] ? void : TArgs extends readonly [infer Arg] ? Arg : TArgs;
|
86
|
+
type GetValue<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TValueType = TransactionRequest['value'], TAbiFunction extends AbiFunction & {
|
87
|
+
type: 'function';
|
88
|
+
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
|
89
|
+
type: 'function';
|
90
|
+
}> = TAbiFunction['stateMutability'] extends 'payable' ? TValueType : TAbiFunction['payable'] extends true ? TValueType : never;
|
91
|
+
|
92
|
+
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;
|
93
|
+
type FormatOptions<TSource, TTarget> = {
|
94
|
+
formatter: Formatter<TSource, TTarget>;
|
95
|
+
};
|
96
|
+
/**
|
97
|
+
* Creates a type that is the result of applying `TFormatter` to `TSource`.
|
98
|
+
*
|
99
|
+
* @example
|
100
|
+
* Formatted<() => { a: undefined, b: bigint }, { a: bigint }>
|
101
|
+
* => { a: undefined, b: bigint }
|
102
|
+
*
|
103
|
+
* @example
|
104
|
+
* Formatted<() => {}, { a: bigint }>
|
105
|
+
* => { a: bigint }
|
106
|
+
*
|
107
|
+
* @example
|
108
|
+
* Formatted<() => { a: bigint | undefined, b: bigint }, { a: bigint, b: bigint }, true>
|
109
|
+
* => { a?: bigint | undefined, b: bigint }
|
110
|
+
*/
|
111
|
+
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;
|
112
|
+
/**
|
113
|
+
* @description Formats a data object using the given replacer and an optional formatter.
|
114
|
+
*/
|
115
|
+
declare function format<TFormatter, TSource extends Record<string, any>, TTarget>(data: TSource, { formatter }: FormatOptions<TSource, TTarget>): Formatted<TFormatter, TTarget, false>;
|
116
|
+
|
117
|
+
type BlockFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'block', NonNullable<Formatters['block']>>;
|
118
|
+
type FormattedBlock<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, Block>;
|
119
|
+
declare function formatBlock(block: Partial<RpcBlock>): Block<bigint, Transaction<bigint, number>>;
|
120
|
+
|
121
|
+
type TransactionFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transaction', NonNullable<Formatters['transaction']>>;
|
122
|
+
type FormattedTransaction<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, Transaction>;
|
123
|
+
declare function formatTransaction(transaction: Partial<RpcTransaction>): Transaction<bigint, number>;
|
124
|
+
|
125
|
+
type TransactionReceiptFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transactionReceipt', NonNullable<Formatters['transactionReceipt']>>;
|
126
|
+
type FormattedTransactionReceipt<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, TransactionReceipt>;
|
127
|
+
|
128
|
+
type TransactionRequestFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transactionRequest', NonNullable<Formatters['transactionRequest']>>;
|
129
|
+
type FormattedTransactionRequest<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, RpcTransactionRequest>;
|
130
|
+
declare function formatTransactionRequest(transactionRequest: Partial<TransactionRequest>): RpcTransactionRequest;
|
131
|
+
|
132
|
+
export { AbiItem as A, BlockFormatter as B, ExtractFunctionNameFromAbi as E, FormattedBlock as F, GetValue as G, TransactionRequestFormatter as T, FormattedTransaction as a, FormattedTransactionRequest as b, formatTransaction as c, formatTransactionRequest as d, Formatted as e, formatBlock as f, ExtractArgsFromAbi as g, ExtractResultFromAbi as h, TransactionFormatter as i, FormattedTransactionReceipt as j, TransactionReceiptFormatter as k, ExtractFormatter as l, ExtractConstructorArgsFromAbi as m, ExtractErrorArgsFromAbi as n, ExtractEventArgsFromAbi as o, format as p };
|
package/dist/utils/index.d.ts
CHANGED
@@ -1,11 +1,36 @@
|
|
1
|
-
export {
|
2
|
-
|
3
|
-
export { B as BlockFormatter,
|
4
|
-
|
5
|
-
import '
|
1
|
+
export { D as DecodeAbiArgs, a as DecodeErrorResultArgs, b as DecodeFunctionDataArgs, c as DecodeFunctionResultArgs, d as DecodeFunctionResultResponse, E as EncodeAbiArgs, e as EncodeDeployDataArgs, f as EncodeErrorResultArgs, g as EncodeEventTopicsArgs, h as EncodeFunctionDataArgs, i as EncodeFunctionResultArgs, l as EncodeRlpResponse, G as GetContractAddressOptions, k as GetCreate2AddressOptions, j as GetCreateAddressOptions, o as boolToBytes, p as boolToHex, q as bytesToBigint, r as bytesToBool, m as bytesToHex, s as bytesToNumber, n as bytesToString, t as decodeAbi, u as decodeBytes, v as decodeErrorResult, w as decodeFunctionData, x as decodeFunctionResult, y as decodeHex, z as decodeRlp, A as encodeAbi, B as encodeBytes, C as encodeDeployData, F as encodeErrorResult, H as encodeEventTopics, I as encodeFunctionData, J as encodeFunctionResult, K as encodeHex, L as encodeRlp, S as formatEther, a7 as formatGwei, a8 as formatUnit, M as getAddress, N as getContractAddress, P as getCreate2Address, O as getCreateAddress, Q as getEventSignature, R as getFunctionSignature, X as hexToBigInt, Y as hexToBool, Z as hexToBytes, a9 as hexToNumber, _ as hexToString, T as isAddress, U as isAddressEqual, V as isBytes, W as isHex, $ as keccak256, a0 as numberToBytes, aa as numberToHex, a1 as pad, a2 as padBytes, a3 as padHex, a4 as parseEther, a5 as parseGwei, a6 as parseUnit, ab as size, ac as slice, ad as sliceBytes, ae as sliceHex, af as stringToBytes, ag as stringToHex, ah as trim } from '../parseGwei-7c87ff41.js';
|
2
|
+
import { A as AbiItem } from '../transactionRequest-08d30731.js';
|
3
|
+
export { B as BlockFormatter, l as ExtractFormatter, e as Formatted, F as FormattedBlock, a as FormattedTransaction, j as FormattedTransactionReceipt, b as FormattedTransactionRequest, i as TransactionFormatter, k as TransactionReceiptFormatter, T as TransactionRequestFormatter, p as format, f as formatBlock, c as formatTransaction, d as formatTransactionRequest } from '../transactionRequest-08d30731.js';
|
4
|
+
import * as abitype_dist_abi_b1bae27f from 'abitype/dist/abi-b1bae27f';
|
5
|
+
import { Abi } from 'abitype';
|
6
|
+
import { A as Address } from '../rpc-b77c5aee.js';
|
7
|
+
export { r as rpc } from '../rpc-26932bae.js';
|
6
8
|
import '../chains.js';
|
7
9
|
import '@wagmi/chains';
|
8
10
|
|
11
|
+
declare function formatAbiItemWithArgs({ abiItem, args, includeFunctionName, includeName, }: {
|
12
|
+
abiItem: AbiItem;
|
13
|
+
args: readonly unknown[];
|
14
|
+
includeFunctionName?: boolean;
|
15
|
+
includeName?: boolean;
|
16
|
+
}): string | undefined;
|
17
|
+
|
18
|
+
declare function formatAbiItemWithParams(abiItem: AbiItem, { includeName }?: {
|
19
|
+
includeName?: boolean;
|
20
|
+
}): string;
|
21
|
+
|
22
|
+
declare function getAbiItem({ abi, name }: {
|
23
|
+
abi: Abi;
|
24
|
+
name: string;
|
25
|
+
}): abitype_dist_abi_b1bae27f.q | abitype_dist_abi_b1bae27f.p | abitype_dist_abi_b1bae27f.o | undefined;
|
26
|
+
|
27
|
+
declare function buildRequest<TRequest extends (args: any) => Promise<any>>(request: TRequest): TRequest;
|
28
|
+
|
29
|
+
declare function extractFunctionParts(def: string): {
|
30
|
+
type: string | undefined;
|
31
|
+
name: string | undefined;
|
32
|
+
params: string | undefined;
|
33
|
+
};
|
9
34
|
declare function extractFunctionName(def: string): string | undefined;
|
10
35
|
declare function extractFunctionParams(def: string): {
|
11
36
|
indexed?: boolean | undefined;
|
@@ -14,4 +39,14 @@ declare function extractFunctionParams(def: string): {
|
|
14
39
|
}[] | undefined;
|
15
40
|
declare function extractFunctionType(def: string): string | undefined;
|
16
41
|
|
17
|
-
|
42
|
+
declare function getContractError(err: unknown, { abi, address, args, functionName, sender, }: {
|
43
|
+
abi: Abi;
|
44
|
+
args: any;
|
45
|
+
address?: Address;
|
46
|
+
functionName: string;
|
47
|
+
sender?: Address;
|
48
|
+
}): unknown;
|
49
|
+
|
50
|
+
declare function stringify(value: unknown): string;
|
51
|
+
|
52
|
+
export { buildRequest, extractFunctionName, extractFunctionParams, extractFunctionParts, extractFunctionType, formatAbiItemWithArgs, formatAbiItemWithParams, getAbiItem, getContractError, stringify };
|
package/dist/utils/index.js
CHANGED
@@ -1,21 +1,4 @@
|
|
1
1
|
import {
|
2
|
-
BaseError,
|
3
|
-
HttpRequestError,
|
4
|
-
InternalRpcError,
|
5
|
-
InvalidInputRpcError,
|
6
|
-
InvalidParamsRpcError,
|
7
|
-
InvalidRequestRpcError,
|
8
|
-
JsonRpcVersionUnsupportedError,
|
9
|
-
LimitExceededRpcError,
|
10
|
-
MethodNotFoundRpcError,
|
11
|
-
MethodNotSupportedRpcError,
|
12
|
-
ParseRpcError,
|
13
|
-
ResourceNotFoundRpcError,
|
14
|
-
ResourceUnavailableRpcError,
|
15
|
-
RpcError,
|
16
|
-
RpcRequestError,
|
17
|
-
TimeoutError,
|
18
|
-
TransactionRejectedRpcError,
|
19
2
|
boolToBytes,
|
20
3
|
boolToHex,
|
21
4
|
buildRequest,
|
@@ -24,24 +7,39 @@ import {
|
|
24
7
|
bytesToHex,
|
25
8
|
bytesToNumber,
|
26
9
|
bytesToString,
|
10
|
+
decodeAbi,
|
27
11
|
decodeBytes,
|
12
|
+
decodeErrorResult,
|
13
|
+
decodeFunctionData,
|
14
|
+
decodeFunctionResult,
|
28
15
|
decodeHex,
|
29
16
|
decodeRlp,
|
17
|
+
encodeAbi,
|
30
18
|
encodeBytes,
|
19
|
+
encodeDeployData,
|
20
|
+
encodeErrorResult,
|
21
|
+
encodeEventTopics,
|
22
|
+
encodeFunctionData,
|
23
|
+
encodeFunctionResult,
|
31
24
|
encodeHex,
|
32
25
|
encodeRlp,
|
33
26
|
extractFunctionName,
|
34
27
|
extractFunctionParams,
|
28
|
+
extractFunctionParts,
|
35
29
|
extractFunctionType,
|
36
30
|
format,
|
31
|
+
formatAbiItemWithArgs,
|
32
|
+
formatAbiItemWithParams,
|
37
33
|
formatBlock,
|
38
34
|
formatEther,
|
39
35
|
formatGwei,
|
40
36
|
formatTransaction,
|
41
37
|
formatTransactionRequest,
|
42
38
|
formatUnit,
|
39
|
+
getAbiItem,
|
43
40
|
getAddress,
|
44
41
|
getContractAddress,
|
42
|
+
getContractError,
|
45
43
|
getCreate2Address,
|
46
44
|
getCreateAddress,
|
47
45
|
getEventSignature,
|
@@ -71,26 +69,10 @@ import {
|
|
71
69
|
sliceHex,
|
72
70
|
stringToBytes,
|
73
71
|
stringToHex,
|
72
|
+
stringify,
|
74
73
|
trim
|
75
|
-
} from "../chunk-
|
74
|
+
} from "../chunk-6GAKRM5P.js";
|
76
75
|
export {
|
77
|
-
BaseError,
|
78
|
-
HttpRequestError,
|
79
|
-
InternalRpcError,
|
80
|
-
InvalidInputRpcError,
|
81
|
-
InvalidParamsRpcError,
|
82
|
-
InvalidRequestRpcError,
|
83
|
-
JsonRpcVersionUnsupportedError,
|
84
|
-
LimitExceededRpcError,
|
85
|
-
MethodNotFoundRpcError,
|
86
|
-
MethodNotSupportedRpcError,
|
87
|
-
ParseRpcError,
|
88
|
-
ResourceNotFoundRpcError,
|
89
|
-
ResourceUnavailableRpcError,
|
90
|
-
RpcError,
|
91
|
-
RpcRequestError,
|
92
|
-
TimeoutError,
|
93
|
-
TransactionRejectedRpcError,
|
94
76
|
boolToBytes,
|
95
77
|
boolToHex,
|
96
78
|
buildRequest,
|
@@ -99,24 +81,39 @@ export {
|
|
99
81
|
bytesToHex,
|
100
82
|
bytesToNumber,
|
101
83
|
bytesToString,
|
84
|
+
decodeAbi,
|
102
85
|
decodeBytes,
|
86
|
+
decodeErrorResult,
|
87
|
+
decodeFunctionData,
|
88
|
+
decodeFunctionResult,
|
103
89
|
decodeHex,
|
104
90
|
decodeRlp,
|
91
|
+
encodeAbi,
|
105
92
|
encodeBytes,
|
93
|
+
encodeDeployData,
|
94
|
+
encodeErrorResult,
|
95
|
+
encodeEventTopics,
|
96
|
+
encodeFunctionData,
|
97
|
+
encodeFunctionResult,
|
106
98
|
encodeHex,
|
107
99
|
encodeRlp,
|
108
100
|
extractFunctionName,
|
109
101
|
extractFunctionParams,
|
102
|
+
extractFunctionParts,
|
110
103
|
extractFunctionType,
|
111
104
|
format,
|
105
|
+
formatAbiItemWithArgs,
|
106
|
+
formatAbiItemWithParams,
|
112
107
|
formatBlock,
|
113
108
|
formatEther,
|
114
109
|
formatGwei,
|
115
110
|
formatTransaction,
|
116
111
|
formatTransactionRequest,
|
117
112
|
formatUnit,
|
113
|
+
getAbiItem,
|
118
114
|
getAddress,
|
119
115
|
getContractAddress,
|
116
|
+
getContractError,
|
120
117
|
getCreate2Address,
|
121
118
|
getCreateAddress,
|
122
119
|
getEventSignature,
|
@@ -146,5 +143,6 @@ export {
|
|
146
143
|
sliceHex,
|
147
144
|
stringToBytes,
|
148
145
|
stringToHex,
|
146
|
+
stringify,
|
149
147
|
trim
|
150
148
|
};
|