@huma-finance/widgets 0.0.8 → 0.0.11

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 (76) hide show
  1. package/dist/cjs/index.cjs +139 -131
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/index.js +139 -131
  4. package/dist/index.js.map +1 -1
  5. package/package.json +4 -4
  6. package/src/components/Activity.tsx +123 -123
  7. package/src/components/AllowListModal.tsx +113 -113
  8. package/src/components/ApproveAllowanceModal.tsx +118 -118
  9. package/src/components/ChooseAmountModal.tsx +315 -315
  10. package/src/components/CreditLine/borrow/1-Evaluation.tsx +158 -159
  11. package/src/components/CreditLine/borrow/2-AllowList.tsx +34 -34
  12. package/src/components/CreditLine/borrow/3-ChooseAmount.tsx +74 -74
  13. package/src/components/CreditLine/borrow/4-ApproveAllowance.tsx +29 -29
  14. package/src/components/CreditLine/borrow/5-Transfer.tsx +30 -30
  15. package/src/components/CreditLine/borrow/6-Success.tsx +30 -30
  16. package/src/components/CreditLine/borrow/index.tsx +119 -119
  17. package/src/components/CreditLine/payment/1-ChooseAmount.tsx +67 -67
  18. package/src/components/CreditLine/payment/2-ApproveAllowance.tsx +23 -23
  19. package/src/components/CreditLine/payment/3-Transfer.tsx +34 -34
  20. package/src/components/CreditLine/payment/4-Success.tsx +39 -39
  21. package/src/components/CreditLine/payment/index.tsx +94 -94
  22. package/src/components/ErrorModal.tsx +132 -132
  23. package/src/components/Factoring/FactoredList.tsx +143 -143
  24. package/src/components/Factoring/UpcomingList.tsx +90 -90
  25. package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +52 -46
  26. package/src/components/InvoiceFactoring/borrow/2-AllowList.tsx +34 -34
  27. package/src/components/InvoiceFactoring/borrow/3-ChooseAmount.tsx +86 -92
  28. package/src/components/InvoiceFactoring/borrow/4-ConfirmTransfer.tsx +104 -104
  29. package/src/components/InvoiceFactoring/borrow/5-ApproveNFT.tsx +55 -55
  30. package/src/components/InvoiceFactoring/borrow/6-Transfer.tsx +34 -34
  31. package/src/components/InvoiceFactoring/borrow/7-Success.tsx +3 -3
  32. package/src/components/InvoiceFactoring/borrow/index.tsx +96 -96
  33. package/src/components/InvoiceFactoring/payment/1-ChooseAmount.tsx +67 -67
  34. package/src/components/InvoiceFactoring/payment/2-ApproveAllowance.tsx +23 -23
  35. package/src/components/InvoiceFactoring/payment/3-Transfer.tsx +34 -34
  36. package/src/components/InvoiceFactoring/payment/4-Success.tsx +23 -23
  37. package/src/components/InvoiceFactoring/payment/index.tsx +86 -86
  38. package/src/components/Lend/supply/1-Evaluation.tsx +86 -86
  39. package/src/components/Lend/supply/2-ChooseAmount.tsx +70 -70
  40. package/src/components/Lend/supply/3-ApproveAllowance.tsx +25 -25
  41. package/src/components/Lend/supply/4-ConfirmTransfer.tsx +104 -104
  42. package/src/components/Lend/supply/6-Transfer.tsx +32 -32
  43. package/src/components/Lend/supply/7-Success.tsx +49 -49
  44. package/src/components/Lend/supply/index.tsx +144 -144
  45. package/src/components/Lend/withdraw/1-CheckWithdrawble.tsx +73 -73
  46. package/src/components/Lend/withdraw/2-ChooseAmount.tsx +50 -50
  47. package/src/components/Lend/withdraw/3-Transfer.tsx +32 -32
  48. package/src/components/Lend/withdraw/4-Success.tsx +49 -49
  49. package/src/components/Lend/withdraw/index.tsx +101 -101
  50. package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +47 -57
  51. package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +124 -124
  52. package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +104 -104
  53. package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +65 -65
  54. package/src/components/StreamFactoring/borrow/5-Permit.tsx +144 -144
  55. package/src/components/StreamFactoring/borrow/6-Transfer.tsx +37 -37
  56. package/src/components/StreamFactoring/borrow/7-Success.tsx +2 -2
  57. package/src/components/StreamFactoring/borrow/index.tsx +94 -95
  58. package/src/components/StreamFactoring/payment/ChooseAmount.tsx +54 -54
  59. package/src/components/StreamFactoring/payment/Success.tsx +23 -23
  60. package/src/components/StreamFactoring/payment/Transfer.tsx +34 -34
  61. package/src/components/StreamFactoring/payment/index.tsx +66 -66
  62. package/src/components/SuperfluidFactoring/SuperfluidFactoredList.tsx +61 -61
  63. package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +185 -185
  64. package/src/components/SuperfluidFactoring/index.tsx +85 -85
  65. package/src/components/TxDoneModal.tsx +83 -83
  66. package/src/components/TxSendModal.tsx +59 -59
  67. package/src/components/ViewOnExplorer.tsx +26 -26
  68. package/src/components/WidgetWrapper.tsx +74 -74
  69. package/src/components/humaModal/HumaModal.tsx +68 -68
  70. package/src/cosmos/SDKTesting.fixture.tsx +557 -515
  71. package/src/hooks/useEA.ts +72 -70
  72. package/src/index.tsx +219 -219
  73. package/src/store/widgets.reducers.ts +120 -120
  74. package/src/store/widgets.store.ts +55 -55
  75. package/src/theme/components.ts +1 -1
  76. package/src/theme/hooks/useGetSizes.ts +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/widgets",
3
- "version": "0.0.8",
3
+ "version": "0.0.11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,8 +30,8 @@
30
30
  "@ethersproject/experimental": "^5.7.0",
31
31
  "@ethersproject/providers": "^5.6.0",
32
32
  "@ethersproject/units": "^5.6.0",
33
- "@huma-finance/sdk": "^0.0.8",
34
- "@huma-finance/shared": "^0.0.8",
33
+ "@huma-finance/sdk": "^0.0.11",
34
+ "@huma-finance/shared": "^0.0.11",
35
35
  "@mui/icons-material": "^5.3.0",
36
36
  "@mui/material": "^5.0.6",
37
37
  "@mui/styles": "^5.0.2",
@@ -191,5 +191,5 @@
191
191
  "optionalDependencies": {
192
192
  "encoding": "^0.1.13"
193
193
  },
194
- "gitHead": "d9e7878a7b163ccc5b29959eb8a0fbb73c988244"
194
+ "gitHead": "12afb4430fa58ad8403bde9aadb52c7ddb1f048c"
195
195
  }
@@ -1,123 +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
- }
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
+ }
@@ -1,113 +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
- }
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
+ }