@huma-finance/widgets 0.0.13 → 0.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/widgets",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
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.13",
34
- "@huma-finance/shared": "^0.0.13",
33
+ "@huma-finance/sdk": "^0.0.15",
34
+ "@huma-finance/shared": "^0.0.15",
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": "d4c4b86cde3f84209204f8f926de995bb07a1bd2"
194
+ "gitHead": "2a3b42fb7373cc84c02cc14057fbe66465ac0988"
195
195
  }
@@ -5,14 +5,16 @@ import { HumaModal, HumaModalHeader } from './humaModal'
5
5
 
6
6
  type Props = {
7
7
  handleClose: () => void
8
+ isOpen: boolean
8
9
  }
9
10
 
10
11
  export function ChainNotSupportedModal({
11
12
  handleClose,
13
+ isOpen,
12
14
  }: Props): React.ReactElement | null {
13
15
  return (
14
16
  <HumaModal
15
- isOpen
17
+ isOpen={isOpen}
16
18
  overflowY='auto'
17
19
  onClose={handleClose}
18
20
  width='480px'
@@ -30,7 +30,7 @@ export function Evaluation({
30
30
  receivable: {
31
31
  address: poolInfo.assetAddress!,
32
32
  },
33
- payerAddress,
33
+ payerWalletAddress: payerAddress,
34
34
  superToken,
35
35
  },
36
36
  },
@@ -1,6 +1,6 @@
1
1
  import { EmotionJSX } from '@emotion/react/types/jsx-namespace'
2
2
  import { AccountStats, PoolInfoType } from '@huma-finance/shared'
3
- import React from 'react'
3
+ import React, { useCallback } from 'react'
4
4
 
5
5
  import { ColumnType } from '../../utilTypes'
6
6
  import { FactoredList } from '../Factoring'
@@ -48,6 +48,14 @@ export function SuperfluidFactoredList({
48
48
  accountStats,
49
49
  handlePayManually,
50
50
  }: Props): React.ReactElement {
51
+ const setItem = useCallback(
52
+ () =>
53
+ Promise.resolve({
54
+ name: poolInfo?.extra?.superTokens?.[0].symbol ?? '',
55
+ }),
56
+ [poolInfo?.extra?.superTokens],
57
+ )
58
+
51
59
  return (
52
60
  <FactoredList
53
61
  title='Streams'
@@ -56,6 +64,7 @@ export function SuperfluidFactoredList({
56
64
  handlePayManually={handlePayManually}
57
65
  getColumns={getColumns}
58
66
  accountStats={accountStats}
67
+ setItem={setItem}
59
68
  />
60
69
  )
61
70
  }
@@ -1,16 +1,14 @@
1
1
  import { gql, useQuery } from '@apollo/client'
2
2
  import { EmotionJSX } from '@emotion/react/types/jsx-namespace'
3
- import { Button } from '@mui/material'
4
- import { useWeb3React } from '@web3-react/core'
5
- import { History } from 'history'
6
3
  import {
7
4
  downScale,
8
5
  getWalletAddressAbbr,
9
6
  PoolInfoType,
10
7
  toBigNumber,
11
8
  } from '@huma-finance/shared'
9
+ import { Button } from '@mui/material'
10
+ import { useWeb3React } from '@web3-react/core'
12
11
  import React, { useCallback, useEffect, useState } from 'react'
13
- import { useHistory } from 'react-router'
14
12
 
15
13
  import { ColumnType } from '../../utilTypes'
16
14
  import { TableActionButton } from '../buttons'
@@ -71,7 +69,6 @@ type Props = {
71
69
  const getUpcomingColumns = (
72
70
  userHasActiveLoan: boolean,
73
71
  handleGetPaid: (id: StreamItem) => void,
74
- history: History,
75
72
  ): ColumnType<StreamItem>[] => [
76
73
  {
77
74
  title: '',
@@ -86,20 +83,6 @@ const getUpcomingColumns = (
86
83
  dataIndex: 'payerAbbr',
87
84
  },
88
85
  { title: 'Flow rate', dataIndex: 'flowrateMonth' },
89
- {
90
- title: 'Payer Approve',
91
- action: (record) => (
92
- <TableActionButton
93
- title='Go To Approve'
94
- handleClick={() =>
95
- history.push(
96
- `/superfluid?payer=${record.payer}&superToken=${record.tokenId}`,
97
- )
98
- }
99
- disabled={userHasActiveLoan}
100
- />
101
- ),
102
- },
103
86
  {
104
87
  title: 'Get Paid',
105
88
  action: (record) => (
@@ -118,7 +101,6 @@ export function SuperfluidUpcomingList({
118
101
  loading,
119
102
  handleGetPaid,
120
103
  }: Props): React.ReactElement {
121
- const history = useHistory()
122
104
  const { account, isActive } = useWeb3React()
123
105
  const [streams, setStreams] = useState<StreamItem[] | undefined>()
124
106
  const { data } = useQuery<{ streams: Stream[] }>(GET_RECEIVED_STREAMS, {
@@ -161,7 +143,7 @@ export function SuperfluidUpcomingList({
161
143
  <UpcomingList<StreamItem>
162
144
  items={streams}
163
145
  loading={loading}
164
- columns={getUpcomingColumns(hasActiveLoan, handleGetPaid, history)}
146
+ columns={getUpcomingColumns(hasActiveLoan, handleGetPaid)}
165
147
  title='Ongoing Streams'
166
148
  connectWalletDesc='Please connect wallet to check your ongoing streams.'
167
149
  noItemDesc='You don’t have any ongoing streams eligible for factoring. For now, you can click the button
package/src/index.tsx CHANGED
@@ -60,14 +60,26 @@ type WidgetProps = {
60
60
  }
61
61
 
62
62
  function Widget(props: WCProps<WidgetProps>) {
63
- const { children, desiredChainId, handleClose } = props
64
- const netWorkVersion =
65
- // @ts-ignore
66
- window.ethereum?.networkVersion || window.ethereum?.chainId
63
+ const { children, desiredChainId } = props
64
+ // @ts-ignore
65
+ const netWorkVersion = window.ethereum?.networkVersion
67
66
  const [currentChainId, setCurrentChainId] = useState<number | undefined>(
68
67
  netWorkVersion ? Number(netWorkVersion) : undefined,
69
68
  )
70
69
  const chainSupported = !!supportedChainId(currentChainId)
70
+ const [chainNotSupportedOpen, setChainNotSupportedOpen] = useState(false)
71
+
72
+ useEffect(() => {
73
+ setCurrentChainId(netWorkVersion ? Number(netWorkVersion) : undefined)
74
+ }, [netWorkVersion])
75
+
76
+ useEffect(() => {
77
+ if (chainSupported) {
78
+ setChainNotSupportedOpen(false)
79
+ } else {
80
+ setChainNotSupportedOpen(true)
81
+ }
82
+ }, [chainSupported])
71
83
 
72
84
  useEffect(() => {
73
85
  const chainChangeListener = (chainId: number) => {
@@ -108,16 +120,17 @@ function Widget(props: WCProps<WidgetProps>) {
108
120
  }, [currentChainId, desiredChainId])
109
121
 
110
122
  const handleCloseCallback = useCallback(() => {
111
- if (handleClose) {
112
- handleClose()
113
- }
114
- }, [handleClose])
123
+ setChainNotSupportedOpen(false)
124
+ }, [])
115
125
 
116
126
  if (!chainSupported) {
117
127
  return (
118
128
  <ThemeProvider theme={themeHuma}>
119
129
  <ReduxProvider store={store}>
120
- <ChainNotSupportedModal handleClose={handleCloseCallback} />
130
+ <ChainNotSupportedModal
131
+ isOpen={chainNotSupportedOpen}
132
+ handleClose={handleCloseCallback}
133
+ />
121
134
  </ReduxProvider>
122
135
  </ThemeProvider>
123
136
  )