@onepercentio/one-ui 0.28.8 → 0.28.9

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 (278) hide show
  1. package/package.json +4 -1
  2. package/src/assets/img/svg/checkbox.svg +3 -0
  3. package/src/assets/styles/index.scss +2 -0
  4. package/src/assets/styles/mixins.scss +12 -0
  5. package/src/assets/styles/variables.scss +49 -0
  6. package/src/components/AdaptiveButton/AdaptiveButton.module.scss +7 -0
  7. package/src/components/AdaptiveButton/AdaptiveButton.tsx +26 -0
  8. package/src/components/AdaptiveButton/index.tsx +1 -0
  9. package/src/components/AdaptiveContainer/AdaptiveContainer.module.scss +53 -0
  10. package/src/components/AdaptiveContainer/AdaptiveContainer.tsx +200 -0
  11. package/src/components/AdaptiveContainer/index.tsx +1 -0
  12. package/src/components/AdaptiveDialog/AdaptiveDialog.module.scss +147 -0
  13. package/src/components/AdaptiveDialog/AdaptiveDialog.tsx +97 -0
  14. package/src/components/AdaptiveDialog/index.tsx +1 -0
  15. package/src/components/AdaptiveSidebar/AdaptiveSidebar.module.scss +49 -0
  16. package/src/components/AdaptiveSidebar/AdaptiveSidebar.sample.tsx +10 -0
  17. package/src/components/AdaptiveSidebar/AdaptiveSidebar.tsx +123 -0
  18. package/src/components/AdaptiveSidebar/index.tsx +1 -0
  19. package/src/components/AnchoredTooltip/AnchoredTooltip.module.scss +64 -0
  20. package/src/components/AnchoredTooltip/AnchoredTooltip.tsx +250 -0
  21. package/src/components/AnchoredTooltip/index.tsx +1 -0
  22. package/src/components/AnimatedEntrance/AnimatedEntrance.module.scss +108 -0
  23. package/src/components/AnimatedEntrance/AnimatedEntrance.tsx +227 -0
  24. package/src/components/AnimatedEntrance/index.tsx +5 -0
  25. package/src/components/AsyncWrapper/AsyncWrapper.tsx +38 -0
  26. package/src/components/AsyncWrapper/index.tsx +1 -0
  27. package/src/components/Avatar/Avatar.module.scss +22 -0
  28. package/src/components/Avatar/Avatar.tsx +31 -0
  29. package/src/components/Avatar/index.tsx +1 -0
  30. package/src/components/BucketFill/BucketFill.module.scss +36 -0
  31. package/src/components/BucketFill/BucketFill.tsx +65 -0
  32. package/src/components/BucketFill/index.tsx +1 -0
  33. package/src/components/Button/Button.module.scss +45 -0
  34. package/src/components/Button/Button.tsx +40 -0
  35. package/src/components/Button/index.tsx +1 -0
  36. package/src/components/Card/Card.module.scss +12 -0
  37. package/src/components/Card/Card.tsx +9 -0
  38. package/src/components/Card/index.tsx +1 -0
  39. package/src/components/Chart/Chart.e2e.ts +4 -0
  40. package/src/components/Chart/Chart.logic.tsx +8 -0
  41. package/src/components/Chart/Chart.module.scss +58 -0
  42. package/src/components/Chart/Chart.types.ts +35 -0
  43. package/src/components/Chart/Chart.view.tsx +240 -0
  44. package/src/components/Chart/index.tsx +1 -0
  45. package/src/components/CheckBox/CheckBox.module.scss +36 -0
  46. package/src/components/CheckBox/CheckBox.tsx +63 -0
  47. package/src/components/CheckBox/index.tsx +1 -0
  48. package/src/components/CodeInput/CodeInput.module.scss +5 -0
  49. package/src/components/CodeInput/CodeInput.tsx +84 -0
  50. package/src/components/CodeInput/index.tsx +1 -0
  51. package/src/components/Collapsable/Collapsable.module.scss +42 -0
  52. package/src/components/Collapsable/Collapsable.tsx +253 -0
  53. package/src/components/Collapsable/index.tsx +1 -0
  54. package/src/components/Countdown/Countdown.tsx +130 -0
  55. package/src/components/Countdown/index.tsx +1 -0
  56. package/src/components/CurrencyInput/CurrencyInput.hook.ts +37 -0
  57. package/src/components/CurrencyInput/CurrencyInput.tsx +25 -0
  58. package/src/components/CurrencyInput/index.tsx +1 -0
  59. package/src/components/Divider/Divider.module.scss +7 -0
  60. package/src/components/Divider/Divider.tsx +13 -0
  61. package/src/components/Divider/index.tsx +1 -0
  62. package/src/components/EmailInput/EmailInput.module.scss +0 -0
  63. package/src/components/EmailInput/EmailInput.tsx +51 -0
  64. package/src/components/EmailInput/index.tsx +1 -0
  65. package/src/components/FadeIn/FadeIn.module.scss +9 -0
  66. package/src/components/FadeIn/FadeIn.tsx +77 -0
  67. package/src/components/FadeIn/index.tsx +1 -0
  68. package/src/components/FileInput/FileInput.module.scss +6 -0
  69. package/src/components/FileInput/FileInput.tsx +75 -0
  70. package/src/components/FileInput/View/BigFactory/BigFactory.module.scss +20 -0
  71. package/src/components/FileInput/View/BigFactory/BigFactory.tsx +48 -0
  72. package/src/components/FileInput/View/BigFactory/index.tsx +1 -0
  73. package/src/components/FileInput/View/Compact/Compact.module.scss +68 -0
  74. package/src/components/FileInput/View/Compact/Compact.tsx +151 -0
  75. package/src/components/FileInput/View/Compact/index.tsx +1 -0
  76. package/src/components/FileInput/View/View.types.ts +12 -0
  77. package/src/components/FileInput/index.tsx +1 -0
  78. package/src/components/FlowController/FlowController.module.scss +47 -0
  79. package/src/components/FlowController/FlowController.tsx +93 -0
  80. package/src/components/FlowController/index.tsx +1 -0
  81. package/src/components/Form/Form.tsx +243 -0
  82. package/src/components/Form/index.ts +1 -0
  83. package/src/components/Form/v2/Form.hook.ts +341 -0
  84. package/src/components/Form/v2/Form.module.scss +0 -0
  85. package/src/components/Form/v2/Form.tsx +78 -0
  86. package/src/components/Form/v2/Form.types.ts +118 -0
  87. package/src/components/Form/v2/FormField/Extensions/DateField/DateField.module.scss +0 -0
  88. package/src/components/Form/v2/FormField/Extensions/DateField/DateField.tsx +73 -0
  89. package/src/components/Form/v2/FormField/Extensions/DateField/index.tsx +1 -0
  90. package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.module.scss +0 -0
  91. package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.tsx +91 -0
  92. package/src/components/Form/v2/FormField/Extensions/PhoneField/index.tsx +1 -0
  93. package/src/components/Form/v2/FormField/FormField.module.scss +0 -0
  94. package/src/components/Form/v2/FormField/FormField.tsx +378 -0
  95. package/src/components/Form/v2/FormField/FormField.types.ts +129 -0
  96. package/src/components/Form/v2/FormField/index.tsx +1 -0
  97. package/src/components/Form/v2/index.tsx +1 -0
  98. package/src/components/Freeze/Freeze.tsx +9 -0
  99. package/src/components/Freeze/index.tsx +1 -0
  100. package/src/components/HSForms/HSForms.tsx +57 -0
  101. package/src/components/HSForms/index.tsx +1 -0
  102. package/src/components/Header/Header.module.scss +119 -0
  103. package/src/components/Header/Header.tsx +138 -0
  104. package/src/components/Header/index.tsx +1 -0
  105. package/src/components/HeaderCloseBtn/HeaderCloseBtn.module.scss +44 -0
  106. package/src/components/HeaderCloseBtn/HeaderCloseBtn.tsx +28 -0
  107. package/src/components/HeaderCloseBtn/index.tsx +1 -0
  108. package/src/components/InfinityScroll/InfinityScroll.module.scss +30 -0
  109. package/src/components/InfinityScroll/InfinityScroll.tsx +187 -0
  110. package/src/components/InfinityScroll/index.tsx +1 -0
  111. package/src/components/Input/Input.module.scss +71 -0
  112. package/src/components/Input/Input.tsx +134 -0
  113. package/src/components/Input/index.tsx +1 -0
  114. package/src/components/InstantCounter/InstantCounter.tsx +77 -0
  115. package/src/components/InstantCounter/index.tsx +1 -0
  116. package/src/components/LavaLamp/LavaLamp.data.tsx +114 -0
  117. package/src/components/LavaLamp/LavaLamp.module.scss +26 -0
  118. package/src/components/LavaLamp/LavaLamp.tsx +131 -0
  119. package/src/components/LavaLamp/index.tsx +1 -0
  120. package/src/components/LavaLamp/v2/LavaLamp.module.scss +23 -0
  121. package/src/components/LavaLamp/v2/LavaLamp.tsx +197 -0
  122. package/src/components/LinkToId/LinkToId.module.scss +4 -0
  123. package/src/components/LinkToId/LinkToId.tsx +51 -0
  124. package/src/components/LinkToId/index.tsx +1 -0
  125. package/src/components/Loader/Loader.module.scss +40 -0
  126. package/src/components/Loader/Loader.tsx +18 -0
  127. package/src/components/Loader/index.tsx +1 -0
  128. package/src/components/LoaderDotsIndicator/LoaderDotsIndicator.tsx +34 -0
  129. package/src/components/LoaderDotsIndicator/index.tsx +1 -0
  130. package/src/components/LoopableVideo/LoopableVideo.tsx +37 -0
  131. package/src/components/LoopableVideo/index.tsx +1 -0
  132. package/src/components/MainGrid/MainGrid.module.scss +28 -0
  133. package/src/components/MainGrid/MainGrid.tsx +68 -0
  134. package/src/components/MainGrid/index.tsx +1 -0
  135. package/src/components/MutableHamburgerButton/MutableHamburgerButton.module.scss +220 -0
  136. package/src/components/MutableHamburgerButton/MutableHamburgerButton.tsx +38 -0
  137. package/src/components/MutableHamburgerButton/index.tsx +1 -0
  138. package/src/components/Notification/Notification.module.scss +25 -0
  139. package/src/components/Notification/Notification.tsx +13 -0
  140. package/src/components/Notification/index.tsx +1 -0
  141. package/src/components/OrderableList/OrderableList.module.scss +98 -0
  142. package/src/components/OrderableList/OrderableList.tsx +564 -0
  143. package/src/components/OrderableList/index.tsx +1 -0
  144. package/src/components/PaginationIndicator/PaginationIndicator.tsx +365 -0
  145. package/src/components/PaginationIndicator/index.tsx +1 -0
  146. package/src/components/Parallax/Parallax.module.scss +28 -0
  147. package/src/components/Parallax/Parallax.tsx +248 -0
  148. package/src/components/Parallax/index.tsx +1 -0
  149. package/src/components/Parallax/math/helpers.ts +289 -0
  150. package/src/components/PasswordInput/PasswordInput.module.scss +17 -0
  151. package/src/components/PasswordInput/PasswordInput.tsx +154 -0
  152. package/src/components/PasswordInput/index.tsx +1 -0
  153. package/src/components/PingPongText/PingPongText.module.scss +4 -0
  154. package/src/components/PingPongText/PingPongText.tsx +83 -0
  155. package/src/components/PingPongText/index.tsx +1 -0
  156. package/src/components/PixelatedScan/PixelatedScan.module.scss +86 -0
  157. package/src/components/PixelatedScan/PixelatedScan.tsx +175 -0
  158. package/src/components/PixelatedScan/index.tsx +1 -0
  159. package/src/components/Portal/Portal.module.scss +3 -0
  160. package/src/components/Portal/Portal.tsx +68 -0
  161. package/src/components/Portal/index.tsx +1 -0
  162. package/src/components/ProgressBar/ProgressBar.module.scss +44 -0
  163. package/src/components/ProgressBar/ProgressBar.tsx +124 -0
  164. package/src/components/ProgressBar/index.tsx +1 -0
  165. package/src/components/ProgressTexts/ProgressTexts.module.scss +37 -0
  166. package/src/components/ProgressTexts/ProgressTexts.tsx +85 -0
  167. package/src/components/ProgressTexts/index.tsx +1 -0
  168. package/src/components/Radio/Radio.module.scss +36 -0
  169. package/src/components/Radio/Radio.tsx +53 -0
  170. package/src/components/Radio/index.tsx +1 -0
  171. package/src/components/SectionContainer/SectionContainer.module.scss +30 -0
  172. package/src/components/SectionContainer/SectionContainer.tsx +49 -0
  173. package/src/components/SectionContainer/index.tsx +1 -0
  174. package/src/components/Select/Select.module.scss +58 -0
  175. package/src/components/Select/Select.tsx +192 -0
  176. package/src/components/Select/index.tsx +1 -0
  177. package/src/components/Skeleton/Skeleton.module.scss +21 -0
  178. package/src/components/Skeleton/Skeleton.tsx +29 -0
  179. package/src/components/Skeleton/index.tsx +1 -0
  180. package/src/components/Spacing/Spacing.module.scss +13 -0
  181. package/src/components/Spacing/Spacing.tsx +24 -0
  182. package/src/components/Spacing/index.tsx +1 -0
  183. package/src/components/StaticScroller/StaticScroller.module.scss +14 -0
  184. package/src/components/StaticScroller/StaticScroller.tsx +83 -0
  185. package/src/components/StaticScroller/index.tsx +1 -0
  186. package/src/components/Switch/Switch.module.scss +43 -0
  187. package/src/components/Switch/Switch.tsx +41 -0
  188. package/src/components/Switch/index.tsx +1 -0
  189. package/src/components/Table/Table.module.scss +76 -0
  190. package/src/components/Table/Table.tsx +152 -0
  191. package/src/components/Table/index.tsx +1 -0
  192. package/src/components/Tabs/Tabs.module.scss +40 -0
  193. package/src/components/Tabs/Tabs.tsx +104 -0
  194. package/src/components/Tabs/index.tsx +1 -0
  195. package/src/components/Text/Text.module.scss +81 -0
  196. package/src/components/Text/Text.tsx +42 -0
  197. package/src/components/Text/index.tsx +1 -0
  198. package/src/components/Transition/MasksFactory/DiagonalReveal.tsx +47 -0
  199. package/src/components/Transition/MasksFactory/DiagonalSquareToBalls.tsx +78 -0
  200. package/src/components/Transition/MasksFactory/PhysicsSquares.tsx +106 -0
  201. package/src/components/Transition/MasksFactory/SquareToBalls.tsx +66 -0
  202. package/src/components/Transition/MasksFactory/utils.ts +35 -0
  203. package/src/components/Transition/Transition.module.scss +211 -0
  204. package/src/components/Transition/Transition.tsx +495 -0
  205. package/src/components/Transition/index.tsx +1 -0
  206. package/src/components/UncontrolledTransition/UncontrolledTransition.ai.md +9 -0
  207. package/src/components/UncontrolledTransition/UncontrolledTransition.sample.tsx +34 -0
  208. package/src/components/UncontrolledTransition/UncontrolledTransition.tsx +143 -0
  209. package/src/components/UncontrolledTransition/index.tsx +2 -0
  210. package/src/components/WalletConnectionWrapper/WalletConnectionWrapper.tsx +212 -0
  211. package/src/components/WalletConnectionWrapper/index.tsx +1 -0
  212. package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.module.scss +5 -0
  213. package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.tsx +52 -0
  214. package/src/components/utilitary/ScrollAndFocusLock/index.tsx +1 -0
  215. package/src/context/AsyncProcess.tsx +107 -0
  216. package/src/context/ContextAsyncControl.tsx +89 -0
  217. package/src/context/CustomBrowserRouter.tsx +55 -0
  218. package/src/context/OneUIProvider.tsx +308 -0
  219. package/src/hooks/logs/useDependencyChangeDetection.ts +25 -0
  220. package/src/hooks/logs/useIsMounting.ts +7 -0
  221. package/src/hooks/persistence/useLocalStorage.ts +45 -0
  222. package/src/hooks/shims/ObjectWatchShim.ts +56 -0
  223. package/src/hooks/ui/useAdaptiveImage.tsx +36 -0
  224. package/src/hooks/ui/useAlternating.tsx +22 -0
  225. package/src/hooks/ui/useBreakpoint.tsx +21 -0
  226. package/src/hooks/ui/useCustomScrollbar.module.scss +20 -0
  227. package/src/hooks/ui/useCustomScrollbar.tsx +22 -0
  228. package/src/hooks/ui/useEffectIf.ts +11 -0
  229. package/src/hooks/ui/useMouseHover.tsx +26 -0
  230. package/src/hooks/ui/usePaginationControls.module.scss +16 -0
  231. package/src/hooks/ui/usePaginationControls.tsx +176 -0
  232. package/src/hooks/ui/useSnapToViewport.module.scss +6 -0
  233. package/src/hooks/ui/useSnapToViewport.ts +28 -0
  234. package/src/hooks/ui/useTilt.tsx +219 -0
  235. package/src/hooks/ui/useZoomable.module.scss +34 -0
  236. package/src/hooks/ui/useZoomable.tsx +144 -0
  237. package/src/hooks/useAsyncControl.ai.md +25 -0
  238. package/src/hooks/useAsyncControl.ts +101 -0
  239. package/src/hooks/useContainedRepositioning.ts +110 -0
  240. package/src/hooks/useCustomHistory.ts +14 -0
  241. package/src/hooks/useElementFit.ts +82 -0
  242. package/src/hooks/useFirestoreWatch.ts +54 -0
  243. package/src/hooks/useForm.ts +49 -0
  244. package/src/hooks/useFreeze.ts +12 -0
  245. package/src/hooks/useHero.module.scss +41 -0
  246. package/src/hooks/useHero.ts +512 -0
  247. package/src/hooks/useIntersection.ts +32 -0
  248. package/src/hooks/useMergeRefs.ts +29 -0
  249. package/src/hooks/useObserve.ts +24 -0
  250. package/src/hooks/usePagination.ts +228 -0
  251. package/src/hooks/usePooledOperation.ts +54 -0
  252. package/src/hooks/usePooling.ts +46 -0
  253. package/src/hooks/useRebound.ts +23 -0
  254. package/src/hooks/useShortIntl.ai.md +5 -0
  255. package/src/hooks/useShortIntl.ts +97 -0
  256. package/src/hooks/utility/useAsyncMemo.ts +43 -0
  257. package/src/hooks/utility/useDepChange.ts +11 -0
  258. package/src/hooks/utility/useEvents.ts +33 -0
  259. package/src/hooks/utility/useImmediate.ts +8 -0
  260. package/src/hooks/utility/useManualInit.ts +24 -0
  261. package/src/hooks/utility/useModule.ts +15 -0
  262. package/src/hooks/utility/useQuery.ts +15 -0
  263. package/src/hooks/utility/useUniqueEffect.ts +22 -0
  264. package/src/index.ts +3 -0
  265. package/src/models/DebugLogger.ts +7 -0
  266. package/src/models/GenericContract.ts +169 -0
  267. package/src/models/Orbs.ts +97 -0
  268. package/src/reac-app-env.d.ts +6 -0
  269. package/src/storybook/assets/video/txt-reversed.mp4 +0 -0
  270. package/src/storybookUtils/index.tsx +53 -0
  271. package/src/type-utils.ts +49 -0
  272. package/src/utility.d.ts +70 -0
  273. package/src/utils/blockchain.ts +43 -0
  274. package/src/utils/flatten.ts +17 -0
  275. package/src/utils/formatters.ts +36 -0
  276. package/src/utils/html.utils.ts +3 -0
  277. package/src/utils/ownEvent.ts +8 -0
  278. package/src/utils/test.ts +19 -0
