viem 0.0.1-alpha.1 → 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/dist/actions/index.d.ts +6 -6
- package/dist/actions/index.js +4 -2
- package/dist/chains.d.ts +3 -3
- package/dist/chains.js +1 -1
- package/dist/{chunk-OQTFTQTO.js → chunk-3TSTZHVO.js} +44 -63
- package/dist/{chunk-Z6LRV6XI.js → chunk-6GAKRM5P.js} +1062 -427
- package/dist/{chunk-LLYFXUSV.js → chunk-NMN4TFDP.js} +184 -198
- package/dist/clients/index.d.ts +5 -6
- package/dist/clients/index.js +2 -4
- package/dist/{createWalletClient-915223f3.d.ts → createWalletClient-d612fe08.d.ts} +1 -1
- package/dist/{eip1193-8f7c22ce.d.ts → eip1193-020a6f13.d.ts} +2 -2
- package/dist/index.d.ts +341 -10
- package/dist/index.js +88 -4
- package/dist/{parseGwei-bbc055e4.d.ts → parseGwei-7c87ff41.d.ts} +70 -118
- 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 -7
- package/dist/utils/index.js +29 -35
- package/dist/{watchAsset-04ab8db5.d.ts → watchAsset-bc6373f4.d.ts} +17 -16
- package/dist/{webSocket-c6e0d26f.d.ts → webSocket-7f88e9e0.d.ts} +4 -9
- package/dist/window.d.ts +2 -2
- package/package.json +5 -2
- package/dist/BaseError-7688f84e.d.ts +0 -18
- package/dist/transactionRequest-ade896ac.d.ts +0 -44
@@ -1,51 +1,78 @@
|
|
1
|
-
import { AbiParameter, AbiParametersToPrimitiveTypes } from 'abitype';
|
2
|
-
import { H as Hex, A as Address,
|
3
|
-
import {
|
4
|
-
import { R as RpcError } from './rpc-3c0e3985.js';
|
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';
|
5
4
|
|
6
|
-
|
5
|
+
type DecodeAbiArgs<TParams extends readonly AbiParameter[]> = {
|
7
6
|
data: Hex;
|
8
7
|
params: TParams;
|
9
|
-
}
|
10
|
-
declare
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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>;
|
18
36
|
|
37
|
+
type EncodeAbiArgs<TParams extends readonly AbiParameter[]> = {
|
38
|
+
params: TParams;
|
39
|
+
values: AbiParametersToPrimitiveTypes<TParams>;
|
40
|
+
};
|
19
41
|
/**
|
20
42
|
* @description Encodes a list of primitive values into an ABI-encoded hex value.
|
21
43
|
*/
|
22
|
-
declare function encodeAbi<TParams extends readonly AbiParameter[]>({ params, values, }: {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
}
|
34
|
-
declare
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
}
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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}`;
|
49
76
|
|
50
77
|
declare function getAddress(address: Address): `0x${string}`;
|
51
78
|
|
@@ -71,81 +98,6 @@ declare function isAddress(address: Address): boolean;
|
|
71
98
|
|
72
99
|
declare function isAddressEqual(a: Address, b: Address): boolean;
|
73
100
|
|
74
|
-
declare function buildRequest<TRequest extends (args: any) => Promise<any>>(request: TRequest): TRequest;
|
75
|
-
declare class RequestError extends BaseError {
|
76
|
-
constructor(err: Error, { docsPath, humanMessage }: {
|
77
|
-
docsPath?: string;
|
78
|
-
humanMessage: string;
|
79
|
-
});
|
80
|
-
}
|
81
|
-
declare class RpcRequestError extends RequestError {
|
82
|
-
code: number;
|
83
|
-
constructor(err: RpcError, { docsPath, humanMessage }: {
|
84
|
-
docsPath?: string;
|
85
|
-
humanMessage: string;
|
86
|
-
});
|
87
|
-
}
|
88
|
-
declare class ParseRpcError extends RpcRequestError {
|
89
|
-
name: string;
|
90
|
-
code: number;
|
91
|
-
constructor(err: RpcError);
|
92
|
-
}
|
93
|
-
declare class InvalidRequestRpcError extends RpcRequestError {
|
94
|
-
name: string;
|
95
|
-
code: number;
|
96
|
-
constructor(err: RpcError);
|
97
|
-
}
|
98
|
-
declare class MethodNotFoundRpcError extends RpcRequestError {
|
99
|
-
name: string;
|
100
|
-
code: number;
|
101
|
-
constructor(err: RpcError);
|
102
|
-
}
|
103
|
-
declare class InvalidParamsRpcError extends RpcRequestError {
|
104
|
-
name: string;
|
105
|
-
code: number;
|
106
|
-
constructor(err: RpcError);
|
107
|
-
}
|
108
|
-
declare class InternalRpcError extends RpcRequestError {
|
109
|
-
name: string;
|
110
|
-
code: number;
|
111
|
-
constructor(err: RpcError);
|
112
|
-
}
|
113
|
-
declare class InvalidInputRpcError extends RpcRequestError {
|
114
|
-
name: string;
|
115
|
-
code: number;
|
116
|
-
constructor(err: RpcError);
|
117
|
-
}
|
118
|
-
declare class ResourceNotFoundRpcError extends RpcRequestError {
|
119
|
-
name: string;
|
120
|
-
code: number;
|
121
|
-
constructor(err: RpcError);
|
122
|
-
}
|
123
|
-
declare class ResourceUnavailableRpcError extends RpcRequestError {
|
124
|
-
name: string;
|
125
|
-
code: number;
|
126
|
-
constructor(err: RpcError);
|
127
|
-
}
|
128
|
-
declare class TransactionRejectedRpcError extends RpcRequestError {
|
129
|
-
name: string;
|
130
|
-
code: number;
|
131
|
-
constructor(err: RpcError);
|
132
|
-
}
|
133
|
-
declare class MethodNotSupportedRpcError extends RpcRequestError {
|
134
|
-
name: string;
|
135
|
-
code: number;
|
136
|
-
constructor(err: RpcError);
|
137
|
-
}
|
138
|
-
declare class LimitExceededRpcError extends RpcRequestError {
|
139
|
-
name: string;
|
140
|
-
code: number;
|
141
|
-
constructor(err: RpcError);
|
142
|
-
}
|
143
|
-
declare class JsonRpcVersionUnsupportedError extends RpcRequestError {
|
144
|
-
name: string;
|
145
|
-
code: number;
|
146
|
-
constructor(err: RpcError);
|
147
|
-
}
|
148
|
-
|
149
101
|
declare function isBytes(value: any): boolean;
|
150
102
|
|
151
103
|
declare function isHex(value: any): boolean;
|
@@ -305,7 +257,7 @@ declare function decodeRlp<TTo extends 'bytes' | 'hex'>(value: ByteArray | Hex,
|
|
305
257
|
|
306
258
|
declare const getEventSignature: (event: `${string}(${string})`) => `0x${string}`;
|
307
259
|
|
308
|
-
declare const getFunctionSignature: (fn: string) => string
|
260
|
+
declare const getFunctionSignature: (fn: string) => `0x${string}`;
|
309
261
|
|
310
262
|
type To = 'hex' | 'bytes';
|
311
263
|
type Keccak256Hash<TTo extends To> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
|
@@ -323,4 +275,4 @@ declare function parseEther(ether: `${number}`, unit?: 'wei' | 'gwei'): bigint;
|
|
323
275
|
|
324
276
|
declare function parseGwei(ether: `${number}`, unit?: 'wei'): bigint;
|
325
277
|
|
326
|
-
export { keccak256 as $,
|
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,12 +1,36 @@
|
|
1
|
-
export {
|
2
|
-
|
3
|
-
export { B as BlockFormatter,
|
4
|
-
|
5
|
-
import 'abitype';
|
6
|
-
import '../rpc-
|
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';
|
7
8
|
import '../chains.js';
|
8
9
|
import '@wagmi/chains';
|
9
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
|
+
};
|
10
34
|
declare function extractFunctionName(def: string): string | undefined;
|
11
35
|
declare function extractFunctionParams(def: string): {
|
12
36
|
indexed?: boolean | undefined;
|
@@ -15,4 +39,14 @@ declare function extractFunctionParams(def: string): {
|
|
15
39
|
}[] | undefined;
|
16
40
|
declare function extractFunctionType(def: string): string | undefined;
|
17
41
|
|
18
|
-
|
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,
|
@@ -26,24 +9,37 @@ import {
|
|
26
9
|
bytesToString,
|
27
10
|
decodeAbi,
|
28
11
|
decodeBytes,
|
12
|
+
decodeErrorResult,
|
13
|
+
decodeFunctionData,
|
14
|
+
decodeFunctionResult,
|
29
15
|
decodeHex,
|
30
16
|
decodeRlp,
|
31
17
|
encodeAbi,
|
32
18
|
encodeBytes,
|
19
|
+
encodeDeployData,
|
20
|
+
encodeErrorResult,
|
21
|
+
encodeEventTopics,
|
22
|
+
encodeFunctionData,
|
23
|
+
encodeFunctionResult,
|
33
24
|
encodeHex,
|
34
25
|
encodeRlp,
|
35
26
|
extractFunctionName,
|
36
27
|
extractFunctionParams,
|
28
|
+
extractFunctionParts,
|
37
29
|
extractFunctionType,
|
38
30
|
format,
|
31
|
+
formatAbiItemWithArgs,
|
32
|
+
formatAbiItemWithParams,
|
39
33
|
formatBlock,
|
40
34
|
formatEther,
|
41
35
|
formatGwei,
|
42
36
|
formatTransaction,
|
43
37
|
formatTransactionRequest,
|
44
38
|
formatUnit,
|
39
|
+
getAbiItem,
|
45
40
|
getAddress,
|
46
41
|
getContractAddress,
|
42
|
+
getContractError,
|
47
43
|
getCreate2Address,
|
48
44
|
getCreateAddress,
|
49
45
|
getEventSignature,
|
@@ -73,26 +69,10 @@ import {
|
|
73
69
|
sliceHex,
|
74
70
|
stringToBytes,
|
75
71
|
stringToHex,
|
72
|
+
stringify,
|
76
73
|
trim
|
77
|
-
} from "../chunk-
|
74
|
+
} from "../chunk-6GAKRM5P.js";
|
78
75
|
export {
|
79
|
-
BaseError,
|
80
|
-
HttpRequestError,
|
81
|
-
InternalRpcError,
|
82
|
-
InvalidInputRpcError,
|
83
|
-
InvalidParamsRpcError,
|
84
|
-
InvalidRequestRpcError,
|
85
|
-
JsonRpcVersionUnsupportedError,
|
86
|
-
LimitExceededRpcError,
|
87
|
-
MethodNotFoundRpcError,
|
88
|
-
MethodNotSupportedRpcError,
|
89
|
-
ParseRpcError,
|
90
|
-
ResourceNotFoundRpcError,
|
91
|
-
ResourceUnavailableRpcError,
|
92
|
-
RpcError,
|
93
|
-
RpcRequestError,
|
94
|
-
TimeoutError,
|
95
|
-
TransactionRejectedRpcError,
|
96
76
|
boolToBytes,
|
97
77
|
boolToHex,
|
98
78
|
buildRequest,
|
@@ -103,24 +83,37 @@ export {
|
|
103
83
|
bytesToString,
|
104
84
|
decodeAbi,
|
105
85
|
decodeBytes,
|
86
|
+
decodeErrorResult,
|
87
|
+
decodeFunctionData,
|
88
|
+
decodeFunctionResult,
|
106
89
|
decodeHex,
|
107
90
|
decodeRlp,
|
108
91
|
encodeAbi,
|
109
92
|
encodeBytes,
|
93
|
+
encodeDeployData,
|
94
|
+
encodeErrorResult,
|
95
|
+
encodeEventTopics,
|
96
|
+
encodeFunctionData,
|
97
|
+
encodeFunctionResult,
|
110
98
|
encodeHex,
|
111
99
|
encodeRlp,
|
112
100
|
extractFunctionName,
|
113
101
|
extractFunctionParams,
|
102
|
+
extractFunctionParts,
|
114
103
|
extractFunctionType,
|
115
104
|
format,
|
105
|
+
formatAbiItemWithArgs,
|
106
|
+
formatAbiItemWithParams,
|
116
107
|
formatBlock,
|
117
108
|
formatEther,
|
118
109
|
formatGwei,
|
119
110
|
formatTransaction,
|
120
111
|
formatTransactionRequest,
|
121
112
|
formatUnit,
|
113
|
+
getAbiItem,
|
122
114
|
getAddress,
|
123
115
|
getContractAddress,
|
116
|
+
getContractError,
|
124
117
|
getCreate2Address,
|
125
118
|
getCreateAddress,
|
126
119
|
getEventSignature,
|
@@ -150,5 +143,6 @@ export {
|
|
150
143
|
sliceHex,
|
151
144
|
stringToBytes,
|
152
145
|
stringToHex,
|
146
|
+
stringify,
|
153
147
|
trim
|
154
148
|
};
|