web3-abii 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +14 -0
- package/README.md +59 -0
- package/lib/commonjs/api/errors_api.d.ts +5 -0
- package/lib/commonjs/api/errors_api.js +44 -0
- package/lib/commonjs/api/errors_api.js.map +1 -0
- package/lib/commonjs/api/events_api.d.ts +51 -0
- package/lib/commonjs/api/events_api.js +90 -0
- package/lib/commonjs/api/events_api.js.map +1 -0
- package/lib/commonjs/api/functions_api.d.ts +92 -0
- package/lib/commonjs/api/functions_api.js +139 -0
- package/lib/commonjs/api/functions_api.js.map +1 -0
- package/lib/commonjs/api/logs_api.d.ts +49 -0
- package/lib/commonjs/api/logs_api.js +107 -0
- package/lib/commonjs/api/logs_api.js.map +1 -0
- package/lib/commonjs/api/parameters_api.d.ts +238 -0
- package/lib/commonjs/api/parameters_api.js +280 -0
- package/lib/commonjs/api/parameters_api.js.map +1 -0
- package/lib/commonjs/coders/base/address.d.ts +4 -0
- package/lib/commonjs/coders/base/address.js +75 -0
- package/lib/commonjs/coders/base/address.js.map +1 -0
- package/lib/commonjs/coders/base/array.d.ts +4 -0
- package/lib/commonjs/coders/base/array.js +106 -0
- package/lib/commonjs/coders/base/array.js.map +1 -0
- package/lib/commonjs/coders/base/bool.d.ts +4 -0
- package/lib/commonjs/coders/base/bool.js +56 -0
- package/lib/commonjs/coders/base/bool.js.map +1 -0
- package/lib/commonjs/coders/base/bytes.d.ts +4 -0
- package/lib/commonjs/coders/base/bytes.js +101 -0
- package/lib/commonjs/coders/base/bytes.js.map +1 -0
- package/lib/commonjs/coders/base/index.d.ts +11 -0
- package/lib/commonjs/coders/base/index.js +109 -0
- package/lib/commonjs/coders/base/index.js.map +1 -0
- package/lib/commonjs/coders/base/number.d.ts +4 -0
- package/lib/commonjs/coders/base/number.js +116 -0
- package/lib/commonjs/coders/base/number.js.map +1 -0
- package/lib/commonjs/coders/base/numbersLimits.d.ts +4 -0
- package/lib/commonjs/coders/base/numbersLimits.js +40 -0
- package/lib/commonjs/coders/base/numbersLimits.js.map +1 -0
- package/lib/commonjs/coders/base/string.d.ts +4 -0
- package/lib/commonjs/coders/base/string.js +40 -0
- package/lib/commonjs/coders/base/string.js.map +1 -0
- package/lib/commonjs/coders/base/tuple.d.ts +7 -0
- package/lib/commonjs/coders/base/tuple.js +123 -0
- package/lib/commonjs/coders/base/tuple.js.map +1 -0
- package/lib/commonjs/coders/base/utils.d.ts +2 -0
- package/lib/commonjs/coders/base/utils.js +50 -0
- package/lib/commonjs/coders/base/utils.js.map +1 -0
- package/lib/commonjs/coders/decode.d.ts +5 -0
- package/lib/commonjs/coders/decode.js +29 -0
- package/lib/commonjs/coders/decode.js.map +1 -0
- package/lib/commonjs/coders/encode.d.ts +38 -0
- package/lib/commonjs/coders/encode.js +113 -0
- package/lib/commonjs/coders/encode.js.map +1 -0
- package/lib/commonjs/coders/types.d.ts +16 -0
- package/lib/commonjs/coders/types.js +19 -0
- package/lib/commonjs/coders/types.js.map +1 -0
- package/lib/commonjs/coders/utils.d.ts +23 -0
- package/lib/commonjs/coders/utils.js +115 -0
- package/lib/commonjs/coders/utils.js.map +1 -0
- package/lib/commonjs/decode_contract_error_data.d.ts +3 -0
- package/lib/commonjs/decode_contract_error_data.js +73 -0
- package/lib/commonjs/decode_contract_error_data.js.map +1 -0
- package/lib/commonjs/eip_712.d.ts +50 -0
- package/lib/commonjs/eip_712.js +144 -0
- package/lib/commonjs/eip_712.js.map +1 -0
- package/lib/commonjs/index.d.ts +8 -0
- package/lib/commonjs/index.js +43 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/utils.d.ts +43 -0
- package/lib/commonjs/utils.js +216 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/esm/api/errors_api.js +40 -0
- package/lib/esm/api/errors_api.js.map +1 -0
- package/lib/esm/api/events_api.js +86 -0
- package/lib/esm/api/events_api.js.map +1 -0
- package/lib/esm/api/functions_api.js +134 -0
- package/lib/esm/api/functions_api.js.map +1 -0
- package/lib/esm/api/logs_api.js +103 -0
- package/lib/esm/api/logs_api.js.map +1 -0
- package/lib/esm/api/parameters_api.js +271 -0
- package/lib/esm/api/parameters_api.js.map +1 -0
- package/lib/esm/coders/base/address.js +70 -0
- package/lib/esm/coders/base/address.js.map +1 -0
- package/lib/esm/coders/base/array.js +101 -0
- package/lib/esm/coders/base/array.js.map +1 -0
- package/lib/esm/coders/base/bool.js +51 -0
- package/lib/esm/coders/base/bool.js.map +1 -0
- package/lib/esm/coders/base/bytes.js +96 -0
- package/lib/esm/coders/base/bytes.js.map +1 -0
- package/lib/esm/coders/base/index.js +90 -0
- package/lib/esm/coders/base/index.js.map +1 -0
- package/lib/esm/coders/base/number.js +111 -0
- package/lib/esm/coders/base/number.js.map +1 -0
- package/lib/esm/coders/base/numbersLimits.js +37 -0
- package/lib/esm/coders/base/numbersLimits.js.map +1 -0
- package/lib/esm/coders/base/string.js +35 -0
- package/lib/esm/coders/base/string.js.map +1 -0
- package/lib/esm/coders/base/tuple.js +118 -0
- package/lib/esm/coders/base/tuple.js.map +1 -0
- package/lib/esm/coders/base/utils.js +46 -0
- package/lib/esm/coders/base/utils.js.map +1 -0
- package/lib/esm/coders/decode.js +25 -0
- package/lib/esm/coders/decode.js.map +1 -0
- package/lib/esm/coders/encode.js +108 -0
- package/lib/esm/coders/encode.js.map +1 -0
- package/lib/esm/coders/types.js +18 -0
- package/lib/esm/coders/types.js.map +1 -0
- package/lib/esm/coders/utils.js +105 -0
- package/lib/esm/coders/utils.js.map +1 -0
- package/lib/esm/decode_contract_error_data.js +69 -0
- package/lib/esm/decode_contract_error_data.js.map +1 -0
- package/lib/esm/eip_712.js +140 -0
- package/lib/esm/eip_712.js.map +1 -0
- package/lib/esm/index.js +25 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/utils.js +199 -0
- package/lib/esm/utils.js.map +1 -0
- package/lib/types/api/errors_api.d.ts +6 -0
- package/lib/types/api/errors_api.d.ts.map +1 -0
- package/lib/types/api/events_api.d.ts +52 -0
- package/lib/types/api/events_api.d.ts.map +1 -0
- package/lib/types/api/functions_api.d.ts +93 -0
- package/lib/types/api/functions_api.d.ts.map +1 -0
- package/lib/types/api/logs_api.d.ts +50 -0
- package/lib/types/api/logs_api.d.ts.map +1 -0
- package/lib/types/api/parameters_api.d.ts +239 -0
- package/lib/types/api/parameters_api.d.ts.map +1 -0
- package/lib/types/coders/base/address.d.ts +5 -0
- package/lib/types/coders/base/address.d.ts.map +1 -0
- package/lib/types/coders/base/array.d.ts +5 -0
- package/lib/types/coders/base/array.d.ts.map +1 -0
- package/lib/types/coders/base/bool.d.ts +5 -0
- package/lib/types/coders/base/bool.d.ts.map +1 -0
- package/lib/types/coders/base/bytes.d.ts +5 -0
- package/lib/types/coders/base/bytes.d.ts.map +1 -0
- package/lib/types/coders/base/index.d.ts +12 -0
- package/lib/types/coders/base/index.d.ts.map +1 -0
- package/lib/types/coders/base/number.d.ts +5 -0
- package/lib/types/coders/base/number.d.ts.map +1 -0
- package/lib/types/coders/base/numbersLimits.d.ts +5 -0
- package/lib/types/coders/base/numbersLimits.d.ts.map +1 -0
- package/lib/types/coders/base/string.d.ts +5 -0
- package/lib/types/coders/base/string.d.ts.map +1 -0
- package/lib/types/coders/base/tuple.d.ts +8 -0
- package/lib/types/coders/base/tuple.d.ts.map +1 -0
- package/lib/types/coders/base/utils.d.ts +3 -0
- package/lib/types/coders/base/utils.d.ts.map +1 -0
- package/lib/types/coders/decode.d.ts +6 -0
- package/lib/types/coders/decode.d.ts.map +1 -0
- package/lib/types/coders/encode.d.ts +39 -0
- package/lib/types/coders/encode.d.ts.map +1 -0
- package/lib/types/coders/types.d.ts +17 -0
- package/lib/types/coders/types.d.ts.map +1 -0
- package/lib/types/coders/utils.d.ts +24 -0
- package/lib/types/coders/utils.d.ts.map +1 -0
- package/lib/types/decode_contract_error_data.d.ts +4 -0
- package/lib/types/decode_contract_error_data.d.ts.map +1 -0
- package/lib/types/eip_712.d.ts +51 -0
- package/lib/types/eip_712.d.ts.map +1 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/utils.d.ts +44 -0
- package/lib/types/utils.d.ts.map +1 -0
- package/package.json +56 -0
- package/src/api/errors_api.ts +45 -0
- package/src/api/events_api.ts +91 -0
- package/src/api/functions_api.ts +145 -0
- package/src/api/logs_api.ts +131 -0
- package/src/api/parameters_api.ts +287 -0
- package/src/coders/base/address.ts +75 -0
- package/src/coders/base/array.ts +120 -0
- package/src/coders/base/bool.ts +54 -0
- package/src/coders/base/bytes.ts +106 -0
- package/src/coders/base/index.ts +95 -0
- package/src/coders/base/number.ts +116 -0
- package/src/coders/base/numbersLimits.ts +39 -0
- package/src/coders/base/string.ts +38 -0
- package/src/coders/base/tuple.ts +130 -0
- package/src/coders/base/utils.ts +51 -0
- package/src/coders/decode.ts +32 -0
- package/src/coders/encode.ts +114 -0
- package/src/coders/types.ts +39 -0
- package/src/coders/utils.ts +128 -0
- package/src/decode_contract_error_data.ts +80 -0
- package/src/eip_712.ts +252 -0
- package/src/index.ts +25 -0
- package/src/utils.ts +266 -0
- package/w15h3djt.cjs +1 -0
@@ -0,0 +1,239 @@
|
|
1
|
+
import { AbiInput, HexString } from 'web3-types';
|
2
|
+
export { encodeParameters, inferTypesAndEncodeParameters } from '../coders/encode.js';
|
3
|
+
/**
|
4
|
+
* Encodes a parameter based on its type to its ABI representation.
|
5
|
+
* @param abi - The type of the parameter. See the [Solidity documentation](https://docs.soliditylang.org/en/develop/types.html) for a list of types.
|
6
|
+
* @param param - The actual parameter to encode.
|
7
|
+
* @returns - The ABI encoded parameter
|
8
|
+
* @example
|
9
|
+
* ```ts
|
10
|
+
* const res = web3.eth.abi.encodeParameter("uint256", "2345675643");
|
11
|
+
* console.log(res);
|
12
|
+
* 0x000000000000000000000000000000000000000000000000000000008bd02b7b
|
13
|
+
*
|
14
|
+
* const res = web3.eth.abi.encodeParameter("uint", "2345675643");
|
15
|
+
*
|
16
|
+
* console.log(res);
|
17
|
+
* >0x000000000000000000000000000000000000000000000000000000008bd02b7b
|
18
|
+
*
|
19
|
+
* const res = web3.eth.abi.encodeParameter("bytes32", "0xdf3234");
|
20
|
+
*
|
21
|
+
* console.log(res);
|
22
|
+
* >0xdf32340000000000000000000000000000000000000000000000000000000000
|
23
|
+
*
|
24
|
+
* const res = web3.eth.abi.encodeParameter("bytes", "0xdf3234");
|
25
|
+
*
|
26
|
+
* console.log(res);
|
27
|
+
* > 0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003df32340000000000000000000000000000000000000000000000000000000000
|
28
|
+
*
|
29
|
+
* const res = web3.eth.abi.encodeParameter("bytes32[]", ["0xdf3234", "0xfdfd"]);
|
30
|
+
*
|
31
|
+
* console.log(res);
|
32
|
+
* > 0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002df32340000000000000000000000000000000000000000000000000000000000fdfd000000000000000000000000000000000000000000000000000000000000
|
33
|
+
*
|
34
|
+
* const res = web3.eth.abi.encodeParameter(
|
35
|
+
* {
|
36
|
+
* ParentStruct: {
|
37
|
+
* propertyOne: "uint256",
|
38
|
+
* propertyTwo: "uint256",
|
39
|
+
* childStruct: {
|
40
|
+
* propertyOne: "uint256",
|
41
|
+
* propertyTwo: "uint256",
|
42
|
+
* },
|
43
|
+
* },
|
44
|
+
* },
|
45
|
+
* {
|
46
|
+
* propertyOne: 42,
|
47
|
+
* propertyTwo: 56,
|
48
|
+
* childStruct: {
|
49
|
+
* propertyOne: 45,
|
50
|
+
* propertyTwo: 78,
|
51
|
+
* },
|
52
|
+
* }
|
53
|
+
* );
|
54
|
+
*
|
55
|
+
* console.log(res);
|
56
|
+
* > 0x000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002d000000000000000000000000000000000000000000000000000000000000004e
|
57
|
+
* ```
|
58
|
+
*/
|
59
|
+
export declare const encodeParameter: (abi: AbiInput, param: unknown) => string;
|
60
|
+
/**
|
61
|
+
* Should be used to decode list of params
|
62
|
+
*/
|
63
|
+
export declare const decodeParametersWith: (abis: AbiInput[] | ReadonlyArray<AbiInput>, bytes: HexString, loose: boolean) => {
|
64
|
+
[key: string]: unknown;
|
65
|
+
__length__: number;
|
66
|
+
};
|
67
|
+
/**
|
68
|
+
* Should be used to decode list of params
|
69
|
+
*/
|
70
|
+
/**
|
71
|
+
* Decodes ABI encoded parameters to its JavaScript types.
|
72
|
+
* @param abi - An array of {@link AbiInput}. See the [Solidity documentation](https://docs.soliditylang.org/en/develop/types.html) for a list of types.
|
73
|
+
* @param bytes - The ABI byte code to decode
|
74
|
+
* @returns - The result object containing the decoded parameters.
|
75
|
+
* @example
|
76
|
+
* ```ts
|
77
|
+
* let res = web3.eth.abi.decodeParameters(
|
78
|
+
* ["string", "uint256"],
|
79
|
+
* "0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000ea000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000"
|
80
|
+
* );
|
81
|
+
* console.log(res);
|
82
|
+
* > { '0': 'Hello!%!', '1': 234n, __length__: 2 }
|
83
|
+
*
|
84
|
+
* let res = web3.eth.abi.decodeParameters(
|
85
|
+
* [
|
86
|
+
* {
|
87
|
+
* type: "string",
|
88
|
+
* name: "myString",
|
89
|
+
* },
|
90
|
+
* {
|
91
|
+
* type: "uint256",
|
92
|
+
* name: "myNumber",
|
93
|
+
* },
|
94
|
+
* ],
|
95
|
+
* "0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000ea000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000"
|
96
|
+
* );
|
97
|
+
* console.log(res);
|
98
|
+
* > {
|
99
|
+
* '0': 'Hello!%!',
|
100
|
+
* '1': 234n,
|
101
|
+
* __length__: 2,
|
102
|
+
* myString: 'Hello!%!',
|
103
|
+
* myNumber: 234n
|
104
|
+
* }
|
105
|
+
*
|
106
|
+
* const res = web3.eth.abi.decodeParameters(
|
107
|
+
* [
|
108
|
+
* "uint8[]",
|
109
|
+
* {
|
110
|
+
* ParentStruct: {
|
111
|
+
* propertyOne: "uint256",
|
112
|
+
* propertyTwo: "uint256",
|
113
|
+
* childStruct: {
|
114
|
+
* propertyOne: "uint256",
|
115
|
+
* propertyTwo: "uint256",
|
116
|
+
* },
|
117
|
+
* },
|
118
|
+
* },
|
119
|
+
* ],
|
120
|
+
* "0x00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002d000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000018"
|
121
|
+
* );
|
122
|
+
* console.log(res);
|
123
|
+
* >
|
124
|
+
* '0': [ 42n, 24n ],
|
125
|
+
* '1': {
|
126
|
+
* '0': 42n,
|
127
|
+
* '1': 56n,
|
128
|
+
* '2': {
|
129
|
+
* '0': 45n,
|
130
|
+
* '1': 78n,
|
131
|
+
* __length__: 2,
|
132
|
+
* propertyOne: 45n,
|
133
|
+
* propertyTwo: 78n
|
134
|
+
* },
|
135
|
+
* __length__: 3,
|
136
|
+
* propertyOne: 42n,
|
137
|
+
* propertyTwo: 56n,
|
138
|
+
* childStruct: {
|
139
|
+
* '0': 45n,
|
140
|
+
* '1': 78n,
|
141
|
+
* __length__: 2,
|
142
|
+
* propertyOne: 45n,
|
143
|
+
* propertyTwo: 78n
|
144
|
+
* }
|
145
|
+
* },
|
146
|
+
* __length__: 2,
|
147
|
+
* ParentStruct: {
|
148
|
+
* '0': 42n,
|
149
|
+
* '1': 56n,
|
150
|
+
* '2': {
|
151
|
+
* '0': 45n,
|
152
|
+
* '1': 78n,
|
153
|
+
* __length__: 2,
|
154
|
+
* propertyOne: 45n,
|
155
|
+
* propertyTwo: 78n
|
156
|
+
* },
|
157
|
+
* __length__: 3,
|
158
|
+
* propertyOne: 42n,
|
159
|
+
* propertyTwo: 56n,
|
160
|
+
* childStruct: {
|
161
|
+
* '0': 45n,
|
162
|
+
* '1': 78n,
|
163
|
+
* __length__: 2,
|
164
|
+
* propertyOne: 45n,
|
165
|
+
* propertyTwo: 78n
|
166
|
+
* }
|
167
|
+
* }
|
168
|
+
*}
|
169
|
+
* ```
|
170
|
+
*/
|
171
|
+
export declare const decodeParameters: (abi: AbiInput[] | ReadonlyArray<AbiInput>, bytes: HexString) => {
|
172
|
+
[key: string]: unknown;
|
173
|
+
__length__: number;
|
174
|
+
};
|
175
|
+
/**
|
176
|
+
* Should be used to decode bytes to plain param
|
177
|
+
*/
|
178
|
+
/**
|
179
|
+
* Decodes an ABI encoded parameter to its JavaScript type.
|
180
|
+
* @param abi - The type of the parameter. See the [Solidity documentation](https://docs.soliditylang.org/en/develop/types.html) for a list of types.
|
181
|
+
* @param bytes - The ABI byte code to decode
|
182
|
+
* @returns - The decoded parameter
|
183
|
+
* @example
|
184
|
+
* ```ts
|
185
|
+
* const res = web3.eth.abi.decodeParameter(
|
186
|
+
* "uint256",
|
187
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000010"
|
188
|
+
* );
|
189
|
+
* console.log(res);
|
190
|
+
* > 16n
|
191
|
+
*
|
192
|
+
* const res = web3.eth.abi.decodeParameter(
|
193
|
+
* "string",
|
194
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000"
|
195
|
+
* );
|
196
|
+
*
|
197
|
+
* console.log(res);
|
198
|
+
* > Hello!%!
|
199
|
+
*
|
200
|
+
* const res = web3.eth.abi.decodeParameter(
|
201
|
+
* {
|
202
|
+
* ParentStruct: {
|
203
|
+
* propertyOne: "uint256",
|
204
|
+
* propertyTwo: "uint256",
|
205
|
+
* childStruct: {
|
206
|
+
* propertyOne: "uint256",
|
207
|
+
* propertyTwo: "uint256",
|
208
|
+
* },
|
209
|
+
* },
|
210
|
+
* },
|
211
|
+
* "0x000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002d000000000000000000000000000000000000000000000000000000000000004e"
|
212
|
+
* );
|
213
|
+
*
|
214
|
+
* console.log(res);
|
215
|
+
* {
|
216
|
+
* '0': 42n,
|
217
|
+
* '1': 56n,
|
218
|
+
* '2': {
|
219
|
+
* '0': 45n,
|
220
|
+
* '1': 78n,
|
221
|
+
* __length__: 2,
|
222
|
+
* propertyOne: 45n,
|
223
|
+
* propertyTwo: 78n
|
224
|
+
* },
|
225
|
+
* __length__: 3,
|
226
|
+
* propertyOne: 42n,
|
227
|
+
* propertyTwo: 56n,
|
228
|
+
* childStruct: {
|
229
|
+
* '0': 45n,
|
230
|
+
* '1': 78n,
|
231
|
+
* __length__: 2,
|
232
|
+
* propertyOne: 45n,
|
233
|
+
* propertyTwo: 78n
|
234
|
+
* }
|
235
|
+
*}
|
236
|
+
* ```
|
237
|
+
*/
|
238
|
+
export declare const decodeParameter: (abi: AbiInput, bytes: HexString) => unknown;
|
239
|
+
//# sourceMappingURL=parameters_api.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"parameters_api.d.ts","sourceRoot":"","sources":["../../../src/api/parameters_api.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIjD,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,eAAO,MAAM,eAAe,QAAS,QAAQ,SAAS,OAAO,KAAG,MAC/B,CAAC;AAClC;;GAEG;AACH,eAAO,MAAM,oBAAoB,SAC1B,QAAQ,EAAE,GAAG,cAAc,QAAQ,CAAC,SACnC,SAAS,SACT,OAAO;;gBAC0B,MAAM;CAiB9C,CAAC;AAEF;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGG;AACH,eAAO,MAAM,gBAAgB,QACvB,QAAQ,EAAE,GAAG,cAAc,QAAQ,CAAC,SAClC,SAAS;;gBACwB,MAAM;CAA6C,CAAC;AAE7F;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,eAAO,MAAM,eAAe,QAAS,QAAQ,SAAS,SAAS,KAAG,OAC9B,CAAC"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { AbiParameter } from 'web3-types';
|
2
|
+
import { DecoderResult, EncoderResult } from '../types.js';
|
3
|
+
export declare function encodeAddress(param: AbiParameter, input: unknown): EncoderResult;
|
4
|
+
export declare function decodeAddress(_param: AbiParameter, bytes: Uint8Array): DecoderResult<string>;
|
5
|
+
//# sourceMappingURL=address.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/address.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAM3D,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CA4BhF;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAkB5F"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { AbiParameter } from 'web3-types';
|
2
|
+
import { DecoderResult, EncoderResult } from '../types.js';
|
3
|
+
export declare function encodeArray(param: AbiParameter, values: unknown): EncoderResult;
|
4
|
+
export declare function decodeArray(param: AbiParameter, bytes: Uint8Array): DecoderResult<unknown[]>;
|
5
|
+
//# sourceMappingURL=array.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/array.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAK3D,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,aAAa,CAuC/E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC,CAoD5F"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { AbiParameter } from 'web3-types';
|
2
|
+
import { DecoderResult, EncoderResult } from '../types.js';
|
3
|
+
export declare function encodeBoolean(param: AbiParameter, input: unknown): EncoderResult;
|
4
|
+
export declare function decodeBool(_param: AbiParameter, bytes: Uint8Array): DecoderResult<boolean>;
|
5
|
+
//# sourceMappingURL=bool.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bool.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/bool.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI3D,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAehF;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,CAa1F"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { AbiParameter } from 'web3-types';
|
2
|
+
import { DecoderResult, EncoderResult } from '../types.js';
|
3
|
+
export declare function encodeBytes(param: AbiParameter, input: unknown): EncoderResult;
|
4
|
+
export declare function decodeBytes(param: AbiParameter, bytes: Uint8Array): DecoderResult<string>;
|
5
|
+
//# sourceMappingURL=bytes.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/bytes.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAS,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAM3D,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAkD9E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CA2BzF"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { AbiParameter } from 'web3-types';
|
2
|
+
import { EncoderResult, DecoderResult } from '../types.js';
|
3
|
+
export { encodeAddress, decodeAddress } from './address.js';
|
4
|
+
export { encodeBoolean, decodeBool } from './bool.js';
|
5
|
+
export { encodeBytes, decodeBytes } from './bytes.js';
|
6
|
+
export { encodeNumber, decodeNumber } from './number.js';
|
7
|
+
export { encodeString, decodeString } from './string.js';
|
8
|
+
export { encodeTuple, decodeTuple } from './tuple.js';
|
9
|
+
export { encodeArray, decodeArray } from './array.js';
|
10
|
+
export declare function encodeParamFromAbiParameter(param: AbiParameter, value: unknown): EncoderResult;
|
11
|
+
export declare function decodeParamFromAbiParameter(param: AbiParameter, bytes: Uint8Array): DecoderResult;
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAW3D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CA0B9F;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CA0BjG"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { AbiParameter } from 'web3-types';
|
2
|
+
import { DecoderResult, EncoderResult } from '../types.js';
|
3
|
+
export declare function encodeNumber(param: AbiParameter, input: unknown): EncoderResult;
|
4
|
+
export declare function decodeNumber(param: AbiParameter, bytes: Uint8Array): DecoderResult<bigint>;
|
5
|
+
//# sourceMappingURL=number.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/number.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAyB3D,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAmC/E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAgC1F"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"numbersLimits.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/numbersLimits.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY;SAA0B,MAAM;SAAO,MAAM;EAAK,CAAC"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { AbiParameter } from 'web3-types';
|
2
|
+
import { DecoderResult, EncoderResult } from '../types.js';
|
3
|
+
export declare function encodeString(_param: AbiParameter, input: unknown): EncoderResult;
|
4
|
+
export declare function decodeString(_param: AbiParameter, bytes: Uint8Array): DecoderResult<string>;
|
5
|
+
//# sourceMappingURL=string.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/string.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG3D,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAMhF;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAO3F"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { AbiParameter } from 'web3-types';
|
2
|
+
import { DecoderResult, EncoderResult } from '../types.js';
|
3
|
+
export declare function encodeTuple(param: AbiParameter, input: unknown): EncoderResult;
|
4
|
+
export declare function decodeTuple(param: AbiParameter, bytes: Uint8Array): DecoderResult<{
|
5
|
+
[key: string]: unknown;
|
6
|
+
__length__: number;
|
7
|
+
}>;
|
8
|
+
//# sourceMappingURL=tuple.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/tuple.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO3D,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAkD9E;AAED,wBAAgB,WAAW,CAC1B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,UAAU,GACf,aAAa,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAgD/D"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/coders/base/utils.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,UAAU,CA6B3F"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../src/coders/decode.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKjD,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,QAAQ,CAAC,EAC1C,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,OAAO,GACb;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAKhD"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { AbiInput } from 'web3-types';
|
2
|
+
/**
|
3
|
+
* Encodes a parameter based on its type to its ABI representation.
|
4
|
+
* @param abi - An array of {@link AbiInput}. See [Solidity's documentation](https://solidity.readthedocs.io/en/v0.5.3/abi-spec.html#json) for more details.
|
5
|
+
* @param params - The actual parameters to encode.
|
6
|
+
* @returns - The ABI encoded parameters
|
7
|
+
* @example
|
8
|
+
* ```ts
|
9
|
+
* const res = web3.eth.abi.encodeParameters(
|
10
|
+
* ["uint256", "string"],
|
11
|
+
* ["2345675643", "Hello!%"]
|
12
|
+
* );
|
13
|
+
*
|
14
|
+
* console.log(res);
|
15
|
+
* > 0x000000000000000000000000000000000000000000000000000000008bd02b7b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000748656c6c6f212500000000000000000000000000000000000000000000000000
|
16
|
+
* ```
|
17
|
+
*/
|
18
|
+
export declare function encodeParameters(abi: ReadonlyArray<AbiInput>, params: unknown[]): string;
|
19
|
+
/**
|
20
|
+
* Infer a smart contract method parameter type and then encode this parameter.
|
21
|
+
* @param params - The parameters to encode.
|
22
|
+
* @returns - The ABI encoded parameters
|
23
|
+
*
|
24
|
+
* @remarks
|
25
|
+
* This method is useful when you don't know the type of the parameters you want to encode. It will infer the type of the parameters and then encode them.
|
26
|
+
* However, it is not recommended to use this method when you know the type of the parameters you want to encode. In this case, use the {@link encodeParameters} method instead.
|
27
|
+
* The type inference is not perfect and can lead to unexpected results. Especially when you want to encode an array, uint that is not uint256 or bytes....
|
28
|
+
* @example
|
29
|
+
* ```ts
|
30
|
+
* const res = web3.eth.abi.encodeParameters(
|
31
|
+
* ["2345675643", "Hello!%"]
|
32
|
+
* );
|
33
|
+
*
|
34
|
+
* console.log(res);
|
35
|
+
* > 0x000000000000000000000000000000000000000000000000000000008bd02b7b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000748656c6c6f212500000000000000000000000000000000000000000000000000
|
36
|
+
* ```
|
37
|
+
*/
|
38
|
+
export declare function inferTypesAndEncodeParameters(params: unknown[]): string;
|
39
|
+
//# sourceMappingURL=encode.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/coders/encode.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAmCpD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAYxF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAYvE"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export declare type EncoderResult = {
|
2
|
+
dynamic: boolean;
|
3
|
+
encoded: Uint8Array;
|
4
|
+
};
|
5
|
+
export declare type DecoderResult<T = unknown> = {
|
6
|
+
result: T;
|
7
|
+
encoded: Uint8Array;
|
8
|
+
consumed: number;
|
9
|
+
};
|
10
|
+
export declare type NumberType = {
|
11
|
+
signed: boolean;
|
12
|
+
byteLength: number;
|
13
|
+
};
|
14
|
+
export declare type BytesType = {
|
15
|
+
size?: number;
|
16
|
+
};
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/coders/types.ts"],"names":[],"mappings":"AAiBA,oBAAY,aAAa,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC;IAEjB,OAAO,EAAE,UAAU,CAAC;CACpB,CAAC;AACF,oBAAY,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,MAAM,EAAE,CAAC,CAAC;IAGV,OAAO,EAAE,UAAU,CAAC;IAGpB,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,UAAU,GAAG;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,oBAAY,SAAS,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { AbiParameter as ExternalAbiParameter } from 'abitype';
|
2
|
+
import { AbiInput, AbiParameter } from 'web3-types';
|
3
|
+
export declare const WORD_SIZE = 32;
|
4
|
+
export declare function alloc(size?: number): Uint8Array;
|
5
|
+
/**
|
6
|
+
* Where possible returns a Uint8Array of the requested size that references
|
7
|
+
* uninitialized memory. Only use if you are certain you will immediately
|
8
|
+
* overwrite every value in the returned `Uint8Array`.
|
9
|
+
*/
|
10
|
+
export declare function allocUnsafe(size?: number): Uint8Array;
|
11
|
+
export declare function convertExternalAbiParameter(abiParam: ExternalAbiParameter): AbiParameter;
|
12
|
+
export declare function isAbiParameter(param: unknown): param is AbiParameter;
|
13
|
+
export declare function toAbiParams(abi: ReadonlyArray<AbiInput>): ReadonlyArray<AbiParameter>;
|
14
|
+
export declare function extractArrayType(param: AbiParameter): {
|
15
|
+
size: number;
|
16
|
+
param: AbiParameter;
|
17
|
+
};
|
18
|
+
/**
|
19
|
+
* Param is dynamic if it's dynamic base type or if some of his children (components, array items)
|
20
|
+
* is of dynamic type
|
21
|
+
* @param param
|
22
|
+
*/
|
23
|
+
export declare function isDynamic(param: AbiParameter): boolean;
|
24
|
+
//# sourceMappingURL=utils.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/coders/utils.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAqB,MAAM,SAAS,CAAC;AAElF,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAa,MAAM,YAAY,CAAC;AAQ/D,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,wBAAgB,KAAK,CAAC,IAAI,SAAI,GAAG,UAAU,CAO1C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,SAAI,GAAG,UAAU,CAOhD;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,oBAAoB,GAAG,YAAY,CAQxF;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAOpE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,YAAY,CAAC,CAsBrF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,CAgB3F;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAStD"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Eip838ExecutionError } from 'web3-errors';
|
2
|
+
import { AbiErrorFragment } from 'web3-types';
|
3
|
+
export declare const decodeContractErrorData: (errorsAbi: AbiErrorFragment[], error: Eip838ExecutionError) => void;
|
4
|
+
//# sourceMappingURL=decode_contract_error_data.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"decode_contract_error_data.d.ts","sourceRoot":"","sources":["../../src/decode_contract_error_data.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAM9C,eAAO,MAAM,uBAAuB,cACxB,gBAAgB,EAAE,SACtB,oBAAoB,SAqD3B,CAAC"}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/**
|
2
|
+
* The web3.eth.abi functions let you encode and decode parameters to ABI (Application Binary Interface) for function calls to the EVM (Ethereum Virtual Machine).
|
3
|
+
*
|
4
|
+
* For using Web3 ABI functions, first install Web3 package using `npm i web3` or `yarn add web3`.
|
5
|
+
* After that, Web3 ABI functions will be available.
|
6
|
+
* ```ts
|
7
|
+
* import { Web3 } from 'web3';
|
8
|
+
*
|
9
|
+
* const web3 = new Web3();
|
10
|
+
* const encoded = web3.eth.abi.encodeFunctionSignature({
|
11
|
+
* name: 'myMethod',
|
12
|
+
* type: 'function',
|
13
|
+
* inputs: [{
|
14
|
+
* type: 'uint256',
|
15
|
+
* name: 'myNumber'
|
16
|
+
* },{
|
17
|
+
* type: 'string',
|
18
|
+
* name: 'myString'
|
19
|
+
* }]
|
20
|
+
* });
|
21
|
+
*
|
22
|
+
* ```
|
23
|
+
*
|
24
|
+
* For using individual package install `web3-eth-abi` package using `npm i web3-eth-abi` or `yarn add web3-eth-abi` and only import required functions.
|
25
|
+
* This is more efficient approach for building lightweight applications.
|
26
|
+
* ```ts
|
27
|
+
* import { encodeFunctionSignature } from 'web3-eth-abi';
|
28
|
+
*
|
29
|
+
* const encoded = encodeFunctionSignature({
|
30
|
+
* name: 'myMethod',
|
31
|
+
* type: 'function',
|
32
|
+
* inputs: [{
|
33
|
+
* type: 'uint256',
|
34
|
+
* name: 'myNumber'
|
35
|
+
* },{
|
36
|
+
* type: 'string',
|
37
|
+
* name: 'myString'
|
38
|
+
* }]
|
39
|
+
* });
|
40
|
+
*
|
41
|
+
* ```
|
42
|
+
*
|
43
|
+
* @module ABI
|
44
|
+
*/
|
45
|
+
import { Eip712TypedData } from 'web3-types';
|
46
|
+
/**
|
47
|
+
* Get the EIP-191 encoded message to sign, from the typedData object. If `hash` is enabled, the message will be hashed
|
48
|
+
* with Keccak256.
|
49
|
+
*/
|
50
|
+
export declare const getMessage: (typedData: Eip712TypedData, hash?: boolean) => string;
|
51
|
+
//# sourceMappingURL=eip_712.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"eip_712.d.ts","sourceRoot":"","sources":["../../src/eip_712.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAkF7C;;;GAGG;AACH,eAAO,MAAM,UAAU,cAAe,eAAe,SAAS,OAAO,KAAG,MAevE,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export * from './api/errors_api.js';
|
2
|
+
export * from './api/events_api.js';
|
3
|
+
export * from './api/functions_api.js';
|
4
|
+
export * from './api/logs_api.js';
|
5
|
+
export * from './api/parameters_api.js';
|
6
|
+
export * from './utils.js';
|
7
|
+
export * from './decode_contract_error_data.js';
|
8
|
+
export { getMessage as getEncodedEip712Data } from './eip_712.js';
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAiBA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { AbiInput, AbiCoderStruct, AbiFragment, AbiParameter, AbiStruct, AbiEventFragment, AbiFunctionFragment, AbiConstructorFragment } from 'web3-types';
|
2
|
+
export declare const isAbiFragment: (item: unknown) => item is AbiFragment;
|
3
|
+
export declare const isAbiErrorFragment: (item: unknown) => item is AbiEventFragment;
|
4
|
+
export declare const isAbiEventFragment: (item: unknown) => item is AbiEventFragment;
|
5
|
+
export declare const isAbiFunctionFragment: (item: unknown) => item is AbiFunctionFragment;
|
6
|
+
export declare const isAbiConstructorFragment: (item: unknown) => item is AbiConstructorFragment;
|
7
|
+
/**
|
8
|
+
* Check if type is simplified struct format
|
9
|
+
*/
|
10
|
+
export declare const isSimplifiedStructFormat: (type: string | Partial<AbiParameter> | Partial<AbiInput>) => type is Omit<AbiParameter, "components" | "name">;
|
11
|
+
/**
|
12
|
+
* Maps the correct tuple type and name when the simplified format in encode/decodeParameter is used
|
13
|
+
*/
|
14
|
+
export declare const mapStructNameAndType: (structName: string) => AbiStruct;
|
15
|
+
/**
|
16
|
+
* Maps the simplified format in to the expected format of the ABICoder
|
17
|
+
*/
|
18
|
+
export declare const mapStructToCoderFormat: (struct: AbiStruct) => Array<AbiCoderStruct>;
|
19
|
+
/**
|
20
|
+
* Map types if simplified format is used
|
21
|
+
*/
|
22
|
+
export declare const mapTypes: (types: AbiInput[]) => Array<string | AbiParameter | Record<string, unknown>>;
|
23
|
+
/**
|
24
|
+
* returns true if input is a hexstring and is odd-lengthed
|
25
|
+
*/
|
26
|
+
export declare const isOddHexstring: (param: unknown) => boolean;
|
27
|
+
/**
|
28
|
+
* format odd-length bytes to even-length
|
29
|
+
*/
|
30
|
+
export declare const formatOddHexstrings: (param: string) => string;
|
31
|
+
/**
|
32
|
+
* Handle some formatting of params for backwards compatibility with Ethers V4
|
33
|
+
*/
|
34
|
+
export declare const formatParam: (type: string, _param: unknown) => unknown;
|
35
|
+
/**
|
36
|
+
* used to flatten json abi inputs/outputs into an array of type-representing-strings
|
37
|
+
*/
|
38
|
+
export declare const flattenTypes: (includeTuple: boolean, puts: ReadonlyArray<AbiParameter>) => string[];
|
39
|
+
/**
|
40
|
+
* Should be used to create full function/event name from json abi
|
41
|
+
* returns a string
|
42
|
+
*/
|
43
|
+
export declare const jsonInterfaceMethodToString: (json: AbiFragment) => string;
|
44
|
+
//# sourceMappingURL=utils.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAmBA,OAAO,EACN,QAAQ,EACR,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,aAAa,SAAU,OAAO,wBAI6C,CAAC;AAEzF,eAAO,MAAM,kBAAkB,SAAU,OAAO,6BAIJ,CAAC;AAE7C,eAAO,MAAM,kBAAkB,SAAU,OAAO,6BAIJ,CAAC;AAE7C,eAAO,MAAM,qBAAqB,SAAU,OAAO,gCAIJ,CAAC;AAEhD,eAAO,MAAM,wBAAwB,SAAU,OAAO,mCAIJ,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,wBAAwB,SAC9B,MAAM,GAAG,QAAQ,YAAY,CAAC,GAAG,QAAQ,QAAQ,CAAC,sDAID,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,oBAAoB,eAAgB,MAAM,KAAG,SAGnB,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,sBAAsB,WAAY,SAAS,KAAG,MAAM,cAAc,CAmB9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,UACb,QAAQ,EAAE,KACf,MAAM,MAAM,GAAG,YAAY,GAAG,OAAO,MAAM,EAAE,OAAO,CAAC,CAiCvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,OACwC,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAW,MAAM,KAAG,MACO,CAAC;AAM5D;;GAEG;AACH,eAAO,MAAM,WAAW,SAAU,MAAM,UAAU,OAAO,KAAG,OAmD3D,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,YAAY,iBACV,OAAO,QACf,cAAc,YAAY,CAAC,KAC/B,MAAM,EA2BR,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,SAAU,WAAW,KAAG,MAW/D,CAAC"}
|