@@ -0,0 +1,169 @@
1
+ // @ts-nocheck
2
+ import {
3
+ Contract,
4
+ ContractOptions,
5
+ EventData,
6
+ PastEventOptions,
7
+ } from "web3-eth-contract";
8
+ import { AbiItem } from "web3-utils";
9
+
10
+ export type AllABIs = readonly any[];
11
+
12
+ type ExtractMethods<A extends AllABIs[number]> = A extends {
13
+ type: "function";
14
+ }
15
+ ? A["name"]
16
+ : never;
17
+
18
+ type ExtractEvents<A extends AllABIs[number]> = A extends {
19
+ type: "event";
20
+ }
21
+ ? A["name"]
22
+ : never;
23
+
24
+ type TypeOrInternalType<T> = T['internalType'] extends unknown ? T['type'] : T['internalType']
25
+
26
+ export type MapTypeToJS<L, C> =
27
+ L extends "tuple[]" ? TuplifyUnion<C[number], C[number]['name']>[] :
28
+ L extends "address" | "uint256" | "uint128" | "uint8" | "string" | "bytes32" | "uint64"
29
+ ? string
30
+ : L extends "uint256[]" | "string[]"
31
+ ? string[]
32
+ : L extends "bool"
33
+ ? boolean
34
+ : L extends 'tuple'
35
+ ? TuplifyUnion<C[number], C[number]['name']>
36
+ : unknown;
37
+
38
+ type ExtractFromObj<R extends (AllABIs[number] & { type: "function" })> = {
39
+ [K in R["outputs"][number]["name"]]: MapTypeToJS<
40
+ TypeOrInternalType<(R["outputs"][number] & {
41
+ name: K;
42
+ })>,
43
+ (R["outputs"][number] & {
44
+ name: K;
45
+ })["components"]
46
+ >;
47
+ }
48
+
49
+ export type ExtractMethodDefinition<
50
+ A extends AllABIs,
51
+ N extends (AllABIs[number] & { type: "function" })["name"],
52
+ R = A[number] & {
53
+ type: "function";
54
+ name: N;
55
+ }
56
+ > = (
57
+ ...args: TuplifyUnion<
58
+ (A[number] & {
59
+ type: "function";
60
+ name: N;
61
+ })["inputs"][number],
62
+ (A[number] & {
63
+ type: "function";
64
+ name: N;
65
+ })["inputs"][number]["name"]
66
+ >
67
+ ) => {
68
+ call: () => Promise<
69
+ R extends { outputs: { length: 1 } }
70
+ ? MapTypeToJS<
71
+ TypeOrInternalType<R["outputs"][0]>,
72
+ R["outputs"][0]['components']
73
+ >
74
+ : R extends { outputs: any }
75
+ ? ExtractFromObj<R>
76
+ : void
77
+ >;
78
+ send: (prop: { from: string, maxPriorityFeePerGas?: number, gas?: number, gasPrice?: string }) => Promise<void>;
79
+ };
80
+
81
+ // oh boy don't do this
82
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
83
+ k: infer I
84
+ ) => void
85
+ ? I
86
+ : never;
87
+ type LastOf<T> = UnionToIntersection<
88
+ T extends any ? () => T : never
89
+ > extends () => infer R
90
+ ? R
91
+ : never;
92
+
93
+ // TS4.0+
94
+ type Push<T extends any[], V> = [...T, V];
95
+
96
+ // TS4.1+
97
+ export type TuplifyUnion<
98
+ FUNCS,
99
+ T,
100
+ L = LastOf<T>,
101
+ N = [T] extends [never] ? true : false
102
+ > = true extends N
103
+ ? []
104
+ : Push<
105
+ TuplifyUnion<FUNCS, Exclude<T, L>>,
106
+ MapTypeToJS<
107
+ TypeOrInternalType<(FUNCS & { name: L })>,
108
+ (FUNCS & { name: L })['components']
109
+ >
110
+ >;
111
+
112
+ export class GenericContract<
113
+ A extends AllABIs = AllABIs,
114
+ E extends string = ExtractEvents<A[number]> | "allEvents"
115
+ > extends Contract {
116
+ events!: Exclude<E, "allEvents">;
117
+ constructor(jsonInterface: A, address?: string, options?: ContractOptions) {
118
+ super(jsonInterface as unknown as AbiItem[], address, options);
119
+ }
120
+ override methods!: {
121
+ [k in ExtractMethods<A[number]>]: ExtractMethodDefinition<A, k>;
122
+ };
123
+ override getPastEvents(event: E): Promise<GenericEventData<A>[]>;
124
+ override getPastEvents(
125
+ event: E,
126
+ options: PastEventOptions,
127
+ callback: (error: Error, event: EventData) => void
128
+ ): Promise<GenericEventData<A>[]>;
129
+ override getPastEvents(
130
+ event: E,
131
+ options: PastEventOptions
132
+ ): Promise<GenericEventData<A>[]>;
133
+ override getPastEvents(
134
+ event: E,
135
+ callback: (error: Error, event: EventData) => void
136
+ ): Promise<GenericEventData<A>[]>;
137
+ override getPastEvents(
138
+ event: any,
139
+ options?: any,
140
+ callback?: any
141
+ ): Promise<GenericEventData<A>[]> {
142
+ return super.getPastEvents(event, options, callback) as any;
143
+ }
144
+ }
145
+
146
+ export default GenericContract;
147
+
148
+ export type GenericEventData<E extends AllABIs> = EventData & GenericEvent<E>;
149
+
150
+ type ABIEvent = AllABIs[number] & { type: "event" };
151
+
152
+ type GenericEvent<
153
+ ABI extends AllABIs,
154
+ E extends string = ExtractEvents<ABI[number]>
155
+ > = {
156
+ event: E;
157
+ returnValues: ExtractReturnValues<ABIEvent & { name: E }>;
158
+ };
159
+
160
+ type ExtractReturnValues<E extends ABIEvent> = ExtractInputType<
161
+ E["inputs"][number]
162
+ >;
163
+
164
+ type ExtractInputType<I extends ABIEvent["inputs"][number]> = {
165
+ [k in I["name"]]: MapTypeToJS<
166
+ TypeOrInternalType<I>,
167
+ I['components']
168
+ >;
169
+ };
@@ -0,0 +1,97 @@
1
+ export interface OrbDrawer {
2
+ drawOrb(x: number, y: number, radius: number): void;
3
+ }
4
+
5
+ class BaseOrb {
6
+ protected drawer: OrbDrawer;
7
+ constructor(drawer: OrbDrawer) {
8
+ this.drawer = drawer;
9
+ }
10
+ }
11
+
12
+ export class Orb extends BaseOrb {
13
+ x: number;
14
+ y: number;
15
+ vx: number;
16
+ vy: number;
17
+ radius: number;
18
+ bounds: { width: number; height: number };
19
+
20
+ constructor(
21
+ drawer: OrbDrawer,
22
+ velocity: number,
23
+ bounds: Orb["bounds"],
24
+ radius: number
25
+ ) {
26
+ super(drawer);
27
+ this.x = (Math.random() * bounds.width) | 0;
28
+ this.y = (Math.random() * bounds.height) | 0;
29
+ this.radius = radius;
30
+ this.bounds = bounds;
31
+
32
+ var radiant = Math.random() * Math.PI * 2,
33
+ vel = velocity;
34
+
35
+ vel *= 0.2;
36
+
37
+ this.vx = Math.cos(radiant) * vel;
38
+ this.vy = Math.sin(radiant) * vel;
39
+ }
40
+ step() {
41
+ this.x += this.vx;
42
+ this.y += this.vy;
43
+
44
+ var radius = this.radius / 2;
45
+
46
+ if (this.x < -radius || this.x > this.bounds.width + radius) this.vx *= -1;
47
+
48
+ if (this.y < -radius || this.y > this.bounds.height + radius) this.vy *= -1;
49
+
50
+ this.drawer.drawOrb(this.x | 0, this.y | 0, this.radius);
51
+ }
52
+ }
53
+
54
+ export class GuideOrb extends BaseOrb {
55
+ lastRadius!: number;
56
+ lastX!: number;
57
+ lastY!: number;
58
+ deflateDuration: number;
59
+
60
+ constructor(drawer: OrbDrawer, deflateDuration: number) {
61
+ super(drawer);
62
+ this.deflateDuration = deflateDuration;
63
+ }
64
+
65
+ step(
66
+ size: number,
67
+ sizeToIncrease: number,
68
+ lastSizeTimestamp: number,
69
+ lastPositionTimestamp: number,
70
+ currPos: { x: number; y: number },
71
+ moveBy: {
72
+ x: number;
73
+ y: number;
74
+ }
75
+ ) {
76
+ const deltaTime = Date.now() - lastSizeTimestamp;
77
+ const deltaTimePercent =
78
+ deltaTime > 250 ? 1 : (deltaTime * 100) / 250 / 100;
79
+
80
+ const radius = size - (sizeToIncrease - sizeToIncrease * deltaTimePercent);
81
+
82
+ this.lastRadius = radius;
83
+
84
+ const deltaTimePos = Date.now() - lastPositionTimestamp;
85
+ const deltaTimePosPercent =
86
+ deltaTimePos > this.deflateDuration
87
+ ? 1
88
+ : (deltaTimePos * 100) / this.deflateDuration / 100;
89
+
90
+ const translateX = currPos.x - (moveBy.x - moveBy.x * deltaTimePosPercent);
91
+ this.lastX = translateX;
92
+ const translateY = currPos.y - (moveBy.y - moveBy.y * deltaTimePosPercent);
93
+ this.lastY = translateY;
94
+
95
+ this.drawer.drawOrb(translateX | 0, translateY | 0, radius);
96
+ }
97
+ }
@@ -0,0 +1,6 @@
1
+ declare module "*.module.scss" {
2
+ const Styles: {
3
+ [style: string]: string;
4
+ };
5
+ export default Styles;
6
+ }
@@ -0,0 +1,53 @@
1
+ import React, { ComponentProps, PropsWithChildren, forwardRef } from "react";
2
+ import Spacing from "../components/Spacing";
3
+ import { _Text } from "../components/Text/Text";
4
+
5
+ export function extractAllPossibilitiesFromEnumProp<
6
+ C extends (...args: any[]) => any,
7
+ K extends keyof P,
8
+ P extends ComponentProps<C> = ComponentProps<C>
9
+ >(component: C, propName: K): P[K][] {
10
+ if (component === _Text)
11
+ (_Text as any).__docgenInfo.props[propName] = {
12
+ type: {
13
+ value: [
14
+ "title",
15
+ "description",
16
+ "error",
17
+ "caption",
18
+ "highlightTitle",
19
+ "highlight",
20
+ "subtitle",
21
+ "boldTitle",
22
+ "link",
23
+ "boldTitleBig",
24
+ "content",
25
+ ].map((a) => ({ value: JSON.stringify(a) })),
26
+ },
27
+ };
28
+ return (component as any).__docgenInfo.props[propName].type.value.map(
29
+ (a: { value: string }) => JSON.parse(a.value)
30
+ ) as P[K][];
31
+ }
32
+
33
+ export function SideBySideContainer({
34
+ children,
35
+ exampleName,
36
+ }: PropsWithChildren<{ exampleName: string }>) {
37
+ return (
38
+ <div
39
+ style={{
40
+ width: "25%",
41
+ marginRight: 24,
42
+ display: "inline-flex",
43
+ flexDirection: "column",
44
+ }}
45
+ >
46
+ <span style={{ borderBottom: "2px solid black", marginBottom: 14 }}>
47
+ Tipo: <b>{exampleName}</b>
48
+ </span>
49
+ {children}
50
+ <Spacing size="large" />
51
+ </div>
52
+ );
53
+ }
@@ -0,0 +1,49 @@
1
+ type FieldValues = any;
2
+ type NestedValue = any;
3
+ export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
4
+ export declare type EmptyObject = {
5
+ [K in string | number]: never;
6
+ };
7
+ export declare type NonUndefined<T> = T extends undefined ? never : T;
8
+ export declare type LiteralUnion<T extends U, U extends Primitive> = T | (U & {
9
+ _?: never;
10
+ });
11
+ export declare type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
12
+ [key in keyof T]: T[key];
13
+ } ? {
14
+ [K in keyof T]?: DeepPartial<T[K]>;
15
+ } : T;
16
+ export declare type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
17
+ export declare type DeepMap<T, TValue> = {
18
+ [K in keyof T]?: IsAny<T[K]> extends true ? any : NonNullable<T[K]> extends NestedValue | Date | FileList | File ? TValue : NonUndefined<T[K]> extends object | null ? DeepMap<T[K], TValue> : NonUndefined<T[K]> extends Array<infer U> ? IsAny<U> extends true ? Array<any> : U extends NestedValue | Date | FileList ? Array<TValue> : U extends object ? Array<DeepMap<U, TValue>> : Array<TValue> : TValue;
19
+ };
20
+ export declare type IsFlatObject<T extends object> = Extract<Exclude<T[keyof T], NestedValue | Date | FileList>, any[] | object> extends never ? true : false;
21
+ declare type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false : true;
22
+ declare type TupleKey<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
23
+ declare type ArrayKey = number;
24
+ declare type PathImpl<K extends string | number, V> = V extends Primitive ? `${K}` : `${K}` | `${K}.${Path<V>}`;
25
+ export declare type Path<T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
26
+ [K in TupleKey<T>]-?: PathImpl<K & string, T[K]>;
27
+ }[TupleKey<T>] : PathImpl<ArrayKey, V> : {
28
+ [K in keyof T]-?: PathImpl<K & string, T[K]>;
29
+ }[keyof T];
30
+ export declare type FieldPath<TFieldValues extends FieldValues> = Path<TFieldValues>;
31
+ declare type ArrayPathImpl<K extends string | number, V> = V extends Primitive ? never : V extends ReadonlyArray<infer U> ? U extends Primitive ? never : `${K}` | `${K}.${ArrayPath<V>}` : `${K}.${ArrayPath<V>}`;
32
+ export declare type ArrayPath<T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
33
+ [K in TupleKey<T>]-?: ArrayPathImpl<K & string, T[K]>;
34
+ }[TupleKey<T>] : ArrayPathImpl<ArrayKey, V> : {
35
+ [K in keyof T]-?: ArrayPathImpl<K & string, T[K]>;
36
+ }[keyof T];
37
+ export declare type FieldArrayPath<TFieldValues extends FieldValues> = ArrayPath<TFieldValues>;
38
+ export declare type PathValue<T, P extends Path<T> | ArrayPath<T>> = P extends `${infer K}.${infer R}` ? K extends keyof T ? R extends Path<T[K]> ? PathValue<T[K], R> : never : K extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? PathValue<V, R & Path<V>> : never : never : P extends keyof T ? T[P] : P extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? V : never : never;
39
+ export declare type FieldPathValue<TFieldValues extends FieldValues, TFieldPath extends FieldPath<TFieldValues>> = PathValue<TFieldValues, TFieldPath>;
40
+ export declare type FieldArrayPathValue<TFieldValues extends FieldValues, TFieldArrayPath extends FieldArrayPath<TFieldValues>> = PathValue<TFieldValues, TFieldArrayPath>;
41
+ export declare type FieldPathValues<TFieldValues extends FieldValues, TPath extends FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[]> = {} & {
42
+ [K in keyof TPath]: FieldPathValue<TFieldValues, TPath[K] & FieldPath<TFieldValues>>;
43
+ };
44
+ /**
45
+ * Returns the type U when this type is resolved
46
+ * Or the fallback type F when type is no resolved
47
+ */
48
+ export declare type UnresolvableOr<U, F> = keyof U extends U ? F : U
49
+ export {};
@@ -0,0 +1,70 @@
1
+ /**
2
+ * These are typings made to support separated function and prevent excessive Generics usage accross the application
3
+ *
4
+ * Redeclare this namespace with the usefull typings for your project and enjoy intelisense :)
5
+ */
6
+ namespace OnepercentUtility {
7
+ /** The ids used by the useShortIntl hooks */
8
+ type IntlIds = "generic.id";
9
+ /** A type hint to bind the LinkToId action and the SectionContainer identifier */
10
+ type PageSections = "example-section-1";
11
+ /** A type hint to autocomplete functions related to the AsyncProcess context */
12
+ namespace AsyncQueue {
13
+ /** These are the recovery types available */
14
+ type RecoveryTypes = {
15
+ [R: string]: any[];
16
+ };
17
+
18
+ /** These are the available UI models */
19
+ type Processes = {
20
+ [k in "waitForBuild"]: [thash: string];
21
+ };
22
+ }
23
+ /** These are the extensible properties for the UI elements */
24
+ namespace UIElements {
25
+ type AdaptiveDialogVariants = "default";
26
+ type ButtonVariants = "transparent" | "filled" | "outline" | "link";
27
+ type TextVariants =
28
+ | "title"
29
+ | "description"
30
+ | "error"
31
+ | "caption"
32
+ | "highlightTitle"
33
+ | "highlight"
34
+ | "subtitle"
35
+ | "boldTitle"
36
+ | "link"
37
+ | "boldTitleBig"
38
+ | "content";
39
+ type SpacingVariants = "large" | "small";
40
+ type TextColors = "primary" | "error" | undefined;
41
+ type FormExtension = {
42
+ fields:
43
+ | {
44
+ type: "phone";
45
+ country: string;
46
+ }
47
+ | {
48
+ type: "date";
49
+ };
50
+ fieldAnswer: {
51
+ phone: [
52
+ phoneNumber: string,
53
+ isValid: boolean,
54
+ error: string | undefined
55
+ ];
56
+ date: string
57
+ };
58
+ };
59
+ }
60
+ }
61
+ declare module "use-wallet" {
62
+ import * as UseWallet from "use-wallet";
63
+ export const useWallet: typeof UseWallet["use-wallet"];
64
+ export const UseWalletProvider: typeof UseWallet["UseWalletProvider"];
65
+ }
66
+
67
+ declare module "*.mp4" {
68
+ const v: string;
69
+ export default v;
70
+ }
@@ -0,0 +1,43 @@
1
+ import { PromiEvent } from 'web3-core'
2
+
3
+ export async function isTransactionMined(transactionHash: string, provider: any) {
4
+ const transaction = await provider.eth.getTransactionReceipt(transactionHash)
5
+
6
+ if (
7
+ !transaction ||
8
+ !transaction.blockHash ||
9
+ transaction.status === undefined
10
+ )
11
+ return undefined // I still don't know if it's loaded
12
+ else return !!transaction.status === true
13
+ }
14
+
15
+ export async function waitForConfirmation(tHash: string, provider: any) {
16
+ return new Promise<void>(async (r, rej) => {
17
+ while (true) {
18
+ const bought = await isTransactionMined(tHash, provider)
19
+ if (bought === undefined)
20
+ await new Promise<void>((r) => setTimeout(() => r(), 2000))
21
+ else {
22
+ if (bought) r()
23
+ else rej('TRANSACTION_FAILED')
24
+ break
25
+ }
26
+ }
27
+ })
28
+ }
29
+
30
+ export function dispatchAndWait(func: any) {
31
+ const _func = func as PromiEvent<any>
32
+ return new Promise<string>((r, rej) => {
33
+ _func.on('transactionHash', (tX) => {
34
+ r(tX)
35
+ })
36
+ _func.catch(rej)
37
+ })
38
+ }
39
+
40
+ export async function sendAndWaitForConfirmation(func: Promise<void>, provider: any) {
41
+ const tHash = await dispatchAndWait(func)
42
+ await waitForConfirmation(tHash, provider)
43
+ }
@@ -0,0 +1,17 @@
1
+ import { FieldPath } from "../types";
2
+
3
+ export function flatten<T extends object>(obj: T): { [k in FieldPath<T>]: string } {
4
+ return Object.assign(
5
+ {},
6
+ ...(function _flatten(o, prevKey: string = ""): any {
7
+ return [].concat(
8
+ ...Object.keys(o).map((_k) => {
9
+ const k = _k as keyof typeof o;
10
+ return typeof o[k] === "object"
11
+ ? _flatten(o[k] as any, prevKey ? `${prevKey}.${k as string}` : (k as string))
12
+ : { [prevKey ? `${prevKey}.${k as string}` : k]: o[k] };
13
+ })
14
+ );
15
+ })(obj)
16
+ );
17
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * A formatter to format to double decimal
3
+ */
4
+ export const currencyNumberFormatter = new Intl.NumberFormat("pt-BR", {
5
+ minimumFractionDigits: 2,
6
+ maximumFractionDigits: 2,
7
+ }).format;
8
+
9
+ /**
10
+ * Instanciate a currency formatter
11
+ */
12
+ export const currencyFormatterFactory = (
13
+ langCode: string,
14
+ currency?: string
15
+ ) => {
16
+ try {
17
+ return new Intl.NumberFormat(langCode, {
18
+ style: "currency",
19
+ currency: currency,
20
+ });
21
+ } catch (e) {
22
+ const f = new Intl.NumberFormat(langCode, {
23
+ minimumFractionDigits: 2,
24
+ maximumFractionDigits: 2,
25
+ });
26
+
27
+ return {
28
+ format: (num: number) => `${currency} ${currencyNumberFormatter(num)}`,
29
+ formatToParts: (num: number) => [
30
+ { type: "currency", value: currency },
31
+ { type: "literal", value: " " },
32
+ ...f.formatToParts(num),
33
+ ],
34
+ };
35
+ }
36
+ };
@@ -0,0 +1,3 @@
1
+ export function isSameTarget({ target, currentTarget }: Event) {
2
+ return target === currentTarget;
3
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Allows invoking a callback, only when the event is ocurring on the same elemnt
3
+ */
4
+ export default function ownEvent<E extends Event>(cb: (e: E) => void) {
5
+ return (e: E) => {
6
+ if (e.currentTarget === e.target) cb(e);
7
+ };
8
+ }
@@ -0,0 +1,19 @@
1
+ type Func = (...args: any[]) => string
2
+
3
+ export const preffixTestIds =
4
+ (preffix: string) =>
5
+ <
6
+ const M extends {
7
+ [k: string]: string | Func
8
+ }
9
+ >(
10
+ testIds: M
11
+ ) => {
12
+ for (let key in testIds)
13
+ if (typeof testIds[key] === 'function') {
14
+ const originalFunction = testIds[key] as Func
15
+ testIds[key] = ((...args: any[]) =>
16
+ `${preffix}-${originalFunction(...args)}`) as any
17
+ } else testIds[key] = `${preffix}-${testIds[key]}` as any
18
+ return testIds
19
+ }