Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Axios Wrapper and Pass SDK Version Header #872

Merged
merged 4 commits into from
Jan 11, 2024

Conversation

mohammeds1992
Copy link
Collaborator

No description provided.

@mohammeds1992 mohammeds1992 linked an issue Nov 23, 2023 that may be closed by this pull request
Copy link

File: packages/restapi/src/lib/alias/getAliasInfo.ts

  • The comment "GET /v1/alias/{aliasAddressinCAIP}/channel" should be moved above the type definition.
  • The comment "Returns the ethereum channel address of the provided alias address along with its verification status" should be moved above the function.

File: packages/restapi/src/lib/channels/_getSubscribers.ts

  • The deprecationWarning constant should be moved outside the function and named in PascalCase.
  • The comment "LEGACY SDK method, kept to support old functionality" should be moved above the function.
  • The comment "can be removed if not needed in future." should be removed.

File: packages/restapi/src/lib/channels/getChannel.ts

  • The comment "GET /v1/channels/{addressinCAIP}" should be moved above the type definition.
  • The comment "Returns the channel information of the provided channel address" should be moved above the function.

File: packages/restapi/src/lib/channels/getDelegates.ts

  • The comment "GET v1/channels/${channelAddressInCAIP}/delegates" should be moved above the type definition.
  • The comment "Returns the list of addresses that the channel has delegated to" should be moved above the function.

File: packages/restapi/src/lib/channels/getSubscribers.ts

  • The comment "GET /v1/channels/:channelId/:subscribers" should be moved above the type definition.
  • The comment "Returns the subscribers of the specified channel" should be moved above the function.
  • There are missing closing braces and parentheses after the throw statements inside the try block.

File: packages/restapi/src/lib/channels/search.ts

  • The comment "GET /v1/channels/search/" should be moved above the type definition.
  • The comment "optional params: page=(1)&limit=(20{min:1}{max:30})&query=(searchquery)" should be moved above the function.

File: packages/restapi/src/lib/channels/subscribe.ts

  • The comment "LEGACY SDK method, kept to support old functionality" should be moved above the function.
  • The comment "Subscribes a user to a channel" should be moved above the function.
  • The comment "sign a message using EIP712" should be moved above the signature variable assignment.

File: packages/restapi/src/lib/channels/subscribeV2.ts

  • The comment "Subscribes a user to a channel (V2)" should be moved above the function.
  • The comment "sign a message using EIP712" should be moved above the signature variable assignment.

File: packages/restapi/src/lib/channels/unsubscribe.ts

  • This file is empty. Should it be removed

Copy link

File: packages/restapi/src/lib/alias/getAliasInfo.ts

  • In the import statement, the '../helpers' path is incorrect. It should be '../helpers/index'.
  • The comment indicating the return value of the function is not placed properly. Move it above the function signature.

File: packages/restapi/src/lib/channels/_getSubscribers.ts

  • The deprecationWarning constant is not used anywhere in the code.

File: packages/restapi/src/lib/channels/getChannel.ts

  • In the import statement, the '../helpers' path is incorrect. It should be '../helpers/index'.

File: packages/restapi/src/lib/channels/getDelegates.ts

  • In the import statement, the '../helpers' path is incorrect. It should be '../helpers/index'.

File: packages/restapi/src/lib/channels/getSubscribers.ts

  • The comment indicating the return type of the function is not placed properly. Move it above the function signature.
  • There are missing closing braces for the if statements checking the values of page and limit.

File: packages/restapi/src/lib/channels/search.ts

  • In the import statement, the '../helpers' path is incorrect. It should be '../helpers/index'.

File: packages/restapi/src/lib/channels/subscribe.ts

  • In the import statements, the '../helpers' and '../types' paths are incorrect. They should be '../helpers/index' and '../types/index' respectively.
  • The comment indicating the deprecated API expects ETH address format should be moved above the 'body' declaration to provide proper context.

File: packages/restapi/src/lib/channels/subscribeV2.ts

  • In the import statements, the '../helpers' and '../types' paths are incorrect. They should be '../helpers/index' and '../types/index' respectively.
  • There are missing closing braces for the getConfig function call.

