Skip to content

Commit

Permalink
fix: fix config from package tag (#893)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman035 authored Nov 28, 2023
1 parent 55fbcdb commit 0ca7c59
Showing 13 changed files with 123 additions and 110 deletions.
7 changes: 5 additions & 2 deletions packages/restapi/src/lib/chat/addAdmins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Constants from '../constants';
import { ALPHA_FEATURE_CONFIG } from '../config';
import Constants, { PACKAGE_BUILD } from '../constants';
import { EnvOptionsType, SignerType, GroupInfoDTO } from '../types';
import {
GroupMemberUpdateOptions,
@@ -23,7 +24,9 @@ export const addAdmins = async (
signer = null,
env = Constants.ENV.PROD,
pgpPrivateKey = null,
overrideSecretKeyGeneration = true,
overrideSecretKeyGeneration = !ALPHA_FEATURE_CONFIG[
PACKAGE_BUILD
].feature.includes(Constants.ALPHA_FEATURES.SCALABILITY_V2),
} = options || {};
try {
if (account == null && signer == null) {
7 changes: 5 additions & 2 deletions packages/restapi/src/lib/chat/addMembers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Constants from '../constants';
import { ALPHA_FEATURE_CONFIG } from '../config';
import Constants, { PACKAGE_BUILD } from '../constants';
import { EnvOptionsType, SignerType, GroupInfoDTO } from '../types';
import { updateGroupMembers } from './updateGroupMembers';
import { GroupMemberUpdateOptions } from './updateGroupMembers';
@@ -24,7 +25,9 @@ export const addMembers = async (
signer = null,
env = Constants.ENV.PROD,
pgpPrivateKey = null,
overrideSecretKeyGeneration = true,
overrideSecretKeyGeneration = !ALPHA_FEATURE_CONFIG[
PACKAGE_BUILD
].feature.includes(Constants.ALPHA_FEATURES.SCALABILITY_V2),
} = options || {};
try {
if (account == null && signer == null) {
7 changes: 5 additions & 2 deletions packages/restapi/src/lib/chat/approveRequest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import { getAPIBaseUrls, isValidETHAddress } from '../helpers';
import Constants from '../constants';
import Constants, { PACKAGE_BUILD } from '../constants';
import { EnvOptionsType, SignerType } from '../types';
import {
getAccountAddress,
@@ -14,6 +14,7 @@ import * as CryptoJS from 'crypto-js';
import * as AES from '../chat/helpers/aes';
import { getGroupInfo } from './getGroupInfo';
import { getAllGroupMembersPublicKeys } from './getAllGroupMembersPublicKeys';
import { ALPHA_FEATURE_CONFIG } from '../config';

export interface ApproveRequestOptionsType extends EnvOptionsType {
/**
@@ -52,7 +53,9 @@ export const approveCore = async (
senderAddress,
env = Constants.ENV.PROD,
pgpPrivateKey = null,
overrideSecretKeyGeneration = true,
overrideSecretKeyGeneration = !ALPHA_FEATURE_CONFIG[
PACKAGE_BUILD
].feature.includes(Constants.ALPHA_FEATURES.SCALABILITY_V2),
} = options || {};

/**
7 changes: 5 additions & 2 deletions packages/restapi/src/lib/chat/modifyRole.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Constants from '../constants';
import { ALPHA_FEATURE_CONFIG } from '../config';
import Constants, { PACKAGE_BUILD } from '../constants';
import { EnvOptionsType, SignerType, GroupInfoDTO } from '../types';
import {
GroupMemberUpdateOptions,
@@ -26,7 +27,9 @@ export const modifyRoles = async (
signer = null,
env = Constants.ENV.PROD,
pgpPrivateKey = null,
overrideSecretKeyGeneration = true,
overrideSecretKeyGeneration = !ALPHA_FEATURE_CONFIG[
PACKAGE_BUILD
].feature.includes(Constants.ALPHA_FEATURES.SCALABILITY_V2),
} = options || {};

try {
7 changes: 5 additions & 2 deletions packages/restapi/src/lib/chat/removeAdmins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Constants from '../constants';
import { ALPHA_FEATURE_CONFIG } from '../config';
import Constants, { PACKAGE_BUILD } from '../constants';
import { EnvOptionsType, SignerType, GroupInfoDTO } from '../types';
import {
GroupMemberUpdateOptions,
@@ -27,7 +28,9 @@ export const removeAdmins = async (
signer = null,
env = Constants.ENV.PROD,
pgpPrivateKey = null,
overrideSecretKeyGeneration = true,
overrideSecretKeyGeneration = !ALPHA_FEATURE_CONFIG[
PACKAGE_BUILD
].feature.includes(Constants.ALPHA_FEATURES.SCALABILITY_V2),
} = options || {};
try {
if (account == null && signer == null) {
7 changes: 5 additions & 2 deletions packages/restapi/src/lib/chat/removeMembers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Constants from '../constants';
import { ALPHA_FEATURE_CONFIG } from '../config';
import Constants, { PACKAGE_BUILD } from '../constants';
import { EnvOptionsType, SignerType, GroupInfoDTO } from '../types';
import {
GroupMemberUpdateOptions,
@@ -23,7 +24,9 @@ export const removeMembers = async (
signer = null,
env = Constants.ENV.PROD,
pgpPrivateKey = null,
overrideSecretKeyGeneration = true,
overrideSecretKeyGeneration = !ALPHA_FEATURE_CONFIG[
PACKAGE_BUILD
].feature.includes(Constants.ALPHA_FEATURES.SCALABILITY_V2),
} = options || {};
try {
if (account == null && signer == null) {
7 changes: 5 additions & 2 deletions packages/restapi/src/lib/chat/updateGroupMembers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import { getAPIBaseUrls } from '../helpers';
import Constants from '../constants';
import Constants, { PACKAGE_BUILD } from '../constants';
import {
getWallet,
PGPHelper,
@@ -15,6 +15,7 @@ import { getGroupInfo } from './getGroupInfo';
import { getGroupMemberStatus } from './getGroupMemberStatus';
import * as AES from '../chat/helpers/aes';
import { getAllGroupMembersPublicKeys } from './getAllGroupMembersPublicKeys';
import { ALPHA_FEATURE_CONFIG } from '../config';

export interface GroupMemberUpdateOptions extends EnvOptionsType {
chatId: string;
@@ -39,7 +40,9 @@ export const updateGroupMembers = async (
signer = null,
env = Constants.ENV.PROD,
pgpPrivateKey = null,
overrideSecretKeyGeneration = true,
overrideSecretKeyGeneration = !ALPHA_FEATURE_CONFIG[
PACKAGE_BUILD
].feature.includes(Constants.ALPHA_FEATURES.SCALABILITY_V2),
} = options;
try {
validateGroupMemberUpdateOptions(options);
30 changes: 21 additions & 9 deletions packages/restapi/src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -40,14 +40,19 @@ const BLOCKCHAIN_NETWORK = {
POLYGON_ZK_EVM_TESTNET: 'eip155:1442',
POLYGON_ZK_EVM_MAINNET: 'eip155:1101',
ARBITRUM_TESTNET: 'eip155:421613',
ARBITRUMONE_MAINNET: "eip155:42161"
ARBITRUMONE_MAINNET: 'eip155:42161',
};

export type ALIAS_CHAIN = 'POLYGON' | 'BSC' | 'OPTIMISM' | 'POLYGONZKEVM' | "ARBITRUMONE";
export type ALIAS_CHAIN =
| 'POLYGON'
| 'BSC'
| 'OPTIMISM'
| 'POLYGONZKEVM'
| 'ARBITRUMONE';

export const ETH_CHAIN_ID = {
[ENV.PROD]: 1,
[ENV.STAGING]:11155111,
[ENV.STAGING]: 11155111,
[ENV.DEV]: 11155111,
[ENV.LOCAL]: 11155111,
};
@@ -81,7 +86,7 @@ export const ALIAS_CHAIN_ID = {
[ENV.STAGING]: 421613,
[ENV.DEV]: 421613,
[ENV.LOCAL]: 421613,
}
},
};

export const CHAIN_ID = {
@@ -106,15 +111,14 @@ export const CHAIN_NAME: { [key: number]: string } = {
1101: 'POLYGONZKEVM',
1442: 'POLYGONZKEVM',
// arbitrun
421613:'ARBITRUN',
42161:'ARBITRUM'
421613: 'ARBITRUN',
42161: 'ARBITRUM',
};
export interface ConfigType {
API_BASE_URL: string;
EPNS_COMMUNICATOR_CONTRACT: string;
}


export const VIEM_CORE_CONFIG = {
[ENV.PROD]: {
NETWORK: mainnet,
@@ -277,7 +281,7 @@ export const TOKEN_VIEM_NETWORK_MAP = {
[ENV.STAGING]: sepolia,
[ENV.DEV]: sepolia,
[ENV.LOCAL]: sepolia,
}
};

export const MIN_TOKEN_BALANCE = {
[ENV.PROD]: 50,
@@ -296,7 +300,6 @@ export const CHANNEL_TYPE = {
GENERAL: 2,
};


export const VIEM_CONFIG = {
[ENV.PROD]: {
[BLOCKCHAIN_NETWORK.ETH_MAINNET]: {
@@ -407,3 +410,12 @@ export const VIEM_CONFIG = {
},
},
};

export const ALPHA_FEATURE_CONFIG = {
STABLE: {
feature: [] as string[],
},
ALPHA: {
feature: [Constants.ALPHA_FEATURES.SCALABILITY_V2],
},
};
9 changes: 8 additions & 1 deletion packages/restapi/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require('../../package.json');

/**
* SUPPORTED ENVIRONEMENTS
*/
@@ -44,9 +47,13 @@ export enum MessageType {
}

export const ALPHA_FEATURES = {
GROUP_SCALABILITY: 'GROUP_SCALABILITY',
SCALABILITY_V2: 'SCALABILITY_V2',
};

export const PACKAGE_BUILD = packageJson.version.includes('alpha')
? 'ALPHA'
: 'STABLE';
console.log(PACKAGE_BUILD);
const Constants = {
ENV,
ENCRYPTION_TYPE,
5 changes: 3 additions & 2 deletions packages/restapi/src/lib/pushapi/PushAPI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Constants, { ENV } from '../constants';
import Constants, { ENV, PACKAGE_BUILD } from '../constants';
import { SignerType, ProgressHookType } from '../types';
import { InfoOptions, PushAPIInitializeProps } from './pushAPITypes';
import * as PUSH_USER from '../user';
@@ -15,6 +15,7 @@ import {
PushStreamInitializeProps,
STREAM,
} from '../pushstream/pushStreamTypes';
import { ALPHA_FEATURE_CONFIG } from '../config';

export class PushAPI {
private signer?: SignerType;
@@ -137,7 +138,7 @@ export class PushAPI {
alpha:
options?.alpha && options.alpha.feature
? options.alpha
: { feature: [] },
: ALPHA_FEATURE_CONFIG[PACKAGE_BUILD],
};

const readMode = !signer;
Loading

0 comments on commit 0ca7c59

Please sign in to comment.