@huma-finance/widgets 0.0.43-beta.122 → 0.0.43-beta.125

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.43-beta.122+c9ac2ce",
3
+ "version": "0.0.43-beta.125+a289bbf",
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.42",
34
- "@huma-finance/shared": "^0.0.42",
33
+ "@huma-finance/sdk": "^0.0.43-beta.125+a289bbf",
34
+ "@huma-finance/shared": "^0.0.43-beta.125+a289bbf",
35
35
  "@mui/icons-material": "^5.3.0",
36
36
  "@mui/material": "^5.0.6",
37
37
  "@mui/styles": "^5.0.2",
@@ -192,5 +192,5 @@
192
192
  "optionalDependencies": {
193
193
  "encoding": "^0.1.13"
194
194
  },
195
- "gitHead": "c9ac2ce4c0d689146c54d3db561fb30ffd62eec3"
195
+ "gitHead": "a289bbfb4c4be42aa42fc0d23f88fada1a064844"
196
196
  }
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 27.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 250 250" style="enable-background:new 0 0 250 250;" xml:space="preserve">
5
+ <style type="text/css">
6
+ .stcelo{fill:#FCFF52;}
7
+ </style>
8
+ <circle class="stcelo" cx="125" cy="125" r="125"/>
9
+ <path d="M188.9,60.7H60.7v128.2h128.2v-44.8h-21.3c-7.3,16.3-23.8,27.7-42.7,27.7c-26,0-47.1-21.3-47.1-47.1c0-25.9,21.1-47,47.1-47
10
+ c19.3,0,35.8,11.7,43.1,28.4h20.9V60.7z"/>
11
+ </svg>
@@ -16,6 +16,7 @@ import { ReactComponent as AutoPaybackSvg } from './auto-payback.svg'
16
16
  import { ReactComponent as ApproveLenderSvg } from './approve-lender.svg'
17
17
  import { ReactComponent as DonutSvg } from './donut.svg'
18
18
  import { ReactComponent as UsdcSvg } from './usdc.svg'
19
+ import { ReactComponent as CeloSvg } from './celo.svg'
19
20
 
20
21
  export function HumaIcon(props: SvgIconProps): React.ReactElement {
21
22
  return <HumaLogoSvg {...props} />
@@ -85,9 +86,17 @@ export function UsdcIcon(props: SvgIconProps): React.ReactElement {
85
86
  return <UsdcSvg {...props} />
86
87
  }
87
88
 
89
+ export function CeloIcon(props: SvgIconProps): React.ReactElement {
90
+ return <CeloSvg {...props} />
91
+ }
92
+
88
93
  export function getIcon(icon: string) {
89
- if (icon === 'USDC') {
90
- return UsdcIcon
91
- }
92
- return null
94
+ if (!icon) return null
95
+
96
+ return (
97
+ {
98
+ USDC: UsdcIcon,
99
+ Celo: CeloIcon,
100
+ }[icon] || null
101
+ )
93
102
  }
@@ -10,6 +10,27 @@ import {
10
10
  newFrontendClient,
11
11
  } from '@notifi-network/notifi-frontend-client'
12
12
 
13
+ export const useDoesChainSupportNotifi = (
14
+ account: string | undefined,
15
+ chainId: number | undefined,
16
+ ) => {
17
+ const [notifiChainSupported, setNotifiChainSupported] = useState(false)
18
+
19
+ useEffect(() => {
20
+ const checkNotifiChainSupported = async () => {
21
+ if (account != null && chainId != null) {
22
+ setNotifiChainSupported(
23
+ doesChainSupportNotifi(chainId, checkIsDev(), account),
24
+ )
25
+ }
26
+ }
27
+
28
+ checkNotifiChainSupported()
29
+ }, [account, chainId])
30
+
31
+ return { notifiChainSupported }
32
+ }
33
+
13
34
  export const useNotifiClient = (
14
35
  account: string | undefined,
15
36
  chainId: number | undefined,
@@ -18,10 +39,11 @@ export const useNotifiClient = (
18
39
  const [notifiClient, setNotifiClient] = useState<NotifiFrontendClient | null>(
19
40
  null,
20
41
  )
42
+ const { notifiChainSupported } = useDoesChainSupportNotifi(account, chainId)
21
43
 
22
44
  useEffect(() => {
23
45
  const createNotifiClient = async () => {
24
- if (account != null && chainId != null) {
46
+ if (account != null && chainId != null && notifiChainSupported) {
25
47
  const client = newFrontendClient({
26
48
  account: { publicKey: account },
27
49
  tenantId: getNotifiDappId(isDev),
@@ -34,7 +56,7 @@ export const useNotifiClient = (
34
56
  }
35
57
 
36
58
  createNotifiClient()
37
- }, [account, chainId, isDev])
59
+ }, [account, chainId, isDev, notifiChainSupported])
38
60
 
39
61
  return { notifiClient }
40
62
  }
@@ -45,10 +67,11 @@ export const useIsFirstTimeNotifiUser = (
45
67
  ) => {
46
68
  const [isFirstTimeNotifiUser, setIsFirstTimeNotifiUser] = useState(false)
47
69
  const { notifiClient } = useNotifiClient(account, chainId, checkIsDev())
70
+ const { notifiChainSupported } = useDoesChainSupportNotifi(account, chainId)
48
71
 
49
72
  useEffect(() => {
50
73
  const checkIsFirstTimeNotifiUser = async () => {
51
- if (notifiClient != null) {
74
+ if (notifiClient != null && notifiChainSupported) {
52
75
  const { userState } = notifiClient
53
76
  // If the user is not authenticated or expired, they are a first time user
54
77
  if (
@@ -71,28 +94,7 @@ export const useIsFirstTimeNotifiUser = (
71
94
  }
72
95
 
73
96
  checkIsFirstTimeNotifiUser()
74
- }, [notifiClient])
97
+ }, [notifiChainSupported, notifiClient])
75
98
 
76
99
  return { isFirstTimeNotifiUser }
77
100
  }
78
-
79
- export const useDoesChainSupportNotifi = (
80
- account: string | undefined,
81
- chainId: number | undefined,
82
- ) => {
83
- const [notifiChainSupported, setNotifiChainSupported] = useState(false)
84
-
85
- useEffect(() => {
86
- const checkNotifiChainSupported = async () => {
87
- if (account != null && chainId != null) {
88
- setNotifiChainSupported(
89
- doesChainSupportNotifi(chainId, checkIsDev(), account),
90
- )
91
- }
92
- }
93
-
94
- checkNotifiChainSupported()
95
- }, [account, chainId])
96
-
97
- return { notifiChainSupported }
98
- }