@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
@@ -0,0 +1,507 @@
1
+ /* eslint-disable jsx-a11y/label-has-associated-control */
2
+ /* eslint-disable react/jsx-boolean-value */
3
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
+ import { useEffect, useState } from 'react'
5
+ import {
6
+ EAService,
7
+ useCreditRecordDetails,
8
+ useReceivableFactoringPoolContract,
9
+ mintReceivableWithMetadata,
10
+ queryForMetadata,
11
+ } from '@huma-finance/sdk'
12
+ import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared'
13
+ import { useAccount } from 'wagmi'
14
+ import { ethers, getDefaultProvider } from 'ethers'
15
+ import { Web3Provider } from '@ethersproject/providers'
16
+
17
+ import { WalletWrapper } from './WalletWrapper'
18
+
19
+ const TEST_PRIVATE_KEY =
20
+ '66667f446ba85d3e9e8fc0d0ce195e49089de15178ff7a42fe3e78ac3c3ad85c'
21
+
22
+ function Fixture() {
23
+ const { address, connector } = useAccount()
24
+ const [chainId, setChainId] = useState(0)
25
+ const [signer, setSigner] = useState<Web3Provider | null>(null)
26
+
27
+ // useCreditRecordDetails
28
+ const [userAddress, setUserAddress] = useState('')
29
+ const [poolName, setPoolName] = useState<POOL_NAME>(POOL_NAME.RequestNetwork)
30
+ const [poolType, setPoolType] = useState<POOL_TYPE>(POOL_TYPE.Invoice)
31
+ const [creditRecordDetails, refreshCreditRecordDetails] =
32
+ useCreditRecordDetails(
33
+ userAddress,
34
+ getDefaultProvider(),
35
+ chainId,
36
+ poolName,
37
+ poolType,
38
+ )
39
+
40
+ // mintReceivableWithMetadata
41
+ const [recipientAddress, setRecipientAddress] = useState(address)
42
+ const [receivableAmount, setReceivableAmount] = useState(100)
43
+ const [maturityDate, setMaturityDate] = useState(Date.now())
44
+ const [paymentMethod, setPaymentMethod] = useState(0)
45
+ const [metadata, setMetadata] = useState(JSON.stringify({ exampleKey: 1 }))
46
+ // Used to set an example tag on the metadata uploaded to ARweave which we can use to query by later
47
+ const [internalID, setInternalID] = useState('3')
48
+ const [mintResult, setMintResult] = useState<any>('')
49
+
50
+ // useReceivableFactoringPoolContract
51
+ const poolContract = useReceivableFactoringPoolContract(
52
+ signer!,
53
+ chainId,
54
+ POOL_NAME.RequestNetwork,
55
+ )
56
+
57
+ // EAService.approve
58
+ const [borrowerAddress, setBorrowerAddress] = useState('')
59
+ const [receivableAddress, setReceivableAddress] = useState(
60
+ '0xC2AC172a293d68f548ea343414584aA37eb29Dcd',
61
+ )
62
+ const [receivableParam, setReceivableParam] = useState('')
63
+ const [approveResult, setApproveResult] = useState<any>('')
64
+
65
+ const [queryResult, setQueryResult] = useState<any>('')
66
+
67
+ useEffect(() => {
68
+ ;(async () => {
69
+ if (address && connector && window.ethereum) {
70
+ setChainId(await connector.getChainId())
71
+ setRecipientAddress(address)
72
+ const tmp = new ethers.providers.Web3Provider(window.ethereum)
73
+ setSigner(tmp)
74
+ }
75
+ })()
76
+ }, [address, connector])
77
+
78
+ const handleRefreshCreditRecordDetailsSubmit = (event: any) => {
79
+ event.preventDefault()
80
+ refreshCreditRecordDetails()
81
+ }
82
+
83
+ const handleEAApproveSubmit = async (event: any) => {
84
+ event.preventDefault()
85
+ try {
86
+ const data = await EAService.approve(
87
+ {
88
+ poolAddress: poolContract!.address,
89
+ borrowerWalletAddress: borrowerAddress,
90
+ receivableAddress,
91
+ receivableParam,
92
+ },
93
+ 5,
94
+ )
95
+ setApproveResult('Success')
96
+ console.log(data)
97
+ } catch (error) {
98
+ setApproveResult('Failed')
99
+ console.log(error)
100
+ }
101
+ }
102
+
103
+ const handleMintReceivableWithMetadataSubmit = async (event: any) => {
104
+ event.preventDefault()
105
+
106
+ if (signer === null) return
107
+
108
+ try {
109
+ const data = await mintReceivableWithMetadata(
110
+ signer,
111
+ TEST_PRIVATE_KEY,
112
+ chainId,
113
+ address!,
114
+ poolName,
115
+ poolType,
116
+ receivableAmount,
117
+ maturityDate,
118
+ paymentMethod,
119
+ JSON.parse(metadata),
120
+ internalID,
121
+ [],
122
+ )
123
+ setMintResult(`Success, Tx Hash: ${data.transactionHash}`)
124
+ console.log(data)
125
+ } catch (error) {
126
+ setMintResult(`Failed, check console for errors`)
127
+ console.log(error)
128
+ }
129
+ }
130
+
131
+ const queryARWeaveSubmit = async (event: any) => {
132
+ event.preventDefault()
133
+
134
+ if (address == null) return
135
+
136
+ try {
137
+ const data = await queryForMetadata(
138
+ chainId,
139
+ poolName,
140
+ poolType,
141
+ address,
142
+ internalID,
143
+ )
144
+ setQueryResult(data)
145
+ console.log(data)
146
+ } catch (error) {
147
+ setQueryResult(`Failed, check console for errors`)
148
+ console.log(error)
149
+ }
150
+ }
151
+
152
+ return (
153
+ <div
154
+ style={{
155
+ fontFamily: 'Helvetica',
156
+ display: 'flex',
157
+ flexDirection: 'column',
158
+ gap: '15px',
159
+ }}
160
+ >
161
+ <div
162
+ style={{
163
+ border: '1px solid gray',
164
+ padding: '0px 10px 20px 10px',
165
+ borderRadius: '10px',
166
+ }}
167
+ >
168
+ <h3>Test useCreditRecordDetails</h3>
169
+ <form
170
+ onSubmit={handleRefreshCreditRecordDetailsSubmit}
171
+ style={{ display: 'flex', flexDirection: 'column', gap: '5px' }}
172
+ >
173
+ <label>
174
+ Network: <input disabled type='text' defaultValue='Goerli' />
175
+ </label>
176
+ <br />
177
+ <label>
178
+ User Address:
179
+ <input
180
+ type='text'
181
+ value={userAddress}
182
+ onChange={(event: any) => {
183
+ setUserAddress(event.target.value)
184
+ }}
185
+ />
186
+ </label>
187
+ <br />
188
+ <label>
189
+ Pool Name:
190
+ <select
191
+ name='pool_name'
192
+ value={poolName}
193
+ onChange={(event: any) => {
194
+ setPoolName(event.target.value)
195
+ }}
196
+ >
197
+ <option value='RequestNetwork'>RequestNetwork</option>
198
+ <option value='HumaCreditLine'>HumaCreditLine</option>
199
+ <option value='Superfluid'>Superfluid</option>
200
+ <option value='Jia'>Jia</option>
201
+ </select>
202
+ </label>
203
+ <br />
204
+ <label>
205
+ Pool Type:
206
+ <select
207
+ name='pool_type'
208
+ value={poolType}
209
+ onChange={(event: any) => {
210
+ setPoolType(event.target.value)
211
+ }}
212
+ >
213
+ <option value='Invoice'>Invoice</option>
214
+ <option value='CreditLine'>CreditLine</option>
215
+ <option value='Stream'>Stream</option>
216
+ </select>
217
+ </label>
218
+ <br />
219
+ <button type='submit' style={{ width: 'fit-content' }}>
220
+ Get Credit Record Details
221
+ </button>
222
+ </form>
223
+ {creditRecordDetails && (
224
+ <div>
225
+ <h2>Credit Record Details:</h2>
226
+ <ul>aprInBps: {creditRecordDetails.aprInBps}</ul>
227
+ <ul>correction: {creditRecordDetails.correction.toString()}</ul>
228
+ <ul>creditLimit: {creditRecordDetails.creditLimit.toString()}</ul>
229
+ <ul>
230
+ defaultAmount: {creditRecordDetails.defaultAmount.toString()}
231
+ </ul>
232
+ <ul>dueDate: {creditRecordDetails.dueDate.toString()}</ul>
233
+ <ul>
234
+ feesAndInterestDue:{' '}
235
+ {creditRecordDetails.feesAndInterestDue.toString()}
236
+ </ul>
237
+ <ul>intervalInDays: {creditRecordDetails.intervalInDays}</ul>
238
+ <ul>missedPeriods: {creditRecordDetails.missedPeriods}</ul>
239
+ <ul>remainingPeriods: {creditRecordDetails.remainingPeriods}</ul>
240
+ <ul>state: {creditRecordDetails.state}</ul>
241
+ <ul>totalDue: {creditRecordDetails.totalDue.toString()}</ul>
242
+ <ul>
243
+ unbilledPrincipal:{' '}
244
+ {creditRecordDetails.unbilledPrincipal.toString()}
245
+ </ul>
246
+ </div>
247
+ )}
248
+ </div>
249
+ <div
250
+ style={{
251
+ border: '1px solid gray',
252
+ padding: '0px 10px 20px 10px',
253
+ borderRadius: '10px',
254
+ }}
255
+ >
256
+ <h3>Test useReceivableFactoringPoolContract</h3>
257
+ {poolContract?.address}
258
+ </div>
259
+ <div
260
+ style={{
261
+ border: '1px solid gray',
262
+ padding: '0px 10px 20px 10px',
263
+ borderRadius: '10px',
264
+ }}
265
+ >
266
+ <form
267
+ onSubmit={handleEAApproveSubmit}
268
+ style={{ display: 'flex', flexDirection: 'column', gap: '5px' }}
269
+ >
270
+ <h3>Test EAService.approve</h3>
271
+ <label>
272
+ Borrower Address:
273
+ <input
274
+ type='text'
275
+ value={borrowerAddress}
276
+ onChange={(event: any) => {
277
+ setBorrowerAddress(event.target.value)
278
+ }}
279
+ />
280
+ </label>
281
+ <br />
282
+ <label>
283
+ Receivable Address:
284
+ <input
285
+ type='text'
286
+ value={receivableAddress}
287
+ onChange={(event: any) => {
288
+ setReceivableAddress(event.target.value)
289
+ }}
290
+ />
291
+ </label>
292
+ <br />
293
+ <label>
294
+ Receivable Parameter (Token ID):
295
+ <input
296
+ type='text'
297
+ value={receivableParam}
298
+ onChange={(event: any) => {
299
+ setReceivableParam(event.target.value)
300
+ }}
301
+ />
302
+ </label>
303
+ <br />
304
+ <button type='submit' style={{ width: 'fit-content' }}>
305
+ Get Credit Record Details
306
+ </button>
307
+ </form>
308
+ {approveResult}
309
+ </div>
310
+ <div
311
+ style={{
312
+ border: '1px solid gray',
313
+ padding: '0px 10px 20px 10px',
314
+ borderRadius: '10px',
315
+ }}
316
+ >
317
+ <form
318
+ onSubmit={handleMintReceivableWithMetadataSubmit}
319
+ style={{ display: 'flex', flexDirection: 'column', gap: '5px' }}
320
+ >
321
+ <h3>Test mintReceivableWithMetadata</h3>
322
+ <label>
323
+ Recipient Address:
324
+ <input
325
+ type='text'
326
+ value={recipientAddress}
327
+ onChange={(event: any) => {
328
+ setRecipientAddress(event.target.value)
329
+ }}
330
+ />
331
+ </label>
332
+ <br />
333
+ <label>
334
+ Pool Name:
335
+ <select
336
+ name='pool_name'
337
+ value={poolName}
338
+ onChange={(event: any) => {
339
+ setPoolName(event.target.value)
340
+ }}
341
+ >
342
+ <option value='RequestNetwork'>RequestNetwork</option>
343
+ <option value='HumaCreditLine'>HumaCreditLine</option>
344
+ <option value='Superfluid'>Superfluid</option>
345
+ <option value='Jia'>Jia</option>
346
+ </select>
347
+ </label>
348
+ <br />
349
+ <label>
350
+ Pool Type:
351
+ <select
352
+ name='pool_type'
353
+ value={poolType}
354
+ onChange={(event: any) => {
355
+ setPoolType(event.target.value)
356
+ }}
357
+ >
358
+ <option value='Invoice'>Invoice</option>
359
+ <option value='CreditLine'>CreditLine</option>
360
+ <option value='Stream'>Stream</option>
361
+ </select>
362
+ </label>
363
+ <br />
364
+ <label>
365
+ Receivable Amount:
366
+ <input
367
+ type='text'
368
+ value={receivableAmount}
369
+ onChange={(event: any) => {
370
+ setReceivableAmount(event.target.value)
371
+ }}
372
+ />
373
+ </label>
374
+ <label>
375
+ Maturity Date:
376
+ <input
377
+ type='text'
378
+ value={maturityDate}
379
+ onChange={(event: any) => {
380
+ setMaturityDate(event.target.value)
381
+ }}
382
+ />
383
+ </label>
384
+ <br />
385
+ <label>
386
+ Payment Method:
387
+ <select
388
+ name='payment_method'
389
+ value={paymentMethod}
390
+ onChange={(event: any) => {
391
+ setPaymentMethod(event.target.value)
392
+ }}
393
+ >
394
+ <option value='0'>Declarative</option>
395
+ <option value='1'>Payable</option>
396
+ </select>
397
+ </label>
398
+ <br />
399
+ <label>
400
+ Metadata:
401
+ <input
402
+ type='text'
403
+ value={metadata}
404
+ onChange={(event: any) => {
405
+ setMetadata(event.target.value)
406
+ }}
407
+ />
408
+ </label>
409
+ <br />
410
+ <label>
411
+ Internal ID (For querying through ARWeave):
412
+ <input
413
+ type='text'
414
+ value={internalID}
415
+ onChange={(event: any) => {
416
+ setInternalID(event.target.value)
417
+ }}
418
+ />
419
+ </label>
420
+ <button type='submit' style={{ width: 'fit-content' }}>
421
+ Mint Receivable With Metadata
422
+ </button>
423
+ <br />
424
+ {mintResult}
425
+ </form>
426
+ {approveResult}
427
+ </div>
428
+ <div
429
+ style={{
430
+ border: '1px solid gray',
431
+ padding: '0px 10px 20px 10px',
432
+ borderRadius: '10px',
433
+ }}
434
+ >
435
+ <h3>Test queryForMetadata</h3>
436
+ <form
437
+ onSubmit={queryARWeaveSubmit}
438
+ style={{ display: 'flex', flexDirection: 'column', gap: '5px' }}
439
+ >
440
+ <label>
441
+ Transaction sender:
442
+ <input type='text' value={address} disabled />
443
+ </label>
444
+ <br />
445
+ <label>
446
+ Pool Name:
447
+ <select
448
+ name='pool_name'
449
+ value={poolName}
450
+ onChange={(event: any) => {
451
+ setPoolName(event.target.value)
452
+ }}
453
+ >
454
+ <option value='RequestNetwork'>RequestNetwork</option>
455
+ <option value='HumaCreditLine'>HumaCreditLine</option>
456
+ <option value='Superfluid'>Superfluid</option>
457
+ <option value='Jia'>Jia</option>
458
+ </select>
459
+ </label>
460
+ <br />
461
+ <label>
462
+ Pool Type:
463
+ <select
464
+ name='pool_type'
465
+ value={poolType}
466
+ onChange={(event: any) => {
467
+ setPoolType(event.target.value)
468
+ }}
469
+ >
470
+ <option value='Invoice'>Invoice</option>
471
+ <option value='CreditLine'>CreditLine</option>
472
+ <option value='Stream'>Stream</option>
473
+ </select>
474
+ </label>
475
+ <label>
476
+ Internal ID (For querying through ARWeave):
477
+ <input
478
+ type='text'
479
+ value={internalID}
480
+ onChange={(event: any) => {
481
+ setInternalID(event.target.value)
482
+ }}
483
+ />
484
+ </label>
485
+ <br />
486
+ <button type='submit' style={{ width: 'fit-content' }}>
487
+ Query Metadata
488
+ </button>
489
+ <br />
490
+ <a
491
+ href={`https://arweave.net/${queryResult}`}
492
+ target='_blank'
493
+ rel='noreferrer'
494
+ >
495
+ {queryResult}
496
+ </a>
497
+ </form>
498
+ </div>
499
+ </div>
500
+ )
501
+ }
502
+
503
+ export default (
504
+ <WalletWrapper>
505
+ <Fixture />
506
+ </WalletWrapper>
507
+ )
@@ -0,0 +1,12 @@
1
+ import { SuperfluidFactoringWidget } from '..'
2
+ import { WalletWrapper } from './WalletWrapper'
3
+
4
+ function Fixture() {
5
+ return <SuperfluidFactoringWidget />
6
+ }
7
+
8
+ export default (
9
+ <WalletWrapper>
10
+ <Fixture />
11
+ </WalletWrapper>
12
+ )
@@ -0,0 +1,52 @@
1
+ /* eslint-disable @typescript-eslint/no-use-before-define */
2
+ import { Button } from '@mui/material'
3
+ import { getDefaultClient } from 'connectkit'
4
+ import {
5
+ createClient,
6
+ goerli,
7
+ useAccount,
8
+ useConnect,
9
+ useDisconnect,
10
+ WagmiConfig,
11
+ } from 'wagmi'
12
+ import { InjectedConnector } from 'wagmi/connectors/injected'
13
+
14
+ const client = createClient(
15
+ getDefaultClient({
16
+ autoConnect: true,
17
+ appName: 'huma widget',
18
+ chains: [goerli],
19
+ }),
20
+ )
21
+
22
+ export function WalletWrapper({ children }: { children: React.ReactNode }) {
23
+ return (
24
+ <WagmiConfig client={client}>
25
+ <Profile />
26
+ {children}
27
+ </WagmiConfig>
28
+ )
29
+ }
30
+
31
+ function Profile() {
32
+ const { address, isConnected } = useAccount()
33
+ const { connect } = useConnect({
34
+ connector: new InjectedConnector(),
35
+ })
36
+ const { disconnect } = useDisconnect()
37
+
38
+ if (isConnected)
39
+ return (
40
+ <div>
41
+ Account: {address}
42
+ <Button variant='contained' onClick={() => disconnect()}>
43
+ Disconnect
44
+ </Button>
45
+ </div>
46
+ )
47
+ return (
48
+ <Button variant='contained' onClick={() => connect()}>
49
+ Connect Wallet
50
+ </Button>
51
+ )
52
+ }