@huma-finance/shared 0.0.30 → 0.0.32

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 (259) hide show
  1. package/dist/abis/BaseCreditPool.json +1179 -1179
  2. package/dist/abis/BaseFeeManager.json +480 -480
  3. package/dist/abis/BasePoolConfig.json +1364 -1364
  4. package/dist/abis/ERC20TransferableReceivable.json +648 -648
  5. package/dist/abis/HDT.json +512 -512
  6. package/dist/abis/IConstantFlowAgreementV1.json +890 -890
  7. package/dist/abis/ISuperfluid.json +1122 -1122
  8. package/dist/abis/InvoiceNFT.json +625 -625
  9. package/dist/abis/Multisend.json +26 -26
  10. package/dist/abis/RealWorldReceivable.json +823 -823
  11. package/dist/abis/ReceivableFactoringPool.json +1529 -1529
  12. package/dist/abis/StreamFactoringPool.json +1523 -1523
  13. package/dist/abis/StreamFeeManager.json +522 -522
  14. package/dist/abis/SuperfluidPoolProcessor.json +692 -692
  15. package/dist/abis/TestERC20.json +358 -358
  16. package/dist/abis/TradableStream.json +850 -850
  17. package/dist/abis/Transfer.json +24 -24
  18. package/dist/abis/TransferNFT.json +27 -27
  19. package/dist/abis/erc20.json +117 -117
  20. package/dist/abis/erc2612.json +132 -132
  21. package/dist/abis/erc721.json +673 -673
  22. package/dist/abis/index.d.ts +3 -3
  23. package/dist/abis/index.js +3 -3
  24. package/dist/abis/types/BaseCreditPool.d.ts +803 -803
  25. package/dist/abis/types/BaseCreditPool.js +1 -1
  26. package/dist/abis/types/BaseFeeManager.d.ts +408 -408
  27. package/dist/abis/types/BaseFeeManager.js +1 -1
  28. package/dist/abis/types/BasePoolConfig.d.ts +1097 -1097
  29. package/dist/abis/types/BasePoolConfig.js +1 -1
  30. package/dist/abis/types/ERC20TransferableReceivable.d.ts +407 -407
  31. package/dist/abis/types/ERC20TransferableReceivable.js +1 -1
  32. package/dist/abis/types/Erc20.d.ts +168 -168
  33. package/dist/abis/types/Erc20.js +1 -1
  34. package/dist/abis/types/Erc2612.d.ts +192 -192
  35. package/dist/abis/types/Erc2612.js +1 -1
  36. package/dist/abis/types/Erc721.d.ts +474 -474
  37. package/dist/abis/types/Erc721.js +1 -1
  38. package/dist/abis/types/HDT.d.ts +369 -369
  39. package/dist/abis/types/HDT.js +1 -1
  40. package/dist/abis/types/IConstantFlowAgreementV1.d.ts +573 -573
  41. package/dist/abis/types/IConstantFlowAgreementV1.js +1 -1
  42. package/dist/abis/types/ISuperfluid.d.ts +728 -728
  43. package/dist/abis/types/ISuperfluid.js +1 -1
  44. package/dist/abis/types/InvoiceNFT.d.ts +425 -425
  45. package/dist/abis/types/InvoiceNFT.js +1 -1
  46. package/dist/abis/types/Multisend.d.ts +50 -50
  47. package/dist/abis/types/Multisend.js +1 -1
  48. package/dist/abis/types/RealWorldReceivable.d.ts +564 -564
  49. package/dist/abis/types/RealWorldReceivable.js +1 -1
  50. package/dist/abis/types/ReceivableFactoringPool.d.ts +999 -999
  51. package/dist/abis/types/ReceivableFactoringPool.js +1 -1
  52. package/dist/abis/types/StreamFactoringPool.d.ts +985 -985
  53. package/dist/abis/types/StreamFactoringPool.js +1 -1
  54. package/dist/abis/types/StreamFeeManager.d.ts +440 -440
  55. package/dist/abis/types/StreamFeeManager.js +1 -1
  56. package/dist/abis/types/SuperfluidPoolProcessor.d.ts +398 -398
  57. package/dist/abis/types/SuperfluidPoolProcessor.js +1 -1
  58. package/dist/abis/types/TestERC20.d.ts +270 -270
  59. package/dist/abis/types/TestERC20.js +1 -1
  60. package/dist/abis/types/TradableStream.d.ts +607 -607
  61. package/dist/abis/types/TradableStream.js +1 -1
  62. package/dist/abis/types/Transfer.d.ts +45 -45
  63. package/dist/abis/types/Transfer.js +1 -1
  64. package/dist/abis/types/TransferNFT.d.ts +45 -45
  65. package/dist/abis/types/TransferNFT.js +1 -1
  66. package/dist/abis/types/common.d.ts +22 -22
  67. package/dist/abis/types/common.js +1 -1
  68. package/dist/abis/types/factories/BaseCreditPool__factory.d.ts +931 -931
  69. package/dist/abis/types/factories/BaseCreditPool__factory.js +1193 -1192
  70. package/dist/abis/types/factories/BaseCreditPool__factory.js.map +1 -1
  71. package/dist/abis/types/factories/BaseFeeManager__factory.d.ts +379 -379
  72. package/dist/abis/types/factories/BaseFeeManager__factory.js +494 -493
  73. package/dist/abis/types/factories/BaseFeeManager__factory.js.map +1 -1
  74. package/dist/abis/types/factories/BasePoolConfig__factory.d.ts +1074 -1074
  75. package/dist/abis/types/factories/BasePoolConfig__factory.js +1378 -1377
  76. package/dist/abis/types/factories/BasePoolConfig__factory.js.map +1 -1
  77. package/dist/abis/types/factories/ERC20TransferableReceivable__factory.d.ts +508 -508
  78. package/dist/abis/types/factories/ERC20TransferableReceivable__factory.js +662 -661
  79. package/dist/abis/types/factories/ERC20TransferableReceivable__factory.js.map +1 -1
  80. package/dist/abis/types/factories/Erc20__factory.d.ts +175 -175
  81. package/dist/abis/types/factories/Erc20__factory.js +236 -235
  82. package/dist/abis/types/factories/Erc20__factory.js.map +1 -1
  83. package/dist/abis/types/factories/Erc2612__factory.d.ts +209 -209
  84. package/dist/abis/types/factories/Erc2612__factory.js +279 -278
  85. package/dist/abis/types/factories/Erc2612__factory.js.map +1 -1
  86. package/dist/abis/types/factories/Erc721__factory.d.ts +539 -539
  87. package/dist/abis/types/factories/Erc721__factory.js +687 -686
  88. package/dist/abis/types/factories/Erc721__factory.js.map +1 -1
  89. package/dist/abis/types/factories/HDT__factory.d.ts +399 -399
  90. package/dist/abis/types/factories/HDT__factory.js +526 -525
  91. package/dist/abis/types/factories/HDT__factory.js.map +1 -1
  92. package/dist/abis/types/factories/IConstantFlowAgreementV1__factory.d.ts +695 -695
  93. package/dist/abis/types/factories/IConstantFlowAgreementV1__factory.js +904 -903
  94. package/dist/abis/types/factories/IConstantFlowAgreementV1__factory.js.map +1 -1
  95. package/dist/abis/types/factories/ISuperfluid__factory.d.ts +866 -866
  96. package/dist/abis/types/factories/ISuperfluid__factory.js +1136 -1135
  97. package/dist/abis/types/factories/ISuperfluid__factory.js.map +1 -1
  98. package/dist/abis/types/factories/InvoiceNFT__factory.d.ts +489 -489
  99. package/dist/abis/types/factories/InvoiceNFT__factory.js +639 -638
  100. package/dist/abis/types/factories/InvoiceNFT__factory.js.map +1 -1
  101. package/dist/abis/types/factories/Multisend__factory.d.ts +26 -26
  102. package/dist/abis/types/factories/Multisend__factory.js +40 -39
  103. package/dist/abis/types/factories/Multisend__factory.js.map +1 -1
  104. package/dist/abis/types/factories/RealWorldReceivable__factory.d.ts +645 -645
  105. package/dist/abis/types/factories/RealWorldReceivable__factory.js +837 -836
  106. package/dist/abis/types/factories/RealWorldReceivable__factory.js.map +1 -1
  107. package/dist/abis/types/factories/ReceivableFactoringPool__factory.d.ts +1204 -1204
  108. package/dist/abis/types/factories/ReceivableFactoringPool__factory.js +1543 -1542
  109. package/dist/abis/types/factories/ReceivableFactoringPool__factory.js.map +1 -1
  110. package/dist/abis/types/factories/StreamFactoringPool__factory.d.ts +1200 -1200
  111. package/dist/abis/types/factories/StreamFactoringPool__factory.js +1537 -1536
  112. package/dist/abis/types/factories/StreamFactoringPool__factory.js.map +1 -1
  113. package/dist/abis/types/factories/StreamFeeManager__factory.d.ts +412 -412
  114. package/dist/abis/types/factories/StreamFeeManager__factory.js +536 -535
  115. package/dist/abis/types/factories/StreamFeeManager__factory.js.map +1 -1
  116. package/dist/abis/types/factories/SuperfluidPoolProcessor__factory.d.ts +546 -546
  117. package/dist/abis/types/factories/SuperfluidPoolProcessor__factory.js +706 -705
  118. package/dist/abis/types/factories/SuperfluidPoolProcessor__factory.js.map +1 -1
  119. package/dist/abis/types/factories/TestERC20__factory.d.ts +280 -280
  120. package/dist/abis/types/factories/TestERC20__factory.js +372 -371
  121. package/dist/abis/types/factories/TestERC20__factory.js.map +1 -1
  122. package/dist/abis/types/factories/TradableStream__factory.d.ts +663 -663
  123. package/dist/abis/types/factories/TradableStream__factory.js +864 -863
  124. package/dist/abis/types/factories/TradableStream__factory.js.map +1 -1
  125. package/dist/abis/types/factories/TransferNFT__factory.d.ts +28 -28
  126. package/dist/abis/types/factories/TransferNFT__factory.js +41 -40
  127. package/dist/abis/types/factories/TransferNFT__factory.js.map +1 -1
  128. package/dist/abis/types/factories/Transfer__factory.d.ts +25 -25
  129. package/dist/abis/types/factories/Transfer__factory.js +38 -37
  130. package/dist/abis/types/factories/Transfer__factory.js.map +1 -1
  131. package/dist/abis/types/factories/index.d.ts +21 -21
  132. package/dist/abis/types/factories/index.js +24 -24
  133. package/dist/abis/types/index.d.ts +43 -43
  134. package/dist/abis/types/index.js +22 -22
  135. package/dist/cjs/hooks/web3/index.js +2 -2
  136. package/dist/cjs/hooks/web3/index.js.map +1 -1
  137. package/dist/cjs/services/IdentityService.d.ts +17 -0
  138. package/dist/cjs/services/IdentityService.js +31 -4
  139. package/dist/cjs/services/IdentityService.js.map +1 -1
  140. package/dist/cjs/utils/chain.d.ts +3 -1
  141. package/dist/cjs/utils/chain.js +9 -1
  142. package/dist/cjs/utils/chain.js.map +1 -1
  143. package/dist/cjs/utils/config.d.ts +1 -0
  144. package/dist/cjs/utils/config.js +10 -1
  145. package/dist/cjs/utils/config.js.map +1 -1
  146. package/dist/cjs/utils/index.d.ts +2 -0
  147. package/dist/cjs/utils/index.js +2 -0
  148. package/dist/cjs/utils/index.js.map +1 -1
  149. package/dist/cjs/utils/notifi.d.ts +3 -0
  150. package/dist/cjs/utils/notifi.js +40 -0
  151. package/dist/cjs/utils/notifi.js.map +1 -0
  152. package/dist/cjs/utils/number.js +7 -1
  153. package/dist/cjs/utils/number.js.map +1 -1
  154. package/dist/cjs/utils/pool.d.ts +1 -0
  155. package/dist/cjs/utils/pool.js +9 -6
  156. package/dist/cjs/utils/pool.js.map +1 -1
  157. package/dist/cjs/utils/realWorldReceivable.d.ts +12 -0
  158. package/dist/cjs/utils/realWorldReceivable.js +3 -0
  159. package/dist/cjs/utils/realWorldReceivable.js.map +1 -0
  160. package/dist/hooks/index.d.ts +18 -18
  161. package/dist/hooks/index.js +18 -18
  162. package/dist/hooks/useActiveRoute.d.ts +8 -8
  163. package/dist/hooks/useActiveRoute.js +7 -7
  164. package/dist/hooks/useAsyncError.d.ts +14 -14
  165. package/dist/hooks/useAsyncError.js +22 -22
  166. package/dist/hooks/useCLPoolContract.d.ts +27 -27
  167. package/dist/hooks/useContract.d.ts +7 -7
  168. package/dist/hooks/useContractFunction.d.ts +18 -18
  169. package/dist/hooks/useContractFunction.js +54 -54
  170. package/dist/hooks/useERC2612Permit/ethPermit/index.d.ts +35 -35
  171. package/dist/hooks/useERC2612Permit/ethPermit/index.js +139 -139
  172. package/dist/hooks/useERC2612Permit/ethPermit/lib.d.ts +1 -1
  173. package/dist/hooks/useERC2612Permit/ethPermit/lib.js +21 -21
  174. package/dist/hooks/useERC2612Permit/ethPermit/rpc.d.ts +10 -10
  175. package/dist/hooks/useERC2612Permit/ethPermit/rpc.js +96 -96
  176. package/dist/hooks/useERC2612Permit/index.d.ts +6 -6
  177. package/dist/hooks/useERC2612Permit/index.js +31 -31
  178. package/dist/hooks/useFactoring.d.ts +19 -19
  179. package/dist/hooks/useForceRefresh.d.ts +1 -1
  180. package/dist/hooks/useForceRefresh.js +8 -8
  181. package/dist/hooks/useGetSizes.d.ts +12 -12
  182. package/dist/hooks/useGetSizes.js +19 -19
  183. package/dist/hooks/useInvoiceNFTContract.d.ts +11 -11
  184. package/dist/hooks/useMQ.d.ts +6 -6
  185. package/dist/hooks/useMQ.js +14 -14
  186. package/dist/hooks/useMount.d.ts +2 -2
  187. package/dist/hooks/useMount.js +8 -8
  188. package/dist/hooks/useParamsSearch.d.ts +2 -2
  189. package/dist/hooks/useParamsSearch.js +6 -6
  190. package/dist/hooks/usePool.d.ts +4 -4
  191. package/dist/hooks/usePoolContract.d.ts +73 -73
  192. package/dist/hooks/useRFPoolContract.d.ts +22 -22
  193. package/dist/hooks/useRefresh.d.ts +1 -1
  194. package/dist/hooks/useRefresh.js +47 -47
  195. package/dist/hooks/web3/index.d.ts +15 -15
  196. package/dist/hooks/web3/index.js +2 -2
  197. package/dist/hooks/web3/index.js.map +1 -1
  198. package/dist/hooks/web3/useConnectors.d.ts +17 -17
  199. package/dist/hooks/web3/useConnectors.js +24 -24
  200. package/dist/hooks/web3/useJsonRpcUrlsMap.d.ts +13 -13
  201. package/dist/index.d.ts +5 -5
  202. package/dist/services/EAService.d.ts +153 -153
  203. package/dist/services/IdentityService.d.ts +17 -0
  204. package/dist/services/IdentityService.js +32 -5
  205. package/dist/services/IdentityService.js.map +1 -1
  206. package/dist/services/RNService.d.ts +14 -14
  207. package/dist/services/index.d.ts +3 -3
  208. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  209. package/dist/utils/JsonRpcConnector.d.ts +11 -11
  210. package/dist/utils/JsonRpcConnector.js +38 -38
  211. package/dist/utils/WalletConnect.d.ts +10 -10
  212. package/dist/utils/WalletConnect.js +50 -49
  213. package/dist/utils/WalletConnect.js.map +1 -1
  214. package/dist/utils/chain.d.ts +3 -1
  215. package/dist/utils/chain.js +7 -0
  216. package/dist/utils/chain.js.map +1 -1
  217. package/dist/utils/common.d.ts +4 -4
  218. package/dist/utils/common.js +10 -10
  219. package/dist/utils/config.d.ts +1 -0
  220. package/dist/utils/config.js +10 -1
  221. package/dist/utils/config.js.map +1 -1
  222. package/dist/utils/const.d.ts +2 -2
  223. package/dist/utils/const.js +2 -2
  224. package/dist/utils/contractError.json +73 -73
  225. package/dist/utils/credit.d.ts +21 -21
  226. package/dist/utils/credit.js +35 -35
  227. package/dist/utils/errors.d.ts +26 -26
  228. package/dist/utils/errors.js +39 -39
  229. package/dist/utils/index.d.ts +2 -0
  230. package/dist/utils/index.js +2 -0
  231. package/dist/utils/index.js.map +1 -1
  232. package/dist/utils/jsonRpcEndpoints.d.ts +12 -12
  233. package/dist/utils/notifi.d.ts +3 -0
  234. package/dist/utils/notifi.js +35 -0
  235. package/dist/utils/notifi.js.map +1 -0
  236. package/dist/utils/number.d.ts +5 -5
  237. package/dist/utils/number.js +7 -1
  238. package/dist/utils/number.js.map +1 -1
  239. package/dist/utils/pool.d.ts +1 -0
  240. package/dist/utils/pool.js +9 -6
  241. package/dist/utils/pool.js.map +1 -1
  242. package/dist/utils/realWorldReceivable.d.ts +12 -0
  243. package/dist/utils/realWorldReceivable.js +2 -0
  244. package/dist/utils/realWorldReceivable.js.map +1 -0
  245. package/dist/utils/request.d.ts +3 -3
  246. package/dist/utils/request.js +38 -38
  247. package/dist/utils/scientificToDecimal.d.ts +1 -1
  248. package/dist/utils/scientificToDecimal.js +57 -57
  249. package/dist/utils/string.d.ts +1 -1
  250. package/dist/utils/string.js +1 -1
  251. package/dist/utils/style.d.ts +1 -1
  252. package/dist/utils/style.js +12 -12
  253. package/dist/utils/time.d.ts +26 -26
  254. package/dist/utils/time.js +50 -50
  255. package/dist/utils/transaction.d.ts +32 -32
  256. package/dist/utils/transaction.js +87 -87
  257. package/dist/utils/web3.d.ts +4 -4
  258. package/dist/utils/web3.js +34 -34
  259. package/package.json +3 -3
