Skip to content

Commit

Permalink
fix: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammeds1992 committed Jan 18, 2024
2 parents aacfea3 + a28452b commit 2979e5a
Show file tree
Hide file tree
Showing 35 changed files with 606 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export const ChatSupportTest = () => {
<SupportChat

signer={librarySigner}
supportAddress="0x6269C363695c5E14447a1b3873d7Ae4Ddf6E6eF7"
apiKey="tAWEnggQ9Z.UaDBNjrvlJZx3giBTIQDcT8bKQo1O1518uF1Tea7rPwfzXv2ouV5rX9ViwgJUrXm"
supportAddress="richa.eth"
env={env}
greetingMsg="How can i help you?"
theme={lightTheme}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ const NETWORK_MAPPING: NwMappingType = {
1442: 'POLYGON_ZK_EVM_TESTNET',
1101: 'POLYGON_ZK_EVM_MAINNET',
421613: "ARBITRUM_TESTNET",
42161: "ARBITRUMONE_MAINNET"
42161: "ARBITRUMONE_MAINNET",
122: "FUSE_MAINNET",
123: "FUSE_TESTNET"
};

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

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],
NON_ETH_CHAINS: [137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123],
ETH_CHAINS: [1, 11155111]
};

Expand Down
81 changes: 77 additions & 4 deletions packages/restapi/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import {
polygonZkEvm,
polygonZkEvmTestnet,
sepolia,
arbitrum,
arbitrumGoerli,
fuse,
fuseSparknet,
} from 'viem/chains';
const { ENV } = Constants;

Expand Down Expand Up @@ -41,14 +45,17 @@ const BLOCKCHAIN_NETWORK = {
POLYGON_ZK_EVM_MAINNET: 'eip155:1101',
ARBITRUM_TESTNET: 'eip155:421613',
ARBITRUMONE_MAINNET: 'eip155:42161',
FUSE_TESTNET: 'eip155:123',
FUSE_MAINNET: 'eip155:122',
};

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

export const ETH_CHAIN_ID = {
[ENV.PROD]: 1,
Expand Down Expand Up @@ -87,6 +94,12 @@ export const ALIAS_CHAIN_ID = {
[ENV.DEV]: 421613,
[ENV.LOCAL]: 421613,
},
FUSE: {
[ENV.PROD]: 122,
[ENV.STAGING]: 123,
[ENV.DEV]: 123,
[ENV.LOCAL]: 123,
},
};

export const CHAIN_ID = {
Expand All @@ -113,6 +126,9 @@ export const CHAIN_NAME: { [key: number]: string } = {
// arbitrun
421613: 'ARBITRUN',
42161: 'ARBITRUM',
// fuse
122: 'FUSE',
123: 'FUSE',
};
export interface ConfigType {
API_BASE_URL: string;
Expand Down Expand Up @@ -187,6 +203,10 @@ const CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.FUSE_MAINNET]: {
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
},
[ENV.STAGING]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand All @@ -213,6 +233,10 @@ const CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
},
[ENV.DEV]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand All @@ -236,9 +260,13 @@ const CONFIG = {
EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x2f6aE0907116A2c50D712e78b48D874fadeB6850',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x7eBb54D86CF928115965DB596a3E600404dD8039',
},
},
[ENV.LOCAL]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand All @@ -258,13 +286,17 @@ const CONFIG = {
EPNS_COMMUNICATOR_CONTRACT: '0x4305D572F2bf38Fc2AE8D0172055b1EFd18F57a6',
},
[BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.DEV],
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x2f6aE0907116A2c50D712e78b48D874fadeB6850',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x7eBb54D86CF928115965DB596a3E600404dD8039',
},
},
};

Expand Down Expand Up @@ -327,6 +359,16 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.ARBITRUMONE_MAINNET]: {
NETWORK: arbitrum,
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.FUSE_MAINNET]: {
NETWORK: fuse,
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
},
[ENV.STAGING]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand Down Expand Up @@ -354,6 +396,16 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
NETWORK: arbitrumGoerli,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
NETWORK: fuseSparknet,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
},
[ENV.DEV]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand Down Expand Up @@ -381,6 +433,16 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
NETWORK: arbitrumGoerli,
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x2f6aE0907116A2c50D712e78b48D874fadeB6850',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
NETWORK: fuseSparknet,
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x7eBb54D86CF928115965DB596a3E600404dD8039',
},
},
[ENV.LOCAL]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand Down Expand Up @@ -408,9 +470,20 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
NETWORK: arbitrumGoerli,
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x2f6aE0907116A2c50D712e78b48D874fadeB6850',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
NETWORK: fuseSparknet,
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x7eBb54D86CF928115965DB596a3E600404dD8039',
},
},
};