File: packages/restapi/src/lib/channels/unsubscribe.ts

  • This file is empty and should be removed.

File: packages/restapi/src/lib/channels/unsubscribeV2.ts

  • This file is empty and should be removed.

File: packages/restapi/src/lib/chat/approveRequest.ts

  • This file is empty and should be removed.

File: packages/restapi/src/lib/chat/chat.ts

  • This file is empty and should be removed.

File: packages/restapi/src/lib/chat/chats.ts

  • This file is empty and should be removed.

File: packages/restapi/src/lib/chat/createGroup.ts

  • This file is empty and should be removed.

File: packages/restapi/src/lib/chat/getGroup.ts

  • This file is empty and should be removed.

File: packages/restapi/src/lib/chat/getGroupAccess.ts

  • This file is empty and should be removed.

File: packages/restapi/src/lib/chat/getGroupByName

Copy link

File: .husky/pre-commit

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

echo "\nRunning GIT hooks..."
yarn cleanbuild
yarn nx affected --target=lint
#yarn nx affected --target=test

All looks good.

File: packages/restapi/src/lib/alias/getAliasInfo.ts

import { getAPIBaseUrls, getCAIPWithChainId } from '../helpers';
import Constants, { ENV } from '../constants';
import { ALIAS_CHAIN, ALIAS_CHAIN_ID } from '../config';
import { axiosGet } from '../utils/axiosUtil';

/**

  • GET /v1/alias/{aliasAddressinCAIP}/channel
    /
    export type GetAliasInfoOptionsType = {
    /
    * alias address of the ethereum channel /
    alias: string;
    /
    * name of the alias chain, can be Polygon or BSC or Optimism */
    aliasChain: ALIAS_CHAIN;
    env?: ENV;
    };
    // Returns the ethereum channel address of the provided alias address along with its verification status
    export const getAliasInfo = async (options: GetAliasInfoOptionsType) => {
    const { alias, aliasChain, env = Constants.ENV.PROD } = options || {};
    const aliasChainId: number = ALIAS_CHAIN_ID[aliasChain][env];
    const _alias = getCAIPWithChainId(alias, aliasChainId, 'Alias');
    const API_BASE_URL = getAPIBaseUrls(env);
    const apiEndpoint = ${API_BASE_URL}/v1/alias;
    const requestUrl = ${apiEndpoint}/${_alias}/channel;
    return await axiosGet(requestUrl)
    .then((response) => response.data)
    .catch((err) => {
    console.error([EPNS-SDK] - API ${requestUrl}: , err);
    });

All looks good.

File: packages/restapi/src/lib/channels/_getSubscribers.ts

import { getCAIPAddress, getAPIBaseUrls, getCAIPDetails } from '../helpers';
import Constants, { ENV } from '../constants';
import { axiosPost } from '../utils/axiosUtil';

export type GetSubscribersOptionsType = {
channel: string; // plain ETH Format only
env?: ENV;
};
/**

  • LEGACY SDK method, kept to support old functionality
  • can be removed if not needed in future.
    */
    const deprecationWarning = `
    [Push SDK]: _getSubscribers() Deprecation Warning!
    This method has been deprecated, please use the below alternatives
    if you need to,
  • to check if user is subscribed or not: user.getSubscriptions()
  • get channels count: channels.getChannels()
    `;
    export const _getSubscribers = async (
    options: GetSubscribersOptionsType
    ): Promise<string[]> => {
    console.warn(deprecationWarning);
    const { channel, env = Constants.ENV.PROD } = options || {};
    const _channelAddress = await getCAIPAddress(env, channel, 'Channel');
    const channelCAIPDetails = getCAIPDetails(_channelAddress

@@ -4,4 +4,4 @@
echo "\nRunning GIT hooks..."
yarn cleanbuild
yarn nx affected --target=lint
yarn nx affected --target=test
#yarn nx affected --target=test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be commented

Copy link

All looks good.

@mohammeds1992 mohammeds1992 merged commit a2dee2b into main Jan 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

😈 [Improvement Proposal] - Axios Util Wrapper
2 participants