@@ -1,58 +1,58 @@
1
- /* eslint-disable no-plusplus */
2
- /* eslint-disable @typescript-eslint/no-use-before-define */
3
- /* eslint-disable radix */
4
- /* eslint-disable prefer-destructuring */
5
- // @ts-nocheck
6
- // github.com/jam3/scientific-to-decimal
7
- export const scientificToDecimal = (value) => {
8
- value = parseFloat(value);
9
- const REGEX_SCIENTIFIC = /(\d+\.?\d*)e\d*(\+|-)(\d+)/;
10
- const valueString = value.toString();
11
- let result = REGEX_SCIENTIFIC.exec(valueString);
12
- let base;
13
- let positiveNegative;
14
- let exponents;
15
- let precision;
16
- let rVal;
17
- // is scientific
18
- if (result) {
19
- // [ '1e+32', '1', '+', '2', index: 0, input: '1e+32' ]
20
- base = result[1];
21
- positiveNegative = result[2];
22
- exponents = result[3];
23
- if (positiveNegative === '+') {
24
- precision = parseInt(exponents);
25
- // base is a decimal
26
- if (base.indexOf('.') !== -1) {
27
- result = /(\d+\.)(\d)/.exec(base);
28
- // [ 2 ] == right side after decimal
29
- // [ 1 ] == left side before decimal
30
- precision -= result[2].length + result[1].length;
31
- rVal = base.split('.').join('') + getZeros(precision);
32
- }
33
- else {
34
- rVal = base + getZeros(precision);
35
- }
36
- }
37
- else {
38
- precision = base.length + parseInt(exponents) - 1;
39
- // if it contains a period we want to drop precision by one
40
- if (base.indexOf('.') !== -1) {
41
- precision--;
42
- }
43
- rVal = value.toFixed(precision);
44
- }
45
- }
46
- else {
47
- rVal = value.toString();
48
- }
49
- return rVal;
50
- };
51
- function getZeros(count) {
52
- let rVal = '';
53
- for (let i = 0; i < count; i++) {
54
- rVal += '0';
55
- }
56
- return rVal;
57
- }
1
+ /* eslint-disable no-plusplus */
2
+ /* eslint-disable @typescript-eslint/no-use-before-define */
3
+ /* eslint-disable radix */
4
+ /* eslint-disable prefer-destructuring */
5
+ // @ts-nocheck
6
+ // github.com/jam3/scientific-to-decimal
7
+ export const scientificToDecimal = (value) => {
8
+ value = parseFloat(value);
9
+ const REGEX_SCIENTIFIC = /(\d+\.?\d*)e\d*(\+|-)(\d+)/;
10
+ const valueString = value.toString();
11
+ let result = REGEX_SCIENTIFIC.exec(valueString);
12
+ let base;
13
+ let positiveNegative;
14
+ let exponents;
15
+ let precision;
16
+ let rVal;
17
+ // is scientific
18
+ if (result) {
19
+ // [ '1e+32', '1', '+', '2', index: 0, input: '1e+32' ]
20
+ base = result[1];
21
+ positiveNegative = result[2];
22
+ exponents = result[3];
23
+ if (positiveNegative === '+') {
24
+ precision = parseInt(exponents);
25
+ // base is a decimal
26
+ if (base.indexOf('.') !== -1) {
27
+ result = /(\d+\.)(\d)/.exec(base);
28
+ // [ 2 ] == right side after decimal
29
+ // [ 1 ] == left side before decimal
30
+ precision -= result[2].length + result[1].length;
31
+ rVal = base.split('.').join('') + getZeros(precision);
32
+ }
33
+ else {
34
+ rVal = base + getZeros(precision);
35
+ }
36
+ }
37
+ else {
38
+ precision = base.length + parseInt(exponents) - 1;
39
+ // if it contains a period we want to drop precision by one
40
+ if (base.indexOf('.') !== -1) {
41
+ precision--;
42
+ }
43
+ rVal = value.toFixed(precision);
44
+ }
45
+ }
46
+ else {
47
+ rVal = value.toString();
48
+ }
49
+ return rVal;
50
+ };
51
+ function getZeros(count) {
52
+ let rVal = '';
53
+ for (let i = 0; i < count; i++) {
54
+ rVal += '0';
55
+ }
56
+ return rVal;
57
+ }
58
58
  //# sourceMappingURL=scientificToDecimal.js.map