export const ALPHA_FEATURE_CONFIG = {
STABLE: {
feature: [] as string[],
Expand Down
2 changes: 1 addition & 1 deletion packages/restapi/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Constants = {
},
DEFAULT_CHAIN_ID: 11155111,
DEV_CHAIN_ID: 99999,
NON_ETH_CHAINS: [137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161],
NON_ETH_CHAINS: [137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123],
ETH_CHAINS: [1, 11155111],
ENC_TYPE_V1: 'x25519-xsalsa20-poly1305',
ENC_TYPE_V2: 'aes256GcmHkdfSha256',
Expand Down
5 changes: 4 additions & 1 deletion packages/restapi/src/lib/constantsV2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ENV, MessageType, ALPHA_FEATURES, ENCRYPTION_TYPE } from './constants';
import { ChatListType } from './pushapi/pushAPITypes';
import { STREAM } from './pushstream/pushStreamTypes';
import { STREAM, VideoEventType } from './pushstream/pushStreamTypes';
import {
ConditionType,
GROUP_INVITER_ROLE,
Expand Down Expand Up @@ -29,6 +29,9 @@ const CONSTANTS = {
},
},
},
VIDEO: {
EVENT: VideoEventType
},
ALPHA_FEATURES: ALPHA_FEATURES,
USER: { ENCRYPTION_TYPE: ENCRYPTION_TYPE },
};
Expand Down
6 changes: 5 additions & 1 deletion packages/restapi/src/lib/payloads/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const CHAIN_ID_TO_SOURCE: ChainIdToSourceType = {
1442: 'POLYGON_ZK_EVM_TESTNET',
1101: 'POLYGON_ZK_EVM_MAINNET',
421613: "ARBITRUM_TESTNET",
42161: "ARBITRUMONE_MAINNET"
42161: "ARBITRUMONE_MAINNET",
122: "FUSE_MAINNET",
123: "FUSE_TESTNET"
};

export const SOURCE_TYPES = {
Expand All @@ -30,6 +32,8 @@ export const SOURCE_TYPES = {
POLYGON_ZK_EVM_MAINNET: 'POLYGON_ZK_EVM_MAINNET',
ARBITRUM_TESTNET: "ARBITRUM_TESTNET",
ARBITRUMONE_MAINNET: "ARBITRUMONE_MAINNET",
FUSE_TESTNET:"FUSE_TESTNET",
FUSE_MAINNET:"FUSE_MAINNET",
THE_GRAPH: 'THE_GRAPH',
PUSH_VIDEO: 'PUSH_VIDEO',
SIMULATE: 'SIMULATE'
Expand Down
4 changes: 1 addition & 3 deletions packages/restapi/src/lib/payloads/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,7 @@ 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,
].includes(chainId)
[1, 11155111, 42, 137, 80001, 56, 97, 10, 420, 1442, 1101, 421613, 42161, 122, 123].includes(chainId)
) {
return `eip155:${chainId}:${address}`;
}
Expand Down
14 changes: 7 additions & 7 deletions packages/restapi/src/lib/pushapi/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Signer as PushSigner } from '../helpers';
import { Video as VideoV1, initVideoCallData } from '../video/Video';
import { VideoV2 } from '../video/VideoV2';
import { VideoInitializeOptions } from './pushAPITypes';
import { VideoEvent, VideoEventType } from '../pushstream/pushStreamTypes';
import { VideoEvent } from '../pushstream/pushStreamTypes';
import { produce } from 'immer';
import { endStream } from '../video/helpers/mediaToggle';

