Skip to content

Commit

Permalink
fix: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammeds1992 committed Mar 21, 2024
2 parents c57951c + e981565 commit ddb3b97
Show file tree
Hide file tree
Showing 31 changed files with 2,485 additions and 235 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const ChatProfileTest = () => {
<ChatProfile
chatProfileLeftHelperComponent={<div>left component</div>}
chatProfileRightHelperComponent={<div>right component</div>}
chatId='eip155:0x455E5AA18469bC6ccEF49594645666C587A3a71B'
chatId='4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68'
// chatId='36baf37e441fdd94e23406c6c716fc4e91a93a9ee68e070cd5b054534dbe09a6'
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const ChatViewBubbles = () => {
return (
<div style={{ height: "350px", width: "500px" }}>
{message.map((msg) => (
<ChatViewBubble chat={msg} />
<ChatViewBubble decryptedMessagePayload={msg} />
))}
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ const NETWORK_MAPPING: NwMappingType = {
421613: "ARBITRUM_TESTNET",
42161: "ARBITRUMONE_MAINNET",
122: "FUSE_MAINNET",
123: "FUSE_TESTNET"
123: "FUSE_TESTNET",
80085: "BERACHAIN_TESTNET",
};

const injected = new InjectedConnector({
supportedChainIds: [1, 3, 4, 11155111, 42, 137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123],
supportedChainIds: [1, 3, 4, 11155111, 42, 137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123,80085],
})

const ConnectWrapper = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/sdk-frontend-react/src/app/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Constants = {
},
DEFAULT_CHAIN_ID: 11155111,
DEV_CHAIN_ID: 99999,
NON_ETH_CHAINS: [137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123],
NON_ETH_CHAINS: [137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123,80085],
ETH_CHAINS: [1, 11155111]
};

Expand Down
29 changes: 7 additions & 22 deletions packages/restapi/src/lib/channels/getChannelNotifications.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import { getCAIPAddress, getAPIBaseUrls, getQueryParams } from '../helpers';
import Constants, { ENV } from '../constants';
import { axiosGet } from '../utils/axiosUtil';
import { parseApiResponse } from '../utils';

/**
* GET /v1/channels/{addressinCAIP}
*/

enum NotifictaionType {
BROADCAT = 1,
TARGETTED = 3,
SUBSET = 4
}
import { NotifictaionType } from '../types';

type GetChannelOptionsType = {
channel: string;
Expand All @@ -36,28 +26,23 @@ export const getChannelNotifications = async (

const _channel = await getCAIPAddress(env, channel, 'Channel');
const API_BASE_URL = getAPIBaseUrls(env);
const apiEndpoint = `${API_BASE_URL}/v1/channels`;
const apiEndpoint = `${API_BASE_URL}/v2/channels`;
const query = getQueryParams(
filter
? {
page,
limit,
notificationType: filter,
raw,
}
: {
page,
limit,
raw,
}
);
const requestUrl = `${apiEndpoint}/${_channel}/notifications?${query}`;
return await axiosGet(requestUrl)
.then((response) => {
if (raw) return {feeds: response.data?.feeds ?? [], itemcount:response.data?.itemcount} ;
else
return { feeds: parseApiResponse(response.data?.feeds?? []), itemcount: response.data?.itemcount}
;
})
.catch((err) => {
console.error(`[Push SDK] - API ${requestUrl}: `, err);
});
return await axiosGet(requestUrl).then((response) => {
return response.data;
});
};
62 changes: 60 additions & 2 deletions packages/restapi/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,31 @@ import {
fuse,
fuseSparknet,
} from 'viem/chains';
import { defineChain } from 'viem';
const { ENV } = Constants;

const berachainTestnet = defineChain({
id: 80085,
name: 'Berachain Artio',
network: 'berachain-testnet',
nativeCurrency: {
decimals: 18,
name: 'BERA Token',
symbol: 'BERA',
},
rpcUrls: {
default: { http: ['https://artio.rpc.berachain.com'] },
public: { http: ['https://artio.rpc.berachain.com'] },
},
blockExplorers: {
default: {
name: 'Berachain',
url: 'https://artio.beratrail.io',
},
},
testnet: true,
});

// for methods not needing the entire config
export const API_BASE_URL = {
[ENV.PROD]: 'https://backend.epns.io/apis',
Expand Down Expand Up @@ -47,6 +70,7 @@ const BLOCKCHAIN_NETWORK = {
ARBITRUMONE_MAINNET: 'eip155:42161',
FUSE_TESTNET: 'eip155:123',
FUSE_MAINNET: 'eip155:122',
BERACHAIN_TESTNET: 'eip155:80085',
};

export type ALIAS_CHAIN =
Expand All @@ -55,7 +79,8 @@ export type ALIAS_CHAIN =
| 'OPTIMISM'
| 'POLYGONZKEVM'
| 'ARBITRUMONE'
| 'FUSE';
| 'FUSE'
| 'BERACHAIN';

export const ETH_CHAIN_ID = {
[ENV.PROD]: 1,
Expand Down Expand Up @@ -100,6 +125,11 @@ export const ALIAS_CHAIN_ID = {
[ENV.DEV]: 123,
[ENV.LOCAL]: 123,
},
BERACHAIN: {
[ENV.STAGING]: 80085,
[ENV.DEV]: 80085,
[ENV.LOCAL]: 80085,
},
};

export const CHAIN_ID = {
Expand Down Expand Up @@ -129,6 +159,8 @@ export const CHAIN_NAME: { [key: number]: string } = {
// fuse
122: 'FUSE',
123: 'FUSE',
// berachain
80085: 'BERACHAIN',
};
export interface ConfigType {
API_BASE_URL: string;
Expand Down Expand Up @@ -237,6 +269,10 @@ const CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.BERACHAIN_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0x7b9C405e261ba671f008c20D0321f62d08C140EC',
},
},
[ENV.DEV]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand Down Expand Up @@ -267,6 +303,10 @@ const CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x7eBb54D86CF928115965DB596a3E600404dD8039',
},
[BLOCKCHAIN_NETWORK.BERACHAIN_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0xA1DF3E68D085aa6918bcc2506b24e499830Db0eB',
},
},
[ENV.LOCAL]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand Down Expand Up @@ -297,6 +337,10 @@ const CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x7eBb54D86CF928115965DB596a3E600404dD8039',
},
[BLOCKCHAIN_NETWORK.BERACHAIN_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0xA1DF3E68D085aa6918bcc2506b24e499830Db0eB',
},
},
};

