@huma-finance/widgets 0.0.6-alpha.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 (203) hide show
  1. package/.env.example +3 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc.js +64 -0
  4. package/.prettierignore +4 -0
  5. package/.prettierrc.js +16 -0
  6. package/API.md +331 -0
  7. package/LICENSE +661 -0
  8. package/README.md +48 -0
  9. package/babel.config.js +15 -0
  10. package/config-overrides.js +9 -0
  11. package/cosmos.config.json +7 -0
  12. package/cypress/e2e/01-invoice-factoring-borrow.test.ts +62 -0
  13. package/cypress/support/e2e.ts +76 -0
  14. package/cypress/support/ethereum.ts +142 -0
  15. package/cypress/tsconfig.json +9 -0
  16. package/cypress/utils/index.ts +54 -0
  17. package/cypress.config.ts +20 -0
  18. package/dist/assets/output-15e10f9f.css +44 -0
  19. package/dist/cjs/assets/output-15e10f9f.css +44 -0
  20. package/dist/cjs/index.cjs +17576 -0
  21. package/dist/cjs/index.cjs.map +1 -0
  22. package/dist/index.d.ts +211 -0
  23. package/dist/index.js +17529 -0
  24. package/dist/index.js.map +1 -0
  25. package/jsdoc2md.json +20 -0
  26. package/package.json +193 -0
  27. package/public/favicon.ico +0 -0
  28. package/public/index.html +40 -0
  29. package/public/logo192.png +0 -0
  30. package/public/logo512.png +0 -0
  31. package/public/manifest.json +25 -0
  32. package/public/robots.txt +3 -0
  33. package/rollup.config.js +81 -0
  34. package/src/components/Activity.tsx +123 -0
  35. package/src/components/AllowListModal.tsx +113 -0
  36. package/src/components/ApolloWrapper.tsx +15 -0
  37. package/src/components/ApproveAllowanceModal.tsx +118 -0
  38. package/src/components/BottomButton.tsx +31 -0
  39. package/src/components/ChooseAmountModal.tsx +315 -0
  40. package/src/components/CreditLine/borrow/1-Evaluation.tsx +159 -0
  41. package/src/components/CreditLine/borrow/2-AllowList.tsx +34 -0
  42. package/src/components/CreditLine/borrow/3-ChooseAmount.tsx +74 -0
  43. package/src/components/CreditLine/borrow/4-ApproveAllowance.tsx +29 -0
  44. package/src/components/CreditLine/borrow/5-Transfer.tsx +30 -0
  45. package/src/components/CreditLine/borrow/6-Success.tsx +30 -0
  46. package/src/components/CreditLine/borrow/index.tsx +119 -0
  47. package/src/components/CreditLine/payment/1-ChooseAmount.tsx +67 -0
  48. package/src/components/CreditLine/payment/2-ApproveAllowance.tsx +23 -0
  49. package/src/components/CreditLine/payment/3-Transfer.tsx +34 -0
  50. package/src/components/CreditLine/payment/4-Success.tsx +39 -0
  51. package/src/components/CreditLine/payment/index.tsx +94 -0
  52. package/src/components/ErrorModal.tsx +132 -0
  53. package/src/components/Factoring/FactoredList.tsx +143 -0
  54. package/src/components/Factoring/UpcomingList.tsx +90 -0
  55. package/src/components/Factoring/index.ts +2 -0
  56. package/src/components/HumaLoading.tsx +68 -0
  57. package/src/components/HumaTable.tsx +158 -0
  58. package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +46 -0
  59. package/src/components/InvoiceFactoring/borrow/2-AllowList.tsx +34 -0
  60. package/src/components/InvoiceFactoring/borrow/3-ChooseAmount.tsx +92 -0
  61. package/src/components/InvoiceFactoring/borrow/4-ConfirmTransfer.tsx +104 -0
  62. package/src/components/InvoiceFactoring/borrow/5-ApproveNFT.tsx +55 -0
  63. package/src/components/InvoiceFactoring/borrow/6-Transfer.tsx +34 -0
  64. package/src/components/InvoiceFactoring/borrow/7-Success.tsx +20 -0
  65. package/src/components/InvoiceFactoring/borrow/index.tsx +96 -0
  66. package/src/components/InvoiceFactoring/payment/1-ChooseAmount.tsx +67 -0
  67. package/src/components/InvoiceFactoring/payment/2-ApproveAllowance.tsx +23 -0
  68. package/src/components/InvoiceFactoring/payment/3-Transfer.tsx +34 -0
  69. package/src/components/InvoiceFactoring/payment/4-Success.tsx +23 -0
  70. package/src/components/InvoiceFactoring/payment/index.tsx +86 -0
  71. package/src/components/Lend/supply/1-Evaluation.tsx +86 -0
  72. package/src/components/Lend/supply/2-ChooseAmount.tsx +70 -0
  73. package/src/components/Lend/supply/3-ApproveAllowance.tsx +25 -0
  74. package/src/components/Lend/supply/4-ConfirmTransfer.tsx +104 -0
  75. package/src/components/Lend/supply/6-Transfer.tsx +32 -0
  76. package/src/components/Lend/supply/7-Success.tsx +49 -0
  77. package/src/components/Lend/supply/index.tsx +144 -0
  78. package/src/components/Lend/withdraw/1-CheckWithdrawble.tsx +73 -0
  79. package/src/components/Lend/withdraw/2-ChooseAmount.tsx +50 -0
  80. package/src/components/Lend/withdraw/3-Transfer.tsx +32 -0
  81. package/src/components/Lend/withdraw/4-Success.tsx +49 -0
  82. package/src/components/Lend/withdraw/index.tsx +101 -0
  83. package/src/components/LoadingModal.tsx +49 -0
  84. package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +57 -0
  85. package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +124 -0
  86. package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +104 -0
  87. package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +65 -0
  88. package/src/components/StreamFactoring/borrow/5-Permit.tsx +144 -0
  89. package/src/components/StreamFactoring/borrow/6-Transfer.tsx +37 -0
  90. package/src/components/StreamFactoring/borrow/7-Success.tsx +20 -0
  91. package/src/components/StreamFactoring/borrow/index.tsx +95 -0
  92. package/src/components/StreamFactoring/payment/ChooseAmount.tsx +54 -0
  93. package/src/components/StreamFactoring/payment/Success.tsx +23 -0
  94. package/src/components/StreamFactoring/payment/Transfer.tsx +34 -0
  95. package/src/components/StreamFactoring/payment/index.tsx +66 -0
  96. package/src/components/SuperfluidFactoring/SuperfluidFactoredList.tsx +61 -0
  97. package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +185 -0
  98. package/src/components/SuperfluidFactoring/index.tsx +85 -0
  99. package/src/components/TxDoneModal.tsx +83 -0
  100. package/src/components/TxSendModal.tsx +59 -0
  101. package/src/components/ViewOnExplorer.tsx +26 -0
  102. package/src/components/WidgetWrapper.tsx +74 -0
  103. package/src/components/WrapperModal.tsx +54 -0
  104. package/src/components/buttons/TableActionButton.tsx +36 -0
  105. package/src/components/buttons/index.ts +1 -0
  106. package/src/components/humaModal/HumaModal.tsx +68 -0
  107. package/src/components/humaModal/HumaModalHeader.tsx +70 -0
  108. package/src/components/humaModal/index.tsx +2 -0
  109. package/src/components/icons/approve-lender.svg +30 -0
  110. package/src/components/icons/auto-payback.svg +40 -0
  111. package/src/components/icons/check-circle.svg +3 -0
  112. package/src/components/icons/check-green.svg +3 -0
  113. package/src/components/icons/check.svg +10 -0
  114. package/src/components/icons/donut.svg +904 -0
  115. package/src/components/icons/ellipse.svg +3 -0
  116. package/src/components/icons/ethereum.svg +1 -0
  117. package/src/components/icons/huma-full.svg +22 -0
  118. package/src/components/icons/huma.svg +15 -0
  119. package/src/components/icons/index.tsx +93 -0
  120. package/src/components/icons/loader.svg +229 -0
  121. package/src/components/icons/metamask.svg +31 -0
  122. package/src/components/icons/polygon.svg +16 -0
  123. package/src/components/icons/receipt.svg +3 -0
  124. package/src/components/icons/separator.svg +3 -0
  125. package/src/components/icons/sorry.svg +31 -0
  126. package/src/components/icons/spinner.gif +0 -0
  127. package/src/components/icons/usdc.svg +5 -0
  128. package/src/components/icons/wallet-connect.svg +12 -0
  129. package/src/cosmos/CreditLineBorrow.fixture.tsx +85 -0
  130. package/src/cosmos/CreditLinePayment.fixture.tsx +49 -0
  131. package/src/cosmos/InvoiceFactoringBorrow.fixture.tsx +111 -0
  132. package/src/cosmos/InvoiceFactoringPayment.fixture.tsx +67 -0
  133. package/src/cosmos/LendSupply.fixture.tsx +75 -0
  134. package/src/cosmos/LendWithdraw.fixture.tsx +43 -0
  135. package/src/cosmos/SDKTesting.fixture.tsx +507 -0
  136. package/src/cosmos/SuperfluidFactoringBorrow.fixture.tsx +12 -0
  137. package/src/cosmos/WalletWrapper.tsx +52 -0
  138. package/src/cosmos/abis/InvoiceNFT.json +644 -0
  139. package/src/cosmos/abis/ReceivableFactoringPool.json +1529 -0
  140. package/src/cosmos/utils/index.ts +169 -0
  141. package/src/fonts/Inter/Inter-Black.ttf +0 -0
  142. package/src/fonts/Inter/Inter-Bold.ttf +0 -0
  143. package/src/fonts/Inter/Inter-ExtraBold.ttf +0 -0
  144. package/src/fonts/Inter/Inter-ExtraLight.ttf +0 -0
  145. package/src/fonts/Inter/Inter-Light.ttf +0 -0
  146. package/src/fonts/Inter/Inter-Medium.ttf +0 -0
  147. package/src/fonts/Inter/Inter-Regular.ttf +0 -0
  148. package/src/fonts/Inter/Inter-SemiBold.ttf +0 -0
  149. package/src/fonts/Inter/Inter-Thin.ttf +0 -0
  150. package/src/fonts/Recoleta/Recoleta-Black.otf +0 -0
  151. package/src/fonts/Recoleta/Recoleta-Bold.otf +0 -0
  152. package/src/fonts/Recoleta/Recoleta-Light.otf +0 -0
  153. package/src/fonts/Recoleta/Recoleta-Medium.otf +0 -0
  154. package/src/fonts/Recoleta/Recoleta-Regular.otf +0 -0
  155. package/src/fonts/Recoleta/Recoleta-RegularDEMO.otf +0 -0
  156. package/src/fonts/Recoleta/Recoleta-SemiBold.otf +0 -0
  157. package/src/fonts/Recoleta/Recoleta-Thin.otf +0 -0
  158. package/src/fonts/Roboto/LICENSE.txt +202 -0
  159. package/src/fonts/Roboto/Roboto-Black.ttf +0 -0
  160. package/src/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
  161. package/src/fonts/Roboto/Roboto-Bold.ttf +0 -0
  162. package/src/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
  163. package/src/fonts/Roboto/Roboto-Italic.ttf +0 -0
  164. package/src/fonts/Roboto/Roboto-Light.ttf +0 -0
  165. package/src/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
  166. package/src/fonts/Roboto/Roboto-Medium.ttf +0 -0
  167. package/src/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  168. package/src/fonts/Roboto/Roboto-Regular.ttf +0 -0
  169. package/src/fonts/Roboto/Roboto-Thin.ttf +0 -0
  170. package/src/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
  171. package/src/fonts/UniNeue/UniNeue-Black.ttf +0 -0
  172. package/src/fonts/UniNeue/UniNeue-Bold.ttf +0 -0
  173. package/src/fonts/UniNeue/UniNeue-Book.ttf +0 -0
  174. package/src/fonts/UniNeue/UniNeue-Heavy.ttf +0 -0
  175. package/src/fonts/UniNeue/UniNeue-Light.ttf +0 -0
  176. package/src/fonts/UniNeue/UniNeue-Regular.ttf +0 -0
  177. package/src/fonts/UniNeue/UniNeue-Thin.ttf +0 -0
  178. package/src/hooks/useEA.ts +70 -0
  179. package/src/hooks/useRedux.ts +6 -0
  180. package/src/index.css +61 -0
  181. package/src/index.tsx +219 -0
  182. package/src/react-app-env.d.ts +1 -0
  183. package/src/reportWebVitals.ts +15 -0
  184. package/src/setupTests.ts +6 -0
  185. package/src/store/index.ts +27 -0
  186. package/src/store/widgets.reducers.ts +120 -0
  187. package/src/store/widgets.selectors.ts +3 -0
  188. package/src/store/widgets.store.ts +55 -0
  189. package/src/theme/breakpoints.ts +10 -0
  190. package/src/theme/components.ts +70 -0
  191. package/src/theme/coreThemeConstants.ts +29 -0
  192. package/src/theme/cssMixins.ts +92 -0
  193. package/src/theme/hooks/useGetSizes.ts +34 -0
  194. package/src/theme/index.ts +24 -0
  195. package/src/theme/palette.ts +150 -0
  196. package/src/theme/shape.ts +7 -0
  197. package/src/theme/theme.types.ts +80 -0
  198. package/src/theme/typography.ts +117 -0
  199. package/src/utilTypes.d.ts +29 -0
  200. package/src/utils/env.ts +9 -0
  201. package/tsconfig.build.json +7 -0
  202. package/tsconfig.json +32 -0
  203. package/webpack.cosmos.js +54 -0
