From b811c0316cb46eb85cb5afa896a58bf507141df4 Mon Sep 17 00:00:00 2001 From: Michael Liu Date: Wed, 7 Aug 2024 17:36:06 -0400 Subject: [PATCH 1/8] Notifi V2 --- packages/huma-widget/package.json | 2 +- .../Notifi/NotifiSubscriptionModal.tsx | 82 ++++++------------- .../src/theme/coreThemeConstants.ts | 2 +- 3 files changed, 25 insertions(+), 61 deletions(-) diff --git a/packages/huma-widget/package.json b/packages/huma-widget/package.json index be075a3..d24effd 100644 --- a/packages/huma-widget/package.json +++ b/packages/huma-widget/package.json @@ -37,7 +37,7 @@ "@mui/styles": "^5.0.2", "@mui/system": "^5.0.6", "@mui/x-date-pickers": "^5.0.7", - "@notifi-network/notifi-frontend-client": "^0.91.1", + "@notifi-network/notifi-frontend-client": "^1.0.1", "@reduxjs/toolkit": "^1.8.6", "@types/utf8": "^3.0.1", "@walletconnect/ethereum-provider": "1.8.0", diff --git a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx index 3bffc53..a0677c1 100644 --- a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx +++ b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx @@ -1,9 +1,10 @@ -import { getBlockchainConfigFromChain, txAtom } from '@huma-finance/shared' +import { + ChainEnum, + getBlockchainConfigFromChain, + txAtom, +} from '@huma-finance/shared' import { Box, css, TextField, Typography, useTheme } from '@mui/material' import { - BroadcastEventTypeItem, - CardConfigItemV1, - DirectPushEventTypeItem, EventTypeItem, NotifiFrontendClient, SignMessageParams, @@ -26,58 +27,23 @@ type Props = { handleSuccess: () => void } -function getIdFromEventType(eventType: EventTypeItem): string { - if (eventType.type === 'directPush') { - const directPushEventType = eventType as DirectPushEventTypeItem - return ( - directPushEventType.directPushId as { - value: string - } - ).value - } - if (eventType.type === 'broadcast') { - const broadcastEventType = eventType as BroadcastEventTypeItem - return ( - broadcastEventType.broadcastId as { - value: string - } - ).value - } - - return '' -} - async function fetchEventTypes( notifiClient: NotifiFrontendClient, -): Promise<(EventTypeItem & { enabled: boolean })[]> { - const subscribedAlerts = await notifiClient.getAlerts() + chainId: number | undefined, +): Promise { + let cardId = '' + if (chainId === ChainEnum.Celo || chainId === ChainEnum.Alfajores) { + cardId = process.env.REACT_APP_NOTIFI_CONFIG_ID_CELO ?? '' + } else if (chainId === ChainEnum.Polygon || chainId === ChainEnum.Amoy) { + cardId = process.env.REACT_APP_NOTIFI_CONFIG_ID_POLYGON ?? '' + } - const subscriptionConfig = (await notifiClient.fetchSubscriptionCard({ - id: process.env.REACT_APP_NOTIFI_CONFIG_ID ?? '', + const subscriptionConfig = await notifiClient.fetchTenantConfig({ + id: cardId ?? '', type: 'SUBSCRIPTION_CARD', - })) as CardConfigItemV1 - - const eventTypes = subscriptionConfig?.eventTypes?.map( - (eventType): EventTypeItem & { enabled: boolean } => { - const eventTypeId = getIdFromEventType(eventType) - let enabled = false - // Check whether the user is subscribed to the event - const subscribedAlert = subscribedAlerts?.find( - (alert) => alert.filterOptions.indexOf(eventTypeId) >= 0, - ) - - if (subscribedAlert) { - enabled = true - } + }) - return { - ...eventType, - enabled, - } - }, - ) - - return eventTypes + return subscriptionConfig.cardConfig.eventTypes as EventTypeItem[] } export function NotifiSubscriptionModal({ @@ -125,9 +91,9 @@ export function NotifiSubscriptionModal({ } // Fetch all event types - const fetchedEventTypes = await fetchEventTypes(notifiClient) + const fetchedEventTypes = await fetchEventTypes(notifiClient, chainId) - // Authorize this email address for this wallet + // Authorize this email address for this wallet await notifiClient.ensureTargetGroup({ name: 'Default', emailAddress: emailAddress!, @@ -203,11 +169,7 @@ export function NotifiSubscriptionModal({ return ( - + Connect your emails to receive important update about your account. @@ -217,7 +179,9 @@ export function NotifiSubscriptionModal({ type='email' value={emailAddress} onChange={handleEmailAddressChange} - variant='standard' + variant='outlined' + color='primary' + focused /> diff --git a/packages/huma-widget/src/theme/coreThemeConstants.ts b/packages/huma-widget/src/theme/coreThemeConstants.ts index ef1a214..0c8e27d 100644 --- a/packages/huma-widget/src/theme/coreThemeConstants.ts +++ b/packages/huma-widget/src/theme/coreThemeConstants.ts @@ -3,7 +3,7 @@ export const coreThemeConstants = { md: 4, }, fontFamily: [ - 'Roboto', + 'Red-Hat-Display', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', From 98e48761e730c0521c5756deb0aa5f86f9c9b415 Mon Sep 17 00:00:00 2001 From: Michael Liu Date: Tue, 13 Aug 2024 10:14:21 -0400 Subject: [PATCH 2/8] Updates --- packages/huma-widget/package.json | 2 + .../Notifi/NotifiContextWrapper.tsx | 7 +- .../Notifi/NotifiSubscriptionModal.tsx | 5 + packages/huma-widget/src/index.tsx | 2 + yarn.lock | 300 +++++++++++++++++- 5 files changed, 313 insertions(+), 3 deletions(-) diff --git a/packages/huma-widget/package.json b/packages/huma-widget/package.json index a9e350d..2ac5b22 100644 --- a/packages/huma-widget/package.json +++ b/packages/huma-widget/package.json @@ -25,6 +25,7 @@ "@emotion/styled": "^11.3.0", "@ethersproject/address": "^5.7.0", "@ethersproject/bignumber": "^5.6.0", + "@ethersproject/bytes": "^5.7.0", "@ethersproject/constants": "^5.7.0", "@ethersproject/contracts": "^5.7.0", "@ethersproject/experimental": "^5.7.0", @@ -39,6 +40,7 @@ "@mui/system": "^5.0.6", "@mui/x-date-pickers": "^5.0.7", "@notifi-network/notifi-frontend-client": "^1.0.1", + "@notifi-network/notifi-react": "^1.1.1", "@reduxjs/toolkit": "^1.8.6", "@types/utf8": "^3.0.1", "@walletconnect/ethereum-provider": "1.8.0", diff --git a/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx b/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx index 3347259..06d1775 100644 --- a/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx +++ b/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx @@ -1,3 +1,4 @@ +import { arrayify } from '@ethersproject/bytes' import { ChainEnum, getBlockchainConfigFromChain } from '@huma-finance/shared' import { NotifiContextProvider } from '@notifi-network/notifi-react' import { useWeb3React } from '@web3-react/core' @@ -5,13 +6,15 @@ import { providers } from 'ethers' import React, { useMemo } from 'react' type Props = { - chainId: ChainEnum + chainId: number + // eslint-disable-next-line @typescript-eslint/no-explicit-any + children?: any } export function NotifiContextWrapper({ chainId, children, -}: React.PropsWithChildren): React.ReactElement | null { +}: Props): React.ReactElement | null { const { account, provider } = useWeb3React() const signer = useMemo(() => { if (provider instanceof providers.JsonRpcProvider) { diff --git a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx index 1b89f4d..4021b4b 100644 --- a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx +++ b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx @@ -33,6 +33,11 @@ async function fetchEventTypes( cardId = process.env.REACT_APP_NOTIFI_CONFIG_ID_CELO ?? '' } else if (chainId === ChainEnum.Polygon || chainId === ChainEnum.Amoy) { cardId = process.env.REACT_APP_NOTIFI_CONFIG_ID_POLYGON ?? '' + } else if ( + chainId === ChainEnum.Scroll || + chainId === ChainEnum.ScrollSepolia + ) { + cardId = process.env.REACT_APP_NOTIFI_CONFIG_ID_SCROLL ?? '' } const subscriptionConfig = await notifiClient.fetchTenantConfig({ diff --git a/packages/huma-widget/src/index.tsx b/packages/huma-widget/src/index.tsx index 27db1c5..9b3a87b 100644 --- a/packages/huma-widget/src/index.tsx +++ b/packages/huma-widget/src/index.tsx @@ -528,3 +528,5 @@ export function ReceivableBackedCreditLinePaymentWidgetV2( ) } + +export * from './components/Notifi/NotifiContextWrapper' diff --git a/yarn.lock b/yarn.lock index 60f0150..dad17ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1225,6 +1225,13 @@ dependencies: regenerator-runtime "^0.14.0" +"@babel/runtime@^7.21.0": + version "7.25.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.25.0.tgz#3af9a91c1b739c569d5d80cc917280919c544ecb" + integrity sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw== + dependencies: + regenerator-runtime "^0.14.0" + "@babel/template@^7.18.10", "@babel/template@^7.22.15", "@babel/template@^7.3.3": version "7.22.15" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.15.tgz#09576efc3830f0430f4548ef971dde1350ef2f38" @@ -2084,6 +2091,11 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" +"@fastify/busboy@^2.0.0": + version "2.1.1" + resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d" + integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA== + "@floating-ui/core@^1.5.3": version "1.5.3" resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.5.3.tgz#b6aa0827708d70971c8679a16cf680a515b8a52a" @@ -3626,6 +3638,11 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== +"@noble/secp256k1@1.7.1", "@noble/secp256k1@^1.7.1": + version "1.7.1" + resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c" + integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -3666,6 +3683,23 @@ graphql-ws "^5.16.0" uuid "^8.3.2" +"@notifi-network/notifi-react@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@notifi-network/notifi-react/-/notifi-react-1.1.1.tgz#1d1caa0299ac6429db169092f4e22ba12538eaad" + integrity sha512-EEpJdcSrVrtLZDdhFwUER6LD6uaPEfDDUU31NJ3SwkJgngVLDOA9hcXqDlmmp5Dx5IMACwYVZ09hrRHlk0TPjw== + dependencies: + "@notifi-network/notifi-frontend-client" "^1.0.1" + "@xmtp/consent-proof-signature" "^0.1.2" + "@xmtp/content-type-reaction" "^1.1.7" + "@xmtp/content-type-remote-attachment" "^1.1.8" + "@xmtp/content-type-reply" "^1.1.9" + "@xmtp/react-sdk" "^6.0.1" + "@xmtp/xmtp-js" "^11.5.0" + clsx "^1.2.1" + date-fns "^2.29.3" + dompurify "^3.0.5" + libphonenumber-js "^1.10.13" + "@npmcli/arborist@6.2.3": version "6.2.3" resolved "https://registry.yarnpkg.com/@npmcli/arborist/-/arborist-6.2.3.tgz#31f8aed2588341864d3811151d929c01308f8e71" @@ -4195,6 +4229,59 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== +"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" + integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== + +"@protobufjs/base64@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" + integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== + +"@protobufjs/codegen@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" + integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== + +"@protobufjs/eventemitter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" + integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q== + +"@protobufjs/fetch@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" + integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== + dependencies: + "@protobufjs/aspromise" "^1.1.1" + "@protobufjs/inquire" "^1.1.0" + +"@protobufjs/float@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" + integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ== + +"@protobufjs/inquire@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" + integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q== + +"@protobufjs/path@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" + integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA== + +"@protobufjs/pool@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" + integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw== + +"@protobufjs/utf8@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" + integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== + "@randlabs/communication-bridge@1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@randlabs/communication-bridge/-/communication-bridge-1.0.1.tgz#d1ecfc29157afcbb0ca2d73122d67905eecb5bf3" @@ -5436,6 +5523,13 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== +"@types/node@>=13.7.0": + version "22.2.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.2.0.tgz#7cf046a99f0ba4d628ad3088cb21f790df9b0c5b" + integrity sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ== + dependencies: + undici-types "~6.13.0" + "@types/node@^12.12.54": version "12.20.55" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" @@ -6586,6 +6680,107 @@ dependencies: tslib "^2.3.0" +"@xmtp/consent-proof-signature@^0.1.2", "@xmtp/consent-proof-signature@^0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@xmtp/consent-proof-signature/-/consent-proof-signature-0.1.3.tgz#19f05c353fdece52a1ab9cce197c60587dc47e78" + integrity sha512-2uTKOd7ov6QnDgCFNnL+4Hx9osxRLSpdBNrbpKauWp8/qrrMEe6yBwFRNq40ieElo1mo1usB8DbhSH0jalcIdw== + dependencies: + "@xmtp/proto" "3.56.0" + long "^5.2.3" + +"@xmtp/content-type-primitives@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@xmtp/content-type-primitives/-/content-type-primitives-1.0.1.tgz#b0bc4b900ad5b6777f4f35cae60511c1d0c9c3ab" + integrity sha512-F/2/yh0UQZb49tuxszTIbH+TDNJhTgSlj3UX8YOevMaMpIAvY26qjIA35M8Bw0nng3aU/iYqFA1p3ZO/7rM9Qw== + dependencies: + "@xmtp/proto" "^3.61.1" + +"@xmtp/content-type-reaction@^1.1.7": + version "1.1.9" + resolved "https://registry.yarnpkg.com/@xmtp/content-type-reaction/-/content-type-reaction-1.1.9.tgz#7b66b6f26d7c2aa40b9d427868a7e2658a89847c" + integrity sha512-/3qN/jNaxb7pYocD9NqmtHLJGe5bD+jmaOSa1LJIIPhhTXAanFbdScb1JzYQHBonyYsOT+hA4bGLjcpWHIYH/w== + dependencies: + "@xmtp/content-type-primitives" "^1.0.1" + +"@xmtp/content-type-remote-attachment@^1.1.8": + version "1.1.9" + resolved "https://registry.yarnpkg.com/@xmtp/content-type-remote-attachment/-/content-type-remote-attachment-1.1.9.tgz#e3a82565095d8c00c5abcdd54bda22a8b27a46eb" + integrity sha512-4/SapFdSOSRCbJTsDx0Z1AO2GpfnfL5hXSEcFHDCVw++zLTObKLRWTwaSRJeI49PLFjYgZPdwSvHkw8hfOSm0A== + dependencies: + "@noble/secp256k1" "^1.7.1" + "@xmtp/content-type-primitives" "^1.0.1" + "@xmtp/proto" "^3.61.1" + "@xmtp/xmtp-js" "^11.6.3" + +"@xmtp/content-type-reply@^1.1.9": + version "1.1.11" + resolved "https://registry.yarnpkg.com/@xmtp/content-type-reply/-/content-type-reply-1.1.11.tgz#bec1b6f4c08fc29efcdc2aafe7eb9410d305dd37" + integrity sha512-6VPW/N6n0a5FIN+9QB6KuouO5KzmLLC7+K6lo1sgQO4mhkbQKocLHN62s9hWYDYpxvD7agH+AE7XcBrRm3yhDA== + dependencies: + "@xmtp/content-type-primitives" "^1.0.1" + "@xmtp/proto" "^3.61.1" + +"@xmtp/proto@3.54.0": + version "3.54.0" + resolved "https://registry.yarnpkg.com/@xmtp/proto/-/proto-3.54.0.tgz#1b6be9fa2268a51b730bf484af3bf0ebc2621505" + integrity sha512-X0jDRR19/tH0qRB8mM/H/vBueQAK22VZF4QUnDN7TgnbNaOYL5DvSmPfXFH+xzeGKQ5S0zgwc+qFJbI4xoKNHw== + dependencies: + long "^5.2.0" + protobufjs "^7.0.0" + rxjs "^7.8.0" + undici "^5.8.1" + +"@xmtp/proto@3.56.0": + version "3.56.0" + resolved "https://registry.yarnpkg.com/@xmtp/proto/-/proto-3.56.0.tgz#48dfbfed6f97e1d14775a10caf274f23238f0594" + integrity sha512-zW8/s7x9je0keYjJpu/c5zmYK5wE14MxcDWLkxzMwRmrajwdy69BNN0NgVJ1uBzMUqGTjnGQJANDev8lpa58qQ== + dependencies: + long "^5.2.0" + protobufjs "^7.0.0" + rxjs "^7.8.0" + undici "^5.8.1" + +"@xmtp/proto@^3.61.1": + version "3.65.1" + resolved "https://registry.yarnpkg.com/@xmtp/proto/-/proto-3.65.1.tgz#3797ff834c8ca74434207c21a92bbdf10ee40760" + integrity sha512-qTnpaCM2IrUlEJQz6yINDYtUgC9W539XovdZIDos07t2OL3d0t8wzn8MB1ess3Z737yj136IODG/wqtfSeAJYg== + dependencies: + long "^5.2.0" + protobufjs "^7.0.0" + rxjs "^7.8.0" + undici "^5.8.1" + +"@xmtp/react-sdk@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/@xmtp/react-sdk/-/react-sdk-6.0.1.tgz#e62508f1acff52fe3585fc5463707337b25ef3aa" + integrity sha512-b+VPH3chZir2M9lPNjkHWzRKg93ACr5GVHUZIGEqNyCWT3twSyagfohGO2vEkHDCbvcFtz75RZeXG3JgTgWWWg== + dependencies: + async-mutex "^0.5.0" + date-fns "^3.4.0" + dexie "^3.2.6" + dexie-react-hooks "^1.1.7" + uuid "^9.0.1" + zod "^3.22.4" + +"@xmtp/user-preferences-bindings-wasm@^0.3.6": + version "0.3.6" + resolved "https://registry.yarnpkg.com/@xmtp/user-preferences-bindings-wasm/-/user-preferences-bindings-wasm-0.3.6.tgz#4ca58dca940574483caa8cbd4d9c609577b1e0f1" + integrity sha512-ANi6ikrO6YBaK978sMuEEnpREvFQQnMVaNdlviaLzmc07u4Of4s/VLNnavl4qTb4F4cvwSiBWou0wSYIE5SWYg== + +"@xmtp/xmtp-js@^11.5.0", "@xmtp/xmtp-js@^11.6.3": + version "11.6.3" + resolved "https://registry.yarnpkg.com/@xmtp/xmtp-js/-/xmtp-js-11.6.3.tgz#cf787dd2f33ea2d9c2d49d4f93441692a2962d4e" + integrity sha512-Bp34Cl6/Ku3gylmQegRWgc2BX20+OD4k6fMWbEoLFKcNxkA0j8XV8Ml7IQ7C+4pyVtrlDA0at33LvmuRd6owsQ== + dependencies: + "@noble/secp256k1" "1.7.1" + "@xmtp/consent-proof-signature" "^0.1.3" + "@xmtp/proto" "3.54.0" + "@xmtp/user-preferences-bindings-wasm" "^0.3.6" + async-mutex "^0.5.0" + elliptic "^6.5.4" + long "^5.2.3" + viem "2.7.15" + "@xtuc/ieee754@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" @@ -6644,6 +6839,11 @@ abitype@0.9.8: resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.9.8.tgz#1f120b6b717459deafd213dfbf3a3dd1bf10ae8c" integrity sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ== +abitype@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.0.tgz#237176dace81d90d018bebf3a45cb42f2a2d9e97" + integrity sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ== + abitype@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.3.0.tgz#75150e337d88cc0b2423ed0d3fc36935f139d04c" @@ -7280,6 +7480,13 @@ async-mutex@^0.2.6: dependencies: tslib "^2.0.0" +async-mutex@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/async-mutex/-/async-mutex-0.5.0.tgz#353c69a0b9e75250971a64ac203b0ebfddd75482" + integrity sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA== + dependencies: + tslib "^2.4.0" + async-retry@^1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.3.3.tgz#0e7f36c04d8478e7a58bdbed80cedf977785f280" @@ -9581,6 +9788,18 @@ dataloader@^2.2.2: resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-2.2.2.tgz#216dc509b5abe39d43a9b9d97e6e5e473dfbe3e0" integrity sha512-8YnDaaf7N3k/q5HnTJVuzSyLETjoZjVmHc4AeKAzOvKHEFQKcn64OKBfzHYtE9zGjctNM7V9I0MfnUVLpi7M5g== +date-fns@^2.29.3: + version "2.30.0" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.30.0.tgz#f367e644839ff57894ec6ac480de40cae4b0f4d0" + integrity sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw== + dependencies: + "@babel/runtime" "^7.21.0" + +date-fns@^3.4.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.6.0.tgz#f20ca4fe94f8b754951b24240676e8618c0206bf" + integrity sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww== + dateformat@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" @@ -9891,6 +10110,16 @@ detect-port-alt@^1.1.6: address "^1.0.1" debug "^2.6.0" +dexie-react-hooks@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/dexie-react-hooks/-/dexie-react-hooks-1.1.7.tgz#75bd92a609a7c3dc3643e2fd21e7db5df6df923b" + integrity sha512-Lwv5W0Hk+uOW3kGnsU9GZoR1er1B7WQ5DSdonoNG+focTNeJbHW6vi6nBoX534VKI3/uwHebYzSw1fwY6a7mTw== + +dexie@^3.2.6: + version "3.2.7" + resolved "https://registry.yarnpkg.com/dexie/-/dexie-3.2.7.tgz#1346541c9c81e3bc6055a042a928837890595e3a" + integrity sha512-2a+BXvVhY5op+smDRLxeBAivE7YcYaneXJ1la3HOkUfX9zKkE/AJ8CNgjiXbtXepFyFmJNGSbmjOwqbT749r/w== + didyoumean@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/didyoumean/-/didyoumean-1.2.2.tgz#989346ffe9e839b4555ecf5666edea0d3e8ad037" @@ -10044,6 +10273,11 @@ domhandler@^4.0.0, domhandler@^4.2.0, domhandler@^4.3.1: dependencies: domelementtype "^2.2.0" +dompurify@^3.0.5: + version "3.1.6" + resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.1.6.tgz#43c714a94c6a7b8801850f82e756685300a027e2" + integrity sha512-cTOAhc36AalkjtBpfG6O8JimdTMWNXjiePT2xQH/ppBGi/4uIpmj8eKyIkMJErXWARyINV/sB38yf8JCLF5pbQ== + domutils@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a" @@ -14905,6 +15139,11 @@ libnpmpublish@7.1.4: sigstore "^1.4.0" ssri "^10.0.1" +libphonenumber-js@^1.10.13: + version "1.11.5" + resolved "https://registry.yarnpkg.com/libphonenumber-js/-/libphonenumber-js-1.11.5.tgz#50a441da5ff9ed9a322d796a14f1e9cbc0fdabdf" + integrity sha512-TwHR5BZxGRODtAfz03szucAkjT5OArXr+94SMtAM2pYXIlQNVMrxvb6uSCbnaJJV6QXEyICk7+l6QPgn72WHhg== + lie@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" @@ -15220,6 +15459,11 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" +long@^5.0.0, long@^5.2.0, long@^5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1" + integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q== + loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" @@ -17908,6 +18152,24 @@ proto-list@~1.2.1: resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" integrity sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA== +protobufjs@^7.0.0: + version "7.3.2" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.3.2.tgz#60f3b7624968868f6f739430cfbc8c9370e26df4" + integrity sha512-RXyHaACeqXeqAKGLDl68rQKbmObRsTIn4TYVUUug1KfS47YWCo5MacGITEryugIgZqORCvJWEk4l449POg5Txg== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/node" ">=13.7.0" + long "^5.0.0" + protocols@^2.0.0, protocols@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/protocols/-/protocols-2.0.1.tgz#8f155da3fc0f32644e83c5782c8e8212ccf70a86" @@ -19068,7 +19330,7 @@ rxjs@^6.6.3: dependencies: tslib "^1.9.0" -rxjs@^7.5.1, rxjs@^7.5.5: +rxjs@^7.5.1, rxjs@^7.5.5, rxjs@^7.8.0: version "7.8.1" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543" integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg== @@ -21028,6 +21290,18 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== +undici-types@~6.13.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.13.0.tgz#e3e79220ab8c81ed1496b5812471afd7cf075ea5" + integrity sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg== + +undici@^5.8.1: + version "5.28.4" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068" + integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g== + dependencies: + "@fastify/busboy" "^2.0.0" + unenv@^1.8.0: version "1.9.0" resolved "https://registry.yarnpkg.com/unenv/-/unenv-1.9.0.tgz#469502ae85be1bd3a6aa60f810972b1a904ca312" @@ -21302,6 +21576,11 @@ uuid@8.3.2, uuid@^8.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== +uuid@^9.0.1: + version "9.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" + integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA== + v8-compile-cache-lib@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" @@ -21396,6 +21675,20 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" +viem@2.7.15: + version "2.7.15" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.7.15.tgz#0dfdcb75be196c85839950b0ccb88be0b377609c" + integrity sha512-I2RMQpg1/MC7fXVjHxeXRPU9k/WEOvZajK/KZSr7DChS0AaZ7uovsQWppwBn2wvZWguTCIRAHqzMwIEGku95yQ== + dependencies: + "@adraffy/ens-normalize" "1.10.0" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@scure/bip32" "1.3.2" + "@scure/bip39" "1.2.1" + abitype "1.0.0" + isows "1.0.3" + ws "8.13.0" + viem@^1.0.0, viem@^1.1.4: version "1.21.4" resolved "https://registry.yarnpkg.com/viem/-/viem-1.21.4.tgz#883760e9222540a5a7e0339809202b45fe6a842d" @@ -22365,6 +22658,11 @@ zlib@^1.0.5: resolved "https://registry.yarnpkg.com/zlib/-/zlib-1.0.5.tgz#6e7c972fc371c645a6afb03ab14769def114fcc0" integrity sha512-40fpE2II+Cd3k8HWTWONfeKE2jL+P42iWJ1zzps5W51qcTsOUKM5Q5m2PFb0CLxlmFAaUuUdJGc3OfZy947v0w== +zod@^3.22.4: + version "3.23.8" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" + integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g== + zustand@4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.4.0.tgz#13b3e8ca959dd53d536034440aec382ff91b65c3" From ccc827d6a3b5bda828e89b20a8cde906d2234f22 Mon Sep 17 00:00:00 2001 From: Michael Liu Date: Fri, 16 Aug 2024 09:42:19 -0400 Subject: [PATCH 3/8] Update --- packages/huma-shared/src/utils/notifi.ts | 8 +- .../Notifi/NotifiContextWrapper.tsx | 4 +- .../Notifi/NotifiSubscriptionModal.tsx | 93 ++++++------------- packages/huma-widget/src/index.tsx | 7 +- 4 files changed, 45 insertions(+), 67 deletions(-) diff --git a/packages/huma-shared/src/utils/notifi.ts b/packages/huma-shared/src/utils/notifi.ts index 04dc0ec..9979293 100644 --- a/packages/huma-shared/src/utils/notifi.ts +++ b/packages/huma-shared/src/utils/notifi.ts @@ -2,7 +2,7 @@ import { ChainEnum } from './chain' export function getBlockchainConfigFromChain( chainEnum: ChainEnum, -): 'POLYGON' | 'ETHEREUM' | 'CELO' { +): 'POLYGON' | 'ETHEREUM' | 'CELO' | 'SCROLL' { switch (chainEnum) { case ChainEnum.Celo: case ChainEnum.Alfajores: @@ -12,6 +12,9 @@ export function getBlockchainConfigFromChain( return 'POLYGON' case ChainEnum.Goerli: return 'ETHEREUM' + case ChainEnum.Scroll: + case ChainEnum.ScrollSepolia: + return 'SCROLL' default: throw new Error('Invalid chain') } @@ -23,12 +26,13 @@ export function doesChainSupportNotifi( ): boolean { switch (chainEnum) { case ChainEnum.Celo: - return true case ChainEnum.Polygon: + case ChainEnum.Scroll: return true case ChainEnum.Alfajores: case ChainEnum.Mumbai: case ChainEnum.Goerli: + case ChainEnum.ScrollSepolia: return isDev default: return false diff --git a/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx b/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx index 06d1775..64c3b49 100644 --- a/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx +++ b/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx @@ -6,7 +6,7 @@ import { providers } from 'ethers' import React, { useMemo } from 'react' type Props = { - chainId: number + chainId: number | undefined // eslint-disable-next-line @typescript-eslint/no-explicit-any children?: any } @@ -23,7 +23,9 @@ export function NotifiContextWrapper({ return undefined }, [provider]) + console.log('1') if (account == null || signer == null || chainId == null) { + console.log('2') return null } diff --git a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx index 4021b4b..2f94f03 100644 --- a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx +++ b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx @@ -1,18 +1,14 @@ -import { ChainEnum, getBlockchainConfigFromChain } from '@huma-finance/shared' import { txAtom } from '@huma-finance/web-shared' import { Box, css, TextField, Typography, useTheme } from '@mui/material' -import { - EventTypeItem, - NotifiFrontendClient, - SignMessageParams, - Uint8SignMessageFunction, -} from '@notifi-network/notifi-frontend-client' -import { useWeb3React } from '@web3-react/core' -import { ethers } from 'ethers' import { useResetAtom } from 'jotai/utils' import React, { useCallback, useState } from 'react' -import { useNotifiClient } from '../../hooks/useNotifi' +import { + useNotifiFrontendClientContext, + useNotifiTargetContext, + useNotifiTenantConfigContext, + useNotifiTopicContext, +} from '@notifi-network/notifi-react' import { useAppDispatch } from '../../hooks/useRedux' import { resetState } from '../../store/widgets.reducers' import { BottomButton } from '../BottomButton' @@ -24,50 +20,24 @@ type Props = { handleSuccess: () => void } -async function fetchEventTypes( - notifiClient: NotifiFrontendClient, - chainId: number | undefined, -): Promise { - let cardId = '' - if (chainId === ChainEnum.Celo || chainId === ChainEnum.Alfajores) { - cardId = process.env.REACT_APP_NOTIFI_CONFIG_ID_CELO ?? '' - } else if (chainId === ChainEnum.Polygon || chainId === ChainEnum.Amoy) { - cardId = process.env.REACT_APP_NOTIFI_CONFIG_ID_POLYGON ?? '' - } else if ( - chainId === ChainEnum.Scroll || - chainId === ChainEnum.ScrollSepolia - ) { - cardId = process.env.REACT_APP_NOTIFI_CONFIG_ID_SCROLL ?? '' - } - - const subscriptionConfig = await notifiClient.fetchTenantConfig({ - id: cardId ?? '', - type: 'SUBSCRIPTION_CARD', - }) - - return subscriptionConfig.cardConfig.eventTypes as EventTypeItem[] -} - export function NotifiSubscriptionModal({ handleSuccess, }: Props): React.ReactElement { const theme = useTheme() const reset = useResetAtom(txAtom) const dispatch = useAppDispatch() - const { account, chainId, provider } = useWeb3React() const [showSuccessScreen, setShowSuccessScreen] = useState(false) const [isLoading, setIsLoading] = useState(false) const [emailAddress, setEmailAddress] = useState('') const [emailValid, setEmailValid] = useState() - const { notifiClient } = useNotifiClient(account, chainId) - - const signMessage: Uint8SignMessageFunction = async ( - message: Uint8Array, - ): Promise => { - const signer = provider!.getSigner() - const signature = await signer.signMessage(Buffer.from(message)) - return ethers.utils.arrayify(signature) - } + const { + frontendClientStatus: { isInitialized, isAuthenticated }, + frontendClient, + login, + } = useNotifiFrontendClientContext() + const { fusionEventTopics } = useNotifiTenantConfigContext() + const { subscribeAlertsDefault } = useNotifiTopicContext() + const { renewTargetGroup } = useNotifiTargetContext() const handleEmailAddressChange = ( event: React.ChangeEvent, @@ -78,40 +48,37 @@ export function NotifiSubscriptionModal({ } const logInAndSubscribe = async (): Promise => { - if (notifiClient != null && chainId != null) { + if (!isAuthenticated) { setIsLoading(true) // Ask user to sign a message to authenticate try { - await notifiClient.logIn({ - walletBlockchain: getBlockchainConfigFromChain(chainId), - signMessage, - } as SignMessageParams) + await login() } catch (e) { setIsLoading(false) return } - // Fetch all event types - const fetchedEventTypes = await fetchEventTypes(notifiClient, chainId) - // Authorize this email address for this wallet - await notifiClient.ensureTargetGroup({ + await frontendClient.ensureTargetGroup({ name: 'Default', emailAddress: emailAddress!, }) - // Intentionally running this in serial because the Notifi ensureAlert can't handle - // multiple calls. Notified their team to fix this. - // eslint-disable-next-line no-restricted-syntax - for (const eventType of fetchedEventTypes) { - // eslint-disable-next-line no-await-in-loop - await notifiClient.ensureAlert({ - eventType, - inputs: {}, - }) + await renewTargetGroup() + const targetGroups = await frontendClient.getTargetGroups() + const targetGroupId = targetGroups.find( + (targetGroup) => targetGroup.name === 'Default', + )?.id + + if (!targetGroupId) { + console.error("Could not find targetGroupId for 'Default' target group") + setIsLoading(false) + return } + await subscribeAlertsDefault(fusionEventTopics, targetGroupId) + setShowSuccessScreen(true) setIsLoading(false) } @@ -193,7 +160,7 @@ export function NotifiSubscriptionModal({ CONNECT EMAIL diff --git a/packages/huma-widget/src/index.tsx b/packages/huma-widget/src/index.tsx index 9b3a87b..7505691 100644 --- a/packages/huma-widget/src/index.tsx +++ b/packages/huma-widget/src/index.tsx @@ -73,6 +73,7 @@ import { SuperfluidFactoring } from './components/SuperfluidFactoring' import { store } from './store' import { themeHuma } from './theme' import { WCProps } from './utilTypes' +import { NotifiContextWrapper } from './components/Notifi/NotifiContextWrapper' /** * Mapping of your JSON-RPC connections indexed by chainId @@ -116,7 +117,11 @@ function Widget(props: WCProps) { - {children} + + + {children} + + From 6e1d8636f531abddaa3cd23a0accdea893aaff3d Mon Sep 17 00:00:00 2001 From: Michael Liu Date: Thu, 29 Aug 2024 12:01:39 -0400 Subject: [PATCH 4/8] Fix types --- packages/huma-sdk/package.json | 2 +- packages/huma-shared/package.json | 2 +- packages/huma-web-shared/package.json | 2 +- packages/huma-widget/package.json | 6 +- .../src/components/Lend/supplyV2/index.tsx | 140 ++++++++++-------- .../Notifi/NotifiContextWrapper.tsx | 2 - yarn.lock | 28 ++-- 7 files changed, 95 insertions(+), 87 deletions(-) diff --git a/packages/huma-sdk/package.json b/packages/huma-sdk/package.json index a9e040d..ce441b8 100644 --- a/packages/huma-sdk/package.json +++ b/packages/huma-sdk/package.json @@ -1,7 +1,7 @@ { "name": "@huma-finance/sdk", "version": "0.0.60", - "types": "./dist/index.d.ts", + "types": "./dist/cjs/index.d.ts", "main": "./dist/cjs/index.js", "module": "./dist/index.js", "files": [ diff --git a/packages/huma-shared/package.json b/packages/huma-shared/package.json index cce0552..f0fea9d 100644 --- a/packages/huma-shared/package.json +++ b/packages/huma-shared/package.json @@ -1,7 +1,7 @@ { "name": "@huma-finance/shared", "version": "0.0.60", - "types": "./dist/index.d.ts", + "types": "./dist/cjs/index.d.ts", "main": "./dist/cjs/index.js", "module": "./dist/index.js", "files": [ diff --git a/packages/huma-web-shared/package.json b/packages/huma-web-shared/package.json index 57b1140..c9727e3 100644 --- a/packages/huma-web-shared/package.json +++ b/packages/huma-web-shared/package.json @@ -1,7 +1,7 @@ { "name": "@huma-finance/web-shared", "version": "0.0.60", - "types": "./dist/index.d.ts", + "types": "./dist/cjs/index.d.ts", "main": "./dist/cjs/index.js", "module": "./dist/index.js", "files": [ diff --git a/packages/huma-widget/package.json b/packages/huma-widget/package.json index c583681..35467b4 100644 --- a/packages/huma-widget/package.json +++ b/packages/huma-widget/package.json @@ -8,7 +8,7 @@ "type": "git", "url": "git+https://github.com/00labs/huma-js.git" }, - "types": "dist/index.d.ts", + "types": "dist/cjs/index.d.ts", "main": "dist/cjs/index.cjs", "module": "dist/index.js", "exports": { @@ -39,8 +39,8 @@ "@mui/styles": "^5.0.2", "@mui/system": "^5.0.6", "@mui/x-date-pickers": "^5.0.7", - "@notifi-network/notifi-frontend-client": "^1.0.1", - "@notifi-network/notifi-react": "^1.1.1", + "@notifi-network/notifi-frontend-client": "^1.1.2", + "@notifi-network/notifi-react": "^1.1.2", "@reduxjs/toolkit": "^1.8.6", "@types/utf8": "^3.0.1", "@walletconnect/ethereum-provider": "1.8.0", diff --git a/packages/huma-widget/src/components/Lend/supplyV2/index.tsx b/packages/huma-widget/src/components/Lend/supplyV2/index.tsx index 9554ae3..6ccb882 100644 --- a/packages/huma-widget/src/components/Lend/supplyV2/index.tsx +++ b/packages/huma-widget/src/components/Lend/supplyV2/index.tsx @@ -124,10 +124,10 @@ export function LendSupplyV2({ return } - if (poolInfo.supplyLink) { - openInNewTab(poolInfo.supplyLink) - handleClose() - } + // if (poolInfo.supplyLink) { + // openInNewTab(poolInfo.supplyLink) + // handleClose() + // } } }, [ dispatch, @@ -168,67 +168,77 @@ export function LendSupplyV2({ handleClose={handleClose} handleSuccess={handleSuccess} > - {step === WIDGET_STEP.ChooseTranche && ( - - )} - {step === WIDGET_STEP.Evaluation && ( - - )} - {step === WIDGET_STEP.ChooseAmount && ( - - )} - {step === WIDGET_STEP.ApproveAllowance && ( - - )} - {step === WIDGET_STEP.Transfer && selectedTranche && ( - - )} - {step === WIDGET_STEP.Done && ( - - )} - {step === WIDGET_STEP.Notifications && ( - - )} - {step === WIDGET_STEP.PointsEarned && transactionHash && ( - - )} - {step === WIDGET_STEP.Error && ( - - )} + ) + // return ( + // + // {step === WIDGET_STEP.ChooseTranche && ( + // + // )} + // {step === WIDGET_STEP.Evaluation && ( + // + // )} + // {step === WIDGET_STEP.ChooseAmount && ( + // + // )} + // {step === WIDGET_STEP.ApproveAllowance && ( + // + // )} + // {step === WIDGET_STEP.Transfer && selectedTranche && ( + // + // )} + // {step === WIDGET_STEP.Done && ( + // + // )} + // {step === WIDGET_STEP.Notifications && ( + // + // )} + // {step === WIDGET_STEP.PointsEarned && transactionHash && ( + // + // )} + // {step === WIDGET_STEP.Error && ( + // + // )} + // + // ) } diff --git a/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx b/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx index 64c3b49..a84fc35 100644 --- a/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx +++ b/packages/huma-widget/src/components/Notifi/NotifiContextWrapper.tsx @@ -23,9 +23,7 @@ export function NotifiContextWrapper({ return undefined }, [provider]) - console.log('1') if (account == null || signer == null || chainId == null) { - console.log('2') return null } diff --git a/yarn.lock b/yarn.lock index 7297f8c..86bedc1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3664,31 +3664,31 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@notifi-network/notifi-frontend-client@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@notifi-network/notifi-frontend-client/-/notifi-frontend-client-1.0.1.tgz#fa409dd7f9d53c3465f9c76be783d3d7489c1fdd" - integrity sha512-AtvvxYc6rHapXbujhnPOo3scsBcQFvtXm+rbbpKHcn4Gu5yZRGHZ9HVOf1UTxNgq3XVFOsFufJ82u1Ybf9WyxQ== +"@notifi-network/notifi-frontend-client@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@notifi-network/notifi-frontend-client/-/notifi-frontend-client-1.1.2.tgz#2c5f1cd8ed6ee5df0c2f254034a443df4a6f8cab" + integrity sha512-JzJsIi6oknezPxthlrbZ1WTpNks3BOJOxjypKXT6KnuMr5S6jH7Q/Voqf6477ii6DKr5zJ2WcuEtCJVJjMr/UA== dependencies: - "@notifi-network/notifi-graphql" "^1.0.0" + "@notifi-network/notifi-graphql" "^1.1.2" graphql-request "^6.0.0" localforage "^1.10.0" -"@notifi-network/notifi-graphql@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@notifi-network/notifi-graphql/-/notifi-graphql-1.0.0.tgz#b944bb075a2e5c43e3d6bedef2b3f4b2a7a70136" - integrity sha512-38T3wWdi/DM1IeZMhM5wPOys0eZ55Id0rBQTZRdM84vRhPQ55vSYg4f67V2jOZ/wE6fYV0n9NRMUMWxFIgM5vQ== +"@notifi-network/notifi-graphql@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@notifi-network/notifi-graphql/-/notifi-graphql-1.1.2.tgz#a73abd2c3890d2d9c573af5a3cf3f9fb775f8ea3" + integrity sha512-My7IJ52J/j46D8ZxbPRTTi3m/qv1oUgDozgWd1Y6oIaT4SMrPq5oKe+8XSq8/s5KDD6kyRJ8G4lRUwfAo+Pobw== dependencies: graphql "^16.6.0" graphql-request "^6.0.0" graphql-ws "^5.16.0" uuid "^8.3.2" -"@notifi-network/notifi-react@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@notifi-network/notifi-react/-/notifi-react-1.1.1.tgz#1d1caa0299ac6429db169092f4e22ba12538eaad" - integrity sha512-EEpJdcSrVrtLZDdhFwUER6LD6uaPEfDDUU31NJ3SwkJgngVLDOA9hcXqDlmmp5Dx5IMACwYVZ09hrRHlk0TPjw== +"@notifi-network/notifi-react@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@notifi-network/notifi-react/-/notifi-react-1.1.2.tgz#42753e7b7dbb8a96329d96248ed7afe52f99c293" + integrity sha512-UlQCzpXHXTPPnZZAj43R9VHVMil0BvR/fkAKpli277kUVKp0pXLny7bf903RKqepRTOTQ4a6pi3kx2L0hHeg1A== dependencies: - "@notifi-network/notifi-frontend-client" "^1.0.1" + "@notifi-network/notifi-frontend-client" "^1.1.2" "@xmtp/consent-proof-signature" "^0.1.2" "@xmtp/content-type-reaction" "^1.1.7" "@xmtp/content-type-remote-attachment" "^1.1.8" From 287ef22d4f4c7c8c63bbe0de3a7daf3ebc74078b Mon Sep 17 00:00:00 2001 From: Michael Liu Date: Thu, 5 Sep 2024 19:41:31 -0400 Subject: [PATCH 5/8] Update --- .../Notifi/NotifiSubscriptionModal.tsx | 112 ++++++++++++++---- packages/huma-widget/src/hooks/useNotifi.ts | 45 ++++--- 2 files changed, 114 insertions(+), 43 deletions(-) diff --git a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx index 2f94f03..b8433f9 100644 --- a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx +++ b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx @@ -1,14 +1,17 @@ import { txAtom } from '@huma-finance/web-shared' import { Box, css, TextField, Typography, useTheme } from '@mui/material' import { useResetAtom } from 'jotai/utils' -import React, { useCallback, useState } from 'react' +import React, { useCallback, useEffect, useState } from 'react' import { + FtuStage, useNotifiFrontendClientContext, useNotifiTargetContext, useNotifiTenantConfigContext, useNotifiTopicContext, + useNotifiUserSettingContext, } from '@notifi-network/notifi-react' +import { NotifiFrontendClient } from '@notifi-network/notifi-frontend-client' import { useAppDispatch } from '../../hooks/useRedux' import { resetState } from '../../store/widgets.reducers' import { BottomButton } from '../BottomButton' @@ -20,6 +23,16 @@ type Props = { handleSuccess: () => void } +const validateDefaultTargetGroup = async ( + frontendClient: NotifiFrontendClient, +) => { + // NOTE: this extra request is necessary as the targetGroupId state in NotifiTargetContext will not be updated constantly right after login + const targetGroup = ( + await frontendClient?.fetchFusionData() + )?.targetGroup?.find((group) => group?.name === 'Default') + return !!targetGroup +} + export function NotifiSubscriptionModal({ handleSuccess, }: Props): React.ReactElement { @@ -31,13 +44,22 @@ export function NotifiSubscriptionModal({ const [emailAddress, setEmailAddress] = useState('') const [emailValid, setEmailValid] = useState() const { - frontendClientStatus: { isInitialized, isAuthenticated }, + frontendClientStatus: { isInitialized, isAuthenticated, isExpired }, frontendClient, login, } = useNotifiFrontendClientContext() const { fusionEventTopics } = useNotifiTenantConfigContext() const { subscribeAlertsDefault } = useNotifiTopicContext() - const { renewTargetGroup } = useNotifiTargetContext() + const { + targetDocument: { targetGroupId }, + updateTargetInputs, + renewTargetGroup, + } = useNotifiTargetContext() + const { + ftuStage, + isLoading: isLoadingFtuStage, + updateFtuStage, + } = useNotifiUserSettingContext() const handleEmailAddressChange = ( event: React.ChangeEvent, @@ -47,6 +69,60 @@ export function NotifiSubscriptionModal({ setEmailAddress(event.target.value) } + useEffect(() => { + async function subscribe() { + if ( + !isInitialized || + !isAuthenticated || + !targetGroupId || + isLoadingFtuStage + ) { + return + } + + // If a user is authenticated but already finished with the FTU (First Time User) setup + // (AKA their login expired and they logged back in), then we can skip the subscription step. + if (ftuStage !== FtuStage.Done) { + await updateTargetInputs('email', { value: emailAddress! }) + // Authorize this email address for this wallet + + if (!targetGroupId) { + setIsLoading(false) + return + } + + await subscribeAlertsDefault(fusionEventTopics, targetGroupId) + await updateFtuStage(FtuStage.Done) + } + + setShowSuccessScreen(true) + setIsLoading(false) + } + + subscribe() + }, [ + isInitialized, + isAuthenticated, + targetGroupId, + updateTargetInputs, + emailAddress, + subscribeAlertsDefault, + fusionEventTopics, + updateFtuStage, + isLoadingFtuStage, + ftuStage, + ]) + + useEffect(() => { + const loginIfExpired = async () => { + if (isExpired) { + await login() + } + } + + loginIfExpired() + }, [isExpired, login]) + const logInAndSubscribe = async (): Promise => { if (!isAuthenticated) { setIsLoading(true) @@ -54,33 +130,17 @@ export function NotifiSubscriptionModal({ // Ask user to sign a message to authenticate try { await login() - } catch (e) { - setIsLoading(false) - return - } - // Authorize this email address for this wallet - await frontendClient.ensureTargetGroup({ - name: 'Default', - emailAddress: emailAddress!, - }) + const isDefaultTargetExist = await validateDefaultTargetGroup( + frontendClient, + ) - await renewTargetGroup() - const targetGroups = await frontendClient.getTargetGroups() - const targetGroupId = targetGroups.find( - (targetGroup) => targetGroup.name === 'Default', - )?.id - - if (!targetGroupId) { - console.error("Could not find targetGroupId for 'Default' target group") + if (!isDefaultTargetExist) { + await renewTargetGroup() + } + } catch (e) { setIsLoading(false) - return } - - await subscribeAlertsDefault(fusionEventTopics, targetGroupId) - - setShowSuccessScreen(true) - setIsLoading(false) } } diff --git a/packages/huma-widget/src/hooks/useNotifi.ts b/packages/huma-widget/src/hooks/useNotifi.ts index 1e86f5b..047bd82 100644 --- a/packages/huma-widget/src/hooks/useNotifi.ts +++ b/packages/huma-widget/src/hooks/useNotifi.ts @@ -8,6 +8,11 @@ import { NotifiFrontendClient, newFrontendClient, } from '@notifi-network/notifi-frontend-client' +import { + FtuStage, + useNotifiFrontendClientContext, + useNotifiUserSettingContext, +} from '@notifi-network/notifi-react' export const useDoesChainSupportNotifi = (chainId: number | undefined) => { const [notifiChainSupported, setNotifiChainSupported] = useState(false) @@ -54,32 +59,31 @@ export const useNotifiClient = ( return { notifiClient } } +// Check if user is authenticated +// If not authenticated or expired, have user login +// After login, check FTU stage +// If FTU stage is not Done, go to signup flow. Otherwise, skip to next step + export const useIsFirstTimeNotifiUser = ( account: string | undefined, chainId: number | undefined, ) => { const [isFirstTimeNotifiUser, setIsFirstTimeNotifiUser] = useState(false) - const { notifiClient } = useNotifiClient(account, chainId) + const { + frontendClientStatus: { isInitialized, isAuthenticated, isExpired }, + } = useNotifiFrontendClientContext() + const { ftuStage, isLoading: isLoadingFtu } = useNotifiUserSettingContext() const { notifiChainSupported } = useDoesChainSupportNotifi(chainId) useEffect(() => { const checkIsFirstTimeNotifiUser = async () => { - if (notifiClient != null && notifiChainSupported) { - const { userState } = notifiClient - // If the user is not authenticated or expired, they are a first time user - if ( - userState == null || - (userState.status !== 'authenticated' && - userState.status !== 'expired') - ) { + if (isInitialized && notifiChainSupported && !isLoadingFtu) { + // If the user is not authenticated or expired, they are possibly a first time user. + if (!isAuthenticated || isExpired) { setIsFirstTimeNotifiUser(true) - } else if (userState.status === 'authenticated') { - // If a user is authenticated, check if they have a target group (AKA email) - // associated with their wallet. If they do not, show them the notifi onboarding flow. - const targetGroups = await notifiClient.getTargetGroups() - const emailTargets = targetGroups[0]?.emailTargets?.[0] - - if (emailTargets == null || emailTargets.emailAddress == null) { + } else if (isAuthenticated) { + // If a user is authenticated, check if they've completed all the FTU (First Time User) stages. + if (ftuStage !== FtuStage.Done) { setIsFirstTimeNotifiUser(true) } } @@ -87,7 +91,14 @@ export const useIsFirstTimeNotifiUser = ( } checkIsFirstTimeNotifiUser() - }, [notifiChainSupported, notifiClient]) + }, [ + ftuStage, + isAuthenticated, + isExpired, + isInitialized, + isLoadingFtu, + notifiChainSupported, + ]) return { isFirstTimeNotifiUser } } From 9215630eb24516314f561f297a64fcbbf750d068 Mon Sep 17 00:00:00 2001 From: Michael Liu Date: Thu, 5 Sep 2024 19:46:50 -0400 Subject: [PATCH 6/8] Remove type package json update --- packages/huma-sdk/package.json | 2 +- packages/huma-shared/package.json | 2 +- packages/huma-web-shared/package.json | 2 +- packages/huma-widget/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/huma-sdk/package.json b/packages/huma-sdk/package.json index ce441b8..a9e040d 100644 --- a/packages/huma-sdk/package.json +++ b/packages/huma-sdk/package.json @@ -1,7 +1,7 @@ { "name": "@huma-finance/sdk", "version": "0.0.60", - "types": "./dist/cjs/index.d.ts", + "types": "./dist/index.d.ts", "main": "./dist/cjs/index.js", "module": "./dist/index.js", "files": [ diff --git a/packages/huma-shared/package.json b/packages/huma-shared/package.json index f0fea9d..cce0552 100644 --- a/packages/huma-shared/package.json +++ b/packages/huma-shared/package.json @@ -1,7 +1,7 @@ { "name": "@huma-finance/shared", "version": "0.0.60", - "types": "./dist/cjs/index.d.ts", + "types": "./dist/index.d.ts", "main": "./dist/cjs/index.js", "module": "./dist/index.js", "files": [ diff --git a/packages/huma-web-shared/package.json b/packages/huma-web-shared/package.json index c9727e3..57b1140 100644 --- a/packages/huma-web-shared/package.json +++ b/packages/huma-web-shared/package.json @@ -1,7 +1,7 @@ { "name": "@huma-finance/web-shared", "version": "0.0.60", - "types": "./dist/cjs/index.d.ts", + "types": "./dist/index.d.ts", "main": "./dist/cjs/index.js", "module": "./dist/index.js", "files": [ diff --git a/packages/huma-widget/package.json b/packages/huma-widget/package.json index 35467b4..561e430 100644 --- a/packages/huma-widget/package.json +++ b/packages/huma-widget/package.json @@ -8,7 +8,7 @@ "type": "git", "url": "git+https://github.com/00labs/huma-js.git" }, - "types": "dist/cjs/index.d.ts", + "types": "dist/index.d.ts", "main": "dist/cjs/index.cjs", "module": "dist/index.js", "exports": { From 605aea5f94d8c702593afa063e956c7d643fd325 Mon Sep 17 00:00:00 2001 From: Michael Liu Date: Thu, 5 Sep 2024 20:08:49 -0400 Subject: [PATCH 7/8] Remove commented code --- .../src/components/Lend/supplyV2/index.tsx | 140 ++++++++---------- 1 file changed, 65 insertions(+), 75 deletions(-) diff --git a/packages/huma-widget/src/components/Lend/supplyV2/index.tsx b/packages/huma-widget/src/components/Lend/supplyV2/index.tsx index 6ccb882..9554ae3 100644 --- a/packages/huma-widget/src/components/Lend/supplyV2/index.tsx +++ b/packages/huma-widget/src/components/Lend/supplyV2/index.tsx @@ -124,10 +124,10 @@ export function LendSupplyV2({ return } - // if (poolInfo.supplyLink) { - // openInNewTab(poolInfo.supplyLink) - // handleClose() - // } + if (poolInfo.supplyLink) { + openInNewTab(poolInfo.supplyLink) + handleClose() + } } }, [ dispatch, @@ -168,77 +168,67 @@ export function LendSupplyV2({ handleClose={handleClose} handleSuccess={handleSuccess} > - + {step === WIDGET_STEP.ChooseTranche && ( + + )} + {step === WIDGET_STEP.Evaluation && ( + + )} + {step === WIDGET_STEP.ChooseAmount && ( + + )} + {step === WIDGET_STEP.ApproveAllowance && ( + + )} + {step === WIDGET_STEP.Transfer && selectedTranche && ( + + )} + {step === WIDGET_STEP.Done && ( + + )} + {step === WIDGET_STEP.Notifications && ( + + )} + {step === WIDGET_STEP.PointsEarned && transactionHash && ( + + )} + {step === WIDGET_STEP.Error && ( + + )} ) - // return ( - // - // {step === WIDGET_STEP.ChooseTranche && ( - // - // )} - // {step === WIDGET_STEP.Evaluation && ( - // - // )} - // {step === WIDGET_STEP.ChooseAmount && ( - // - // )} - // {step === WIDGET_STEP.ApproveAllowance && ( - // - // )} - // {step === WIDGET_STEP.Transfer && selectedTranche && ( - // - // )} - // {step === WIDGET_STEP.Done && ( - // - // )} - // {step === WIDGET_STEP.Notifications && ( - // - // )} - // {step === WIDGET_STEP.PointsEarned && transactionHash && ( - // - // )} - // {step === WIDGET_STEP.Error && ( - // - // )} - // - // ) } From 6c1fe6b47c17912d50e7a10d55449608ea67463c Mon Sep 17 00:00:00 2001 From: Michael Liu Date: Sat, 14 Sep 2024 13:12:14 -0400 Subject: [PATCH 8/8] Final updates --- packages/huma-shared/src/utils/env.ts | 1 + .../components/Lend/supplyV2/7-Notifications.tsx | 7 ++++++- .../components/Notifi/NotifiSubscriptionModal.tsx | 15 ++++++++++++++- packages/huma-widget/src/hooks/useNotifi.ts | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/huma-shared/src/utils/env.ts b/packages/huma-shared/src/utils/env.ts index 1bcfb94..c779c78 100644 --- a/packages/huma-shared/src/utils/env.ts +++ b/packages/huma-shared/src/utils/env.ts @@ -4,5 +4,6 @@ export const checkIsDev = () => window.location.hostname.startsWith('v2') || window.location.hostname.startsWith('pr-') || window.location.hostname.startsWith('deploy-preview') || + window.location.hostname.startsWith('localhost') || process.env.NODE_ENV === 'development' ) diff --git a/packages/huma-widget/src/components/Lend/supplyV2/7-Notifications.tsx b/packages/huma-widget/src/components/Lend/supplyV2/7-Notifications.tsx index bf5ffd1..85be158 100644 --- a/packages/huma-widget/src/components/Lend/supplyV2/7-Notifications.tsx +++ b/packages/huma-widget/src/components/Lend/supplyV2/7-Notifications.tsx @@ -25,5 +25,10 @@ export function Notifications({ } }, [campaign, dispatch, handleAction]) - return + return ( + + ) } diff --git a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx index b8433f9..2f5c967 100644 --- a/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx +++ b/packages/huma-widget/src/components/Notifi/NotifiSubscriptionModal.tsx @@ -20,6 +20,7 @@ import { LoadingModal } from '../LoadingModal' import { WrapperModal } from '../WrapperModal' type Props = { + successText?: string handleSuccess: () => void } @@ -34,6 +35,7 @@ const validateDefaultTargetGroup = async ( } export function NotifiSubscriptionModal({ + successText, handleSuccess, }: Props): React.ReactElement { const theme = useTheme() @@ -93,6 +95,16 @@ export function NotifiSubscriptionModal({ await subscribeAlertsDefault(fusionEventTopics, targetGroupId) await updateFtuStage(FtuStage.Done) + + const targetGroup = ( + await frontendClient?.fetchFusionData() + )?.targetGroup?.find((group) => group?.name === 'Default') + const emailTarget = targetGroup?.emailTargets?.[0] + if (emailTarget && !emailTarget.isConfirmed) { + await frontendClient.sendEmailTargetVerification({ + targetId: emailTarget.id, + }) + } } setShowSuccessScreen(true) @@ -111,6 +123,7 @@ export function NotifiSubscriptionModal({ updateFtuStage, isLoadingFtuStage, ftuStage, + frontendClient, ]) useEffect(() => { @@ -190,7 +203,7 @@ export function NotifiSubscriptionModal({ - DONE + {successText ?? 'DONE'} ) diff --git a/packages/huma-widget/src/hooks/useNotifi.ts b/packages/huma-widget/src/hooks/useNotifi.ts index 047bd82..7aacdce 100644 --- a/packages/huma-widget/src/hooks/useNotifi.ts +++ b/packages/huma-widget/src/hooks/useNotifi.ts @@ -77,7 +77,7 @@ export const useIsFirstTimeNotifiUser = ( useEffect(() => { const checkIsFirstTimeNotifiUser = async () => { - if (isInitialized && notifiChainSupported && !isLoadingFtu) { + if (isInitialized && notifiChainSupported) { // If the user is not authenticated or expired, they are possibly a first time user. if (!isAuthenticated || isExpired) { setIsFirstTimeNotifiUser(true)