Expand Down Expand Up @@ -406,6 +450,11 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.BERACHAIN_TESTNET]: {
NETWORK: berachainTestnet,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0x7b9C405e261ba671f008c20D0321f62d08C140EC',
},
},
[ENV.DEV]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand Down Expand Up @@ -443,6 +492,11 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x7eBb54D86CF928115965DB596a3E600404dD8039',
},
[BLOCKCHAIN_NETWORK.BERACHAIN_TESTNET]: {
NETWORK: berachainTestnet,
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0xA1DF3E68D085aa6918bcc2506b24e499830Db0eB',
},
},
[ENV.LOCAL]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand Down Expand Up @@ -480,10 +534,14 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x7eBb54D86CF928115965DB596a3E600404dD8039',
},
[BLOCKCHAIN_NETWORK.BERACHAIN_TESTNET]: {
NETWORK: berachainTestnet,
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0xA1DF3E68D085aa6918bcc2506b24e499830Db0eB',
},
},
};


export const ALPHA_FEATURE_CONFIG = {
STABLE: {
feature: [] as string[],
Expand Down
4 changes: 3 additions & 1 deletion packages/restapi/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const Constants = {
},
DEFAULT_CHAIN_ID: 11155111,
DEV_CHAIN_ID: 99999,
NON_ETH_CHAINS: [137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123],
NON_ETH_CHAINS: [
137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123, 80085,
],
ETH_CHAINS: [1, 11155111],
ENC_TYPE_V1: 'x25519-xsalsa20-poly1305',
ENC_TYPE_V2: 'aes256GcmHkdfSha256',
Expand Down
32 changes: 19 additions & 13 deletions packages/restapi/src/lib/constantsV2.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { ALPHA_FEATURES, ENCRYPTION_TYPE, ENV, MessageType } from './constants';
import { ChannelListOrderType, ChannelListSortType, ChannelListType } from './pushNotification/PushNotificationTypes';
import {
ChannelListOrderType,
ChannelListSortType,
ChannelListType,
} from './pushNotification/PushNotificationTypes';
import { ChatListType } from './pushapi/pushAPITypes';
import { STREAM, SpaceEventType, VideoEventType } from './pushstream/pushStreamTypes';
import {
STREAM,
SpaceEventType,
VideoEventType,
} from './pushstream/pushStreamTypes';
import { initSpaceData } from './space';
import {
ConditionType,
GROUP_INVITER_ROLE,
GROUP_RULES_CATEGORY,
GROUP_RULES_PERMISSION,
GROUP_RULES_SUB_CATEGORY,
NotifictaionType,
VideoCallStatus,
} from './types';
import { initVideoCallData } from './video';
Expand Down Expand Up @@ -36,30 +45,27 @@ const CONSTANTS = {
VIDEO: {
EVENT: VideoEventType,
STATUS: VideoCallStatus,
INITIAL_DATA: initVideoCallData
INITIAL_DATA: initVideoCallData,
},
SPACE: {
EVENT: SpaceEventType,
INITIAL_DATA: initSpaceData
INITIAL_DATA: initSpaceData,
},
ALPHA_FEATURES: ALPHA_FEATURES,
USER: { ENCRYPTION_TYPE: ENCRYPTION_TYPE },
NOTIFICATION: {
TYPE: {
BROADCAST: 1,
SUBSET: 4,
TARGETTED: 3
},
TYPE: NotifictaionType,
CHANNEL: {
LIST_TYPE: ChannelListType,
}
},
},
FILTER: {
CHANNEL_LIST: {
SORT: ChannelListSortType,
ORDER: ChannelListOrderType
}
}
ORDER: ChannelListOrderType,
},
NOTIFICATION_TYPE: NotifictaionType,
},
};

