From c0fda1905294d4255ac934c7df51e1b4f2c09567 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 23 Apr 2024 16:28:21 +0200 Subject: [PATCH 01/12] chore: show discover api --- docs/web3inbox/frontend-integration/api.mdx | 95 +++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index 449517774..10d4760ef 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -663,5 +663,100 @@ interface NotifyNotification { } ``` + + + +### Discover apps to subscribe to + + + + + +```ts +const { subscribe } = useSubscribe(); +const { data: apps, isLoading, discover } = useDiscoverApps() + +return ( +
+ + {apps.map(app => ( +
{ + const url = new URL(app.url); + subscribe(url.hostname); + }} key={app.id}> + + {app.name} + {app.description} + {app.url} +
+ )} +
+) +``` + +#### References + +- **discover:** `() => NotifyApp[]`, refresh `apps` manually and also return updated `apps`. +- **apps:** `NotifyApp[]` + +``` +interface NotifyApp { + id: string + name: string + description: string + url: string + icon: string + isVerified: boolean + isFeatured: boolean + isComingSoon: boolean +} +``` + + +
+ + + +```ts +const apps = await client.discoverApps() + +for(const app of apps) { + console.log({ + id: app.id, + name: app.name, + url: app.url, + icon: app.icon, + isVerified: app.isVerified, + isFeatured: app.isFeatured, + isComingSoon: app.isComingSoon, + }) +} + +// subscribe to the first app +const appUrl = new URL(apps[0].url) +client.subscribeToDapp(undefined, appUrl.hostname) +``` + +#### References +- **discoverApps:** `() => NotifyApp[]` + +``` +interface NotifyApp { + id: string + name: string + description: string + url: string + icon: string + isVerified: boolean + isFeatured: boolean + isComingSoon: boolean +} +``` + + +
From 8fffc66857f99a2e34a09e2bff1b95fbabfcc114 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 23 Apr 2024 18:25:15 +0200 Subject: [PATCH 02/12] chore: untabify --- docs/web3inbox/frontend-integration/api.mdx | 56 ++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index 10d4760ef..13e5aa39a 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -17,8 +17,8 @@ Furthremore you may need to configure the `domain` and `isLimited` parameters: - `allApps` determines if your app has access to all of the user's subscriptions, or only the ones that the app is hosted on. By setting it to `true`, it enables setting `domain` to a value other than `window.location.host`. Setting `allApps: true` can be useful during development to allow your localhost-deployed app to access the subscriptions for the domain you setup. Note that most apps do not need to set this in production environments, as they only need access to their own subscriptions. When enabled, the user has to sign a SIWE message granting your app more permissions, and this requires additional consideration from the user. Read [here](../authorization-signatures/about) for more details. @@ -56,8 +56,8 @@ const client = await Web3InboxClient.init({ projectId, domain, allApps }) ### Setting account for web3inbox @@ -108,8 +108,8 @@ client.watchAccount(account => { ### Registering an account **Note**: [EIP-1271 signatures](https://eips.ethereum.org/EIPS/eip-1271) coming from smart wallets are supported in version `1.1.0` and above. @@ -190,8 +190,8 @@ This use case is for Dapps that have multile active accounts or wallets with mul ::: @@ -322,8 +322,8 @@ client.watchSubscriptions(subscriptions => console.log({ subscriptions })) Get notifications @@ -484,8 +484,8 @@ await markAllNotificationsAsRead(); Manage and fetch notification types. @@ -551,8 +551,8 @@ If you wish to receive live push notifications to your React Native or Web app, Your integration will obtain a token from Firebase and you will need to pass this token to the Web3Inbox SDK using the `registerWithPushServer()` function. @@ -605,8 +605,8 @@ Either APNS or FCM can be used to recieve push notifications. Token here is the ## Listening For Events @@ -669,8 +669,8 @@ interface NotifyNotification { ### Discover apps to subscribe to @@ -683,16 +683,16 @@ return (
{apps.map(app => ( -
{ - const url = new URL(app.url); - subscribe(url.hostname); - }} key={app.id}> - - {app.name} - {app.description} - {app.url} -
- )} +
{ + const url = new URL(app.url); + subscribe(url.hostname); + }} key={app.id}> + + {app.name} + {app.description} + {app.url} +
+ )}
) ``` From 6d6f89e8081613b4608eadeeb4d965e92f4801c8 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 23 Apr 2024 18:35:51 +0200 Subject: [PATCH 03/12] chore: add subscribe function --- docs/web3inbox/frontend-integration/api.mdx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index 13e5aa39a..bdae9e9cb 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -683,10 +683,7 @@ return (
{apps.map(app => ( -
{ - const url = new URL(app.url); - subscribe(url.hostname); - }} key={app.id}> +
{app.name} {app.description} @@ -712,6 +709,7 @@ interface NotifyApp { isVerified: boolean isFeatured: boolean isComingSoon: boolean + subscribe: () => Promise } ``` @@ -736,8 +734,7 @@ for(const app of apps) { } // subscribe to the first app -const appUrl = new URL(apps[0].url) -client.subscribeToDapp(undefined, appUrl.hostname) +await app[0].subscribe() ``` #### References @@ -753,6 +750,7 @@ interface NotifyApp { isVerified: boolean isFeatured: boolean isComingSoon: boolean + subscribe: () => Promise } ``` From f50255fcc79d5324919e79a6e83f7edd5beb1d38 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 23 Apr 2024 18:42:14 +0200 Subject: [PATCH 04/12] chore: remove unused hook --- docs/web3inbox/frontend-integration/api.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index bdae9e9cb..55f7a5622 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -676,7 +676,6 @@ interface NotifyNotification { ```ts -const { subscribe } = useSubscribe(); const { data: apps, isLoading, discover } = useDiscoverApps() return ( From aeb37e34606a1fcc25a3068276ef2453fe35f91e Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Mon, 6 May 2024 15:35:27 +0200 Subject: [PATCH 05/12] chore: clarify fields --- docs/web3inbox/frontend-integration/api.mdx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index 55f7a5622..e6c940aa0 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -745,10 +745,11 @@ interface NotifyApp { name: string description: string url: string + appDomain: string icon: string - isVerified: boolean - isFeatured: boolean - isComingSoon: boolean + isVerified: boolean // Is this app verified for its domain + isFeatured: boolean // Is this app flagged as featured + isComingSoon: boolean // Is this app coming soon or already available subscribe: () => Promise } ``` From bfe847ebd495044d46623a3be5ec735c898b0772 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Mon, 6 May 2024 15:36:20 +0200 Subject: [PATCH 06/12] Update docs/web3inbox/frontend-integration/api.mdx Co-authored-by: Chris Smith <1979423+chris13524@users.noreply.github.com> --- docs/web3inbox/frontend-integration/api.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index e6c940aa0..285493840 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -695,7 +695,7 @@ return ( #### References -- **discover:** `() => NotifyApp[]`, refresh `apps` manually and also return updated `apps`. +- **refresh:** `() => NotifyApp[]`, refresh `apps` manually and also return updated `apps`. - **apps:** `NotifyApp[]` ``` From b0af2517713e84b5598cdd4052430fe8617e035a Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 7 May 2024 12:08:42 +0200 Subject: [PATCH 07/12] chore: clarify discover process --- docs/web3inbox/frontend-integration/api.mdx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index 285493840..811488c92 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -668,6 +668,10 @@ interface NotifyNotification { ### Discover apps to subscribe to +A list is maintained by WalletConnect to dapps one can subscribe to. + +You can add your app to this list by following: https://docs.walletconnect.com/web3inbox/cloud-setup + Promise } ``` @@ -741,7 +746,7 @@ await app[0].subscribe() ``` interface NotifyApp { - id: string + id: string // The ID of the app on the discover list name: string description: string url: string From 4af694125d3f9d4ecf5ea3154d7051d3410bcdfa Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 7 May 2024 14:16:32 +0200 Subject: [PATCH 08/12] Update docs/web3inbox/frontend-integration/api.mdx Co-authored-by: Chris Smith <1979423+chris13524@users.noreply.github.com> --- docs/web3inbox/frontend-integration/api.mdx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index 811488c92..44ec91c9a 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -668,9 +668,7 @@ interface NotifyNotification { ### Discover apps to subscribe to -A list is maintained by WalletConnect to dapps one can subscribe to. - -You can add your app to this list by following: https://docs.walletconnect.com/web3inbox/cloud-setup +Apps wanting to provide users a list of apps that users may want to subscribe to can use this function. This list is manually curated by us, and apps can submit a request to be added to this list in our Cloud app by following [this guide](https://docs.walletconnect.com/web3inbox/cloud-setup). Date: Tue, 7 May 2024 14:24:20 +0200 Subject: [PATCH 09/12] chore: add pagination --- docs/web3inbox/frontend-integration/api.mdx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index 44ec91c9a..0e585724b 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -678,7 +678,10 @@ Apps wanting to provide users a list of apps that users may want to subscribe to ```ts -const { data: apps, isLoading, discover } = useDiscoverApps() +const { data: apps, isLoading, discover, currentPageNumber, nextPage } = useDiscoverApps({ + isInfiniteScroll?: boolean, + appsPerPage?: number +}) return (
@@ -699,6 +702,8 @@ return ( - **refresh:** `() => NotifyApp[]`, refresh `apps` manually and also return updated `apps`. - **apps:** `NotifyApp[]` +- **isInfiniteScroll:** Whether or not to keep already fetched apps when getting next page +- **appsPerPage:** Number representing how many apps to get per fetch ``` interface NotifyApp { @@ -721,7 +726,10 @@ interface NotifyApp { ```ts -const apps = await client.discoverApps() +const { apps, nextPage } = await client.discoverApps({ + isInfiniteScroll?: boolean, + appsPerPage?: number +}) for(const app of apps) { console.log({ @@ -741,6 +749,8 @@ await app[0].subscribe() #### References - **discoverApps:** `() => NotifyApp[]` +- **isInfiniteScroll:** Whether or not to keep already fetched apps when getting next page +- **appsPerPage:** Number representing how many apps to get per fetch ``` interface NotifyApp { From 0fc5dd645da2cc093285cba5e9e05851cdab3541 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 7 May 2024 14:56:49 +0200 Subject: [PATCH 10/12] chore: add filters --- docs/web3inbox/frontend-integration/api.mdx | 52 ++++++++++++++------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index 0e585724b..3ea51ad81 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -680,7 +680,9 @@ Apps wanting to provide users a list of apps that users may want to subscribe to ```ts const { data: apps, isLoading, discover, currentPageNumber, nextPage } = useDiscoverApps({ isInfiniteScroll?: boolean, - appsPerPage?: number + appsPerPage?: number, + isVerified: true, // Filter by featured projects, defaulted to true + isFeatured: true // Filter by verified projects, defaulted to true }) return ( @@ -726,25 +728,41 @@ interface NotifyApp { ```ts -const { apps, nextPage } = await client.discoverApps({ - isInfiniteScroll?: boolean, - appsPerPage?: number -}) -for(const app of apps) { - console.log({ - id: app.id, - name: app.name, - url: app.url, - icon: app.icon, - isVerified: app.isVerified, - isFeatured: app.isFeatured, - isComingSoon: app.isComingSoon, - }) +let apps; + +const onUpdate = (newApps) => { + for(const app of apps) { + console.log({ + id: app.id, + name: app.name, + url: app.url, + icon: app.icon, + isVerified: app.isVerified, + isFeatured: app.isFeatured, + isComingSoon: app.isComingSoon, + }) + } + + // subscribe to the first app + await app[0].subscribe() } -// subscribe to the first app -await app[0].subscribe() +const { nextPage } = await client.pageDiscoverApps({ + isInfiniteScroll: boolean, + appsPerPage: number, + isVerified: true, // Filter by featured projects, defaulted to true + isFeatured: true // Filter by verified projects, defaulted to true +})(onUpdate) + +const singleFetchedApps = await client.discoverApps({ + page: 1, + entries: 5, + isVerified: true, // Filter by featured projects, defaulted to true + isFeatured: true // Filter by verified projects, defaulted to true +}) + + ``` #### References From 137774ec0bae0fdf671c822273a1a4095490aaf9 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Fri, 10 May 2024 14:50:00 +0200 Subject: [PATCH 11/12] chore: remove refresh --- docs/web3inbox/frontend-integration/api.mdx | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index 3ea51ad81..ce60ea8f6 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -678,11 +678,11 @@ Apps wanting to provide users a list of apps that users may want to subscribe to ```ts -const { data: apps, isLoading, discover, currentPageNumber, nextPage } = useDiscoverApps({ - isInfiniteScroll?: boolean, - appsPerPage?: number, - isVerified: true, // Filter by featured projects, defaulted to true - isFeatured: true // Filter by verified projects, defaulted to true +const { data: apps, isLoading, currentPageNumber, nextPage, previousPage, getPage } = useDiscoverApps({ + isInfiniteScroll?: boolean, // Default to false + appsPerPage?: number, // Default to 10 + isVerified?: boolean, // Filter by featured projects, defaulted to true + isFeatured?: boolean // Filter by verified projects, defaulted to true }) return ( @@ -702,7 +702,7 @@ return ( #### References -- **refresh:** `() => NotifyApp[]`, refresh `apps` manually and also return updated `apps`. +- **getPage:** `(page: number) => Promise`, Fetch a specific page, does not affect state - **apps:** `NotifyApp[]` - **isInfiniteScroll:** Whether or not to keep already fetched apps when getting next page - **appsPerPage:** Number representing how many apps to get per fetch @@ -729,9 +729,7 @@ interface NotifyApp { ```ts -let apps; - -const onUpdate = (newApps) => { +const onUpdate = ({apps, currentPage}: {apps: NotifyApp[], currentPage: number}) => { for(const app of apps) { console.log({ id: app.id, @@ -748,11 +746,11 @@ const onUpdate = (newApps) => { await app[0].subscribe() } -const { nextPage } = await client.pageDiscoverApps({ - isInfiniteScroll: boolean, - appsPerPage: number, - isVerified: true, // Filter by featured projects, defaulted to true - isFeatured: true // Filter by verified projects, defaulted to true +const { previousPage, nextPage } = await client.pageDiscoverApps({ + isInfiniteScroll?: boolean, // Default to false + appsPerPage?: number, // Default to 10 + isVerified?: boolean, // Filter by featured projects, defaulted to true + isFeatured?: boolean // Filter by verified projects, defaulted to true })(onUpdate) const singleFetchedApps = await client.discoverApps({ From 17a0ab06432bdf31d99eb0b3fab49e7c114f2d63 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Fri, 10 May 2024 14:51:24 +0200 Subject: [PATCH 12/12] chore: update jsx --- docs/web3inbox/frontend-integration/api.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/web3inbox/frontend-integration/api.mdx b/docs/web3inbox/frontend-integration/api.mdx index ce60ea8f6..7a9c41efe 100644 --- a/docs/web3inbox/frontend-integration/api.mdx +++ b/docs/web3inbox/frontend-integration/api.mdx @@ -687,7 +687,6 @@ const { data: apps, isLoading, currentPageNumber, nextPage, previousPage, getPag return (
- {apps.map(app => (
@@ -696,6 +695,9 @@ return ( {app.url}
)} +
) ```