@@ -1 +1 @@
1
- export declare const capitalizeFirstLetter: (str: string) => string;
1
+ export declare const capitalizeFirstLetter: (str: string) => string;
@@ -1,2 +1,2 @@
1
- export const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
1
+ export const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2
2
  //# sourceMappingURL=string.js.map
@@ -1 +1 @@
1
- export declare const combineStyles: (...styles: any[]) => (theme: any) => any;
1
+ export declare const combineStyles: (...styles: any[]) => (theme: any) => any;
@@ -1,13 +1,13 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- export const combineStyles = (...styles) => function CombineStyles(theme) {
3
- const outStyles = styles.map((arg) => {
4
- // Apply the "theme" object for style functions.
5
- if (typeof arg === 'function') {
6
- return arg(theme);
7
- }
8
- // Objects need no change.
9
- return arg;
10
- });
11
- return outStyles.reduce((acc, val) => Object.assign(acc, val));
12
- };
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ export const combineStyles = (...styles) => function CombineStyles(theme) {
3
+ const outStyles = styles.map((arg) => {
4
+ // Apply the "theme" object for style functions.
5
+ if (typeof arg === 'function') {
6
+ return arg(theme);
7
+ }
8
+ // Objects need no change.
9
+ return arg;
10
+ });
11
+ return outStyles.reduce((acc, val) => Object.assign(acc, val));
12
+ };
13
13
  //# sourceMappingURL=style.js.map
