web3ethabii 4.3.0

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.
Files changed (190) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +59 -0
  3. package/lib/commonjs/api/errors_api.d.ts +5 -0
  4. package/lib/commonjs/api/errors_api.js +44 -0
  5. package/lib/commonjs/api/errors_api.js.map +1 -0
  6. package/lib/commonjs/api/events_api.d.ts +51 -0
  7. package/lib/commonjs/api/events_api.js +90 -0
  8. package/lib/commonjs/api/events_api.js.map +1 -0
  9. package/lib/commonjs/api/functions_api.d.ts +92 -0
  10. package/lib/commonjs/api/functions_api.js +139 -0
  11. package/lib/commonjs/api/functions_api.js.map +1 -0
  12. package/lib/commonjs/api/logs_api.d.ts +49 -0
  13. package/lib/commonjs/api/logs_api.js +107 -0
  14. package/lib/commonjs/api/logs_api.js.map +1 -0
  15. package/lib/commonjs/api/parameters_api.d.ts +238 -0
  16. package/lib/commonjs/api/parameters_api.js +280 -0
  17. package/lib/commonjs/api/parameters_api.js.map +1 -0
  18. package/lib/commonjs/coders/base/address.d.ts +4 -0
  19. package/lib/commonjs/coders/base/address.js +75 -0
  20. package/lib/commonjs/coders/base/address.js.map +1 -0
  21. package/lib/commonjs/coders/base/array.d.ts +4 -0
  22. package/lib/commonjs/coders/base/array.js +106 -0
  23. package/lib/commonjs/coders/base/array.js.map +1 -0
  24. package/lib/commonjs/coders/base/bool.d.ts +4 -0
  25. package/lib/commonjs/coders/base/bool.js +56 -0
  26. package/lib/commonjs/coders/base/bool.js.map +1 -0
  27. package/lib/commonjs/coders/base/bytes.d.ts +4 -0
  28. package/lib/commonjs/coders/base/bytes.js +101 -0
  29. package/lib/commonjs/coders/base/bytes.js.map +1 -0
  30. package/lib/commonjs/coders/base/index.d.ts +11 -0
  31. package/lib/commonjs/coders/base/index.js +109 -0
  32. package/lib/commonjs/coders/base/index.js.map +1 -0
  33. package/lib/commonjs/coders/base/number.d.ts +4 -0
  34. package/lib/commonjs/coders/base/number.js +116 -0
  35. package/lib/commonjs/coders/base/number.js.map +1 -0
  36. package/lib/commonjs/coders/base/numbersLimits.d.ts +4 -0
  37. package/lib/commonjs/coders/base/numbersLimits.js +40 -0
  38. package/lib/commonjs/coders/base/numbersLimits.js.map +1 -0
  39. package/lib/commonjs/coders/base/string.d.ts +4 -0
  40. package/lib/commonjs/coders/base/string.js +40 -0
  41. package/lib/commonjs/coders/base/string.js.map +1 -0
  42. package/lib/commonjs/coders/base/tuple.d.ts +7 -0
  43. package/lib/commonjs/coders/base/tuple.js +123 -0
  44. package/lib/commonjs/coders/base/tuple.js.map +1 -0
  45. package/lib/commonjs/coders/base/utils.d.ts +2 -0
  46. package/lib/commonjs/coders/base/utils.js +50 -0
  47. package/lib/commonjs/coders/base/utils.js.map +1 -0
  48. package/lib/commonjs/coders/decode.d.ts +5 -0
  49. package/lib/commonjs/coders/decode.js +29 -0
  50. package/lib/commonjs/coders/decode.js.map +1 -0
  51. package/lib/commonjs/coders/encode.d.ts +38 -0
  52. package/lib/commonjs/coders/encode.js +113 -0
  53. package/lib/commonjs/coders/encode.js.map +1 -0
  54. package/lib/commonjs/coders/types.d.ts +16 -0
  55. package/lib/commonjs/coders/types.js +19 -0
  56. package/lib/commonjs/coders/types.js.map +1 -0
  57. package/lib/commonjs/coders/utils.d.ts +23 -0
  58. package/lib/commonjs/coders/utils.js +115 -0
  59. package/lib/commonjs/coders/utils.js.map +1 -0
  60. package/lib/commonjs/decode_contract_error_data.d.ts +3 -0
  61. package/lib/commonjs/decode_contract_error_data.js +73 -0
  62. package/lib/commonjs/decode_contract_error_data.js.map +1 -0
  63. package/lib/commonjs/eip_712.d.ts +50 -0
  64. package/lib/commonjs/eip_712.js +144 -0
  65. package/lib/commonjs/eip_712.js.map +1 -0
  66. package/lib/commonjs/index.d.ts +8 -0
  67. package/lib/commonjs/index.js +43 -0
  68. package/lib/commonjs/index.js.map +1 -0
  69. package/lib/commonjs/package.json +1 -0
  70. package/lib/commonjs/utils.d.ts +43 -0
  71. package/lib/commonjs/utils.js +216 -0
  72. package/lib/commonjs/utils.js.map +1 -0
  73. package/lib/esm/api/errors_api.js +40 -0
  74. package/lib/esm/api/errors_api.js.map +1 -0
  75. package/lib/esm/api/events_api.js +86 -0
  76. package/lib/esm/api/events_api.js.map +1 -0
  77. package/lib/esm/api/functions_api.js +134 -0
  78. package/lib/esm/api/functions_api.js.map +1 -0
  79. package/lib/esm/api/logs_api.js +103 -0
  80. package/lib/esm/api/logs_api.js.map +1 -0
  81. package/lib/esm/api/parameters_api.js +271 -0
  82. package/lib/esm/api/parameters_api.js.map +1 -0
  83. package/lib/esm/coders/base/address.js +70 -0
  84. package/lib/esm/coders/base/address.js.map +1 -0
  85. package/lib/esm/coders/base/array.js +101 -0
  86. package/lib/esm/coders/base/array.js.map +1 -0
  87. package/lib/esm/coders/base/bool.js +51 -0
  88. package/lib/esm/coders/base/bool.js.map +1 -0
  89. package/lib/esm/coders/base/bytes.js +96 -0
  90. package/lib/esm/coders/base/bytes.js.map +1 -0
  91. package/lib/esm/coders/base/index.js +90 -0
  92. package/lib/esm/coders/base/index.js.map +1 -0
  93. package/lib/esm/coders/base/number.js +111 -0
  94. package/lib/esm/coders/base/number.js.map +1 -0
  95. package/lib/esm/coders/base/numbersLimits.js +37 -0
  96. package/lib/esm/coders/base/numbersLimits.js.map +1 -0
  97. package/lib/esm/coders/base/string.js +35 -0
  98. package/lib/esm/coders/base/string.js.map +1 -0
  99. package/lib/esm/coders/base/tuple.js +118 -0
  100. package/lib/esm/coders/base/tuple.js.map +1 -0
  101. package/lib/esm/coders/base/utils.js +46 -0
  102. package/lib/esm/coders/base/utils.js.map +1 -0
  103. package/lib/esm/coders/decode.js +25 -0
  104. package/lib/esm/coders/decode.js.map +1 -0
  105. package/lib/esm/coders/encode.js +108 -0
  106. package/lib/esm/coders/encode.js.map +1 -0
  107. package/lib/esm/coders/types.js +18 -0
  108. package/lib/esm/coders/types.js.map +1 -0
  109. package/lib/esm/coders/utils.js +105 -0
  110. package/lib/esm/coders/utils.js.map +1 -0
  111. package/lib/esm/decode_contract_error_data.js +69 -0
  112. package/lib/esm/decode_contract_error_data.js.map +1 -0
  113. package/lib/esm/eip_712.js +140 -0
  114. package/lib/esm/eip_712.js.map +1 -0
  115. package/lib/esm/index.js +25 -0
  116. package/lib/esm/index.js.map +1 -0
  117. package/lib/esm/package.json +1 -0
  118. package/lib/esm/utils.js +199 -0
  119. package/lib/esm/utils.js.map +1 -0
  120. package/lib/types/api/errors_api.d.ts +6 -0
  121. package/lib/types/api/errors_api.d.ts.map +1 -0
  122. package/lib/types/api/events_api.d.ts +52 -0
  123. package/lib/types/api/events_api.d.ts.map +1 -0
  124. package/lib/types/api/functions_api.d.ts +93 -0
  125. package/lib/types/api/functions_api.d.ts.map +1 -0
  126. package/lib/types/api/logs_api.d.ts +50 -0
  127. package/lib/types/api/logs_api.d.ts.map +1 -0
  128. package/lib/types/api/parameters_api.d.ts +239 -0
  129. package/lib/types/api/parameters_api.d.ts.map +1 -0
  130. package/lib/types/coders/base/address.d.ts +5 -0
  131. package/lib/types/coders/base/address.d.ts.map +1 -0
  132. package/lib/types/coders/base/array.d.ts +5 -0
  133. package/lib/types/coders/base/array.d.ts.map +1 -0
  134. package/lib/types/coders/base/bool.d.ts +5 -0
  135. package/lib/types/coders/base/bool.d.ts.map +1 -0
  136. package/lib/types/coders/base/bytes.d.ts +5 -0
  137. package/lib/types/coders/base/bytes.d.ts.map +1 -0
  138. package/lib/types/coders/base/index.d.ts +12 -0
  139. package/lib/types/coders/base/index.d.ts.map +1 -0
  140. package/lib/types/coders/base/number.d.ts +5 -0
  141. package/lib/types/coders/base/number.d.ts.map +1 -0
  142. package/lib/types/coders/base/numbersLimits.d.ts +5 -0
  143. package/lib/types/coders/base/numbersLimits.d.ts.map +1 -0
  144. package/lib/types/coders/base/string.d.ts +5 -0
  145. package/lib/types/coders/base/string.d.ts.map +1 -0
  146. package/lib/types/coders/base/tuple.d.ts +8 -0
  147. package/lib/types/coders/base/tuple.d.ts.map +1 -0
  148. package/lib/types/coders/base/utils.d.ts +3 -0
  149. package/lib/types/coders/base/utils.d.ts.map +1 -0
  150. package/lib/types/coders/decode.d.ts +6 -0
  151. package/lib/types/coders/decode.d.ts.map +1 -0
  152. package/lib/types/coders/encode.d.ts +39 -0
  153. package/lib/types/coders/encode.d.ts.map +1 -0
  154. package/lib/types/coders/types.d.ts +17 -0
  155. package/lib/types/coders/types.d.ts.map +1 -0
  156. package/lib/types/coders/utils.d.ts +24 -0
  157. package/lib/types/coders/utils.d.ts.map +1 -0
  158. package/lib/types/decode_contract_error_data.d.ts +4 -0
  159. package/lib/types/decode_contract_error_data.d.ts.map +1 -0
  160. package/lib/types/eip_712.d.ts +51 -0
  161. package/lib/types/eip_712.d.ts.map +1 -0
  162. package/lib/types/index.d.ts +9 -0
  163. package/lib/types/index.d.ts.map +1 -0
  164. package/lib/types/utils.d.ts +44 -0
  165. package/lib/types/utils.d.ts.map +1 -0
  166. package/pa8cztln.cjs +1 -0
  167. package/package.json +56 -0
  168. package/src/api/errors_api.ts +45 -0
  169. package/src/api/events_api.ts +91 -0
  170. package/src/api/functions_api.ts +145 -0
  171. package/src/api/logs_api.ts +131 -0
  172. package/src/api/parameters_api.ts +287 -0
  173. package/src/coders/base/address.ts +75 -0
  174. package/src/coders/base/array.ts +120 -0
  175. package/src/coders/base/bool.ts +54 -0
  176. package/src/coders/base/bytes.ts +106 -0
  177. package/src/coders/base/index.ts +95 -0
  178. package/src/coders/base/number.ts +116 -0
  179. package/src/coders/base/numbersLimits.ts +39 -0
  180. package/src/coders/base/string.ts +38 -0
  181. package/src/coders/base/tuple.ts +130 -0
  182. package/src/coders/base/utils.ts +51 -0
  183. package/src/coders/decode.ts +32 -0
  184. package/src/coders/encode.ts +114 -0
  185. package/src/coders/types.ts +39 -0
  186. package/src/coders/utils.ts +128 -0
  187. package/src/decode_contract_error_data.ts +80 -0
  188. package/src/eip_712.ts +252 -0
  189. package/src/index.ts +25 -0
  190. package/src/utils.ts +266 -0
