diff --git a/packages/restapi/src/lib/channels/getChannelNotifications.ts b/packages/restapi/src/lib/channels/getChannelNotifications.ts index de50e6da3..8e813668b 100644 --- a/packages/restapi/src/lib/channels/getChannelNotifications.ts +++ b/packages/restapi/src/lib/channels/getChannelNotifications.ts @@ -50,7 +50,6 @@ export const getChannelNotifications = async ( } ); const requestUrl = `${apiEndpoint}/${_channel}/notifications?${query}`; - return await axiosGet(requestUrl) .then((response) => { if (raw) return {feeds: response.data?.feeds ?? [], itemcount:response.data?.itemcount} ; diff --git a/packages/restapi/src/lib/constantsV2.ts b/packages/restapi/src/lib/constantsV2.ts index 346d9f1a8..955e952d4 100644 --- a/packages/restapi/src/lib/constantsV2.ts +++ b/packages/restapi/src/lib/constantsV2.ts @@ -38,6 +38,13 @@ const CONSTANTS = { }, ALPHA_FEATURES: ALPHA_FEATURES, USER: { ENCRYPTION_TYPE: ENCRYPTION_TYPE }, + NOTIFICATION: { + TYPE: { + BROADCAST: 1, + SUBSET: 4, + TARGETTED: 3 + } + } }; export default CONSTANTS; diff --git a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts index a0f7bcd25..dbdab6063 100644 --- a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts +++ b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts @@ -118,7 +118,6 @@ export type NotificationSetting = { export type NotificationSettings = NotificationSetting[]; export type ChannelFeedsOptions = { - account?: string; page?: number; limit?: number; raw?: boolean; diff --git a/packages/restapi/src/lib/pushNotification/channel.ts b/packages/restapi/src/lib/pushNotification/channel.ts index 3f7359de6..762a563a5 100644 --- a/packages/restapi/src/lib/pushNotification/channel.ts +++ b/packages/restapi/src/lib/pushNotification/channel.ts @@ -20,6 +20,7 @@ import { getCAIPDetails, validateCAIP, getFallbackETHCAIPAddress, + pCAIP10ToWallet, } from '../helpers'; import PROGRESSHOOK from '../progressHook'; import * as viem from 'viem'; @@ -412,15 +413,17 @@ export class Channel extends PushNotificationBaseClass { } }; - notifications = async(options?:ChannelFeedsOptions) => { + notifications = async(account: string, options?:ChannelFeedsOptions) => { try{ const { - account = this.account, page, limit, filter = null, raw = true } = options || {} + if(account.split(":").length == 2){ + account = pCAIP10ToWallet(account) + } return await PUSH_CHANNEL.getChannelNotifications({ channel: account as string, env: this.env, diff --git a/packages/restapi/tests/lib/notification/channel.test.ts b/packages/restapi/tests/lib/notification/channel.test.ts index e67467970..6fdd8dab8 100644 --- a/packages/restapi/tests/lib/notification/channel.test.ts +++ b/packages/restapi/tests/lib/notification/channel.test.ts @@ -13,12 +13,7 @@ import { createPublicClient, } from 'viem'; import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'; - -export enum NotifictaionType { - BROADCAT = 1, - TARGETTED = 3, - SUBSET = 4 -} +import CONSTANTS from '../../../src/lib/constantsV2'; describe('PushAPI.channel functionality', () => { let userAlice: PushAPI; @@ -571,19 +566,19 @@ describe('PushAPI.channel functionality', () => { describe("notifications", async()=>{ it("Should fetch channel specific feeds", async()=>{ - const res = await userAlice.channel.notifications({raw: false}) + const res = await userAlice.channel.notifications("eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681",{raw: false}) console.log(res) expect(res).not.null }) it("Should fetch channel specific feeds in raw fomrta", async()=>{ - const res = await userAlice.channel.notifications({raw: true}) + const res = await userAlice.channel.notifications("eip155:0xD8634C39BBFd4033c0d3289C4515275102423681",{raw: true}) console.log(res) expect(res).not.null }) it("Should fetch channel specific feeds broadcast type", async()=>{ - const res = await userAlice.channel.notifications({raw: true, filter: NotifictaionType.BROADCAT}) + const res = await userAlice.channel.notifications("0xD8634C39BBFd4033c0d3289C4515275102423681",{raw: false, filter: CONSTANTS.NOTIFICATION.TYPE.TARGETTED}) console.log(res) expect(res).not.null })