@@ -1,26 +1,26 @@
1
- import moment from 'moment';
2
- export declare const MILLISECONDS = 1000;
3
- export declare const DAY_SECONDS: number;
4
- export declare const TIME_FORMAT_LL = "ll";
5
- export declare const timestampToStr: (timestamp: number, format: string) => string;
6
- /**
7
- * Convert timestamp to format ll: Nov 12, 2022
8
- *
9
- * @param timestamp
10
- * @returns format ll: Nov 12, 2022
11
- */
12
- export declare const timestampToLL: (timestamp?: number) => string;
13
- /**
14
- * get unix time in seconds
15
- *
16
- * @returns timestamp
17
- */
18
- export declare const getUnixTimestamp: (date?: moment.Moment) => number;
19
- export declare const secondsToDays: (seconds: number | undefined) => number;
20
- export declare const timeUtil: {
21
- timestampToStr: (timestamp: number, format: string) => string;
22
- timestampToLL: (timestamp?: number) => string;
23
- getUnixTimestamp: (date?: moment.Moment) => number;
24
- secondsToDays: (seconds: number | undefined) => number;
25
- sleep: (ms: number) => Promise<unknown>;
26
- };
1
+ import moment from 'moment';
2
+ export declare const MILLISECONDS = 1000;
3
+ export declare const DAY_SECONDS: number;
4
+ export declare const TIME_FORMAT_LL = "ll";
5
+ export declare const timestampToStr: (timestamp: number, format: string) => string;
6
+ /**
7
+ * Convert timestamp to format ll: Nov 12, 2022
8
+ *
9
+ * @param timestamp
10
+ * @returns format ll: Nov 12, 2022
11
+ */
12
+ export declare const timestampToLL: (timestamp?: number) => string;
13
+ /**
14
+ * get unix time in seconds
15
+ *
16
+ * @returns timestamp
17
+ */
18
+ export declare const getUnixTimestamp: (date?: moment.Moment) => number;
19
+ export declare const secondsToDays: (seconds: number | undefined) => number;
20
+ export declare const timeUtil: {
21
+ timestampToStr: (timestamp: number, format: string) => string;
22
+ timestampToLL: (timestamp?: number) => string;
23
+ getUnixTimestamp: (date?: moment.Moment) => number;
24
+ secondsToDays: (seconds: number | undefined) => number;
25
+ sleep: (ms: number) => Promise<unknown>;
26
+ };
@@ -1,51 +1,51 @@
1
- import moment from 'moment';
2
- import { isEmpty } from './common';
3
- export const MILLISECONDS = 1000;
4
- export const DAY_SECONDS = 24 * 60 * 60;
5
- export const TIME_FORMAT_LL = 'll';
6
- export const timestampToStr = (timestamp, format) => moment.unix(timestamp).format(format);
7
- /**
8
- * Convert timestamp to format ll: Nov 12, 2022
9
- *
10
- * @param timestamp
11
- * @returns format ll: Nov 12, 2022
12
- */
13
- export const timestampToLL = (timestamp) => {
14
- if (!timestamp) {
15
- return '';
16
- }
17
- return timestampToStr(timestamp, TIME_FORMAT_LL);
18
- };
19
- /**
20
- * get unix time in seconds
21
- *
22
- * @returns timestamp
23
- */
24
- export const getUnixTimestamp = (date) => {
25
- if (date) {
26
- return date.unix();
27
- }
28
- return Math.floor(Date.now() / MILLISECONDS);
29
- };
30
- export const secondsToDays = (seconds) => {
31
- if (isEmpty(seconds)) {
32
- return 0;
33
- }
34
- try {
35
- return seconds / DAY_SECONDS;
36
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
- }
38
- catch (error) {
39
- return 0;
40
- }
41
- };
42
- // eslint-disable-next-line no-promise-executor-return
43
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
44
- export const timeUtil = {
45
- timestampToStr,
46
- timestampToLL,
47
- getUnixTimestamp,
48
- secondsToDays,
49
- sleep,
50
- };
1
+ import moment from 'moment';
2
+ import { isEmpty } from './common';
3
+ export const MILLISECONDS = 1000;
4
+ export const DAY_SECONDS = 24 * 60 * 60;
5
+ export const TIME_FORMAT_LL = 'll';
6
+ export const timestampToStr = (timestamp, format) => moment.unix(timestamp).format(format);
7
+ /**
8
+ * Convert timestamp to format ll: Nov 12, 2022
9
+ *
10
+ * @param timestamp
11
+ * @returns format ll: Nov 12, 2022
12
+ */
13
+ export const timestampToLL = (timestamp) => {
14
+ if (!timestamp) {
15
+ return '';
16
+ }
17
+ return timestampToStr(timestamp, TIME_FORMAT_LL);
18
+ };
19
+ /**
20
+ * get unix time in seconds
21
+ *
22
+ * @returns timestamp
23
+ */
24
+ export const getUnixTimestamp = (date) => {
25
+ if (date) {
26
+ return date.unix();
27
+ }
28
+ return Math.floor(Date.now() / MILLISECONDS);
29
+ };
30
+ export const secondsToDays = (seconds) => {
31
+ if (isEmpty(seconds)) {
32
+ return 0;
33
+ }
34
+ try {
35
+ return seconds / DAY_SECONDS;
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ }
38
+ catch (error) {
39
+ return 0;
40
+ }
41
+ };
42
+ // eslint-disable-next-line no-promise-executor-return
43
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
44
+ export const timeUtil = {
45
+ timestampToStr,
46
+ timestampToLL,
47
+ getUnixTimestamp,
48
+ secondsToDays,
49
+ sleep,
50
+ };
51
51
  //# sourceMappingURL=time.js.map