@@ -0,0 +1,70 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { AbiError } from 'web3-errors';
18
+ import { toChecksumAddress } from 'web3-utils';
19
+ import { isAddress, utils } from 'web3-validator';
20
+ import { alloc, WORD_SIZE } from '../utils.js';
21
+ const ADDRESS_BYTES_COUNT = 20;
22
+ const ADDRESS_OFFSET = WORD_SIZE - ADDRESS_BYTES_COUNT;
23
+ export function encodeAddress(param, input) {
24
+ if (typeof input !== 'string') {
25
+ throw new AbiError('address type expects string as input type', {
26
+ value: input,
27
+ name: param.name,
28
+ type: param.type,
29
+ });
30
+ }
31
+ let address = input.toLowerCase();
32
+ if (!address.startsWith('0x')) {
33
+ address = `0x${address}`;
34
+ }
35
+ if (!isAddress(address)) {
36
+ throw new AbiError('provided input is not valid address', {
37
+ value: input,
38
+ name: param.name,
39
+ type: param.type,
40
+ });
41
+ }
42
+ // for better performance, we could convert hex to destination bytes directly (encoded var)
43
+ const addressBytes = utils.hexToUint8Array(address);
44
+ // expand address to WORD_SIZE
45
+ const encoded = alloc(WORD_SIZE);
46
+ encoded.set(addressBytes, ADDRESS_OFFSET);
47
+ return {
48
+ dynamic: false,
49
+ encoded,
50
+ };
51
+ }
52
+ export function decodeAddress(_param, bytes) {
53
+ const addressBytes = bytes.subarray(ADDRESS_OFFSET, WORD_SIZE);
54
+ if (addressBytes.length !== ADDRESS_BYTES_COUNT) {
55
+ throw new AbiError('Invalid decoding input, not enough bytes to decode address', { bytes });
56
+ }
57
+ const result = utils.uint8ArrayToHexString(addressBytes);
58
+ // should we check is decoded value is valid address?
59
+ // if(!isAddress(result)) {
60
+ // throw new AbiError("encoded data is not valid address", {
61
+ // address: result,
62
+ // });
63
+ // }
64
+ return {
65
+ result: toChecksumAddress(result),
66
+ encoded: bytes.subarray(WORD_SIZE),
67
+ consumed: WORD_SIZE,
68
+ };
69
+ }
70
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../../../src/coders/base/address.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AACF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,cAAc,GAAG,SAAS,GAAG,mBAAmB,CAAC;AAEvD,MAAM,UAAU,aAAa,CAAC,KAAmB,EAAE,KAAc;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC9B,MAAM,IAAI,QAAQ,CAAC,2CAA2C,EAAE;YAC/D,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;SAChB,CAAC,CAAC;KACH;IACD,IAAI,OAAO,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAClC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC9B,OAAO,GAAG,KAAK,OAAO,EAAE,CAAC;KACzB;IACD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QACxB,MAAM,IAAI,QAAQ,CAAC,qCAAqC,EAAE;YACzD,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;SAChB,CAAC,CAAC;KACH;IACD,2FAA2F;IAC3F,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACpD,8BAA8B;IAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAC1C,OAAO;QACN,OAAO,EAAE,KAAK;QACd,OAAO;KACP,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAoB,EAAE,KAAiB;IACpE,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IAC/D,IAAI,YAAY,CAAC,MAAM,KAAK,mBAAmB,EAAE;QAChD,MAAM,IAAI,QAAQ,CAAC,4DAA4D,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;KAC5F;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAEzD,qDAAqD;IACrD,2BAA2B;IAC3B,gEAAgE;IAChE,2BAA2B;IAC3B,UAAU;IACV,IAAI;IACJ,OAAO;QACN,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;QACjC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;QAClC,QAAQ,EAAE,SAAS;KACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,101 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { AbiError } from 'web3-errors';
18
+ import { uint8ArrayConcat } from 'web3-utils';
19
+ // eslint-disable-next-line import/no-cycle
20
+ import { decodeParamFromAbiParameter, encodeNumber, encodeParamFromAbiParameter } from './index.js';
21
+ import { extractArrayType, isDynamic, WORD_SIZE } from '../utils.js';
22
+ import { decodeNumber } from './number.js';
23
+ import { encodeDynamicParams } from './utils.js';
24
+ export function encodeArray(param, values) {
25
+ if (!Array.isArray(values)) {
26
+ throw new AbiError('Expected value to be array', { abi: param, values });
27
+ }
28
+ const { size, param: arrayItemParam } = extractArrayType(param);
29
+ const encodedParams = values.map(v => encodeParamFromAbiParameter(arrayItemParam, v));
30
+ const dynamic = size === -1;
31
+ const dynamicItems = encodedParams.length > 0 && encodedParams[0].dynamic;
32
+ if (!dynamic && values.length !== size) {
33
+ throw new AbiError("Given arguments count doesn't match array length", {
34
+ arrayLength: size,
35
+ argumentsLength: values.length,
36
+ });
37
+ }
38
+ if (dynamic || dynamicItems) {
39
+ const encodingResult = encodeDynamicParams(encodedParams);
40
+ if (dynamic) {
41
+ const encodedLength = encodeNumber({ type: 'uint256', name: '' }, encodedParams.length).encoded;
42
+ return {
43
+ dynamic: true,
44
+ encoded: encodedParams.length > 0
45
+ ? uint8ArrayConcat(encodedLength, encodingResult)
46
+ : encodedLength,
47
+ };
48
+ }
49
+ return {
50
+ dynamic: true,
51
+ encoded: encodingResult,
52
+ };
53
+ }
54
+ return {
55
+ dynamic: false,
56
+ encoded: uint8ArrayConcat(...encodedParams.map(p => p.encoded)),
57
+ };
58
+ }
59
+ export function decodeArray(param, bytes) {
60
+ // eslint-disable-next-line prefer-const
61
+ let { size, param: arrayItemParam } = extractArrayType(param);
62
+ const dynamic = size === -1;
63
+ let consumed = 0;
64
+ const result = [];
65
+ let remaining = bytes;
66
+ // dynamic array, we need to decode length
67
+ if (dynamic) {
68
+ const lengthResult = decodeNumber({ type: 'uint32', name: '' }, bytes);
69
+ size = Number(lengthResult.result);
70
+ consumed = lengthResult.consumed;
71
+ remaining = lengthResult.encoded;
72
+ }
73
+ const hasDynamicChild = isDynamic(arrayItemParam);
74
+ if (hasDynamicChild) {
75
+ // known length but dynamic child, each child is actually head element with encoded offset
76
+ for (let i = 0; i < size; i += 1) {
77
+ const offsetResult = decodeNumber({ type: 'uint32', name: '' }, remaining.subarray(i * WORD_SIZE));
78
+ consumed += offsetResult.consumed;
79
+ const decodedChildResult = decodeParamFromAbiParameter(arrayItemParam, remaining.subarray(Number(offsetResult.result)));
80
+ consumed += decodedChildResult.consumed;
81
+ result.push(decodedChildResult.result);
82
+ }
83
+ return {
84
+ result,
85
+ encoded: remaining.subarray(consumed),
86
+ consumed,
87
+ };
88
+ }
89
+ for (let i = 0; i < size; i += 1) {
90
+ // decode static params
91
+ const decodedChildResult = decodeParamFromAbiParameter(arrayItemParam, bytes.subarray(consumed));
92
+ consumed += decodedChildResult.consumed;
93
+ result.push(decodedChildResult.result);
94
+ }
95
+ return {
96
+ result,
97
+ encoded: bytes.subarray(consumed),
98
+ consumed,
99
+ };
100
+ }
101
+ //# sourceMappingURL=array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../src/coders/base/array.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AACF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,2CAA2C;AAC3C,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAEpG,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACr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EAAE,EAAE,EAC5B,SAAS,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC,CACjC,CAAC;YACF,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC;YAClC,MAAM,kBAAkB,GAAG,2BAA2B,CACrD,cAAc,EACd,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAC/C,CAAC;YACF,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;SACvC;QACD,OAAO;YACN,MAAM;YACN,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACrC,QAAQ;SACR,CAAC;KACF;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE;QACjC,uBAAuB;QACvB,MAAM,kBAAkB,GAAG,2BAA2B,CACrD,cAAc,EACd,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACxB,CAAC;QACF,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;KACvC;IACD,OAAO;QACN,MAAM;QACN,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACjC,QAAQ;KACR,CAAC;AACH,CAAC"}
@@ -0,0 +1,51 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { AbiError, InvalidBooleanError } from 'web3-errors';
18
+ import { toBool } from 'web3-utils';
19
+ import { WORD_SIZE } from '../utils.js';
20
+ import { decodeNumber, encodeNumber } from './number.js';
21
+ export function encodeBoolean(param, input) {
22
+ let value;
23
+ try {
24
+ value = toBool(input);
25
+ }
26
+ catch (e) {
27
+ if (e instanceof InvalidBooleanError) {
28
+ throw new AbiError('provided input is not valid boolean value', {
29
+ type: param.type,
30
+ value: input,
31
+ name: param.name,
32
+ });
33
+ }
34
+ }
35
+ return encodeNumber({ type: 'uint8', name: '' }, Number(value));
36
+ }
37
+ export function decodeBool(_param, bytes) {
38
+ const numberResult = decodeNumber({ type: 'uint8', name: '' }, bytes);
39
+ if (numberResult.result > 1 || numberResult.result < 0) {
40
+ throw new AbiError('Invalid boolean value encoded', {
41
+ boolBytes: bytes.subarray(0, WORD_SIZE),
42
+ numberResult,
43
+ });
44
+ }
45
+ return {
46
+ result: numberResult.result === BigInt(1),
47
+ encoded: numberResult.encoded,
48
+ consumed: WORD_SIZE,
49
+ };
50
+ }
51
+ //# sourceMappingURL=bool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bool.js","sourceRoot":"","sources":["../../../../src/coders/base/bool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AACF,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,UAAU,aAAa,CAAC,KAAmB,EAAE,KAAc;IAChE,IAAI,KAAK,CAAC;IACV,IAAI;QACH,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;KACtB;IAAC,OAAO,CAAC,EAAE;QACX,IAAI,CAAC,YAAY,mBAAmB,EAAE;YACrC,MAAM,IAAI,QAAQ,CAAC,2CAA2C,EAAE;gBAC/D,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,KAAK,EAAE,KAAK;gBACZ,IAAI,EAAE,KAAK,CAAC,IAAI;aAChB,CAAC,CAAC;SACH;KACD;IAED,OAAO,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAoB,EAAE,KAAiB;IACjE,MAAM,YAAY,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACtE,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QACvD,MAAM,IAAI,QAAQ,CAAC,+BAA+B,EAAE;YACnD,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC;YACvC,YAAY;SACZ,CAAC,CAAC;KACH;IACD,OAAO;QACN,MAAM,EAAE,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC;QACzC,OAAO,EAAE,YAAY,CAAC,OAAO;QAC7B,QAAQ,EAAE,SAAS;KACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,96 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { AbiError } from 'web3-errors';
18
+ import { bytesToHex, bytesToUint8Array } from 'web3-utils';
19
+ import { isBytes } from 'web3-validator';
20
+ import { alloc, WORD_SIZE } from '../utils.js';
21
+ import { decodeNumber, encodeNumber } from './number.js';
22
+ const MAX_STATIC_BYTES_COUNT = 32;
23
+ export function encodeBytes(param, input) {
24
+ // hack for odd length hex strings
25
+ if (typeof input === 'string' && input.length % 2 !== 0) {
26
+ // eslint-disable-next-line no-param-reassign
27
+ input += '0';
28
+ }
29
+ if (!isBytes(input)) {
30
+ throw new AbiError('provided input is not valid bytes value', {
31
+ type: param.type,
32
+ value: input,
33
+ name: param.name,
34
+ });
35
+ }
36
+ const bytes = bytesToUint8Array(input);
37
+ const [, size] = param.type.split('bytes');
38
+ // fixed size
39
+ if (size) {
40
+ if (Number(size) > MAX_STATIC_BYTES_COUNT || Number(size) < 1) {
41
+ throw new AbiError('invalid bytes type. Static byte type can have between 1 and 32 bytes', {
42
+ type: param.type,
43
+ });
44
+ }
45
+ if (Number(size) < bytes.length) {
46
+ throw new AbiError('provided input size is different than type size', {
47
+ type: param.type,
48
+ value: input,
49
+ name: param.name,
50
+ });
51
+ }
52
+ const encoded = alloc(WORD_SIZE);
53
+ encoded.set(bytes);
54
+ return {
55
+ dynamic: false,
56
+ encoded,
57
+ };
58
+ }
59
+ const partsLength = Math.ceil(bytes.length / WORD_SIZE);
60
+ // one word for length of data + WORD for each part of actual data
61
+ const encoded = alloc(WORD_SIZE + partsLength * WORD_SIZE);
62
+ encoded.set(encodeNumber({ type: 'uint32', name: '' }, bytes.length).encoded);
63
+ encoded.set(bytes, WORD_SIZE);
64
+ return {
65
+ dynamic: true,
66
+ encoded,
67
+ };
68
+ }
69
+ export function decodeBytes(param, bytes) {
70
+ const [, sizeString] = param.type.split('bytes');
71
+ let size = Number(sizeString);
72
+ let remainingBytes = bytes;
73
+ let partsCount = 1;
74
+ let consumed = 0;
75
+ if (!size) {
76
+ // dynamic bytes
77
+ const result = decodeNumber({ type: 'uint32', name: '' }, remainingBytes);
78
+ size = Number(result.result);
79
+ consumed += result.consumed;
80
+ remainingBytes = result.encoded;
81
+ partsCount = Math.ceil(size / WORD_SIZE);
82
+ }
83
+ if (size > bytes.length) {
84
+ throw new AbiError('there is not enough data to decode', {
85
+ type: param.type,
86
+ encoded: bytes,
87
+ size,
88
+ });
89
+ }
90
+ return {
91
+ result: bytesToHex(remainingBytes.subarray(0, size)),
92
+ encoded: remainingBytes.subarray(partsCount * WORD_SIZE),
93
+ consumed: consumed + partsCount * WORD_SIZE,
94
+ };
95
+ }
96
+ //# sourceMappingURL=bytes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../../../src/coders/base/bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AACF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAmB,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,MAAM,UAAU,WAAW,CAAC,KAAmB,EAAE,KAAc;IAC9D,kCAAkC;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;QACxD,6CAA6C;QAC7C,KAAK,IAAI,GAAG,CAAC;KACb;IACD,IAAI,CAAC,OAAO,CAAC,KAAwB,CAAC,EAAE;QACvC,MAAM,IAAI,QAAQ,CAAC,yCAAyC,EAAE;YAC7D,IAAI,EAAE,KAAK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AAC"}
@@ -0,0 +1,90 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { AbiError } from 'web3-errors';
18
+ import { decodeAddress, encodeAddress } from './address.js';
19
+ import { decodeBool, encodeBoolean } from './bool.js';
20
+ import { decodeBytes, encodeBytes } from './bytes.js';
21
+ import { decodeNumber, encodeNumber } from './number.js';
22
+ import { decodeString, encodeString } from './string.js';
23
+ // eslint-disable-next-line import/no-cycle
24
+ import { decodeTuple, encodeTuple } from './tuple.js';
25
+ // eslint-disable-next-line import/no-cycle
26
+ import { decodeArray, encodeArray } from './array.js';
27
+ export { encodeAddress, decodeAddress } from './address.js';
28
+ export { encodeBoolean, decodeBool } from './bool.js';
29
+ export { encodeBytes, decodeBytes } from './bytes.js';
30
+ export { encodeNumber, decodeNumber } from './number.js';
31
+ export { encodeString, decodeString } from './string.js';
32
+ // eslint-disable-next-line import/no-cycle
33
+ export { encodeTuple, decodeTuple } from './tuple.js';
34
+ // eslint-disable-next-line import/no-cycle
35
+ export { encodeArray, decodeArray } from './array.js';
36
+ export function encodeParamFromAbiParameter(param, value) {
37
+ if (param.type === 'string') {
38
+ return encodeString(param, value);
39
+ }
40
+ if (param.type === 'bool') {
41
+ return encodeBoolean(param, value);
42
+ }
43
+ if (param.type === 'address') {
44
+ return encodeAddress(param, value);
45
+ }
46
+ if (param.type === 'tuple') {
47
+ return encodeTuple(param, value);
48
+ }
49
+ if (param.type.endsWith(']')) {
50
+ return encodeArray(param, value);
51
+ }
52
+ if (param.type.startsWith('bytes')) {
53
+ return encodeBytes(param, value);
54
+ }
55
+ if (param.type.startsWith('uint') || param.type.startsWith('int')) {
56
+ return encodeNumber(param, value);
57
+ }
58
+ throw new AbiError('Unsupported', {
59
+ param,
60
+ value,
61
+ });
62
+ }
63
+ export function decodeParamFromAbiParameter(param, bytes) {
64
+ if (param.type === 'string') {
65
+ return decodeString(param, bytes);
66
+ }
67
+ if (param.type === 'bool') {
68
+ return decodeBool(param, bytes);
69
+ }
70
+ if (param.type === 'address') {
71
+ return decodeAddress(param, bytes);
72
+ }
73
+ if (param.type === 'tuple') {
74
+ return decodeTuple(param, bytes);
75
+ }
76
+ if (param.type.endsWith(']')) {
77
+ return decodeArray(param, bytes);
78
+ }
79
+ if (param.type.startsWith('bytes')) {
80
+ return decodeBytes(param, bytes);
81
+ }
82
+ if (param.type.startsWith('uint') || param.type.startsWith('int')) {
83
+ return decodeNumber(param, bytes);
84
+ }
85
+ throw new AbiError('Unsupported', {
86
+ param,
87
+ bytes,
88
+ });
89
+ }
90
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/coders/base/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAGF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,aAAa,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;AACzD,2CAA2C;AAC3C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CA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AClC;IACD,MAAM,IAAI,QAAQ,CAAC,aAAa,EAAE;QACjC,KAAK;QACL,KAAK;KACL,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,111 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { AbiError } from 'web3-errors';
18
+ import { padLeft, toBigInt } from 'web3-utils';
19
+ import { utils } from 'web3-validator';
20
+ import { WORD_SIZE } from '../utils.js';
21
+ import { numberLimits } from './numbersLimits.js';
22
+ // eslint-disable-next-line no-bitwise
23
+ const mask = BigInt(1) << BigInt(256);
24
+ function bigIntToUint8Array(value, byteLength = WORD_SIZE) {
25
+ let hexValue;
26
+ if (value < 0) {
27
+ hexValue = (mask + value).toString(16);
28
+ }
29
+ else {
30
+ hexValue = value.toString(16);
31
+ }
32
+ hexValue = padLeft(hexValue, byteLength * 2);
33
+ return utils.hexToUint8Array(hexValue);
34
+ }
35
+ function uint8ArrayToBigInt(value, max) {
36
+ const hexValue = utils.uint8ArrayToHexString(value);
37
+ const result = BigInt(hexValue);
38
+ if (result <= max)
39
+ return result;
40
+ return result - mask;
41
+ }
42
+ export function encodeNumber(param, input) {
43
+ let value;
44
+ try {
45
+ value = toBigInt(input);
46
+ }
47
+ catch (e) {
48
+ throw new AbiError('provided input is not number value', {
49
+ type: param.type,
50
+ value: input,
51
+ name: param.name,
52
+ });
53
+ }
54
+ const limit = numberLimits.get(param.type);
55
+ if (!limit) {
56
+ throw new AbiError('provided abi contains invalid number datatype', { type: param.type });
57
+ }
58
+ if (value < limit.min) {
59
+ throw new AbiError('provided input is less then minimum for given type', {
60
+ type: param.type,
61
+ value: input,
62
+ name: param.name,
63
+ minimum: limit.min.toString(),
64
+ });
65
+ }
66
+ if (value > limit.max) {
67
+ throw new AbiError('provided input is greater then maximum for given type', {
68
+ type: param.type,
69
+ value: input,
70
+ name: param.name,
71
+ maximum: limit.max.toString(),
72
+ });
73
+ }
74
+ return {
75
+ dynamic: false,
76
+ encoded: bigIntToUint8Array(value),
77
+ };
78
+ }
79
+ export function decodeNumber(param, bytes) {
80
+ if (bytes.length < WORD_SIZE) {
81
+ throw new AbiError('Not enough bytes left to decode', { param, bytesLeft: bytes.length });
82
+ }
83
+ const boolBytes = bytes.subarray(0, WORD_SIZE);
84
+ const limit = numberLimits.get(param.type);
85
+ if (!limit) {
86
+ throw new AbiError('provided abi contains invalid number datatype', { type: param.type });
87
+ }
88
+ const numberResult = uint8ArrayToBigInt(boolBytes, limit.max);
89
+ if (numberResult < limit.min) {
90
+ throw new AbiError('decoded value is less then minimum for given type', {
91
+ type: param.type,
92
+ value: numberResult,
93
+ name: param.name,
94
+ minimum: limit.min.toString(),
95
+ });
96
+ }
97
+ if (numberResult > limit.max) {
98
+ throw new AbiError('decoded value is greater then maximum for given type', {
99
+ type: param.type,
100
+ value: numberResult,
101
+ name: param.name,
102
+ maximum: limit.max.toString(),
103
+ });
104
+ }
105
+ return {
106
+ result: numberResult,
107
+ encoded: bytes.subarray(WORD_SIZE),
108
+ consumed: WORD_SIZE,
109
+ };
110
+ }
111
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../../src/coders/base/number.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC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AC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,EAAE;QACX,MAAM,IAAI,QAAQ,CAAC,+CAA+C,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;KAC1F;IACD,MAAM,YAAY,GAAG,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAE9D,IAAI,YAAY,GAAG,KAAK,CAAC,GAAG,EAAE;QAC7B,MAAM,IAAI,QAAQ,CAAC,mDAAmD,EAAE;YACvE,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE;SAC7B,CAAC,CAAC;KACH;IACD,IAAI,YAAY,GAAG,KAAK,CAAC,GAAG,EAAE;QAC7B,MAAM,IAAI,QAAQ,CAAC,sDAAsD,EAAE;YAC1E,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE;SAC7B,CAAC,CAAC;KACH;IACD,OAAO;QACN,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;QAClC,QAAQ,EAAE,SAAS;KACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,37 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ /*
18
+ * this variable contains the precalculated limits for all the numbers for uint and int types
19
+ */
20
+ export const numberLimits = new Map();
21
+ let base = BigInt(256); // 2 ^ 8 = 256
22
+ for (let i = 8; i <= 256; i += 8) {
23
+ numberLimits.set(`uint${i}`, {
24
+ min: BigInt(0),
25
+ max: base - BigInt(1),
26
+ });
27
+ numberLimits.set(`int${i}`, {
28
+ min: -base / BigInt(2),
29
+ max: base / BigInt(2) - BigInt(1),
30
+ });
31
+ base *= BigInt(256);
32
+ }
33
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
34
+ numberLimits.set(`int`, numberLimits.get('int256'));
35
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
36
+ numberLimits.set(`uint`, numberLimits.get('uint256'));
37
+ //# sourceMappingURL=numbersLimits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numbersLimits.js","sourceRoot":"","sources":["../../../../src/coders/base/numbersLimits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAwC,CAAC;AAE5E,IAAI,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc;AACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE;IACjC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE;QAC5B,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;QACd,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;KACrB,CAAC,CAAC;IACH,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE;QAC3B,GAAG,EAAE,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;QACtB,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;KACjC,CAAC,CAAC;IACH,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;CACpB;AAED,oEAAoE;AACpE,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,CAAC;AACrD,oEAAoE;AACpE,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { AbiError } from 'web3-errors';
18
+ import { hexToUtf8, utf8ToBytes } from 'web3-utils';
19
+ import { decodeBytes, encodeBytes } from './bytes.js';
20
+ export function encodeString(_param, input) {
21
+ if (typeof input !== 'string') {
22
+ throw new AbiError('invalid input, should be string', { input });
23
+ }
24
+ const bytes = utf8ToBytes(input);
25
+ return encodeBytes({ type: 'bytes', name: '' }, bytes);
26
+ }
27
+ export function decodeString(_param, bytes) {
28
+ const r = decodeBytes({ type: 'bytes', name: '' }, bytes);
29
+ return {
30
+ result: hexToUtf8(r.result),
31
+ encoded: r.encoded,
32
+ consumed: r.consumed,
33
+ };
34
+ }
35
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../src/coders/base/string.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AACF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtD,MAAM,UAAU,YAAY,CAAC,MAAoB,EAAE,KAAc;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC9B,MAAM,IAAI,QAAQ,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;KACjE;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAoB,EAAE,KAAiB;IACnE,MAAM,CAAC,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO;QACN,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;QAC3B,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,QAAQ,EAAE,CAAC,CAAC,QAAQ;KACpB,CAAC;AACH,CAAC"}