package/jsdoc2md.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "source": {
3
+ "includePattern": ".+\\.ts(doc|x)?$",
4
+ "excludePattern": ".+\\.(test|spec).ts"
5
+ },
6
+ "plugins": ["plugins/markdown", "jsdoc-babel"],
7
+ "babel": {
8
+ "extensions": ["ts", "tsx"],
9
+ "ignore": ["**/*.(test|spec).ts"],
10
+ "babelrc": false,
11
+ "presets": [
12
+ ["@babel/preset-env", { "targets": { "node": true } }],
13
+ "@babel/preset-typescript"
14
+ ],
15
+ "plugins": [
16
+ "@babel/proposal-class-properties",
17
+ "@babel/proposal-object-rest-spread"
18
+ ]
19
+ }
20
+ }
package/package.json ADDED
@@ -0,0 +1,193 @@
1
+ {
2
+ "name": "@huma-finance/widgets",
3
+ "version": "0.0.6-alpha.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/00labs/huma-dapp.git"
10
+ },
11
+ "types": "dist/index.d.ts",
12
+ "main": "dist/cjs/index.cjs",
13
+ "module": "dist/index.js",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js",
18
+ "require": "./dist/cjs/index.cjs"
19
+ }
20
+ },
21
+ "dependencies": {
22
+ "@apollo/client": "^3.7.2",
23
+ "@coinbase/wallet-sdk": "^3.5.3",
24
+ "@emotion/react": "^11.5.0",
25
+ "@emotion/styled": "^11.3.0",
26
+ "@ethersproject/address": "^5.7.0",
27
+ "@ethersproject/bignumber": "^5.6.0",
28
+ "@ethersproject/constants": "^5.7.0",
29
+ "@ethersproject/contracts": "^5.7.0",
30
+ "@ethersproject/experimental": "^5.7.0",
31
+ "@ethersproject/providers": "^5.6.0",
32
+ "@ethersproject/units": "^5.6.0",
33
+ "@mui/icons-material": "^5.3.0",
34
+ "@mui/material": "^5.0.6",
35
+ "@mui/styles": "^5.0.2",
36
+ "@mui/system": "^5.0.6",
37
+ "@mui/x-date-pickers": "^5.0.7",
38
+ "@reduxjs/toolkit": "^1.8.6",
39
+ "@types/utf8": "^3.0.1",
40
+ "@walletconnect/ethereum-provider": "1.8.0",
41
+ "@walletconnect/jsonrpc-http-connection": "^1.0.3",
42
+ "@walletconnect/jsonrpc-provider": "^1.0.5",
43
+ "@web3-react/coinbase-wallet": "8.0.34-beta.0",
44
+ "@web3-react/core": "8.0.35-beta.0",
45
+ "@web3-react/eip1193": "8.0.26-beta.0",
46
+ "@web3-react/empty": "8.0.20-beta.0",
47
+ "@web3-react/gnosis-safe": "8.0.6-beta.0",
48
+ "@web3-react/metamask": "8.0.28-beta.0",
49
+ "@web3-react/network": "8.0.27-beta.0",
50
+ "@web3-react/types": "8.0.20-beta.0",
51
+ "@web3-react/url": "8.0.25-beta.0",
52
+ "@web3-react/walletconnect": "8.0.35-beta.0",
53
+ "buffer": "^6.0.3",
54
+ "customize-cra": "^1.0.0",
55
+ "dayjs": "^1.11.6",
56
+ "encoding": "^0.1.13",
57
+ "ethers": "^5.7.2",
58
+ "formik": "^2.2.9",
59
+ "graphql": "^16.6.0",
60
+ "history": "^5.3.0",
61
+ "jotai": "^1.13.1",
62
+ "moment": "^2.29.4",
63
+ "qrcode": "^1.5.1",
64
+ "query-string": "^7.1.1",
65
+ "react": "^18.2.0",
66
+ "react-app-rewired": "^2.2.1",
67
+ "react-dom": "^18.2.0",
68
+ "react-redux": "^8.0.4",
69
+ "react-router": "^5.2.1",
70
+ "react-router-dom": "^5.3.0",
71
+ "react-scripts": "5.0.1",
72
+ "tslib": "^2.5.0",
73
+ "typescript": "^4.8.4",
74
+ "utf8": "^3.0.0",
75
+ "web-vitals": "^2.1.4",
76
+ "yup": "^0.32.11"
77
+ },
78
+ "scripts": {
79
+ "start": "tsc -w",
80
+ "prebuild": "tsc -p tsconfig.build.json",
81
+ "build": "rollup -c",
82
+ "cosmos": "cosmos",
83
+ "lint-staged": "lint-staged",
84
+ "e2e": "cypress run --config baseUrl=http://localhost:8000 --headed --browser chrome --e2e",
85
+ "generateDocs": "jsdoc2md --files 'src/**/*.tsx' --configure ./jsdoc2md.json > API.md",
86
+ "contracts:compile:abi": "typechain --target ethers-v5 --out-dir src/abis/types \"./src/abis/**/*.json\""
87
+ },
88
+ "husky": {
89
+ "hooks": {
90
+ "pre-commit": "git add . && lint-staged"
91
+ }
92
+ },
93
+ "lint-staged": {
94
+ "src/**/*.{js,ts,tsx,css,sass,less,graphql}": [
95
+ "eslint --fix --max-warnings=0",
96
+ "prettier --write",
97
+ "git add ."
98
+ ]
99
+ },
100
+ "browserslist": {
101
+ "production": [
102
+ ">0.2%",
103
+ "not dead",
104
+ "not op_mini all"
105
+ ],
106
+ "development": [
107
+ "last 1 chrome version",
108
+ "last 1 firefox version",
109
+ "last 1 safari version"
110
+ ]
111
+ },
112
+ "devDependencies": {
113
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.0",
114
+ "@babel/plugin-transform-runtime": "^7.21.0",
115
+ "@babel/preset-react": "^7.14.5",
116
+ "@emotion/babel-plugin": "^11.10.2",
117
+ "@emotion/babel-preset-css-prop": "^11.2.0",
118
+ "@rollup/plugin-babel": "^6.0.3",
119
+ "@rollup/plugin-commonjs": "^24.0.1",
120
+ "@rollup/plugin-image": "^3.0.2",
121
+ "@rollup/plugin-inject": "^5.0.3",
122
+ "@rollup/plugin-json": "^6.0.0",
123
+ "@rollup/plugin-node-resolve": "^15.0.1",
124
+ "@rollup/plugin-typescript": "^11.0.0",
125
+ "@rollup/plugin-url": "^8.0.1",
126
+ "@sentry/webpack-plugin": "^1.20.0",
127
+ "@svgr/rollup": "^6.5.1",
128
+ "@svgr/webpack": "^6.5.1",
129
+ "@testing-library/cypress": "^9.0.0",
130
+ "@testing-library/jest-dom": "^5.16.5",
131
+ "@testing-library/react": "^13.4.0",
132
+ "@testing-library/user-event": "^14.4.3",
133
+ "@typechain/ethers-v5": "^10.1.0",
134
+ "@types/jest": "^27.5.2",
135
+ "@types/node": "^17.0.45",
136
+ "@types/qrcode": "^1.5.0",
137
+ "@types/react": "^18.0.21",
138
+ "@types/react-dom": "^18.0.6",
139
+ "@types/react-router-dom": "^5.3.2",
140
+ "@types/testing-library__cypress": "^5.0.9",
141
+ "@typescript-eslint/eslint-plugin": "^5.41.0",
142
+ "@typescript-eslint/parser": "^5.41.0",
143
+ "assert": "^2.0.0",
144
+ "browserify-zlib": "^0.2.0",
145
+ "buffer": "^6.0.3",
146
+ "connectkit": "^1.2.2",
147
+ "crypto-browserify": "^3.12.0",
148
+ "cypress": "^12.9.0",
149
+ "cypress-iframe": "^1.0.1",
150
+ "dotenv": "^16.0.3",
151
+ "eslint": "^8.2.0",
152
+ "eslint-config-airbnb": "19.0.4",
153
+ "eslint-config-airbnb-typescript": "^17.0.0",
154
+ "eslint-config-prettier": "^8.5.0",
155
+ "eslint-plugin-import": "^2.25.3",
156
+ "eslint-plugin-jest": "^27.1.3",
157
+ "eslint-plugin-jsx-a11y": "^6.5.1",
158
+ "eslint-plugin-prettier": "^4.2.1",
159
+ "eslint-plugin-react": "^7.28.0",
160
+ "eslint-plugin-react-hooks": "^4.3.0",
161
+ "file-loader": "^6.2.0",
162
+ "husky": "^8.0.0",
163
+ "jsdoc": "^4.0.2",
164
+ "jsdoc-babel": "^0.5.0",
165
+ "jsdoc-to-markdown": "^8.0.0",
166
+ "lint-staged": "^10.5.4",
167
+ "node-sass": "^8.0.0",
168
+ "path-browserify": "^1.0.1",
169
+ "prettier": "^2.7.1",
170
+ "react-cosmos": "^5.7.2",
171
+ "rollup-plugin-dts": "^5.2.0",
172
+ "rollup-plugin-node-externals": "^5.1.2",
173
+ "rollup-plugin-peer-deps-external": "^2.2.4",
174
+ "rollup-plugin-polyfill-node": "^0.12.0",
175
+ "rollup-plugin-postcss": "^4.0.2",
176
+ "rollup-plugin-scss": "^4.0.0",
177
+ "stream-browserify": "^3.0.0",
178
+ "typechain": "^8.1.0",
179
+ "url-loader": "^4.1.1",
180
+ "wagmi": "^0.12.10"
181
+ },
182
+ "peerDependencies": {
183
+ "ethers": "^5.6.1",
184
+ "react": ">=16.8.0",
185
+ "react-dom": ">=16.8.0",
186
+ "react-redux": ">=7.2.2",
187
+ "redux": ">=4.1.2"
188
+ },
189
+ "optionalDependencies": {
190
+ "encoding": "^0.1.13"
191
+ },
192
+ "gitHead": "0b1feed2400122e9c08f33e803f941ac48013a65"
193
+ }
Binary file
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta name="description" content="Income backed DeFi for the 99%" />
9
+ <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
10
+ <!--
11
+ manifest.json provides metadata used when your web app is installed on a
12
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
13
+ -->
14
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
15
+ <!--
16
+ Notice the use of %PUBLIC_URL% in the tags above.
17
+ It will be replaced with the URL of the `public` folder during the build.
18
+ Only files inside the `public` folder can be referenced from the HTML.
19
+
20
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
21
+ work correctly both with client-side routing and a non-root public URL.
22
+ Learn how to configure a non-root public URL by running `npm run build`.
23
+ -->
24
+ <title>Huma Finance</title>
25
+ </head>
26
+ <body>
27
+ <noscript>You need to enable JavaScript to run this app.</noscript>
28
+ <div id="root"></div>
29
+ <!--
30
+ This HTML file is a template.
31
+ If you open it directly in the browser, you will see an empty page.
32
+
33
+ You can add webfonts, meta tags, or analytics to this file.
34
+ The build step will place the bundled scripts into the <body> tag.
35
+
36
+ To begin the development, run `npm start` or `yarn start`.
37
+ To create a production bundle, use `npm run build` or `yarn build`.
38
+ -->
39
+ </body>
40
+ </html>
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
@@ -0,0 +1,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
@@ -0,0 +1,81 @@
1
+ const { babel } = require('@rollup/plugin-babel')
2
+ const commonjs = require('@rollup/plugin-commonjs')
3
+ const inject = require('@rollup/plugin-inject')
4
+ const json = require('@rollup/plugin-json')
5
+ const { nodeResolve: resolve } = require('@rollup/plugin-node-resolve')
6
+ const { default: dts } = require('rollup-plugin-dts')
7
+ const url = require('@rollup/plugin-url')
8
+ const svgr = require('@svgr/rollup')
9
+ const externals = require('rollup-plugin-node-externals')
10
+ const sass = require('rollup-plugin-scss')
11
+
12
+ const EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx']
13
+
14
+ const transpile = {
15
+ input: 'src/index.tsx',
16
+ external: (source) => {
17
+ return source.startsWith('@ethersproject/')
18
+ },
19
+ plugins: [
20
+ externals({
21
+ exclude: [/\.json$/, /\.css$/],
22
+ deps: true,
23
+ peerDeps: true,
24
+ }),
25
+ resolve({ extensions: EXTENSIONS }),
26
+ json(),
27
+ url({ include: ['**/*.png', '**/*.svg', '**/*.gif'], limit: Infinity }),
28
+ svgr({ jsxRuntime: 'automatic' }),
29
+ sass(),
30
+ commonjs(),
31
+
32
+ babel({
33
+ babelHelpers: 'runtime',
34
+ extensions: EXTENSIONS,
35
+ }),
36
+ inject({ React: 'react' }),
37
+ ],
38
+ onwarn: (warning, warn) => {
39
+ if (warning.code === 'UNUSED_EXTERNAL_IMPORT') return
40
+ if (warning.code === 'THIS_IS_UNDEFINED') return
41
+ if (warning.code === 'CIRCULAR_DEPENDENCY') return
42
+
43
+ warn(warning)
44
+ console.log(warning.loc, '\n')
45
+ },
46
+ }
47
+
48
+ const esm = {
49
+ ...transpile,
50
+ output: {
51
+ file: 'dist/index.js',
52
+ format: 'esm',
53
+ sourcemap: true,
54
+ },
55
+ }
56
+
57
+ const cjs = {
58
+ ...transpile,
59
+ output: {
60
+ dir: 'dist/cjs',
61
+ entryFileNames: '[name].cjs',
62
+ chunkFileNames: '[name]-[hash].cjs',
63
+ format: 'cjs',
64
+ sourcemap: true,
65
+ },
66
+ watch: false,
67
+ }
68
+
69
+ const types = {
70
+ input: 'dts/index.d.ts',
71
+ output: { file: 'dist/index.d.ts' },
72
+ external: (source) =>
73
+ source.endsWith('.css') || source.endsWith('/external.d.ts'),
74
+ plugins: [dts({ compilerOptions: { baseUrl: 'dts' } })],
75
+ watch: false,
76
+ }
77
+
78
+ const config = [esm, cjs, types]
79
+ config.config = { ...esm, output: { ...esm.output, sourcemap: true } }
80
+
81
+ module.exports = config
@@ -0,0 +1,123 @@
1
+ import { gql, useQuery } from '@apollo/client'
2
+ import { Box, css } from '@mui/material'
3
+ import { useWeb3React } from '@web3-react/core'
4
+ import {
5
+ CreditEvent,
6
+ CreditEventText,
7
+ downScale,
8
+ PoolInfoType,
9
+ timeUtil,
10
+ useMQ,
11
+ } from '@huma-finance/shared'
12
+ import { useEffect, useState } from 'react'
13
+
14
+ import { HumaTable } from './HumaTable'
15
+
16
+ const GET_ACTIVITY = gql`
17
+ query GetCreditLineActivity($pool: String!, $owner: String!, $event: [Int]!) {
18
+ creditEvents(
19
+ where: { pool: $pool, owner: $owner, event_in: $event }
20
+ orderBy: timestamp
21
+ orderDirection: desc
22
+ ) {
23
+ id
24
+ amount
25
+ timestamp
26
+ owner
27
+ pool
28
+ event
29
+ }
30
+ }
31
+ `
32
+
33
+ type Props = {
34
+ poolInfo: PoolInfoType
35
+ targetEvents: CreditEvent[]
36
+ }
37
+
38
+ type ActivityDataType = {
39
+ id: string
40
+ owner: string
41
+ pool: string
42
+ timestamp: string
43
+ amount: string
44
+ event: number
45
+ eventText: string | undefined
46
+ }
47
+
48
+ const columns = [
49
+ { title: 'Action', dataIndex: 'eventText', noSeparator: true },
50
+ { title: 'Amount', dataIndex: 'amount' },
51
+ { title: 'Date', dataIndex: 'timestamp' },
52
+ ]
53
+
54
+ export function Activity({
55
+ poolInfo,
56
+ targetEvents,
57
+ }: Props): React.ReactElement | null {
58
+ const { account } = useWeb3React()
59
+ const { decimals } = poolInfo.poolUnderlyingToken
60
+ const [events, setEvents] = useState<ActivityDataType[] | undefined>()
61
+ const { data } = useQuery<{
62
+ creditEvents: ActivityDataType[]
63
+ }>(GET_ACTIVITY, {
64
+ variables: {
65
+ pool: poolInfo.pool,
66
+ owner: account,
67
+ event: targetEvents,
68
+ },
69
+ })
70
+ const { isSmSize } = useMQ()
71
+
72
+ const getPadding = () => {
73
+ if (isSmSize) {
74
+ return '16px 24px'
75
+ }
76
+ return '33px 48px'
77
+ }
78
+
79
+ useEffect(() => {
80
+ if (!data?.creditEvents) {
81
+ return
82
+ }
83
+ const result = data.creditEvents.map((item) => {
84
+ const event = JSON.parse(JSON.stringify(item)) as ActivityDataType
85
+ event.eventText = CreditEventText[item.event]
86
+ event.amount = downScale(event.amount, decimals)
87
+ event.timestamp = timeUtil.timestampToLL(Number(event.timestamp))
88
+ return event
89
+ })
90
+ setEvents(result)
91
+ }, [data?.creditEvents, decimals])
92
+
93
+ const styles = {
94
+ wrapper: css`
95
+ margin-top: 71px;
96
+ `,
97
+ title: css`
98
+ font-family: 'Uni-Neue-Black';
99
+ font-size: 24px;
100
+ color: #6b6572;
101
+ margin-bottom: 14px;
102
+ `,
103
+ tableWrapper: css`
104
+ background: #ffffff;
105
+ box-shadow: 0px 4px 40px 8px rgba(0, 0, 0, 0.04);
106
+ border-radius: 24px;
107
+ padding: ${getPadding()};
108
+ `,
109
+ }
110
+
111
+ if (!events) {
112
+ return null
113
+ }
114
+
115
+ return (
116
+ <Box css={styles.wrapper}>
117
+ <Box css={styles.title}>Recent Activity</Box>
118
+ <Box css={styles.tableWrapper}>
119
+ <HumaTable columns={columns} rows={events} hideRowsPerPage={isSmSize} />
120
+ </Box>
121
+ </Box>
122
+ )
123
+ }
@@ -0,0 +1,113 @@
1
+ import { Box, Button, css, useTheme } from '@mui/material'
2
+ import { useWeb3React } from '@web3-react/core'
3
+ import {
4
+ EARejectMessageWithAllowList,
5
+ EARejectReason,
6
+ EAService,
7
+ PoolInfoType,
8
+ } from '@huma-finance/shared'
9
+ import React, { useCallback, useState } from 'react'
10
+
11
+ import { CustomError } from '../utilTypes'
12
+ import { ErrorModal } from './ErrorModal'
13
+ import { CheckCircleIcon } from './icons'
14
+ import { LoadingModal } from './LoadingModal'
15
+ import { WrapperModal } from './WrapperModal'
16
+
17
+ type Props = {
18
+ poolInfo: PoolInfoType
19
+ handleSuccess: () => void
20
+ handleError: (errorMessage: string) => void
21
+ }
22
+
23
+ export function AllowListModal({
24
+ poolInfo,
25
+ handleSuccess,
26
+ handleError,
27
+ }: Props): React.ReactElement | null {
28
+ const theme = useTheme()
29
+ const { account } = useWeb3React()
30
+ const [status, setStatus] = useState<
31
+ 'notApproved' | 'approving' | 'approved'
32
+ >('notApproved')
33
+
34
+ const styles = {
35
+ congratsWrapper: css`
36
+ font-family: 'Uni-Neue-Regular';
37
+ font-size: 16px;
38
+ padding: 0 16px;
39
+ ${theme.cssMixins.rowVCentered}
40
+ margin-top: 60px;
41
+ height: 52px;
42
+ background: linear-gradient(
43
+ 0deg,
44
+ rgba(255, 255, 255, 0.9),
45
+ rgba(255, 255, 255, 0.9)
46
+ ),
47
+ #2e7d32;
48
+ border-radius: 4px;
49
+ `,
50
+ bottom: css`
51
+ & .MuiButtonBase-root {
52
+ width: 100%;
53
+ position: absolute;
54
+ bottom: 0;
55
+ }
56
+ `,
57
+ }
58
+
59
+ const addToAllowList = useCallback(async () => {
60
+ try {
61
+ setStatus('approving')
62
+ await EAService.addToAllowList(account!, poolInfo.pool)
63
+ setStatus('approved')
64
+ } catch (e) {
65
+ const error = e as CustomError
66
+ handleError(error.message)
67
+ }
68
+ }, [account, handleError, poolInfo.pool])
69
+
70
+ const continueToBorrow = () => {
71
+ handleSuccess()
72
+ }
73
+
74
+ if (status === 'approving') {
75
+ return (
76
+ <LoadingModal
77
+ title='Add To Allowlist'
78
+ description='Waiting for approval confirmation...'
79
+ />
80
+ )
81
+ }
82
+
83
+ if (status === 'approved') {
84
+ return (
85
+ <WrapperModal title='Add To Allowlist'>
86
+ <>
87
+ <Box css={styles.congratsWrapper}>
88
+ <CheckCircleIcon />
89
+ <Box sx={{ marginLeft: '6px' }}>
90
+ Congrats, you have been added to the allowlist
91
+ </Box>
92
+ </Box>
93
+ <Box css={styles.bottom}>
94
+ <Button variant='contained' onClick={continueToBorrow}>
95
+ CONTINUE TO BORROW
96
+ </Button>
97
+ </Box>
98
+ </>
99
+ </WrapperModal>
100
+ )
101
+ }
102
+
103
+ return (
104
+ <ErrorModal
105
+ title='Application Not Approved'
106
+ errorReason={EARejectReason}
107
+ errorMessage={EARejectMessageWithAllowList}
108
+ handleOk={addToAllowList}
109
+ okText='ADD ME TO ALLOWLIST'
110
+ shouldResetState={false}
111
+ />
112
+ )
113
+ }
@@ -0,0 +1,15 @@
1
+ import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client'
2
+
3
+ import { WCProps } from '../utilTypes'
4
+
5
+ export function ApolloWrapper({
6
+ uri,
7
+ children,
8
+ }: WCProps<{ uri: string }>): React.ReactElement | null {
9
+ const client = new ApolloClient({
10
+ uri,
11
+ cache: new InMemoryCache(),
12
+ })
13
+
14
+ return <ApolloProvider client={client}>{children}</ApolloProvider>
15
+ }