From 7b710e678a7e905adf9d7abb24ab67860d46c6c5 Mon Sep 17 00:00:00 2001 From: Pratham Bhatnagar Date: Tue, 9 Apr 2024 15:48:58 +0530 Subject: [PATCH 1/3] feat: add Polygon Amoy Support --- .../src/app/components/Connect.tsx | 4 +- .../sdk-frontend-react/src/app/helpers.ts | 2 +- packages/restapi/src/lib/config.ts | 61 +++++++++++++------ packages/restapi/src/lib/constants.ts | 2 +- .../restapi/src/lib/payloads/constants.ts | 4 +- packages/restapi/src/lib/payloads/helpers.ts | 2 +- packages/uiweb/README.md | 2 +- .../chat/constants/chainDetails.tsx | 6 +- .../components/notification/chainDetails.tsx | 4 +- .../src/lib/components/notification/index.tsx | 2 +- packages/uiweb/src/lib/config/constants.ts | 12 ++-- 11 files changed, 62 insertions(+), 39 deletions(-) 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 c792f7ebe..bb86a0764 100644 --- a/packages/examples/sdk-frontend-react/src/app/components/Connect.tsx +++ b/packages/examples/sdk-frontend-react/src/app/components/Connect.tsx @@ -12,7 +12,7 @@ const NETWORK_MAPPING: NwMappingType = { 11155111: 'ETH_SEPOLIA', 3: 'ETH_ROPSTEN', 137: 'POLYGON_MAINNET', - 80001: 'POLYGON_MUMBAI', + 80002: 'POLYGON_AMOY', 56: 'BSC_MAINNET', 97: 'BSC_TESTNET', 11155420: 'OPTIMISM_TESTNET', @@ -28,7 +28,7 @@ const NETWORK_MAPPING: NwMappingType = { const injected = new InjectedConnector({ supportedChainIds: [ - 1, 3, 4, 11155111, 42, 137, 80001, 56, 97, 10, 11155420, 1442, 1101, 421614, + 1, 3, 4, 11155111, 42, 137, 80002, 56, 97, 10, 11155420, 1442, 1101, 421614, 42161, 122, 123, 80085, ], }); diff --git a/packages/examples/sdk-frontend-react/src/app/helpers.ts b/packages/examples/sdk-frontend-react/src/app/helpers.ts index f4b43cd0d..f7a467193 100644 --- a/packages/examples/sdk-frontend-react/src/app/helpers.ts +++ b/packages/examples/sdk-frontend-react/src/app/helpers.ts @@ -19,7 +19,7 @@ const Constants = { DEFAULT_CHAIN_ID: 11155111, DEV_CHAIN_ID: 99999, NON_ETH_CHAINS: [ - 137, 80001, 56, 97, 10, 11155420, 1442, 1101, 421614, 42161, 122, 123, + 137, 80002, 56, 97, 10, 11155420, 1442, 1101, 421614, 42161, 122, 123, 80085, ], ETH_CHAINS: [1, 11155111], diff --git a/packages/restapi/src/lib/config.ts b/packages/restapi/src/lib/config.ts index 4b79cb2de..c70c38087 100644 --- a/packages/restapi/src/lib/config.ts +++ b/packages/restapi/src/lib/config.ts @@ -5,7 +5,6 @@ import { tokenABI } from './abis/token'; import { mainnet, polygon, - polygonMumbai, bsc, bscTestnet, optimism, @@ -20,6 +19,30 @@ import { } from 'viem/chains'; import { defineChain } from 'viem'; +const polygonAmoy = defineChain({ + id: 80002, + name: 'Polygon Amoy Testnet', + network: 'polygon-amoy', + nativeCurrency: { + decimals: 18, + name: 'MATIC', + symbol: 'MATIC', + }, + rpcUrls: { + default: { http: ['https://rpc-amoy.polygon.technology/'] }, + public: { http: ['https://rpc-amoy.polygon.technology/'] }, + }, + blockExplorers: { + default: { + name: 'Polygon Amoy', + url: 'https://www.oklink.com/amoy', + }, + }, + testnet: true, +}); + + + const berachainTestnet = defineChain({ id: 80085, name: 'Berachain Artio', @@ -58,7 +81,7 @@ const BLOCKCHAIN_NETWORK = { ETH_MAINNET: 'eip155:1', ETH_SEPOLIA: 'eip155:11155111', POLYGON_MAINNET: 'eip155:137', - POLYGON_MUMBAI: 'eip155:80001', + POLYGON_AMOY: 'eip155:80002', BSC_MAINNET: 'eip155:56', BSC_TESTNET: 'eip155:97', OPTIMISM_TESTNET: 'eip155:11155420', @@ -92,9 +115,9 @@ export const ALIAS_CHAIN_ID: { } = { POLYGON: { [ENV.PROD]: 137, - [ENV.STAGING]: 80001, - [ENV.DEV]: 80001, - [ENV.LOCAL]: 80001, + [ENV.STAGING]: 80002, + [ENV.DEV]: 80002, + [ENV.LOCAL]: 80002, }, BSC: { [ENV.PROD]: 56, @@ -145,7 +168,7 @@ export const CHAIN_NAME: { [key: number]: string } = { 11155111: 'ETHEREUM', // polygon 137: 'POLYGON', - 80001: 'POLYGON', + 80002: 'POLYGON', // bsc 56: 'BSC', 97: 'BSC', @@ -247,7 +270,7 @@ const CONFIG = { API_BASE_URL: API_BASE_URL[ENV.STAGING], EPNS_COMMUNICATOR_CONTRACT: '0x0c34d54a09cfe75bccd878a469206ae77e0fe6e7', }, - [BLOCKCHAIN_NETWORK.POLYGON_MUMBAI]: { + [BLOCKCHAIN_NETWORK.POLYGON_AMOY]: { API_BASE_URL: API_BASE_URL[ENV.STAGING], EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', }, @@ -281,9 +304,9 @@ const CONFIG = { API_BASE_URL: API_BASE_URL[ENV.DEV], EPNS_COMMUNICATOR_CONTRACT: '0x9dDCD7ed7151afab43044E4D694FA064742C428c', }, - [BLOCKCHAIN_NETWORK.POLYGON_MUMBAI]: { + [BLOCKCHAIN_NETWORK.POLYGON_AMOY]: { API_BASE_URL: API_BASE_URL[ENV.DEV], - EPNS_COMMUNICATOR_CONTRACT: '0xAf55BE8e6b0d6107891bA76eADeEa032ef8A4504', + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.BSC_TESTNET]: { API_BASE_URL: API_BASE_URL[ENV.DEV], @@ -315,9 +338,9 @@ const CONFIG = { API_BASE_URL: API_BASE_URL[ENV.LOCAL], EPNS_COMMUNICATOR_CONTRACT: '0x9dDCD7ed7151afab43044E4D694FA064742C428c', }, - [BLOCKCHAIN_NETWORK.POLYGON_MUMBAI]: { + [BLOCKCHAIN_NETWORK.POLYGON_AMOY]: { API_BASE_URL: API_BASE_URL[ENV.LOCAL], - EPNS_COMMUNICATOR_CONTRACT: '0xAf55BE8e6b0d6107891bA76eADeEa032ef8A4504', + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.BSC_TESTNET]: { API_BASE_URL: API_BASE_URL[ENV.LOCAL], @@ -422,8 +445,8 @@ export const VIEM_CONFIG = { API_BASE_URL: API_BASE_URL[ENV.STAGING], EPNS_COMMUNICATOR_CONTRACT: '0x0c34d54a09cfe75bccd878a469206ae77e0fe6e7', }, - [BLOCKCHAIN_NETWORK.POLYGON_MUMBAI]: { - NETWORK: polygonMumbai, + [BLOCKCHAIN_NETWORK.POLYGON_AMOY]: { + NETWORK: polygonAmoy, API_BASE_URL: API_BASE_URL[ENV.STAGING], EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', }, @@ -464,10 +487,10 @@ export const VIEM_CONFIG = { API_BASE_URL: API_BASE_URL[ENV.DEV], EPNS_COMMUNICATOR_CONTRACT: '0x9dDCD7ed7151afab43044E4D694FA064742C428c', }, - [BLOCKCHAIN_NETWORK.POLYGON_MUMBAI]: { - NETWORK: polygonMumbai, + [BLOCKCHAIN_NETWORK.POLYGON_AMOY]: { + NETWORK: polygonAmoy, API_BASE_URL: API_BASE_URL[ENV.DEV], - EPNS_COMMUNICATOR_CONTRACT: '0xAf55BE8e6b0d6107891bA76eADeEa032ef8A4504', + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.BSC_TESTNET]: { NETWORK: bscTestnet, @@ -506,10 +529,10 @@ export const VIEM_CONFIG = { API_BASE_URL: API_BASE_URL[ENV.DEV], EPNS_COMMUNICATOR_CONTRACT: '0x9dDCD7ed7151afab43044E4D694FA064742C428c', }, - [BLOCKCHAIN_NETWORK.POLYGON_MUMBAI]: { - NETWORK: polygonMumbai, + [BLOCKCHAIN_NETWORK.POLYGON_AMOY]: { + NETWORK: polygonAmoy, API_BASE_URL: API_BASE_URL[ENV.DEV], - EPNS_COMMUNICATOR_CONTRACT: '0xAf55BE8e6b0d6107891bA76eADeEa032ef8A4504', + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.BSC_TESTNET]: { NETWORK: bscTestnet, diff --git a/packages/restapi/src/lib/constants.ts b/packages/restapi/src/lib/constants.ts index 1b10f7460..e31535276 100644 --- a/packages/restapi/src/lib/constants.ts +++ b/packages/restapi/src/lib/constants.ts @@ -66,7 +66,7 @@ const Constants = { DEFAULT_CHAIN_ID: 11155111, DEV_CHAIN_ID: 99999, NON_ETH_CHAINS: [ - 137, 80001, 56, 97, 10, 11155420, 1442, 1101, 421614, 42161, 122, 123, + 137, 80002, 56, 97, 10, 11155420, 1442, 1101, 421614, 42161, 122, 123, 80085, ], ETH_CHAINS: [1, 11155111], diff --git a/packages/restapi/src/lib/payloads/constants.ts b/packages/restapi/src/lib/payloads/constants.ts index 18f4bee0b..4dc57268d 100644 --- a/packages/restapi/src/lib/payloads/constants.ts +++ b/packages/restapi/src/lib/payloads/constants.ts @@ -6,7 +6,7 @@ export const CHAIN_ID_TO_SOURCE: ChainIdToSourceType = { 1: 'ETH_MAINNET', 11155111: 'ETH_TEST_SEPOLIA', 137: 'POLYGON_MAINNET', - 80001: 'POLYGON_TEST_MUMBAI', + 80002: 'POLYGON_TEST_AMOY', 56: 'BSC_MAINNET', 97: 'BSC_TESTNET', 10: 'OPTIMISM_MAINNET', @@ -24,7 +24,7 @@ export const SOURCE_TYPES = { ETH_MAINNET: 'ETH_MAINNET', ETH_TEST_SEPOLIA: 'ETH_TEST_SEPOLIA', POLYGON_MAINNET: 'POLYGON_MAINNET', - POLYGON_TEST_MUMBAI: 'POLYGON_TEST_MUMBAI', + POLYGON_TEST_AMOY: 'POLYGON_TEST_AMOY', BSC_MAINNET: 'BSC_MAINNET', BSC_TESTNET: 'BSC_TESTNET', OPTIMISM_MAINNET: 'OPTIMISM_MAINNET', diff --git a/packages/restapi/src/lib/payloads/helpers.ts b/packages/restapi/src/lib/payloads/helpers.ts index ca26b2a03..228cbb77b 100644 --- a/packages/restapi/src/lib/payloads/helpers.ts +++ b/packages/restapi/src/lib/payloads/helpers.ts @@ -329,7 +329,7 @@ export function getCAIPFormat(chainId: number, address: string) { // EVM based chains if ( [ - 1, 11155111, 42, 137, 80001, 56, 97, 10, 11155420, 1442, 1101, 421614, + 1, 11155111, 42, 137, 80002, 56, 97, 10, 11155420, 1442, 1101, 421614, 42161, 122, 123, 80085, ].includes(chainId) ) { diff --git a/packages/uiweb/README.md b/packages/uiweb/README.md index 13c496fe5..a1406b96f 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_MUMBAI", "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", "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", "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/constants/chainDetails.tsx b/packages/uiweb/src/lib/components/chat/constants/chainDetails.tsx index 71df6f491..cd6e2d67f 100644 --- a/packages/uiweb/src/lib/components/chat/constants/chainDetails.tsx +++ b/packages/uiweb/src/lib/components/chat/constants/chainDetails.tsx @@ -28,9 +28,9 @@ export const NETWORK_ICON_DETAILS = { label: 'ETHEREUM MAINNET', icon: createSVGIcon(, 'Ethereum Mainnet'), }, - 80001: { - label: 'POLYGON MUMBAI', - icon: createSVGIcon(, 'Polygon Mumbai'), + 80002: { + label: 'POLYGON AMOY', + icon: createSVGIcon(, 'Polygon Amoy'), }, 137: { label: 'POLYGON MAINNET', diff --git a/packages/uiweb/src/lib/components/notification/chainDetails.tsx b/packages/uiweb/src/lib/components/notification/chainDetails.tsx index f4a3ebf6b..a90f32331 100644 --- a/packages/uiweb/src/lib/components/notification/chainDetails.tsx +++ b/packages/uiweb/src/lib/components/notification/chainDetails.tsx @@ -25,8 +25,8 @@ export default { icon: createSVGIcon(, 'Ethereum Mainnet'), }, POLYGON_TEST_MUMBAI: { - label: 'POLYGON MUMBAI', - icon: createSVGIcon(, 'Polygon Mumbai'), + label: 'POLYGON AMOY', + icon: createSVGIcon(, 'Polygon Amoy'), }, POLYGON_MAINNET: { label: 'POLYGON MAINNET', diff --git a/packages/uiweb/src/lib/components/notification/index.tsx b/packages/uiweb/src/lib/components/notification/index.tsx index 7db49a5fa..0a4922a03 100644 --- a/packages/uiweb/src/lib/components/notification/index.tsx +++ b/packages/uiweb/src/lib/components/notification/index.tsx @@ -25,7 +25,7 @@ export {lightTheme as notificationLightTheme,darkTheme as notificationDarkTheme, // ================= Define types export type chainNameType = | 'ETH_TEST_SEPOLIA' - | 'POLYGON_TEST_MUMBAI' + | 'POLYGON_TEST_AMOY' | 'ETH_MAINNET' | 'POLYGON_MAINNET' | 'BSC_MAINNET' diff --git a/packages/uiweb/src/lib/config/constants.ts b/packages/uiweb/src/lib/config/constants.ts index 4381fb23e..11ba4c577 100644 --- a/packages/uiweb/src/lib/config/constants.ts +++ b/packages/uiweb/src/lib/config/constants.ts @@ -22,8 +22,8 @@ export const NETWORK_DETAILS = { 11155111: { network: 'sepolia', }, - 80001: { - network: 'polygon-mumbai', + 80002: { + network: 'polygon-amoy', }, 1: { network: 'mainnet', @@ -53,7 +53,7 @@ export const CoreRPC = { const TESTNET_NETWORK = { ETHEREUM: 'eip155:11155111', - POLYGON: 'eip155:80001', + POLYGON: 'eip155:80002', BSC: 'eip155:97', OPTIMISM: 'eip155:11155420', POLYGON_ZK_EVM: 'eip155:1442', @@ -89,7 +89,7 @@ export const allowedNetworks = { ], dev: [ 11155111, // for eth sepolia - 80001, //for mumbai polygon + 80002, //for mumbai amoy 97, // bnb testnet 11155420, // optimism sepolia testnet 421614, // for arbitrum testnet @@ -99,7 +99,7 @@ export const allowedNetworks = { staging: [ // 42, //for kovan 11155111, // for sepolia - 80001, //for mumbai polygon + 80002, //for mumbai amoy 97, // bnb testnet 11155420, // optimism sepolia testnet 421614, // for arbitrum testnet @@ -108,7 +108,7 @@ export const allowedNetworks = { ], local: [ 11155111, // for eth sepolia - 80001, //for mumbai polygon + 80002, //for mumbai amoy 97, // bnb testnet 11155420, // optimism sepolia testnet 421614, // for arbitrum testnet From d6c08974ec66fba780bdc23141b08c576ebd9e82 Mon Sep 17 00:00:00 2001 From: aman035 Date: Wed, 10 Apr 2024 14:13:15 +0530 Subject: [PATCH 2/3] test: added amoy test cases --- packages/restapi/tests/.env.sample | 1 + .../restapi/tests/lib/alias/polygon.test.ts | 84 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 packages/restapi/tests/lib/alias/polygon.test.ts diff --git a/packages/restapi/tests/.env.sample b/packages/restapi/tests/.env.sample index 4c4067f9a..fbfbf384a 100644 --- a/packages/restapi/tests/.env.sample +++ b/packages/restapi/tests/.env.sample @@ -7,6 +7,7 @@ ENV=env_name BERACHAIN_CHANNEL_PRIVATE_KEY=your_berachain_channel_private_key ARBITRUM_CHANNEL_PRIVATE_KEY=your_arbitrum_channel_private_key OPTIMISM_CHANNEL_PRIVATE_KEY=your_optimism_channel_private_key +POLYGON_CHANNEL_PRIVATE_KEY=your_polygon_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/polygon.test.ts b/packages/restapi/tests/lib/alias/polygon.test.ts new file mode 100644 index 000000000..5aa2cfc2e --- /dev/null +++ b/packages/restapi/tests/lib/alias/polygon.test.ts @@ -0,0 +1,84 @@ +import { ethers } from 'ethers'; +import { PushAPI } from '../../../src'; +import { ENV } from '../../../src/lib/constants'; + +describe('POLYGON 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://rpc-amoy.polygon.technology/' + ); + const signer = new ethers.Wallet( + `0x${process.env['POLYGON_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 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:80002:${account}`, + progressHook: (progress: any) => console.log(progress), + }); + }); + + 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:80002:${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:80002:${account}`, + }); + }); + + it('Should be able to remove delegatee', async () => { + await userAlice.channel.delegate.remove(account2); + }); +}); From 03bcb7b4263e1fd5d34feed090ec7eb2e39e8247 Mon Sep 17 00:00:00 2001 From: Pratham Bhatnagar Date: Wed, 10 Apr 2024 16:44:02 +0530 Subject: [PATCH 3/3] fix: fix minor changes --- .../src/screens/NotificationScreen.tsx | 2 +- .../notification/NotificationItem.tsx | 2 +- packages/uireactnative/src/lib/constants.ts | 4 +- .../components/chat/ConnectButton/index.tsx | 64 ++++++++-------- .../chat/helpers/tokenHelpers/chain.ts | 26 +++---- .../components/notification/chainDetails.tsx | 2 +- .../components/widget/ConnectButton/index.tsx | 74 ++++++++++--------- packages/uiweb/src/lib/config/constants.ts | 6 +- packages/uiweb/src/lib/helpers/udResolver.ts | 2 +- 9 files changed, 92 insertions(+), 90 deletions(-) diff --git a/packages/examples/sdk-react-native/src/screens/NotificationScreen.tsx b/packages/examples/sdk-react-native/src/screens/NotificationScreen.tsx index c8fdd5533..d7b36bbc4 100644 --- a/packages/examples/sdk-react-native/src/screens/NotificationScreen.tsx +++ b/packages/examples/sdk-react-native/src/screens/NotificationScreen.tsx @@ -16,7 +16,7 @@ export const NotificationScreen = () => { image: undefined, url: 'https://push.org/', theme: 'light', - chainName: 'POLYGON_TEST_MUMBAI', + chainName: 'POLYGON_TEST_AMOY', cta: 'https://github.com/ethereum-push-notification-service/', }, { diff --git a/packages/uireactnative/src/lib/components/notification/NotificationItem.tsx b/packages/uireactnative/src/lib/components/notification/NotificationItem.tsx index 5ba18de4d..6cb29da2c 100644 --- a/packages/uireactnative/src/lib/components/notification/NotificationItem.tsx +++ b/packages/uireactnative/src/lib/components/notification/NotificationItem.tsx @@ -43,7 +43,7 @@ function extractTimeStamp(notificationBody: string): { type chainNameType = | 'ETH_TEST_SEPOLIA' - | 'POLYGON_TEST_MUMBAI' + | 'POLYGON_TEST_AMOY' | 'ETH_MAINNET' | 'POLYGON_MAINNET' | 'BSC_MAINNET' diff --git a/packages/uireactnative/src/lib/constants.ts b/packages/uireactnative/src/lib/constants.ts index cb7a6425c..ea82aed95 100644 --- a/packages/uireactnative/src/lib/constants.ts +++ b/packages/uireactnative/src/lib/constants.ts @@ -70,8 +70,8 @@ export const GLOBALS = { label: 'ETHEREUM MAINNET', icon: EthereumSVG, }, - POLYGON_TEST_MUMBAI: { - label: 'POLYGON MUMBAI', + POLYGON_TEST_AMOY: { + label: 'POLYGON AMOY', icon: PolygonSVG, }, POLYGON_MAINNET: { diff --git a/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx b/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx index ca758fb37..a339765e3 100644 --- a/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx +++ b/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx @@ -1,13 +1,13 @@ import { IChatTheme } from '../theme'; -import coinbaseWalletModule from '@web3-onboard/coinbase' +import coinbaseWalletModule from '@web3-onboard/coinbase'; import { ConnectButtonSub } from './ConnectButton'; import { BLOCKNATIVE_PROJECT_ID, InfuraAPIKey } from '../../../config'; import { Web3OnboardProvider } from '@web3-onboard/react'; import injectedModule, { ProviderLabel } from '@web3-onboard/injected-wallets'; -import walletConnectModule from '@web3-onboard/walletconnect' +import walletConnectModule from '@web3-onboard/walletconnect'; import init from '@web3-onboard/core'; -import PushIcon from "../../../icons/Bell.svg" +import PushIcon from '../../../icons/Bell.svg'; const APP_META_DATA = { name: 'Push Protocol', @@ -17,86 +17,84 @@ const APP_META_DATA = { recommendedInjectedWallets: [ { name: 'MetaMask', url: 'https://metamask.io' }, - ] -} + ], +}; const wcv2InitOptions = { projectId: BLOCKNATIVE_PROJECT_ID, - requiredChains: [1, 56] -} + requiredChains: [1, 56], +}; -const walletConnect = walletConnectModule(wcv2InitOptions) -const coinbaseWalletSdk = coinbaseWalletModule({ darkMode: true }) +const walletConnect = walletConnectModule(wcv2InitOptions); +const coinbaseWalletSdk = coinbaseWalletModule({ darkMode: true }); const CHAINS = [ { id: '0x1', token: 'ETH', label: 'Ethereum Mainnet', - rpcUrl: `https://mainnet.infura.io/v3/${InfuraAPIKey}` + rpcUrl: `https://mainnet.infura.io/v3/${InfuraAPIKey}`, }, { id: '0xAA36A7', token: 'ETH', label: 'Sepolia', - rpcUrl: `https://sepolia.infura.io/v3/${InfuraAPIKey}` + rpcUrl: `https://sepolia.infura.io/v3/${InfuraAPIKey}`, }, { - id: '0x13881', + id: '0x13882', token: 'MATIC', - label: 'Polygon - Mumbai', - rpcUrl: 'https://matic-mumbai.chainstacklabs.com' + label: 'Polygon - Amoy', + rpcUrl: 'https://rpc-amoy.polygon.technology', }, { id: '0x38', token: 'BNB', label: 'Binance', - rpcUrl: 'https://bsc-dataseed.binance.org/' + rpcUrl: 'https://bsc-dataseed.binance.org/', }, { id: '0xA', token: 'OETH', label: 'Optimism', - rpcUrl: 'https://mainnet.optimism.io' + rpcUrl: 'https://mainnet.optimism.io', }, { id: '0xA4B1', token: 'ARB-ETH', label: 'Arbitrum', - rpcUrl: 'https://rpc.ankr.com/arbitrum' - } -] - - -const wallets = [injectedModule(), walletConnect, coinbaseWalletSdk] - - + rpcUrl: 'https://rpc.ankr.com/arbitrum', + }, +]; +const wallets = [injectedModule(), walletConnect, coinbaseWalletSdk]; const web3OnBoard = init({ wallets, - chains:CHAINS, - appMetadata:APP_META_DATA, + chains: CHAINS, + appMetadata: APP_META_DATA, accountCenter: { desktop: { - enabled: false + enabled: false, }, mobile: { - enabled: false - } + enabled: false, + }, }, connect: { autoConnectLastWallet: true, - } -}) + }, +}); interface IConnectButtonCompProps { autoConnect?: boolean; } -export const ConnectButtonComp: React.FC = ({ autoConnect }) => { +export const ConnectButtonComp: React.FC = ({ + autoConnect, +}) => { return ( ); -}; \ No newline at end of file +}; diff --git a/packages/uiweb/src/lib/components/chat/helpers/tokenHelpers/chain.ts b/packages/uiweb/src/lib/components/chat/helpers/tokenHelpers/chain.ts index 1f15f8058..e53db5b32 100644 --- a/packages/uiweb/src/lib/components/chat/helpers/tokenHelpers/chain.ts +++ b/packages/uiweb/src/lib/components/chat/helpers/tokenHelpers/chain.ts @@ -1,4 +1,4 @@ -import { InfuraAPIKey } from "../../../../config"; +import { InfuraAPIKey } from '../../../../config'; const getInfuraUrlFor = (network: string, key: string) => `https://${network}.infura.io/v3/${key}`; @@ -8,26 +8,26 @@ const getRpcURL = (network: string, key: string) => { }; export const getChainRPC = (chainId: number): string => { - const key = InfuraAPIKey; - + const key = InfuraAPIKey; + switch (chainId) { case 1: - return getRpcURL("mainnet", key); + return getRpcURL('mainnet', key); case 137: - return getRpcURL("polygon-mainnet", key); + return getRpcURL('polygon-mainnet', key); case 10: - return getRpcURL("optimism-mainnet", key); + return getRpcURL('optimism-mainnet', key); case 56: - return "https://bsc-dataseed.binance.org/"; + return 'https://bsc-dataseed.binance.org/'; case 11155111: - return getRpcURL("sepolia", key); + return getRpcURL('sepolia', key); case 11155420: - return getRpcURL("optimism-sepolia", key); - case 80001: - return getRpcURL("polygon-mumbai", key); + return getRpcURL('optimism-sepolia', key); + case 80002: + return getRpcURL('polygon-amoy', key); case 97: - return "https://data-seed-prebsc-1-s1.binance.org:8545"; + return 'https://data-seed-prebsc-1-s1.binance.org:8545'; default: - return getRpcURL("mainnet", key); + return getRpcURL('mainnet', key); } }; diff --git a/packages/uiweb/src/lib/components/notification/chainDetails.tsx b/packages/uiweb/src/lib/components/notification/chainDetails.tsx index a90f32331..6c3ed2827 100644 --- a/packages/uiweb/src/lib/components/notification/chainDetails.tsx +++ b/packages/uiweb/src/lib/components/notification/chainDetails.tsx @@ -24,7 +24,7 @@ export default { label: 'ETHEREUM MAINNET', icon: createSVGIcon(, 'Ethereum Mainnet'), }, - POLYGON_TEST_MUMBAI: { + POLYGON_TEST_AMOY: { label: 'POLYGON AMOY', icon: createSVGIcon(, 'Polygon Amoy'), }, diff --git a/packages/uiweb/src/lib/components/widget/ConnectButton/index.tsx b/packages/uiweb/src/lib/components/widget/ConnectButton/index.tsx index 25c631a52..9e50b9aca 100644 --- a/packages/uiweb/src/lib/components/widget/ConnectButton/index.tsx +++ b/packages/uiweb/src/lib/components/widget/ConnectButton/index.tsx @@ -1,12 +1,11 @@ - -import coinbaseWalletModule from '@web3-onboard/coinbase' +import coinbaseWalletModule from '@web3-onboard/coinbase'; import { ConnectButtonSub } from './ConnectButton'; import { BLOCKNATIVE_PROJECT_ID, InfuraAPIKey } from '../../../config'; import { Web3OnboardProvider } from '@web3-onboard/react'; import injectedModule from '@web3-onboard/injected-wallets'; -import walletConnectModule from '@web3-onboard/walletconnect' +import walletConnectModule from '@web3-onboard/walletconnect'; import init from '@web3-onboard/core'; -import PushIcon from "../../../icons/Bell.svg" +import PushIcon from '../../../icons/Bell.svg'; import { SignerType } from '@pushprotocol/restapi'; const APP_META_DATA = { @@ -17,90 +16,95 @@ const APP_META_DATA = { recommendedInjectedWallets: [ { name: 'MetaMask', url: 'https://metamask.io' }, - ] -} + ], +}; const wcv2InitOptions = { projectId: BLOCKNATIVE_PROJECT_ID, - requiredChains: [1, 56] -} + requiredChains: [1, 56], +}; -const walletConnect = walletConnectModule(wcv2InitOptions) -const coinbaseWalletSdk = coinbaseWalletModule({ darkMode: true }) +const walletConnect = walletConnectModule(wcv2InitOptions); +const coinbaseWalletSdk = coinbaseWalletModule({ darkMode: true }); const CHAINS = [ { id: '0x1', token: 'ETH', label: 'Ethereum Mainnet', - rpcUrl: `https://mainnet.infura.io/v3/${InfuraAPIKey}` + rpcUrl: `https://mainnet.infura.io/v3/${InfuraAPIKey}`, }, { id: '0xAA36A7', token: 'ETH', label: 'Sepolia', - rpcUrl: `https://sepolia.infura.io/v3/${InfuraAPIKey}` + rpcUrl: `https://sepolia.infura.io/v3/${InfuraAPIKey}`, }, { id: '0x13881', token: 'MATIC', - label: 'Polygon - Mumbai', - rpcUrl: 'https://matic-mumbai.chainstacklabs.com' + label: 'Polygon - Amoy', + rpcUrl: 'https://rpc-amoy.polygon.technology', }, { id: '0x38', token: 'BNB', label: 'Binance', - rpcUrl: 'https://bsc-dataseed.binance.org/' + rpcUrl: 'https://bsc-dataseed.binance.org/', }, { id: '0xA', token: 'OETH', label: 'Optimism', - rpcUrl: 'https://mainnet.optimism.io' + rpcUrl: 'https://mainnet.optimism.io', }, { id: '0xA4B1', token: 'ARB-ETH', label: 'Arbitrum', - rpcUrl: 'https://rpc.ankr.com/arbitrum' - } -] - - -const wallets = [injectedModule(), walletConnect, coinbaseWalletSdk] - - + rpcUrl: 'https://rpc.ankr.com/arbitrum', + }, +]; +const wallets = [injectedModule(), walletConnect, coinbaseWalletSdk]; const web3OnBoard = init({ wallets, - chains:CHAINS, - appMetadata:APP_META_DATA, + chains: CHAINS, + appMetadata: APP_META_DATA, accountCenter: { desktop: { - enabled: false + enabled: false, }, mobile: { - enabled: false - } + enabled: false, + }, }, connect: { autoConnectLastWallet: true, }, -}) +}); interface IConnectButtonCompProps { autoconnect?: boolean; - setAccount: React.Dispatch>; + setAccount: React.Dispatch>; signer: SignerType | undefined; setSigner: React.Dispatch>; - } -export const ConnectButtonComp: React.FC = ({ autoconnect,setAccount,setSigner,signer }) => { +export const ConnectButtonComp: React.FC = ({ + autoconnect, + setAccount, + setSigner, + signer, +}) => { return ( - + ); -}; \ No newline at end of file +}; diff --git a/packages/uiweb/src/lib/config/constants.ts b/packages/uiweb/src/lib/config/constants.ts index 11ba4c577..6084e97a5 100644 --- a/packages/uiweb/src/lib/config/constants.ts +++ b/packages/uiweb/src/lib/config/constants.ts @@ -89,7 +89,7 @@ export const allowedNetworks = { ], dev: [ 11155111, // for eth sepolia - 80002, //for mumbai amoy + 80002, //for polygon amoy 97, // bnb testnet 11155420, // optimism sepolia testnet 421614, // for arbitrum testnet @@ -99,7 +99,7 @@ export const allowedNetworks = { staging: [ // 42, //for kovan 11155111, // for sepolia - 80002, //for mumbai amoy + 80002, //for polygon amoy 97, // bnb testnet 11155420, // optimism sepolia testnet 421614, // for arbitrum testnet @@ -108,7 +108,7 @@ export const allowedNetworks = { ], local: [ 11155111, // for eth sepolia - 80002, //for mumbai amoy + 80002, //for polygon amoy 97, // bnb testnet 11155420, // optimism sepolia testnet 421614, // for arbitrum testnet diff --git a/packages/uiweb/src/lib/helpers/udResolver.ts b/packages/uiweb/src/lib/helpers/udResolver.ts index 3391a09d4..b2ea60086 100644 --- a/packages/uiweb/src/lib/helpers/udResolver.ts +++ b/packages/uiweb/src/lib/helpers/udResolver.ts @@ -5,7 +5,7 @@ import type { Env } from '@pushprotocol/restapi'; export const getUdResolver = (env:Env): Resolution => { const l1ChainId = allowedNetworks[env].includes(1) ? 1 : 5; - const l2ChainId = allowedNetworks[env].includes(137) ? 137 : 80001; + const l2ChainId = allowedNetworks[env].includes(137) ? 137 : 80002; // ToDo: Enable for sepolia chainId once UD supports it // const l1ChainId = appConfig.allowedNetworks.includes(1) ? 1 : 11155111; return Resolution.fromEthersProvider({