diff --git a/packages/examples/sdk-backend-node/src/main.ts b/packages/examples/sdk-backend-node/src/main.ts index fd7744a1c..97150161f 100644 --- a/packages/examples/sdk-backend-node/src/main.ts +++ b/packages/examples/sdk-backend-node/src/main.ts @@ -76,9 +76,11 @@ const updatedNftGroupName = uniqueNamesGenerator({ // Video Data const videoChainId = +process.env.VIDEO_CHAIN_ID; let videoData = PushAPI.video.initVideoCallData; -const videoSetData: (fn:(data:PushAPI.VideoCallData) => PushAPI.VideoCallData) => void = (fn) => { +const videoSetData: ( + fn: (data: PushAPI.VideoCallData) => PushAPI.VideoCallData +) => void = (fn) => { videoData = fn(videoData); -} +}; let videoObject = null; const videoLocalStream = null; // get the local stream const videoSenderAddress = process.env.VIDEO_SENDER_ADDRESS; @@ -424,11 +426,14 @@ async function runChatUseCases() { await PushAPI_chat_requests(); console.log('PushAPI.chat.send'); - await PushAPI_chat_send(); + const TargetChatId = await PushAPI_chat_send(); console.log('PushAPI.chat.approve'); await PushAPI_chat_approve(); + console.log('PushAPI chat Video call Notification'); + await PushAPI_chat_video_call_notification(TargetChatId); + console.log('PushAPI.chat.createGroup'); const chatId = await PushAPI_chat_createGroup(); @@ -694,6 +699,7 @@ async function PushAPI_chat_send(silent = !showAPIResponse) { if (!silent) { console.log(response); } + return response.chatId; } // Push Chat - Approve @@ -951,6 +957,55 @@ async function PushChatSDKSocket(silent = !showAPIResponse) { await delay(4000); } +async function PushAPI_chat_video_call_notification( + chatId: string, + silent = !showAPIResponse +) { + // Fetch user + const user = await PushAPI.user.get({ + account: signer.address, + env: env as ENV, + }); + + // Decrypt PGP Key + const pgpDecrpyptedPvtKey = await PushAPI.chat.decryptPGPKey({ + encryptedPGPPrivateKey: user.encryptedPrivateKey, + signer: signer, + }); + // get PGP KEy + const apiResponse = await PushAPI.payloads.sendNotification({ + senderType: 1, + signer: signer, + pgpPrivateKey: pgpDecrpyptedPvtKey, + chatId: chatId, + type: 3, // target + identityType: 2, // direct payload + notification: { + title: `VC TITLE:`, + body: `VC BODY`, + }, + payload: { + title: `payload title`, + body: `sample msg body`, + cta: '', + img: '', + additionalMeta: { + type: '1+1', + data: 'Random DATA', + domain: 'push.org', + }, + }, + recipients: signerSecondAccount.address, // recipient address + channel: signer.address, // your channel address + env: env as ENV, + }); + + console.log('PushAPI.payloads.sendNotification | Response - 204 OK'); + if (!silent) { + console.log(apiResponse); + } +} + // Push Chat - Run Chat Use cases async function runNFTChatUseCases() { console.log(` @@ -976,11 +1031,14 @@ async function runNFTChatUseCases() { await PushAPI_nft_chat_requests(); console.log('PushAPI.chat.send'); - await PushAPI_nft_chat_send(); + const TargetchatId = await PushAPI_nft_chat_send(); console.log('PushAPI.chat.approve'); await PushAPI_nft_chat_approve(); + console.log('NFT Video Call Notification'); + await PushAPI_nft_chat_video_call_notification(TargetchatId); + console.log('PushAPI.chat.createGroup'); const chatId = await PushAPI_nft_chat_createGroup(); @@ -1245,6 +1303,7 @@ async function PushAPI_nft_chat_send(silent = !showAPIResponse) { if (!silent) { console.log(response); } + return response.chatId; } // Push Chat - Approve @@ -1278,6 +1337,55 @@ async function PushAPI_nft_chat_approve(silent = !showAPIResponse) { } } +async function PushAPI_nft_chat_video_call_notification( + chatId: string, + silent = !showAPIResponse +) { + // Fetch user + const user = await PushAPI.user.get({ + account: nftAccount1, + env: env as ENV, + }); + + // Decrypt PGP Key + const pgpDecrpyptedPvtKey = await PushAPI.chat.decryptPGPKey({ + encryptedPGPPrivateKey: user.encryptedPrivateKey, + signer: nftSigner1, + }); + + const apiResponse = await PushAPI.payloads.sendNotification({ + senderType: 1, + signer: nftSigner1, + pgpPrivateKey: pgpDecrpyptedPvtKey, + chatId: chatId, + type: 1, // target + identityType: 2, // direct payload + notification: { + title: `VC TITLE:`, + body: `VC BODY`, + }, + payload: { + title: `payload title`, + body: `sample msg body`, + cta: '', + img: '', + additionalMeta: { + type: '1+1', + data: 'Random DATA', + domain: 'push.org', + }, + }, + recipients: nftAccount1, // recipient address + channel: nftAccount1, // your channel address + env: env as ENV, + }); + + console.log('PushAPI.payloads.sendNotification | Response - 204 OK'); + if (!silent) { + console.log(apiResponse); + } +} + // Push Chat - PushAPI.chat.createGroup async function PushAPI_nft_chat_createGroup( silent = !showAPIResponse @@ -1498,7 +1606,7 @@ async function PushNFTChatSDKSocket(silent = !showAPIResponse) { } // Push Video - Run Video Use cases -async function runVideoUseCases(){ +async function runVideoUseCases() { console.log(` ██╗ ██╗██╗██████╗ ███████╗ ██████╗ ██║ ██║██║██╔══██╗██╔════╝██╔═══██╗ @@ -1530,7 +1638,7 @@ async function runVideoUseCases(){ await PushVideoSDKSocket(); } -async function PushAPI_video_object_init(){ +async function PushAPI_video_object_init() { // Fetch user const user = await PushAPI.user.get({ account: `eip155:${signer.address}`, @@ -1556,10 +1664,10 @@ async function PushAPI_video_object_init(){ return videoObject; } -async function PushAPI_video_create(){ +async function PushAPI_video_create() { await videoObject.create({ - stream: videoLocalStream -}); + stream: videoLocalStream, + }); } async function PushAPI_video_request() { @@ -1570,7 +1678,7 @@ async function PushAPI_video_request() { }); } -async function PushAPI_video_accept_request(){ +async function PushAPI_video_accept_request() { videoObject.acceptRequest({ signalData: videoSignalData_1, senderAddress: videoRecipientAddress, @@ -1579,13 +1687,13 @@ async function PushAPI_video_accept_request(){ }); } -async function PushAPI_video_connect(){ +async function PushAPI_video_connect() { videoObject.connect({ - signalData: {} // signalData from sockets - }) + signalData: {}, // signalData from sockets + }); } -async function PushAPI_video_disconnect(){ +async function PushAPI_video_disconnect() { videoObject.disconnect(); } @@ -1660,7 +1768,7 @@ function start() { runNotificaitonsUseCases().then(() => { runChatUseCases().then(() => { runNFTChatUseCases().then(() => { - if(videoLocalStream !== null){ + if (videoLocalStream !== null) { /* - One instance of videoObject corresponds to one user/peer of the call - For a wallet-to-wallet video call we need 2 such users/peers diff --git a/packages/restapi/CHANGELOG.md b/packages/restapi/CHANGELOG.md index 9be102169..785c5a8cb 100644 --- a/packages/restapi/CHANGELOG.md +++ b/packages/restapi/CHANGELOG.md @@ -31,17 +31,33 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/s ### Bug Fixes * add deprecated info to chat.chat ([#392](https://github.com/ethereum-push-notification-service/push-sdk/issues/392)) ([d84ae64](https://github.com/ethereum-push-notification-service/push-sdk/commit/d84ae64c116adb7eea9e8faf7929b6eb3b74c657)) +* Merge branch 'alpha' into alpha-deployment ([549fd83](https://github.com/ethereum-push-notification-service/push-sdk/commit/549fd839867d84a98a10206a7f9945aeb1720e49)) +* Merge branch 'main' into alpha ([72464fd](https://github.com/ethereum-push-notification-service/push-sdk/commit/72464fd97260b612649035e3b241f946de8f9e92)) * show hardcoded msg rather than throwing error ([#388](https://github.com/ethereum-push-notification-service/push-sdk/issues/388)) ([8962e10](https://github.com/ethereum-push-notification-service/push-sdk/commit/8962e10036916d0bc161324f5684f74bb7b74dc3)) +* **video:** set trickle to true while creating peer instance ([#397](https://github.com/ethereum-push-notification-service/push-sdk/issues/397)) ([0b609be](https://github.com/ethereum-push-notification-service/push-sdk/commit/0b609bec87a6187d1e7cbf8052a2b9a36b9fcd7a)) -## [1.2.15](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.2.14...restapi-1.2.15) (2023-05-12) +## [0.0.1-alpha.7](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.6...restapi-0.0.1-alpha.7) (2023-05-15) ### Bug Fixes -* fix eip712v2 ([#385](https://github.com/ethereum-push-notification-service/push-sdk/issues/385)) ([42c10ba](https://github.com/ethereum-push-notification-service/push-sdk/commit/42c10ba6f5331c9caf5db7136ba94d1a6ed05e10)) -* Merge branch 'main' into deployment ([3250a7c](https://github.com/ethereum-push-notification-service/push-sdk/commit/3250a7cfc3bb8fefd630179cd204deef023a5e6c)) +* Merge branch 'alpha' into alpha-deployment ([37c1c8d](https://github.com/ethereum-push-notification-service/push-sdk/commit/37c1c8db579876f5835c2e5bb5e6baf073dc9208)) +* **video:** remove status change upon connect in request ([#394](https://github.com/ethereum-push-notification-service/push-sdk/issues/394)) ([7441ef0](https://github.com/ethereum-push-notification-service/push-sdk/commit/7441ef0fb2c9ed39e12a4f1819ade0ee7e0d6b10)) + + + +## [0.0.1-alpha.6](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.5...restapi-0.0.1-alpha.6) (2023-05-14) + + +### Bug Fixes + +* add video call retry logic upon error & doc: add video call in restapi/readme ([#391](https://github.com/ethereum-push-notification-service/push-sdk/issues/391)) ([9c8c86b](https://github.com/ethereum-push-notification-service/push-sdk/commit/9c8c86b35d1cb0300d0170e87931dd31a15f9342)) + + + +## [0.0.1-alpha.5](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.4...restapi-0.0.1-alpha.5) (2023-05-14) diff --git a/packages/restapi/src/lib/channels/_getSubscribers.ts b/packages/restapi/src/lib/channels/_getSubscribers.ts index 6e4733980..704f09b99 100644 --- a/packages/restapi/src/lib/channels/_getSubscribers.ts +++ b/packages/restapi/src/lib/channels/_getSubscribers.ts @@ -35,7 +35,7 @@ export const _getSubscribers = async ( env = Constants.ENV.PROD, } = options || {}; - const _channelAddress = getCAIPAddress(env, channel, 'Channel'); + const _channelAddress = await getCAIPAddress(env, channel, 'Channel'); const channelCAIPDetails = getCAIPDetails(_channelAddress); if (!channelCAIPDetails) throw Error('Invalid Channel CAIP!'); diff --git a/packages/restapi/src/lib/channels/getChannel.ts b/packages/restapi/src/lib/channels/getChannel.ts index 39dcb3d8c..eb9a661da 100644 --- a/packages/restapi/src/lib/channels/getChannel.ts +++ b/packages/restapi/src/lib/channels/getChannel.ts @@ -22,7 +22,7 @@ export const getChannel = async ( env = Constants.ENV.PROD, } = options || {}; - const _channel = getCAIPAddress(env, channel, 'Channel'); + const _channel = await getCAIPAddress(env, channel, 'Channel'); const API_BASE_URL = getAPIBaseUrls(env); const apiEndpoint = `${API_BASE_URL}/v1/channels`; const requestUrl = `${apiEndpoint}/${_channel}`; diff --git a/packages/restapi/src/lib/channels/getDelegates.ts b/packages/restapi/src/lib/channels/getDelegates.ts index d45d90fc0..ef825c96c 100644 --- a/packages/restapi/src/lib/channels/getDelegates.ts +++ b/packages/restapi/src/lib/channels/getDelegates.ts @@ -27,7 +27,7 @@ export const getDelegates = async ( env = Constants.ENV.PROD, } = options || {}; - const _channel = getCAIPAddress(env, channel, 'Channel'); + const _channel = await getCAIPAddress(env, channel, 'Channel'); const API_BASE_URL = getAPIBaseUrls(env); const apiEndpoint = `${API_BASE_URL}/v1/channels`; const requestUrl = `${apiEndpoint}/${_channel}/delegates`; diff --git a/packages/restapi/src/lib/channels/getSubscribers.ts b/packages/restapi/src/lib/channels/getSubscribers.ts index bf1248fed..50f2f7824 100644 --- a/packages/restapi/src/lib/channels/getSubscribers.ts +++ b/packages/restapi/src/lib/channels/getSubscribers.ts @@ -47,7 +47,7 @@ export const getSubscribers = async ( if (limit > 30) { throw new Error("limit must be lesser than or equal to 30"); } - const _channel = getCAIPAddress(env, channel, 'Channel'); + const _channel = await getCAIPAddress(env, channel, 'Channel'); const API_BASE_URL = getAPIBaseUrls(env); const apiEndpoint = `${API_BASE_URL}/v1/channels/${_channel}/subscribers?page=${page}&limit=${limit}`; return await axios.get(apiEndpoint) diff --git a/packages/restapi/src/lib/channels/subscribe.ts b/packages/restapi/src/lib/channels/subscribe.ts index 1b2541d21..4db84c914 100644 --- a/packages/restapi/src/lib/channels/subscribe.ts +++ b/packages/restapi/src/lib/channels/subscribe.ts @@ -43,14 +43,14 @@ export const subscribe = async ( } = options || {}; try { - const _channelAddress = getCAIPAddress(env, channelAddress, 'Channel'); + const _channelAddress = await getCAIPAddress(env, channelAddress, 'Channel'); const channelCAIPDetails = getCAIPDetails(_channelAddress); if (!channelCAIPDetails) throw Error('Invalid Channel CAIP!'); const chainId = parseInt(channelCAIPDetails.networkId, 10); - const _userAddress = getCAIPAddress(env, userAddress, 'User'); + const _userAddress = await getCAIPAddress(env, userAddress, 'User'); const userCAIPDetails = getCAIPDetails(_userAddress); if (!userCAIPDetails) throw Error('Invalid User CAIP!'); diff --git a/packages/restapi/src/lib/channels/unsubscribe.ts b/packages/restapi/src/lib/channels/unsubscribe.ts index 404410edf..19ec57b36 100644 --- a/packages/restapi/src/lib/channels/unsubscribe.ts +++ b/packages/restapi/src/lib/channels/unsubscribe.ts @@ -43,14 +43,14 @@ export const unsubscribe = async ( } = options || {}; try { - const _channelAddress = getCAIPAddress(env, channelAddress, 'Channel'); + const _channelAddress = await getCAIPAddress(env, channelAddress, 'Channel'); const channelCAIPDetails = getCAIPDetails(_channelAddress); if (!channelCAIPDetails) throw Error('Invalid Channel CAIP!'); const chainId = parseInt(channelCAIPDetails.networkId, 10); - const _userAddress = getCAIPAddress(env, userAddress, 'User'); + const _userAddress = await getCAIPAddress(env, userAddress, 'User'); const userCAIPDetails = getCAIPDetails(_userAddress); if (!userCAIPDetails) throw Error('Invalid User CAIP!'); diff --git a/packages/restapi/src/lib/helpers/address.ts b/packages/restapi/src/lib/helpers/address.ts index 395b2712f..2457953e2 100644 --- a/packages/restapi/src/lib/helpers/address.ts +++ b/packages/restapi/src/lib/helpers/address.ts @@ -1,5 +1,6 @@ import * as ethers from 'ethers'; import Constants, {ENV} from '../constants'; +import { getUserDID } from '../chat/helpers'; export interface AddressValidatorsType { [key: string]: ({ address } : { address: string }) => boolean; @@ -66,6 +67,8 @@ export function validateCAIP(addressInCAIP: string) { if (!networkId) return false; if (!address) return false; + if(isValidCAIP10NFTAddress(addressInCAIP))return true; + const validatorFn = AddressValidators[blockchain]; return validatorFn({ address }); @@ -115,7 +118,10 @@ export function getFallbackETHCAIPAddress(env: ENV, address: string) { * else * throw error! */ -export function getCAIPAddress(env: ENV, address: string, msg?: string) { +export async function getCAIPAddress(env: ENV, address: string, msg?: string) { + if(isValidCAIP10NFTAddress(address)){ + return await getUserDID(address, env); + } if (validateCAIP(address)) { return address; } else { diff --git a/packages/restapi/src/lib/payloads/helpers.ts b/packages/restapi/src/lib/payloads/helpers.ts index 0bd5df87b..ff876ae3b 100644 --- a/packages/restapi/src/lib/payloads/helpers.ts +++ b/packages/restapi/src/lib/payloads/helpers.ts @@ -91,7 +91,7 @@ export async function getRecipients({ */ if (notificationType === NOTIFICATION_TYPE.TARGETTED) { if (typeof recipients === 'string') { - addressInCAIP = getCAIPAddress(env, recipients, 'Recipient'); + addressInCAIP = await getCAIPAddress(env, recipients, 'Recipient'); secret = ''; // do secret stuff // TODO return { @@ -100,15 +100,18 @@ export async function getRecipients({ } } else if (notificationType === NOTIFICATION_TYPE.SUBSET) { if (Array.isArray(recipients)) { - const recipientObject = recipients.reduce((_recipients, _rAddress) => { - addressInCAIP = getCAIPAddress(env, _rAddress, 'Recipient'); - secret = ''; // do secret stuff // TODO + const recipientObject = recipients.reduce( + async (_recipients, _rAddress) => { + addressInCAIP = await getCAIPAddress(env, _rAddress, 'Recipient'); + secret = ''; // do secret stuff // TODO - return { - ..._recipients, - [addressInCAIP]: secret, - }; - }, {}); + return { + ..._recipients, + [addressInCAIP]: secret, + }; + }, + {} + ); return recipientObject; } @@ -119,23 +122,23 @@ export async function getRecipients({ */ if (notificationType === NOTIFICATION_TYPE.BROADCAST) { - if (!recipients) { - // return getCAIPFormat(chainId, channel || ''); - return getCAIPAddress(env, channel, 'Recipient'); - } + return await getCAIPAddress(env, channel, 'Recipient'); } else if (notificationType === NOTIFICATION_TYPE.TARGETTED) { if (typeof recipients === 'string') { - return getCAIPAddress(env, recipients, 'Recipient'); + return await getCAIPAddress(env, recipients, 'Recipient'); } } else if (notificationType === NOTIFICATION_TYPE.SUBSET) { if (Array.isArray(recipients)) { - const recipientObject = recipients.reduce((_recipients, _rAddress) => { - addressInCAIP = getCAIPAddress(env, _rAddress, 'Recipient'); - return { - ..._recipients, - [addressInCAIP]: null, - }; - }, {}); + const recipientObject = recipients.reduce( + async (_recipients, _rAddress) => { + addressInCAIP = await getCAIPAddress(env, _rAddress, 'Recipient'); + return { + ..._recipients, + [addressInCAIP]: null, + }; + }, + {} + ); return recipientObject; } } @@ -143,7 +146,7 @@ export async function getRecipients({ return recipients; } -export function getRecipientFieldForAPIPayload({ +export async function getRecipientFieldForAPIPayload({ env, notificationType, recipients, @@ -158,10 +161,10 @@ export function getRecipientFieldForAPIPayload({ notificationType === NOTIFICATION_TYPE.TARGETTED && typeof recipients === 'string' ) { - return getCAIPAddress(env, recipients, 'Recipient'); + return await getCAIPAddress(env, recipients, 'Recipient'); } - return getCAIPAddress(env, channel, 'Recipient'); + return await getCAIPAddress(env, channel, 'Recipient'); } export async function getVerificationProof({ diff --git a/packages/restapi/src/lib/payloads/sendNotifications.ts b/packages/restapi/src/lib/payloads/sendNotifications.ts index 01987699f..eb262f5f8 100644 --- a/packages/restapi/src/lib/payloads/sendNotifications.ts +++ b/packages/restapi/src/lib/payloads/sendNotifications.ts @@ -9,7 +9,14 @@ import { getSource, getUUID, } from './helpers'; -import { getCAIPAddress, getCAIPDetails, getConfig } from '../helpers'; +import { + getAPIBaseUrls, + getCAIPAddress, + getCAIPDetails, + getConfig, + isValidCAIP10NFTAddress, + isValidETHAddress, +} from '../helpers'; import { IDENTITY_TYPE, DEFAULT_DOMAIN } from './constants'; import { ENV } from '../constants'; @@ -20,6 +27,15 @@ function validateOptions(options: any) { if (!options?.channel) { throw '[Push SDK] - Error - sendNotification() - "channel" is mandatory!'; } + if (!isValidETHAddress(options.channel)) { + throw '[Push SDK] - Error - sendNotification() - "channel" is invalid!'; + } + if (options.senderType === 0 && options.signer === undefined) { + throw '[Push SDK] - Error - sendNotification() - "signer" is mandatory!'; + } + if (options.senderType === 1 && options.pgpPrivateKey === undefined) { + throw '[Push SDK] - Error - sendNotification() - "pgpPrivateKey" is mandatory!'; + } /** * Apart from IPFS, GRAPH use cases "notification", "payload" is mandatory @@ -60,9 +76,6 @@ export async function sendNotification(options: ISendNotificationInputOptions) { validateOptions(options); - if (signer === undefined) { - throw new Error(`Signer is necessary!`); - } if ( payload && payload.additionalMeta && @@ -71,8 +84,7 @@ export async function sendNotification(options: ISendNotificationInputOptions) { ) { payload.additionalMeta.domain = DEFAULT_DOMAIN; } - - const _channelAddress = getCAIPAddress(env, channel, 'Channel'); + const _channelAddress = await getCAIPAddress(env, channel, 'Channel'); const channelCAIPDetails = getCAIPDetails(_channelAddress); if (!channelCAIPDetails) throw Error('Invalid Channel CAIP!'); @@ -80,10 +92,12 @@ export async function sendNotification(options: ISendNotificationInputOptions) { const uuid = getUUID(); const chainId = parseInt(channelCAIPDetails.networkId, 10); - const { API_BASE_URL, EPNS_COMMUNICATOR_CONTRACT } = getConfig( - env, - channelCAIPDetails - ); + const API_BASE_URL = getAPIBaseUrls(env); + let COMMUNICATOR_CONTRACT = ''; + if (senderType === 0) { + const { EPNS_COMMUNICATOR_CONTRACT } = getConfig(env, channelCAIPDetails); + COMMUNICATOR_CONTRACT = EPNS_COMMUNICATOR_CONTRACT; + } const _recipients = await getRecipients({ env, @@ -101,7 +115,7 @@ export async function sendNotification(options: ISendNotificationInputOptions) { chainId, identityType, notificationType: type, - verifyingContract: EPNS_COMMUNICATOR_CONTRACT, + verifyingContract: COMMUNICATOR_CONTRACT, payload: notificationPayload, graph, ipfsHash, @@ -125,12 +139,12 @@ export async function sendNotification(options: ISendNotificationInputOptions) { verificationProof, identity, sender: - senderType === 1 + senderType === 1 && !isValidCAIP10NFTAddress(_channelAddress) ? `${channelCAIPDetails?.blockchain}:${channelCAIPDetails?.address}` : _channelAddress, source, /** note this recipient key has a different expectation from the BE API, see the funciton for more */ - recipient: getRecipientFieldForAPIPayload({ + recipient: await getRecipientFieldForAPIPayload({ env, notificationType: type, recipients: recipients || '', diff --git a/packages/restapi/src/lib/user/getDelegations.ts b/packages/restapi/src/lib/user/getDelegations.ts index acea37325..ba211d09b 100644 --- a/packages/restapi/src/lib/user/getDelegations.ts +++ b/packages/restapi/src/lib/user/getDelegations.ts @@ -27,7 +27,7 @@ export const getDelegations = async ( env = Constants.ENV.PROD, } = options || {}; - const _user = getCAIPAddress(env, user, 'User'); + const _user = await getCAIPAddress(env, user, 'User'); const API_BASE_URL = getAPIBaseUrls(env); const apiEndpoint = `${API_BASE_URL}/v1/users/${_user}/delegations`; const requestUrl = `${apiEndpoint}`; diff --git a/packages/restapi/src/lib/user/getFeeds.ts b/packages/restapi/src/lib/user/getFeeds.ts index 1f33837fd..87c7fd42a 100644 --- a/packages/restapi/src/lib/user/getFeeds.ts +++ b/packages/restapi/src/lib/user/getFeeds.ts @@ -29,7 +29,7 @@ export const getFeeds = async ( raw = false, } = options || {}; - const _user = getCAIPAddress(env, user, 'User'); + const _user = await getCAIPAddress(env, user, 'User'); const API_BASE_URL = getAPIBaseUrls(env); const apiEndpoint = `${API_BASE_URL}/v1/users/${_user}/feeds`; diff --git a/packages/restapi/src/lib/user/getSubscriptions.ts b/packages/restapi/src/lib/user/getSubscriptions.ts index 9aae4c9ad..7e45d061e 100644 --- a/packages/restapi/src/lib/user/getSubscriptions.ts +++ b/packages/restapi/src/lib/user/getSubscriptions.ts @@ -15,7 +15,7 @@ export const getSubscriptions = async ( env = Constants.ENV.PROD, } = options || {}; - const _user = getCAIPAddress(env, user, 'User'); + const _user = await getCAIPAddress(env, user, 'User'); const API_BASE_URL = getAPIBaseUrls(env); const apiEndpoint = `${API_BASE_URL}/v1/users/${_user}/subscriptions`; const requestUrl = `${apiEndpoint}`;