@huma-finance/widgets 0.0.7 → 0.0.10
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.
- package/.env.example +2 -2
- package/.eslintignore +2 -2
- package/.eslintrc.js +64 -64
- package/.prettierignore +4 -4
- package/.prettierrc.js +16 -16
- package/API.md +331 -331
- package/LICENSE +660 -660
- package/README.md +48 -48
- package/babel.config.js +15 -15
- package/config-overrides.js +9 -9
- package/cosmos.config.json +7 -7
- package/cypress/e2e/01-invoice-factoring-borrow.test.ts +62 -62
- package/cypress/support/e2e.ts +76 -76
- package/cypress/support/ethereum.ts +142 -142
- package/cypress/tsconfig.json +9 -9
- package/cypress/utils/index.ts +54 -54
- package/cypress.config.ts +20 -20
- package/jsdoc2md.json +20 -20
- package/package.json +4 -4
- package/public/index.html +40 -40
- package/public/manifest.json +25 -25
- package/public/robots.txt +3 -3
- package/rollup.config.js +81 -81
- package/src/components/ApolloWrapper.tsx +15 -15
- package/src/components/BottomButton.tsx +31 -31
- package/src/components/Factoring/index.ts +2 -2
- package/src/components/HumaLoading.tsx +68 -68
- package/src/components/HumaTable.tsx +158 -158
- package/src/components/InvoiceFactoring/borrow/3-ChooseAmount.tsx +13 -19
- package/src/components/InvoiceFactoring/borrow/4-ConfirmTransfer.tsx +3 -3
- package/src/components/InvoiceFactoring/borrow/7-Success.tsx +20 -20
- package/src/components/Lend/supply/4-ConfirmTransfer.tsx +3 -3
- package/src/components/LoadingModal.tsx +49 -49
- package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +11 -11
- package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +3 -3
- package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +2 -2
- package/src/components/StreamFactoring/borrow/7-Success.tsx +20 -20
- package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +1 -1
- package/src/components/SuperfluidFactoring/index.tsx +1 -1
- package/src/components/WrapperModal.tsx +54 -54
- package/src/components/buttons/TableActionButton.tsx +36 -36
- package/src/components/buttons/index.ts +1 -1
- package/src/components/humaModal/HumaModalHeader.tsx +70 -70
- package/src/components/humaModal/index.tsx +2 -2
- package/src/components/icons/approve-lender.svg +30 -30
- package/src/components/icons/auto-payback.svg +40 -40
- package/src/components/icons/check-circle.svg +3 -3
- package/src/components/icons/check-green.svg +3 -3
- package/src/components/icons/check.svg +10 -10
- package/src/components/icons/donut.svg +904 -904
- package/src/components/icons/ellipse.svg +3 -3
- package/src/components/icons/huma-full.svg +22 -22
- package/src/components/icons/huma.svg +15 -15
- package/src/components/icons/index.tsx +93 -93
- package/src/components/icons/loader.svg +229 -229
- package/src/components/icons/metamask.svg +31 -31
- package/src/components/icons/polygon.svg +16 -16
- package/src/components/icons/receipt.svg +3 -3
- package/src/components/icons/separator.svg +3 -3
- package/src/components/icons/sorry.svg +31 -31
- package/src/components/icons/usdc.svg +5 -5
- package/src/components/icons/wallet-connect.svg +11 -11
- package/src/cosmos/CreditLineBorrow.fixture.tsx +85 -85
- package/src/cosmos/CreditLinePayment.fixture.tsx +49 -49
- package/src/cosmos/InvoiceFactoringBorrow.fixture.tsx +111 -111
- package/src/cosmos/InvoiceFactoringPayment.fixture.tsx +67 -67
- package/src/cosmos/LendSupply.fixture.tsx +75 -75
- package/src/cosmos/LendWithdraw.fixture.tsx +43 -43
- package/src/cosmos/SDKTesting.fixture.tsx +32 -23
- package/src/cosmos/SuperfluidFactoringBorrow.fixture.tsx +12 -12
- package/src/cosmos/WalletWrapper.tsx +52 -52
- package/src/cosmos/abis/InvoiceNFT.json +644 -644
- package/src/cosmos/abis/ReceivableFactoringPool.json +1529 -1529
- package/src/cosmos/utils/index.ts +169 -169
- package/src/fonts/Recoleta/Recoleta-Black.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Bold.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Light.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Medium.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Regular.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-RegularDEMO.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-SemiBold.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Thin.otf +0 -0
- package/src/hooks/useEA.ts +11 -9
- package/src/hooks/useRedux.ts +6 -6
- package/src/index.css +61 -61
- package/src/index.tsx +1 -7
- package/src/react-app-env.d.ts +1 -1
- package/src/reportWebVitals.ts +15 -15
- package/src/setupTests.ts +6 -6
- package/src/store/index.ts +27 -27
- package/src/store/widgets.reducers.ts +7 -7
- package/src/store/widgets.selectors.ts +3 -3
- package/src/store/widgets.store.ts +2 -2
- package/src/theme/breakpoints.ts +10 -10
- package/src/theme/components.ts +70 -70
- package/src/theme/coreThemeConstants.ts +29 -29
- package/src/theme/cssMixins.ts +92 -92
- package/src/theme/hooks/useGetSizes.ts +31 -34
- package/src/theme/index.ts +24 -24
- package/src/theme/palette.ts +150 -150
- package/src/theme/shape.ts +7 -7
- package/src/theme/theme.types.ts +80 -80
- package/src/theme/typography.ts +117 -117
- package/src/utilTypes.d.ts +29 -29
- package/src/utils/env.ts +9 -9
- package/tsconfig.build.json +7 -7
- package/tsconfig.json +32 -32
- package/webpack.cosmos.js +54 -54
- package/dist/assets/output-15e10f9f.css +0 -44
- package/dist/cjs/assets/output-15e10f9f.css +0 -44
- package/dist/cjs/index.cjs +0 -17576
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -211
- package/dist/index.js +0 -17529
- package/dist/index.js.map +0 -1
|
@@ -5,37 +5,45 @@ import { useEffect, useState } from 'react'
|
|
|
5
5
|
import {
|
|
6
6
|
EAService,
|
|
7
7
|
useCreditRecordDetails,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
usePoolContract,
|
|
9
|
+
ARWeaveService,
|
|
10
|
+
ReceivableService,
|
|
11
11
|
} from '@huma-finance/sdk'
|
|
12
12
|
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared'
|
|
13
13
|
import { useAccount } from 'wagmi'
|
|
14
|
-
import { ethers
|
|
15
|
-
import { Web3Provider } from '@ethersproject/providers'
|
|
14
|
+
import { ethers } from 'ethers'
|
|
15
|
+
import { JsonRpcProvider, Web3Provider } from '@ethersproject/providers'
|
|
16
16
|
|
|
17
17
|
import { WalletWrapper } from './WalletWrapper'
|
|
18
18
|
|
|
19
|
-
const TEST_PRIVATE_KEY =
|
|
20
|
-
|
|
19
|
+
const TEST_PRIVATE_KEY = 'REPLACE_WITH_YOUR_PRIVATE_KEY'
|
|
20
|
+
const INFURA_PROVIDER_KEY = 'REPLACE_WITH_YOUR_INFURA_PROVIDER_KEY'
|
|
21
21
|
|
|
22
22
|
function Fixture() {
|
|
23
23
|
const { address, connector } = useAccount()
|
|
24
24
|
const [chainId, setChainId] = useState(0)
|
|
25
25
|
const [signer, setSigner] = useState<Web3Provider | null>(null)
|
|
26
26
|
|
|
27
|
+
if (TEST_PRIVATE_KEY === 'REPLACE_WITH_YOUR_PRIVATE_KEY') {
|
|
28
|
+
console.error('Please replace TEST_PRIVATE_KEY with your own private key')
|
|
29
|
+
}
|
|
30
|
+
if (INFURA_PROVIDER_KEY === 'REPLACE_WITH_YOUR_INFURA_PROVIDER_KEY') {
|
|
31
|
+
console.error('Please replace INFURA_PROVIDER_KEY with your own key')
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
// useCreditRecordDetails
|
|
28
35
|
const [userAddress, setUserAddress] = useState('')
|
|
29
36
|
const [poolName, setPoolName] = useState<POOL_NAME>(POOL_NAME.RequestNetwork)
|
|
30
37
|
const [poolType, setPoolType] = useState<POOL_TYPE>(POOL_TYPE.Invoice)
|
|
38
|
+
const provider = new JsonRpcProvider(
|
|
39
|
+
`https://goerli.infura.io/v3/${INFURA_PROVIDER_KEY}`,
|
|
40
|
+
{
|
|
41
|
+
name: 'goerli',
|
|
42
|
+
chainId: 5,
|
|
43
|
+
},
|
|
44
|
+
)
|
|
31
45
|
const [creditRecordDetails, refreshCreditRecordDetails] =
|
|
32
|
-
useCreditRecordDetails(
|
|
33
|
-
userAddress,
|
|
34
|
-
getDefaultProvider(),
|
|
35
|
-
chainId,
|
|
36
|
-
poolName,
|
|
37
|
-
poolType,
|
|
38
|
-
)
|
|
46
|
+
useCreditRecordDetails(userAddress, provider, chainId, poolName, poolType)
|
|
39
47
|
|
|
40
48
|
// mintReceivableWithMetadata
|
|
41
49
|
const [recipientAddress, setRecipientAddress] = useState(address)
|
|
@@ -47,11 +55,12 @@ function Fixture() {
|
|
|
47
55
|
const [internalID, setInternalID] = useState('3')
|
|
48
56
|
const [mintResult, setMintResult] = useState<any>('')
|
|
49
57
|
|
|
50
|
-
//
|
|
51
|
-
const poolContract =
|
|
58
|
+
// usePoolContract
|
|
59
|
+
const poolContract = usePoolContract(
|
|
52
60
|
signer!,
|
|
53
61
|
chainId,
|
|
54
62
|
POOL_NAME.RequestNetwork,
|
|
63
|
+
POOL_TYPE.Invoice,
|
|
55
64
|
)
|
|
56
65
|
|
|
57
66
|
// EAService.approve
|
|
@@ -69,6 +78,7 @@ function Fixture() {
|
|
|
69
78
|
if (address && connector && window.ethereum) {
|
|
70
79
|
setChainId(await connector.getChainId())
|
|
71
80
|
setRecipientAddress(address)
|
|
81
|
+
// @ts-ignore
|
|
72
82
|
const tmp = new ethers.providers.Web3Provider(window.ethereum)
|
|
73
83
|
setSigner(tmp)
|
|
74
84
|
}
|
|
@@ -106,11 +116,10 @@ function Fixture() {
|
|
|
106
116
|
if (signer === null) return
|
|
107
117
|
|
|
108
118
|
try {
|
|
109
|
-
const data = await mintReceivableWithMetadata(
|
|
119
|
+
const data = await ReceivableService.mintReceivableWithMetadata(
|
|
110
120
|
signer,
|
|
111
|
-
TEST_PRIVATE_KEY
|
|
121
|
+
TEST_PRIVATE_KEY!,
|
|
112
122
|
chainId,
|
|
113
|
-
address!,
|
|
114
123
|
poolName,
|
|
115
124
|
poolType,
|
|
116
125
|
receivableAmount,
|
|
@@ -134,7 +143,7 @@ function Fixture() {
|
|
|
134
143
|
if (address == null) return
|
|
135
144
|
|
|
136
145
|
try {
|
|
137
|
-
const data = await queryForMetadata(
|
|
146
|
+
const data = await ARWeaveService.queryForMetadata(
|
|
138
147
|
chainId,
|
|
139
148
|
poolName,
|
|
140
149
|
poolType,
|
|
@@ -253,7 +262,7 @@ function Fixture() {
|
|
|
253
262
|
borderRadius: '10px',
|
|
254
263
|
}}
|
|
255
264
|
>
|
|
256
|
-
<h3>Test
|
|
265
|
+
<h3>Test usePoolContract</h3>
|
|
257
266
|
{poolContract?.address}
|
|
258
267
|
</div>
|
|
259
268
|
<div
|
|
@@ -408,7 +417,7 @@ function Fixture() {
|
|
|
408
417
|
</label>
|
|
409
418
|
<br />
|
|
410
419
|
<label>
|
|
411
|
-
|
|
420
|
+
Reference ID (For querying through ARWeave):
|
|
412
421
|
<input
|
|
413
422
|
type='text'
|
|
414
423
|
value={internalID}
|
|
@@ -473,7 +482,7 @@ function Fixture() {
|
|
|
473
482
|
</select>
|
|
474
483
|
</label>
|
|
475
484
|
<label>
|
|
476
|
-
|
|
485
|
+
Reference ID (For querying through ARWeave):
|
|
477
486
|
<input
|
|
478
487
|
type='text'
|
|
479
488
|
value={internalID}
|
|
@@ -1,12 +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
|
-
)
|
|
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
|
+
)
|
|
@@ -1,52 +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
|
-
}
|
|
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
|
+
}
|