diff --git a/packages/examples/sdk-frontend-react/src/app/components/Connect.tsx b/packages/examples/sdk-frontend-react/src/app/components/Connect.tsx index a41a755f6..c80d25357 100644 --- a/packages/examples/sdk-frontend-react/src/app/components/Connect.tsx +++ b/packages/examples/sdk-frontend-react/src/app/components/Connect.tsx @@ -27,13 +27,16 @@ const NETWORK_MAPPING: NwMappingType = { 59141: 'LINEA_TESTNET', 59144: 'LINEA_MAINNET', 111557560: 'CYBER_CONNECT_TESTNET', - 7560: 'CYBER_CONNECT_MAINNET' + 7560: 'CYBER_CONNECT_MAINNET', + 84532: 'BASE_TESTNET', + 8453: 'BASE_MAINNET', + }; const injected = new InjectedConnector({ supportedChainIds: [ 1, 3, 4, 11155111, 42, 137, 80002, 56, 97, 10, 11155420, 2442, 1101, 421614, - 42161, 122, 123, 80085, 59144, 59141, 111557560, 7560 + 42161, 122, 123, 80085, 59144, 59141, 111557560, 7560, 84532, 8453, ], }); diff --git a/packages/examples/sdk-frontend-react/src/app/helpers.ts b/packages/examples/sdk-frontend-react/src/app/helpers.ts index 8b79768a7..9d8883312 100644 --- a/packages/examples/sdk-frontend-react/src/app/helpers.ts +++ b/packages/examples/sdk-frontend-react/src/app/helpers.ts @@ -20,7 +20,7 @@ const Constants = { DEV_CHAIN_ID: 99999, NON_ETH_CHAINS: [ 137, 80002, 56, 97, 10, 11155420, 2442, 1101, 421614, 42161, 122, 123, - 80085, 59141, 59144,111557560, 7560 + 80085, 59141, 59144,111557560, 7560, 84532, 8453, ], ETH_CHAINS: [1, 11155111], }; diff --git a/packages/restapi/src/lib/chat/helpers/payloadHelper.ts b/packages/restapi/src/lib/chat/helpers/payloadHelper.ts index 6ab762e1e..d22d2ba16 100644 --- a/packages/restapi/src/lib/chat/helpers/payloadHelper.ts +++ b/packages/restapi/src/lib/chat/helpers/payloadHelper.ts @@ -110,7 +110,7 @@ export const sendMessagePayloadCore = async ( env: ENV, pgpHelper: IPGPHelper ): Promise => { - const isGroup = !isValidPushCAIP(receiverAddress); + const isGroup = group !== null; let secretKey: string; if (isGroup && group?.encryptedSecret && group.sessionKey) { diff --git a/packages/restapi/src/lib/chat/helpers/pgp.ts b/packages/restapi/src/lib/chat/helpers/pgp.ts index 6240dc60d..0c06c7d24 100644 --- a/packages/restapi/src/lib/chat/helpers/pgp.ts +++ b/packages/restapi/src/lib/chat/helpers/pgp.ts @@ -75,6 +75,8 @@ const PGPHelper:IPGPHelper = { }) const publicKey: openpgp.PublicKey = await openpgp.readKey({ armoredKey: publicKeyArmored }) const verificationResult = await openpgp.verify({ + // setting date to 1 day in the future to avoid issues with clock skew + date: new Date(Date.now() + 1000 * 60 * 60 * 24), message, signature, verificationKeys: publicKey diff --git a/packages/restapi/src/lib/chat/send.ts b/packages/restapi/src/lib/chat/send.ts index 741e1e423..55838da14 100644 --- a/packages/restapi/src/lib/chat/send.ts +++ b/packages/restapi/src/lib/chat/send.ts @@ -1,4 +1,9 @@ -import { convertToValidDID, getAPIBaseUrls, isValidPushCAIP } from '../helpers'; +import { + convertToValidDID, + getAPIBaseUrls, + isValidPushCAIP, + walletToPCAIP10, +} from '../helpers'; import Constants, { MessageType, ENV } from '../constants'; import { ChatSendOptionsType, MessageWithCID, SignerType } from '../types'; import { @@ -15,6 +20,7 @@ import { validateMessageObj } from '../validations/messageObject'; import { axiosPost } from '../utils/axiosUtil'; import { getGroupInfo } from './getGroupInfo'; import { handleError } from '../errors/validationError'; +import * as PUSH_CHAT from '../chat'; /** * SENDS A PUSH CHAT MESSAGE @@ -36,7 +42,7 @@ export const sendCore = async ( * 2. Takes care of deprecated fields */ const computedOptions = computeOptions(options); - const { messageType, messageObj, account, to, signer, pgpPrivateKey, env } = + let { messageType, messageObj, account, to, signer, pgpPrivateKey, env } = computedOptions; /** * Validate Input Options @@ -50,16 +56,40 @@ export const sendCore = async ( env, pgpHelper ); - const receiver = await convertToValidDID(to, env); + let receiver = await convertToValidDID(to, env); const API_BASE_URL = getAPIBaseUrls(env); - const isGroup = isValidPushCAIP(to) ? false : true; - - const group = isGroup - ? await getGroupInfo({ - chatId: to, - env: env, - }) - : null; + + const isChatId = isValidPushCAIP(to) ? false : true; + let isGroup = false; + let group = null; + + if (isChatId) { + const request: PUSH_CHAT.GetChatInfoType = { + recipient: to, + account: account!, + env: env, + }; + + const chatInfo = await PUSH_CHAT.getChatInfo(request); + isGroup = chatInfo?.meta?.group ?? false; + + group = isGroup + ? await getGroupInfo({ + chatId: to, + env: env, + }) + : null; + + if (!isGroup) { + const participants = chatInfo.participants ?? []; + // Find the participant that is not the account being used + const messageSentTo = participants.find( + (participant) => participant !== walletToPCAIP10(account!) + ); + to = messageSentTo!; + receiver = to; + } + } // Not supported by legacy sdk versions, need to override messageContent to avoid parsing errors on legacy sdk versions let messageContent: string; diff --git a/packages/restapi/src/lib/config.ts b/packages/restapi/src/lib/config.ts index 15751ea54..235bb709f 100644 --- a/packages/restapi/src/lib/config.ts +++ b/packages/restapi/src/lib/config.ts @@ -16,6 +16,8 @@ import { fuse, fuseSparknet, linea, + base, + baseSepolia } from 'viem/chains'; import { berachainTestnet, polygonAmoy, polygonZkEvmCordona, cyberConnectMainnet, cyberConnectTestnet, lineaSepoliaTestnet } from './customChains'; @@ -51,7 +53,9 @@ const BLOCKCHAIN_NETWORK = { LINEA_MAINNET: 'eip155:59144', LINEA_TESTNET: 'eip155:59141', CYBER_CONNECT_TESTNET: 'eip155:111557560', - CYBER_CONNECT_MAINNET: 'eip155:7560' + CYBER_CONNECT_MAINNET: 'eip155:7560', + BASE_TESTNET: 'eip155:84532', + BASE_MAINNET: 'eip155:8453', }; export type ALIAS_CHAIN = @@ -63,7 +67,8 @@ export type ALIAS_CHAIN = | 'FUSE' | 'BERACHAIN' | 'LINEA' - | 'CYBERCONNECT'; + | 'CYBERCONNECT' + | 'BASE'; export const ETH_CHAIN_ID = { [ENV.PROD]: 1, @@ -127,7 +132,13 @@ export const ALIAS_CHAIN_ID: { [ENV.STAGING]: 111557560, [ENV.DEV]: 111557560, [ENV.LOCAL]: 111557560, - } + }, + BASE: { + [ENV.PROD]: 8453, + [ENV.STAGING]: 84532, + [ENV.DEV]: 84532, + [ENV.LOCAL]: 84532, + }, }; export const CHAIN_ID = { @@ -164,7 +175,10 @@ export const CHAIN_NAME: { [key: number]: string } = { 59141: 'LINEA', // cyberconnect 7560: 'CYBER_CONNECT_MAINNET', - 111557560: 'CYBER_CONNECT_TESTNET' + 111557560: 'CYBER_CONNECT_TESTNET', + // base + 8453: 'BASE_MAINNET', + 84532: 'BASE_TESTNET', }; export interface ConfigType { API_BASE_URL: string; @@ -250,6 +264,10 @@ const CONFIG = { [BLOCKCHAIN_NETWORK.LINEA_MAINNET]:{ API_BASE_URL: API_BASE_URL[ENV.PROD], EPNS_COMMUNICATOR_CONTRACT: '0x0d8e75CB5d8873c43c5d9Add71Fd71a09F7Ef890', + }, + [BLOCKCHAIN_NETWORK.BASE_MAINNET]: { + API_BASE_URL: API_BASE_URL[ENV.PROD], + EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', } }, [ENV.STAGING]: { @@ -293,6 +311,10 @@ const CONFIG = { API_BASE_URL: API_BASE_URL[ENV.STAGING], EPNS_COMMUNICATOR_CONTRACT: '0x6e489B7af21cEb969f49A90E481274966ce9D74d', }, + [BLOCKCHAIN_NETWORK.BASE_TESTNET]: { + API_BASE_URL: API_BASE_URL[ENV.STAGING], + EPNS_COMMUNICATOR_CONTRACT: '0x6e489B7af21cEb969f49A90E481274966ce9D74d', + } }, [ENV.DEV]: { [BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: { @@ -335,6 +357,10 @@ const CONFIG = { API_BASE_URL: API_BASE_URL[ENV.DEV], EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F', }, + [BLOCKCHAIN_NETWORK.BASE_TESTNET]: { + API_BASE_URL: API_BASE_URL[ENV.DEV], + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F', + } }, [ENV.LOCAL]: { [BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: { @@ -377,6 +403,10 @@ const CONFIG = { API_BASE_URL: API_BASE_URL[ENV.DEV], EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F', }, + [BLOCKCHAIN_NETWORK.BASE_TESTNET]: { + API_BASE_URL: API_BASE_URL[ENV.LOCAL], + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F', + } }, }; @@ -459,6 +489,11 @@ export const VIEM_CONFIG = { API_BASE_URL: API_BASE_URL[ENV.PROD], EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', }, + [BLOCKCHAIN_NETWORK.BASE_MAINNET]: { + NETWORK: base, + API_BASE_URL: API_BASE_URL[ENV.PROD], + EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', + } }, [ENV.STAGING]: { [BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: { @@ -511,6 +546,11 @@ export const VIEM_CONFIG = { API_BASE_URL: API_BASE_URL[ENV.STAGING], EPNS_COMMUNICATOR_CONTRACT: '0x6e489B7af21cEb969f49A90E481274966ce9D74d', }, + [BLOCKCHAIN_NETWORK.BASE_TESTNET]: { + NETWORK: baseSepolia, + API_BASE_URL: API_BASE_URL[ENV.STAGING], + EPNS_COMMUNICATOR_CONTRACT: '0x6e489B7af21cEb969f49A90E481274966ce9D74d', + } }, [ENV.DEV]: { [BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: { @@ -560,34 +600,39 @@ export const VIEM_CONFIG = { }, [BLOCKCHAIN_NETWORK.CYBER_CONNECT_TESTNET]: { NETWORK: cyberConnectTestnet, - API_BASE_URL: API_BASE_URL[ENV.STAGING], + API_BASE_URL: API_BASE_URL[ENV.DEV], EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F', }, + [BLOCKCHAIN_NETWORK.BASE_TESTNET]: { + NETWORK: baseSepolia, + API_BASE_URL: API_BASE_URL[ENV.DEV], + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F', + } }, [ENV.LOCAL]: { [BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: { NETWORK: sepolia, - API_BASE_URL: API_BASE_URL[ENV.DEV], + API_BASE_URL: API_BASE_URL[ENV.LOCAL], EPNS_COMMUNICATOR_CONTRACT: '0x9dDCD7ed7151afab43044E4D694FA064742C428c', }, [BLOCKCHAIN_NETWORK.POLYGON_AMOY]: { NETWORK: polygonAmoy, - API_BASE_URL: API_BASE_URL[ENV.DEV], + API_BASE_URL: API_BASE_URL[ENV.LOCAL], EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.BSC_TESTNET]: { NETWORK: bscTestnet, - API_BASE_URL: API_BASE_URL[ENV.DEV], + API_BASE_URL: API_BASE_URL[ENV.LOCAL], EPNS_COMMUNICATOR_CONTRACT: '0x4132061E3349ff36cFfCadA460E10Bd4f31F7ea8', }, [BLOCKCHAIN_NETWORK.OPTIMISM_TESTNET]: { NETWORK: optimismSepolia, - API_BASE_URL: API_BASE_URL[ENV.DEV], + API_BASE_URL: API_BASE_URL[ENV.LOCAL], EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317', }, [BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: { NETWORK: polygonZkEvmCordona, - API_BASE_URL: API_BASE_URL[ENV.DEV], + API_BASE_URL: API_BASE_URL[ENV.LOCAL], EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: { @@ -612,9 +657,14 @@ export const VIEM_CONFIG = { }, [BLOCKCHAIN_NETWORK.CYBER_CONNECT_TESTNET]: { NETWORK: cyberConnectTestnet, - API_BASE_URL: API_BASE_URL[ENV.STAGING], + API_BASE_URL: API_BASE_URL[ENV.LOCAL], EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F', }, + [BLOCKCHAIN_NETWORK.BASE_TESTNET]: { + NETWORK: baseSepolia, + API_BASE_URL: API_BASE_URL[ENV.LOCAL], + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F', + } }, }; diff --git a/packages/restapi/src/lib/constants.ts b/packages/restapi/src/lib/constants.ts index 76867ad1c..b890b51f4 100644 --- a/packages/restapi/src/lib/constants.ts +++ b/packages/restapi/src/lib/constants.ts @@ -67,7 +67,7 @@ const Constants = { DEV_CHAIN_ID: 99999, NON_ETH_CHAINS: [ 137, 80002, 56, 97, 10, 11155420, 2442, 1101, 421614, 42161, 122, 123, - 80085,59141, 59144, 111557560,7560 + 80085,59141, 59144, 111557560, 7560, 84532, 8453, ], ETH_CHAINS: [1, 11155111], ENC_TYPE_V1: 'x25519-xsalsa20-poly1305', diff --git a/packages/restapi/src/lib/payloads/constants.ts b/packages/restapi/src/lib/payloads/constants.ts index 006a5ae54..48b99c85e 100644 --- a/packages/restapi/src/lib/payloads/constants.ts +++ b/packages/restapi/src/lib/payloads/constants.ts @@ -22,6 +22,8 @@ export const CHAIN_ID_TO_SOURCE: ChainIdToSourceType = { 59144: 'LINEA_MAINNET', 7560: 'CYBER_CONNECT_MAINNET', 111557560: 'CYBER_CONNECT_TESTNET', + 84532: 'BASE_TESTNET', + 8453: 'BASE_MAINNET', }; export const SOURCE_TYPES = { @@ -47,11 +49,13 @@ export const SOURCE_TYPES = { SIMULATE: 'SIMULATE', CYBER_CONNECT_TESTNET: 'CYBER_CONNECT_TESTNET', CYBER_CONNECT_MAINNET: 'CYBER_CONNECT_MAINNET', + BASE_TESTNET: 'BASE_TESTNET', + BASE_MAINNET: 'BASE_MAINNET', }; export const SUPPORTED_CHAINS = [ 1, 11155111, 42, 137, 80002, 56, 97, 10, 11155420, 2442, 1101, 421614, 42161, - 122, 123, 80085, 111557560, 7560, 59141, 59144 + 122, 123, 80085, 111557560, 7560, 59141, 59144, 84532, 8453, ]; export enum IDENTITY_TYPE { diff --git a/packages/restapi/src/lib/progressHook.ts b/packages/restapi/src/lib/progressHook.ts index 675106177..980ca516f 100644 --- a/packages/restapi/src/lib/progressHook.ts +++ b/packages/restapi/src/lib/progressHook.ts @@ -155,13 +155,13 @@ const PROGRESSHOOK: Record< 'PUSH-DECRYPT-AUTH-01': { progressId: 'PUSH-DECRYPT-AUTH-01', progressTitle: 'Decrypting Profile Creds', - progressInfo: 'Please sign the transaction to decrypt profile creds', + progressInfo: 'Please sign the transaction to decrypt profile creds.', level: 'INFO', }, 'PUSH-DECRYPT-AUTH-02': { progressId: 'PUSH-DECRYPT-AUTH-02', progressTitle: 'Push Profile Creds Unlocked', - progressInfo: 'Unlocking push profile creds', + progressInfo: 'Unlocking push profile creds.', level: 'SUCCESS', }, /** @@ -191,7 +191,7 @@ const PROGRESSHOOK: Record< 'PUSH-CHANNEL-CREATE-02': { progressId: 'PUSH-CHANNEL-CREATE-02', progressTitle: 'Approving PUSH tokens', - progressInfo: 'Gives approval to Push Core contract to spend 50 DAI', + progressInfo: 'Gives approval to Push Core contract to spend 50 PUSH', level: 'INFO', }, 'PUSH-CHANNEL-CREATE-03': { @@ -218,7 +218,7 @@ const PROGRESSHOOK: Record< 'PUSH-CHANNEL-UPDATE-02': { progressId: 'PUSH-CHANNEL-UPDATE-02', progressTitle: 'Approving PUSH tokens', - progressInfo: 'Gives approval to Push Core contract to spend 50 DAI', + progressInfo: 'Gives approval to Push Core contract to spend 50 PUSH', level: 'INFO', }, 'PUSH-CHANNEL-UPDATE-03': { diff --git a/packages/restapi/src/lib/pushapi/chat.ts b/packages/restapi/src/lib/pushapi/chat.ts index b3570b291..9dc2e5f09 100644 --- a/packages/restapi/src/lib/pushapi/chat.ts +++ b/packages/restapi/src/lib/pushapi/chat.ts @@ -143,6 +143,32 @@ export class Chat { return historyMessages.map((message: any) => ({ ...message, listType })); } + async message( + target: string, + options?: { + reference?: string | null; + } + ) { + let reference: string; + + const { threadHash, intent } = await PUSH_CHAT.conversationHash({ + conversationId: target, + account: this.account, + env: this.env, + }); + + reference = options?.reference || threadHash; + + if (!reference) return {}; + + const historyMessages = await this.history(target, { reference, limit: 1 }); + const listType = intent ? 'CHATS' : 'REQUESTS'; + + return historyMessages.length > 0 + ? { ...historyMessages[0], listType } + : null; + } + async send(recipient: string, options: Message): Promise { if (!this.decryptedPgpPvtKey) { throw new Error(PushAPI.ensureSignerMessage()); diff --git a/packages/restapi/tests/.env.sample b/packages/restapi/tests/.env.sample index 2dcc097f7..46846d7c2 100644 --- a/packages/restapi/tests/.env.sample +++ b/packages/restapi/tests/.env.sample @@ -11,6 +11,7 @@ OPTIMISM_CHANNEL_PRIVATE_KEY=your_optimism_channel_private_key POLYGON_CHANNEL_PRIVATE_KEY=your_polygon_channel_private_key POLYGON_ZKEVM_CHANNEL_PRIVATE_KEY=your_polygon_zkevm_channel_private_key CYBER_CONNECT_CHANNEL_PRIVATE_KEY=your_cyber_connect_channel_private_key +BASE_CHANNEL_PRIVATE_KEY=your_base_channel_private_key WALLET_PRIVATE_KEY=your_wallet_private_key WALLET_PRIVATE_KEY_2=your_wallet_private_key_2 diff --git a/packages/restapi/tests/lib/alias/base.test.ts b/packages/restapi/tests/lib/alias/base.test.ts new file mode 100644 index 000000000..f81fb1013 --- /dev/null +++ b/packages/restapi/tests/lib/alias/base.test.ts @@ -0,0 +1,87 @@ +import { ethers } from 'ethers'; +import { PushAPI } from '../../../src'; +import { ENV } from '../../../src/lib/constants'; + +describe('BERACHAIN ALIAS functionality', () => { + let userAlice: PushAPI; + let userBob: PushAPI; + let account: string; + let account2: string; + + // accessing env dynamically using process.env + type EnvStrings = keyof typeof ENV; + const envMode = process.env.ENV as EnvStrings; + const _env = ENV[envMode]; + + before(async () => { + const provider = new ethers.providers.JsonRpcProvider( + 'https://sepolia.base.org' // base sepolia Provider + ); + const signer = new ethers.Wallet( + `0x${process.env['BERACHAIN_CHANNEL_PRIVATE_KEY']}`, + provider + ); + account = signer.address; + userAlice = await PushAPI.initialize(signer, { + env: _env, + }); + + const signer2 = new ethers.Wallet(ethers.Wallet.createRandom().privateKey); + account2 = signer2.address; + userBob = await PushAPI.initialize(signer2, { env: _env }); + }); + + it.skip('Should be able to create channel', async () => { + const channelInfo = await userAlice.channel.info(); + if (channelInfo) return; // skip if already exists + const res = await userAlice.channel.create({ + name: 'SDK Alias Test', + description: 'Testing using sdk', + url: 'https://push.org', + icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAz0lEQVR4AcXBsU0EQQyG0e+saWJ7oACiKYDMEZVs6GgSpC2BIhzRwAS0sgk9HKn3gpFOAv3v3V4/3+4U4Z1q5KTy42Ql940qvFONnFSGmCFmiN2+fj7uCBlihpgh1ngwcvKfwjuVIWaIGWKNB+GdauSk8uNkJfeNKryzYogZYoZY40m5b/wlQ8wQM8TayMlKeKcaOVkJ71QjJyuGmCFmiDUe+HFy4VyEd57hx0mV+0ZliBlihlgL71w4FyMnVXhnZeSkiu93qheuDDFDzBD7BcCyMAOfy204AAAAAElFTkSuQmCC', + alias: `eip155:84532:${account}`, + progressHook: (progress: any) => console.log(progress), + }); + console.log(res); + }); + + it('Should be able to send notifications', async () => { + await userAlice.channel.send(['*'], { + notification: { + title: 'hi', + body: 'test-broadcast', + }, + payload: { + title: 'testing broadcast notification', + body: 'testing with random body', + cta: 'https://google.com/', + embed: 'https://avatars.githubusercontent.com/u/64157541?s=200&v=4', + }, + channel: `eip155:84532:${account}`, + }); + }); + + it('Should be able to add delegatee', async () => { + await userAlice.channel.delegate.add(account2); + }); + + it('Should be able to send notifications from delegate', async () => { + await userBob.channel.send(['*'], { + notification: { + title: 'hi', + body: 'test-broadcast', + }, + payload: { + title: 'testing broadcast notification', + body: 'testing with random body', + cta: 'https://google.com/', + embed: 'https://avatars.githubusercontent.com/u/64157541?s=200&v=4', + }, + channel: `eip155:84532:${account}`, + }); + }); + + it('Should be able to remove delegatee', async () => { + await userAlice.channel.delegate.remove(account2); + }); +}); diff --git a/packages/uiweb/README.md b/packages/uiweb/README.md index f103c1278..59522134c 100644 --- a/packages/uiweb/README.md +++ b/packages/uiweb/README.md @@ -149,7 +149,7 @@ where | cta | string | Call To Action Link (given during notification creation) | | image | string | Any media link (given during notification creation) | | url | string | Channel Link (given during channel setup) | -| chainName | string | Can be anyone of the following blockchain networks on which the notification was sent - "ETH_MAINNET", "ETH_TEST_SEPOLIA", "POLYGON_MAINNET", "POLYGON_TEST_AMOY", "BSC_MAINNET, "BSC_TESTNET", "OPTIMISM_MAINNET", "OPTIMISM_TESTNET", "POLYGON_ZK_EVM_TESTNET", "POLYGON_ZK_EVM_MAINNET", "ARBITRUM_TESTNET", "ARBITRUMONE_MAINNET", "FUSE_TESTNET", "FUSE_MAINNET", "BERACHIAN_TESTNET", "LINEA_MAINNET", "LINEA_TESTNET", "CYBER_CONNECT_TESTNET , "CYBER_CONNECT_MAINNET", "THE_GRAPH" | +| chainName | string | Can be anyone of the following blockchain networks on which the notification was sent - "ETH_MAINNET", "ETH_TEST_SEPOLIA", "POLYGON_MAINNET", "POLYGON_TEST_AMOY", "BSC_MAINNET, "BSC_TESTNET", "OPTIMISM_MAINNET", "OPTIMISM_TESTNET", "POLYGON_ZK_EVM_TESTNET", "POLYGON_ZK_EVM_MAINNET", "ARBITRUM_TESTNET", "ARBITRUMONE_MAINNET", "FUSE_TESTNET", "FUSE_MAINNET", "BERACHIAN_TESTNET", "LINEA_MAINNET", "LINEA_TESTNET", "CYBER_CONNECT_TESTNET , "CYBER_CONNECT_MAINNET", "BASE_MAINNET" , "BASE_TESTNET", "THE_GRAPH" | | theme | string | 'light' or 'dark' (customization to be given by the dApp) | | customTheme | INotificationItemTheme | custom theme object for the component | | isSpam | boolean | whether a spam notification or not | diff --git a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx index 18f266ce6..9317e3aca 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx @@ -585,7 +585,7 @@ export const ChatViewList: React.FC = (options: IChatViewLis }; //styles -const ChatViewListCard = styled(Section) ` +const ChatViewListCard = styled(Section)` &::-webkit-scrollbar-thumb { background: ${(props) => props.theme.scrollbarColor}; border-radius: 10px; diff --git a/packages/uiweb/src/lib/components/chat/constants/chainDetails.tsx b/packages/uiweb/src/lib/components/chat/constants/chainDetails.tsx index 620654948..ea49d6b47 100644 --- a/packages/uiweb/src/lib/components/chat/constants/chainDetails.tsx +++ b/packages/uiweb/src/lib/components/chat/constants/chainDetails.tsx @@ -1,102 +1,105 @@ - -import Tooltip from "../../tooltip"; +import Tooltip from '../../tooltip'; import { EthereumSvg } from '../../../icons/EthereumSvg'; -import { PolygonSvg } from "../../../icons/PolygonSvg"; -import { BSCSvg } from "../../../icons/BSCSvg"; -import { OptimismSvg } from "../../../icons/OptimismSvg"; -import { PolygonzkevmSvg } from "../../../icons/PolygonzkevmSvg"; -import { ArbitrumSvg } from "../../../icons/ArbitrumSvg" -import { FuseSvg } from "../../../icons/FuseSvg" -import React from "react"; -import { BerachainSVG } from "../../../icons/BerachainSVG"; -import LineaSVG from "../../../icons/LineaSVG"; +import { PolygonSvg } from '../../../icons/PolygonSvg'; +import { BSCSvg } from '../../../icons/BSCSvg'; +import { OptimismSvg } from '../../../icons/OptimismSvg'; +import { PolygonzkevmSvg } from '../../../icons/PolygonzkevmSvg'; +import { ArbitrumSvg } from '../../../icons/ArbitrumSvg'; +import { FuseSvg } from '../../../icons/FuseSvg'; +import { BerachainSVG } from '../../../icons/BerachainSVG'; +import { LineaSVG } from '../../../icons/LineaSVG'; +import { BaseSVG } from '../../../icons/baseSVG'; -import { CyberConnectSVG } from "../../../icons/CyberConnectSVG"; -const createSVGIcon = (element:any, chainName: string) => { - return ( - - {element} - - ); +import { CyberConnectSVG } from '../../../icons/CyberConnectSVG'; +const createSVGIcon = (element: any, chainName: string) => { + return {element}; }; -export const NETWORK_ICON_DETAILS = { +export const NETWORK_ICON_DETAILS = { 11155111: { label: 'ETHEREUM SEPOLIA', - icon: createSVGIcon(, 'Ethereum Sepolia'), + icon: createSVGIcon(, 'Ethereum Sepolia'), }, 1: { label: 'ETHEREUM MAINNET', - icon: createSVGIcon(, 'Ethereum Mainnet'), + icon: createSVGIcon(, 'Ethereum Mainnet'), }, 80002: { label: 'POLYGON AMOY', - icon: createSVGIcon(, 'Polygon Amoy'), + icon: createSVGIcon(, 'Polygon Amoy'), }, 137: { label: 'POLYGON MAINNET', - icon: createSVGIcon(, 'Polygon Mainnet'), + icon: createSVGIcon(, 'Polygon Mainnet'), }, 97: { label: 'BSC TESTNET', - icon: createSVGIcon(, 'Bsc Testnet'), + icon: createSVGIcon(, 'Bsc Testnet'), }, 56: { label: 'BSC MAINNET', - icon: createSVGIcon(, 'Bsc Mainnet'), + icon: createSVGIcon(, 'Bsc Mainnet'), }, 11155420: { label: 'OPTIMISM TESTNET', - icon: createSVGIcon(, 'Optimism Testnet'), + icon: createSVGIcon(, 'Optimism Testnet'), }, 10: { label: 'OPTIMISM MAINNET', - icon: createSVGIcon(, 'Optimism Mainnet'), + icon: createSVGIcon(, 'Optimism Mainnet'), }, 1442: { label: 'POLYGON ZK EVM TESTNET', - icon: createSVGIcon(, 'Polygon ZK EVM Testnet'), + icon: createSVGIcon(, 'Polygon ZK EVM Testnet'), }, 1101: { label: 'POLYGON ZK EVM MAINNET', - icon: createSVGIcon(, 'Polygon ZK EVM Mainnet'), + icon: createSVGIcon(, 'Polygon ZK EVM Mainnet'), }, 42161: { label: 'ARBITRUMONE MAINNET', - icon: createSVGIcon(, 'Arbitrum Mainnet'), + icon: createSVGIcon(, 'Arbitrum Mainnet'), }, 421614: { label: 'ARBITRUM TESTNET', - icon: createSVGIcon(, 'Arbitrum Testnet'), + icon: createSVGIcon(, 'Arbitrum Testnet'), }, - 123 : { + 123: { label: 'FUSE TESTNET', - icon: createSVGIcon(, 'Fuse Testnet'), + icon: createSVGIcon(, 'Fuse Testnet'), }, - 122 : { + 122: { label: 'FUSE MAINNET', - icon: createSVGIcon(, 'Fuse Mainnet'), + icon: createSVGIcon(, 'Fuse Mainnet'), }, - 80085 : { + 80085: { label: 'BERACHAIN TESTNET', - icon: createSVGIcon(, 'Berachain Testnet'), + icon: createSVGIcon(, 'Berachain Testnet'), }, - 59141 : { + 59141: { label: 'LINEA TESTNET', - icon: createSVGIcon(, 'Linea Testnet'), + icon: createSVGIcon(, 'Linea Testnet'), }, - 59144 : { + 59144: { label: 'LIENA MAINNET', - icon: createSVGIcon(, 'Linea Mainnet'), + icon: createSVGIcon(, 'Linea Mainnet'), }, 111557560: { label: 'CYBER CONNECT TESTNET', - icon: createSVGIcon(, 'CyberConnect Testnet'), + icon: createSVGIcon(, 'CyberConnect Testnet'), }, 7560: { label: 'CYBER CONNECT MAINNET', - icon: createSVGIcon(, 'CyberConnect Mainnet'), - } + icon: createSVGIcon(, 'CyberConnect Mainnet'), + }, + 84532: { + label: 'BASE TESTNET', + icon: createSVGIcon(, 'Base Testnet'), + }, + 8453: { + label: 'BASE MAINNET', + icon: createSVGIcon(, 'Base Testnet'), + }, }; diff --git a/packages/uiweb/src/lib/components/notification/chainDetails.tsx b/packages/uiweb/src/lib/components/notification/chainDetails.tsx index 60f9e8273..ade80811b 100644 --- a/packages/uiweb/src/lib/components/notification/chainDetails.tsx +++ b/packages/uiweb/src/lib/components/notification/chainDetails.tsx @@ -9,8 +9,9 @@ import { OptimismSvg } from '../../icons/OptimismSvg'; import { PolygonSvg } from '../../icons/PolygonSvg'; import { PolygonzkevmSvg } from '../../icons/PolygonzkevmSvg'; import { TheGraphSvg } from '../../icons/TheGraphSvg'; -import LineaSVG from '../../icons/LineaSVG'; +import { LineaSVG } from '../../icons/LineaSVG'; import { CyberConnectSVG } from '../../icons/CyberConnectSVG'; +import { BaseSVG } from '../../icons/baseSVG'; const createSVGIcon = (element: any, chainName: string) => { return {element}; }; @@ -99,4 +100,12 @@ export default { label: 'CYBER CONNECT MAINNET', icon: createSVGIcon(, 'CyberConnect Mainnet'), }, + BASE_TESTNET: { + label: 'BASE TESTNET', + icon: createSVGIcon(, 'Base Testnet'), + }, + BASE_MAINNET: { + label: 'BASE MAINNET', + icon: createSVGIcon(, 'Base Mainnet'), + }, }; diff --git a/packages/uiweb/src/lib/components/notification/index.tsx b/packages/uiweb/src/lib/components/notification/index.tsx index 31dedba9a..02a010ef0 100644 --- a/packages/uiweb/src/lib/components/notification/index.tsx +++ b/packages/uiweb/src/lib/components/notification/index.tsx @@ -45,6 +45,8 @@ export type chainNameType = | 'LINEA_TESTNET' | 'CYBER_CONNECT_TESTNET' | 'CYBER_CONNECT_MAINNET' + | 'BASE_TESTNET' + | 'BASE_MAINNET' | undefined; export type NotificationItemProps = { diff --git a/packages/uiweb/src/lib/config/constants.ts b/packages/uiweb/src/lib/config/constants.ts index c5c089154..d57413840 100644 --- a/packages/uiweb/src/lib/config/constants.ts +++ b/packages/uiweb/src/lib/config/constants.ts @@ -61,6 +61,7 @@ const TESTNET_NETWORK = { FUSE: 'eip155:123', BERACHAIN: 'eip155:80085', CYBER_CONNECT: 'eip155:111557560', + BASE: 'eip155:84532', }; const MAINET_NETWORK = { ETHEREUM: 'eip155:1', @@ -71,6 +72,7 @@ const MAINET_NETWORK = { ARBITRUM: 'eip155:42161', FUSE: 'eip155:122', CYBER_CONNECT: 'eip155:7560', + BASE: 'eip155:8453', }; export const BLOCKCHAIN_NETWORK = { @@ -90,6 +92,7 @@ export const allowedNetworks = { 122, // for fuse mainnet 59144, // for linea mainnet 7569, // for cyber connect mainnet + 8453, // for base mainnet ], dev: [ 11155111, // for eth sepolia @@ -102,6 +105,7 @@ export const allowedNetworks = { 59141, // for linea testnet 2442, // polygon zkevm 111557560, // cyber connect testnet + 84532, // for base testnet ], staging: [ // 42, //for kovan @@ -115,6 +119,7 @@ export const allowedNetworks = { 59141, // for linea testnet 2442, // polygon zkevm 111557560, // cyber connect testnet + 84532, // for base testnet ], local: [ 11155111, // for eth sepolia @@ -127,6 +132,7 @@ export const allowedNetworks = { 59141, // for linea testnet 2442, // polygon zkevm 111557560, // cyber connect testnet + 84532, // for base testnet ], }; diff --git a/packages/uiweb/src/lib/icons/LineaSVG.tsx b/packages/uiweb/src/lib/icons/LineaSVG.tsx index 2dab10fad..2278c3456 100644 --- a/packages/uiweb/src/lib/icons/LineaSVG.tsx +++ b/packages/uiweb/src/lib/icons/LineaSVG.tsx @@ -1,7 +1,7 @@ import * as React from "react" import { SVGProps } from "react" -const LineaSVG = (props: SVGProps) => ( +export const LineaSVG = (props: SVGProps) => ( ) => ( ) -export default LineaSVG + diff --git a/packages/uiweb/src/lib/icons/base.svg b/packages/uiweb/src/lib/icons/base.svg new file mode 100644 index 000000000..da7e6fbe9 --- /dev/null +++ b/packages/uiweb/src/lib/icons/base.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/uiweb/src/lib/icons/baseSVG.tsx b/packages/uiweb/src/lib/icons/baseSVG.tsx new file mode 100644 index 000000000..9f896a270 --- /dev/null +++ b/packages/uiweb/src/lib/icons/baseSVG.tsx @@ -0,0 +1,17 @@ +import * as React from "react" +import { SVGProps } from "react" + +export const BaseSVG = (props: SVGProps) => ( + + + +) +