Expand Down Expand Up @@ -73,7 +73,7 @@ export class Video {
const chatId = rules.access.data.chatId;

// If the event is RequestVideo, update the video call 'data' state with the incoming call data
if (data.event === VideoEventType.RequestVideo) {
if (data.event === CONSTANTS.VIDEO.EVENT.REQUEST) {
videoV1Instance.setData((oldData) => {
return produce(oldData, (draft) => {
draft.local.address = this.account;
Expand All @@ -89,7 +89,7 @@ export class Video {
// Check if the chatId from the incoming video event matches the chatId of the current video instance
if (chatId && chatId === videoV1Instance.data.meta.chatId) {
// If the event is DenyVideo, destroy the local stream & reset the video call data
if (data.event === VideoEventType.DenyVideo) {
if (data.event === CONSTANTS.VIDEO.EVENT.DENY) {
// destroy the local stream
if (videoV1Instance.data.local.stream) {
endStream(videoV1Instance.data.local.stream);
Expand All @@ -100,15 +100,15 @@ export class Video {

// If the event is ApproveVideo or RetryApproveVideo, connect to the video
if (
data.event === VideoEventType.ApproveVideo ||
data.event === VideoEventType.RetryApproveVideo
data.event === CONSTANTS.VIDEO.EVENT.APPROVE ||
data.event === CONSTANTS.VIDEO.EVENT.RETRY_APPROVE
) {
videoV1Instance.connect({ peerAddress: address, signalData: signal });
}

// If the event is RetryRequestVideo and the current instance is the initiator, send a request
if (
data.event === VideoEventType.RetryRequestVideo &&
data.event === CONSTANTS.VIDEO.EVENT.RETRY_REQUEST &&
videoV1Instance.isInitiator()
) {
videoV1Instance.request({
Expand All @@ -121,7 +121,7 @@ export class Video {

// If the event is RetryRequestVideo and the current instance is not the initiator, accept the request
if (
data.event === VideoEventType.RetryRequestVideo &&
data.event === CONSTANTS.VIDEO.EVENT.RETRY_REQUEST &&
!videoV1Instance.isInitiator()
) {
videoV1Instance.acceptRequest({
Expand Down
21 changes: 13 additions & 8 deletions packages/restapi/src/lib/pushstream/DataModifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ export class DataModifier {
includeRaw = false,
eventType: MessageEventType
): MessageEvent {

if (data.hasIntent === false && eventType === 'message') {
eventType = MessageEventType.Request;
}

const messageEvent: MessageEvent = {
event: eventType,
origin: data.messageOrigin,
Expand Down Expand Up @@ -400,19 +405,19 @@ export class DataModifier {
): VideoEventType {
switch (currentVideoStatus) {
case VideoCallStatus.INITIALIZED:
return VideoEventType.RequestVideo;
return VideoEventType.REQUEST;
case VideoCallStatus.RECEIVED:
return VideoEventType.ApproveVideo;
return VideoEventType.APPROVE;
case VideoCallStatus.CONNECTED:
return VideoEventType.ConnectVideo;
return VideoEventType.CONNECT;
case VideoCallStatus.ENDED:
return VideoEventType.DisconnectVideo;
return VideoEventType.DISCONNECT;
case VideoCallStatus.DISCONNECTED:
return VideoEventType.DenyVideo;
return VideoEventType.DENY;
case VideoCallStatus.RETRY_INITIALIZED:
return VideoEventType.RetryRequestVideo;
return VideoEventType.RETRY_REQUEST;
case VideoCallStatus.RETRY_RECEIVED:
return VideoEventType.RetryApproveVideo;
return VideoEventType.RETRY_APPROVE;
default:
throw new Error(`Unknown video call status: ${currentVideoStatus}`);
}
Expand All @@ -426,7 +431,7 @@ export class DataModifier {
const { senderAddress, signalData, status, chatId }: VideoDataType =
JSON.parse(data.payload.data.additionalMeta?.data);

// To maintain backward compatibility, if the rules object is not present in the payload,
// To maintain backward compatibility, if the rules object is not present in the payload,
// we create a new rules object with chatId from additionalMeta.data
const rules = data.payload.rules ?? {
access: {
Expand Down
14 changes: 7 additions & 7 deletions packages/restapi/src/lib/pushstream/pushStreamTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export enum GroupEventType {
}

export enum VideoEventType {
RequestVideo = 'video.request',
ApproveVideo = 'video.approve',
DenyVideo = 'video.deny',
ConnectVideo = 'video.connect',
DisconnectVideo = 'video.disconnect',
REQUEST = 'video.request',
APPROVE = 'video.approve',
DENY = 'video.deny',
CONNECT = 'video.connect',
DISCONNECT = 'video.disconnect',
// retry events
RetryRequestVideo = 'video.retry.request',
RetryApproveVideo = 'video.retry.approve'
RETRY_REQUEST = 'video.retry.request',
RETRY_APPROVE = 'video.retry.approve'
}

export enum ProposedEventNames {
Expand Down
Loading

0 comments on commit 2979e5a

Please sign in to comment.