@@ -1,32 +1,32 @@
1
- import { BigNumber } from '@ethersproject/bignumber';
2
- import { ContractReceipt } from '@ethersproject/contracts';
3
- import { Web3Provider } from '@ethersproject/providers';
4
- import { ethers } from 'ethers';
5
- export declare enum TxStateType {
6
- Success = "Success",
7
- Denied = "Denied",
8
- Invalid = "Invalid",
9
- Failed = "Failed",
10
- New = "New",
11
- GasEstimating = "GasEstimating",
12
- Signing = "Signing",
13
- Confirming = "Confirming"
14
- }
15
- export interface TxResponse {
16
- txReceipt: ContractReceipt;
17
- }
18
- export interface Event {
19
- name: string;
20
- type: string;
21
- value: string;
22
- }
23
- export interface EventLog {
24
- name: string;
25
- events: Event[];
26
- address: string;
27
- }
28
- export declare const isTxFailed: (txState: TxStateType) => boolean;
29
- export declare const increaseGasLimit: (estimatedGasLimit: BigNumber) => BigNumber;
30
- export declare const getTransactionErrorFromHash: (provider: Web3Provider, txHash: string) => Promise<string>;
31
- export declare const getTransactionErrorFromError: (e: any) => string | null;
32
- export declare const decodeLogs: (txlogs: any[], abi: any) => ethers.utils.LogDescription[];
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ import { ContractReceipt } from '@ethersproject/contracts';
3
+ import { Web3Provider } from '@ethersproject/providers';
4
+ import { ethers } from 'ethers';
5
+ export declare enum TxStateType {
6
+ Success = "Success",
7
+ Denied = "Denied",
8
+ Invalid = "Invalid",
9
+ Failed = "Failed",
10
+ New = "New",
11
+ GasEstimating = "GasEstimating",
12
+ Signing = "Signing",
13
+ Confirming = "Confirming"
14
+ }
15
+ export interface TxResponse {
16
+ txReceipt: ContractReceipt;
17
+ }
18
+ export interface Event {
19
+ name: string;
20
+ type: string;
21
+ value: string;
22
+ }
23
+ export interface EventLog {
24
+ name: string;
25
+ events: Event[];
26
+ address: string;
27
+ }
28
+ export declare const isTxFailed: (txState: TxStateType) => boolean;
29
+ export declare const increaseGasLimit: (estimatedGasLimit: BigNumber) => BigNumber;
30
+ export declare const getTransactionErrorFromHash: (provider: Web3Provider, txHash: string) => Promise<string>;
31
+ export declare const getTransactionErrorFromError: (e: any) => string | null;
32
+ export declare const decodeLogs: (txlogs: any[], abi: any) => ethers.utils.LogDescription[];
@@ -1,88 +1,88 @@
1
- import { ethers } from 'ethers';
2
- import TxErrors from './contractError.json';
3
- import { capitalizeFirstLetter } from './string';
4
- export var TxStateType;
5
- (function (TxStateType) {
6
- TxStateType["Success"] = "Success";
7
- TxStateType["Denied"] = "Denied";
8
- TxStateType["Invalid"] = "Invalid";
9
- TxStateType["Failed"] = "Failed";
10
- TxStateType["New"] = "New";
11
- TxStateType["GasEstimating"] = "GasEstimating";
12
- TxStateType["Signing"] = "Signing";
13
- TxStateType["Confirming"] = "Confirming";
14
- })(TxStateType || (TxStateType = {}));
15
- export const isTxFailed = (txState) => [TxStateType.Denied, TxStateType.Invalid, TxStateType.Failed].includes(txState);
16
- export const increaseGasLimit = (estimatedGasLimit) => {
17
- if (!estimatedGasLimit || Number.isNaN(estimatedGasLimit.toNumber())) {
18
- console.log('estimatedGasLimit', estimatedGasLimit);
19
- throw new Error('Estimated gas limited error.');
20
- }
21
- return estimatedGasLimit.mul(150).div(100);
22
- };
23
- const parseErrorMessageToUserFriendlyMessage = (message) => capitalizeFirstLetter(message
24
- .replace('()', '')
25
- .split(/(?=[A-Z])/)
26
- .join(' ')
27
- .toLowerCase());
28
- const findContractErrorMessage = (code) => {
29
- let reason = null;
30
- Object.keys(TxErrors).forEach((key) => {
31
- // @ts-ignore
32
- if (code.toLowerCase() === TxErrors[key].toLowerCase()) {
33
- reason = parseErrorMessageToUserFriendlyMessage(key);
34
- }
35
- });
36
- return reason;
37
- };
38
- export const getTransactionErrorFromHash = async (provider, txHash) => {
39
- const commonErrorMessage = 'Send transaction failed';
40
- try {
41
- const originTx = await provider.getTransaction(txHash);
42
- const { from, to, data, gasLimit, blockNumber } = originTx;
43
- // Only provide necessary params to get the tx return which can avoid unexpected error
44
- const tx = { from, to, data, gasLimit };
45
- const code = await provider.call(tx, blockNumber);
46
- const reason = findContractErrorMessage(code);
47
- return reason !== null && reason !== void 0 ? reason : commonErrorMessage;
48
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
- }
50
- catch (error) {
51
- if (!error.data) {
52
- console.error(error);
53
- return commonErrorMessage;
54
- }
55
- const code = error.data.replace('Reverted ', '');
56
- const reason = ethers.utils.toUtf8String(`0x${code.substr(138)}`);
57
- return reason;
58
- }
59
- };
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- export const getTransactionErrorFromError = (e) => {
62
- var _a, _b, _c, _d, _e;
63
- const errorCode = ((_c = (_b = (_a = e.error) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.originalError) === null || _c === void 0 ? void 0 : _c.data) || ((_e = (_d = e.error) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.data);
64
- if (errorCode) {
65
- const contractErrorMessage = findContractErrorMessage(errorCode);
66
- if (contractErrorMessage) {
67
- return contractErrorMessage;
68
- }
69
- }
70
- return null;
71
- };
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
- export const decodeLogs = (txlogs, abi) => {
74
- const result = [];
75
- const iface = new ethers.utils.Interface(abi);
76
- // eslint-disable-next-line no-restricted-syntax
77
- for (const log of txlogs) {
78
- try {
79
- result.push(iface.parseLog(log));
80
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
- }
82
- catch (error) {
83
- console.error(error);
84
- }
85
- }
86
- return result;
87
- };
1
+ import { ethers } from 'ethers';
2
+ import TxErrors from './contractError.json';
3
+ import { capitalizeFirstLetter } from './string';
4
+ export var TxStateType;
5
+ (function (TxStateType) {
6
+ TxStateType["Success"] = "Success";
7
+ TxStateType["Denied"] = "Denied";
8
+ TxStateType["Invalid"] = "Invalid";
9
+ TxStateType["Failed"] = "Failed";
10
+ TxStateType["New"] = "New";
11
+ TxStateType["GasEstimating"] = "GasEstimating";
12
+ TxStateType["Signing"] = "Signing";
13
+ TxStateType["Confirming"] = "Confirming";
14
+ })(TxStateType || (TxStateType = {}));
15
+ export const isTxFailed = (txState) => [TxStateType.Denied, TxStateType.Invalid, TxStateType.Failed].includes(txState);
16
+ export const increaseGasLimit = (estimatedGasLimit) => {
17
+ if (!estimatedGasLimit || Number.isNaN(estimatedGasLimit.toNumber())) {
18
+ console.log('estimatedGasLimit', estimatedGasLimit);
19
+ throw new Error('Estimated gas limited error.');
20
+ }
21
+ return estimatedGasLimit.mul(150).div(100);
22
+ };
23
+ const parseErrorMessageToUserFriendlyMessage = (message) => capitalizeFirstLetter(message
24
+ .replace('()', '')
25
+ .split(/(?=[A-Z])/)
26
+ .join(' ')
27
+ .toLowerCase());
28
+ const findContractErrorMessage = (code) => {
29
+ let reason = null;
30
+ Object.keys(TxErrors).forEach((key) => {
31
+ // @ts-ignore
32
+ if (code.toLowerCase() === TxErrors[key].toLowerCase()) {
33
+ reason = parseErrorMessageToUserFriendlyMessage(key);
34
+ }
35
+ });
36
+ return reason;
37
+ };
38
+ export const getTransactionErrorFromHash = async (provider, txHash) => {
39
+ const commonErrorMessage = 'Send transaction failed';
40
+ try {
41
+ const originTx = await provider.getTransaction(txHash);
42
+ const { from, to, data, gasLimit, blockNumber } = originTx;
43
+ // Only provide necessary params to get the tx return which can avoid unexpected error
44
+ const tx = { from, to, data, gasLimit };
45
+ const code = await provider.call(tx, blockNumber);
46
+ const reason = findContractErrorMessage(code);
47
+ return reason !== null && reason !== void 0 ? reason : commonErrorMessage;
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ }
50
+ catch (error) {
51
+ if (!error.data) {
52
+ console.error(error);
53
+ return commonErrorMessage;
54
+ }
55
+ const code = error.data.replace('Reverted ', '');
56
+ const reason = ethers.utils.toUtf8String(`0x${code.substr(138)}`);
57
+ return reason;
58
+ }
59
+ };
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ export const getTransactionErrorFromError = (e) => {
62
+ var _a, _b, _c, _d, _e;
63
+ const errorCode = ((_c = (_b = (_a = e.error) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.originalError) === null || _c === void 0 ? void 0 : _c.data) || ((_e = (_d = e.error) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.data);
64
+ if (errorCode) {
65
+ const contractErrorMessage = findContractErrorMessage(errorCode);
66
+ if (contractErrorMessage) {
67
+ return contractErrorMessage;
68
+ }
69
+ }
70
+ return null;
71
+ };
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
+ export const decodeLogs = (txlogs, abi) => {
74
+ const result = [];
75
+ const iface = new ethers.utils.Interface(abi);
76
+ // eslint-disable-next-line no-restricted-syntax
77
+ for (const log of txlogs) {
78
+ try {
79
+ result.push(iface.parseLog(log));
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ }
82
+ catch (error) {
83
+ console.error(error);
84
+ }
85
+ }
86
+ return result;
87
+ };
88
88
  //# sourceMappingURL=transaction.js.map
@@ -1,4 +1,4 @@
1
- import { Contract } from '@ethersproject/contracts';
2
- import { JsonRpcProvider } from '@ethersproject/providers';
3
- export declare function isAddress(value: any): string | false;
4
- export declare function getContract(address: string, ABI: any, provider: JsonRpcProvider, account?: string): Contract;
1
+ import { Contract } from '@ethersproject/contracts';
2
+ import { JsonRpcProvider } from '@ethersproject/providers';
3
+ export declare function isAddress(value: any): string | false;
4
+ export declare function getContract(address: string, ABI: any, provider: JsonRpcProvider, account?: string): Contract;
@@ -1,35 +1,35 @@
1
- import { Contract } from '@ethersproject/contracts';
2
- import { AddressZero } from '@ethersproject/constants';
3
- import { getAddress } from '@ethersproject/address';
4
- // returns the checksummed address if the address is valid, otherwise returns false
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- export function isAddress(value) {
7
- try {
8
- // Alphabetical letters must be made lowercase for getAddress to work.
9
- // See documentation here: https://docs.ethers.io/v5/api/utils/address/
10
- return getAddress(value.toLowerCase());
11
- }
12
- catch (_a) {
13
- return false;
14
- }
15
- }
16
- // account is not optional
17
- function getSigner(provider, account) {
18
- return provider.getSigner(account).connectUnchecked();
19
- }
20
- // account is optional
21
- function getProviderOrSigner(provider, account) {
22
- return account ? getSigner(provider, account) : provider;
23
- }
24
- // account is optional
25
- export function getContract(address,
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- ABI, provider, account) {
28
- if (!isAddress(address) || address === AddressZero) {
29
- throw Error(`Invalid 'address' parameter '${address}'.`);
30
- }
31
- return new Contract(address, ABI,
32
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
- getProviderOrSigner(provider, account));
34
- }
1
+ import { Contract } from '@ethersproject/contracts';
2
+ import { AddressZero } from '@ethersproject/constants';
3
+ import { getAddress } from '@ethersproject/address';
4
+ // returns the checksummed address if the address is valid, otherwise returns false
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ export function isAddress(value) {
7
+ try {
8
+ // Alphabetical letters must be made lowercase for getAddress to work.
9
+ // See documentation here: https://docs.ethers.io/v5/api/utils/address/
10
+ return getAddress(value.toLowerCase());
11
+ }
12
+ catch (_a) {
13
+ return false;
14
+ }
15
+ }
16
+ // account is not optional
17
+ function getSigner(provider, account) {
18
+ return provider.getSigner(account).connectUnchecked();
19
+ }
20
+ // account is optional
21
+ function getProviderOrSigner(provider, account) {
22
+ return account ? getSigner(provider, account) : provider;
23
+ }
24
+ // account is optional
25
+ export function getContract(address,
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ ABI, provider, account) {
28
+ if (!isAddress(address) || address === AddressZero) {
29
+ throw Error(`Invalid 'address' parameter '${address}'.`);
30
+ }
31
+ return new Contract(address, ABI,
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ getProviderOrSigner(provider, account));
34
+ }
35
35
  //# sourceMappingURL=web3.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/shared",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/index.js",
@@ -8,7 +8,7 @@
8
8
  "dist"
9
9
  ],
10
10
  "scripts": {
11
- "start": "tsc -w",
11
+ "start": "tsc -w --project ./tsconfig.build.json",
12
12
  "postbuild": "copyfiles -u 1 ./src/components/icons/*.svg dist",
13
13
  "build": "tsc --project ./tsconfig.build.json && tsc --project ./tsconfig.cjs.json",
14
14
  "contracts:compile:abi": "typechain --target ethers-v5 --out-dir src/abis/types \"./src/abis/**/*.json\"",
@@ -149,5 +149,5 @@
149
149
  "optionalDependencies": {
150
150
  "encoding": "^0.1.13"
151
151
  },
152
- "gitHead": "90e96b82dd363680ab6db853dd12ecc213932923"
152
+ "gitHead": "d58baeee71cc6d50a8dab3ce91411bf88c846f00"
153
153
  }