export default CONSTANTS;
4 changes: 3 additions & 1 deletion packages/restapi/src/lib/payloads/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const CHAIN_ID_TO_SOURCE: ChainIdToSourceType = {
421613: "ARBITRUM_TESTNET",
42161: "ARBITRUMONE_MAINNET",
122: "FUSE_MAINNET",
123: "FUSE_TESTNET"
123: "FUSE_TESTNET",
80085: "BERACHAIN_TESTNET"
};

export const SOURCE_TYPES = {
Expand All @@ -34,6 +35,7 @@ export const SOURCE_TYPES = {
ARBITRUMONE_MAINNET: "ARBITRUMONE_MAINNET",
FUSE_TESTNET:"FUSE_TESTNET",
FUSE_MAINNET:"FUSE_MAINNET",
BERACHAIN_TESTNET: "BERACHAIN_TESTNET",
THE_GRAPH: 'THE_GRAPH',
PUSH_VIDEO: 'PUSH_VIDEO',
SIMULATE: 'SIMULATE'
Expand Down
9 changes: 6 additions & 3 deletions packages/restapi/src/lib/payloads/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export async function getVerificationProof({
wallet,
pgpPrivateKey,
env,
rules
rules,
}: {
senderType: 0 | 1;
signer: any;
Expand All @@ -212,7 +212,7 @@ export async function getVerificationProof({
wallet?: walletType;
pgpPrivateKey?: string;
env?: ENV;
rules?:VideoNotificationRules;
rules?: VideoNotificationRules;
}) {
let message = null;
let verificationProof = null;
Expand Down Expand Up @@ -328,7 +328,10 @@ export function getSource(
export function getCAIPFormat(chainId: number, address: string) {
// EVM based chains
if (
[1, 11155111, 42, 137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123].includes(chainId)
[
1, 11155111, 42, 137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161,
122, 123, 80085,
].includes(chainId)
) {
return `eip155:${chainId}:${address}`;
}
Expand Down
Loading

0 comments on commit ddb3b97

Please sign in to comment.