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 bb86a0764..72c56fafb 100644 --- a/packages/examples/sdk-frontend-react/src/app/components/Connect.tsx +++ b/packages/examples/sdk-frontend-react/src/app/components/Connect.tsx @@ -17,7 +17,7 @@ const NETWORK_MAPPING: NwMappingType = { 97: 'BSC_TESTNET', 11155420: 'OPTIMISM_TESTNET', 10: 'OPTIMISM_MAINNET', - 1442: 'POLYGON_ZK_EVM_TESTNET', + 2442: 'POLYGON_ZK_EVM_TESTNET', 1101: 'POLYGON_ZK_EVM_MAINNET', 421614: 'ARBITRUM_TESTNET', 42161: 'ARBITRUMONE_MAINNET', @@ -28,7 +28,7 @@ const NETWORK_MAPPING: NwMappingType = { const injected = new InjectedConnector({ supportedChainIds: [ - 1, 3, 4, 11155111, 42, 137, 80002, 56, 97, 10, 11155420, 1442, 1101, 421614, + 1, 3, 4, 11155111, 42, 137, 80002, 56, 97, 10, 11155420, 2442, 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 f7a467193..afb608532 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, 80002, 56, 97, 10, 11155420, 1442, 1101, 421614, 42161, 122, 123, + 137, 80002, 56, 97, 10, 11155420, 2442, 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 c70c38087..6afd11afc 100644 --- a/packages/restapi/src/lib/config.ts +++ b/packages/restapi/src/lib/config.ts @@ -10,7 +10,6 @@ import { optimism, optimismSepolia, polygonZkEvm, - polygonZkEvmTestnet, sepolia, arbitrum, arbitrumSepolia, @@ -19,6 +18,28 @@ import { } from 'viem/chains'; import { defineChain } from 'viem'; +const polygonZkEvmCordona = defineChain({ + id: 2442, + name: 'Polygon zkEVM Cardona Testnet', + network: 'polygon-zkevm-testnet', + nativeCurrency: { + decimals: 18, + name: 'ETH', + symbol: 'ETH', + }, + rpcUrls: { + default: { http: ['https://rpc.cardona.zkevm-rpc.com/'] }, + public: { http: ['https://rpc.cardona.zkevm-rpc.com/'] }, + }, + blockExplorers: { + default: { + name: 'Polygon zkEVM Cardona', + url: ' https://cardona-zkevm.polygonscan.com/', + }, + }, + testnet: true, +}) + const polygonAmoy = defineChain({ id: 80002, name: 'Polygon Amoy Testnet', @@ -86,7 +107,7 @@ const BLOCKCHAIN_NETWORK = { BSC_TESTNET: 'eip155:97', OPTIMISM_TESTNET: 'eip155:11155420', OPTIMISM_MAINNET: 'eip155:10', - POLYGON_ZK_EVM_TESTNET: 'eip155:1442', + POLYGON_ZK_EVM_TESTNET: 'eip155:2442', POLYGON_ZK_EVM_MAINNET: 'eip155:1101', ARBITRUM_TESTNET: 'eip155:421614', ARBITRUMONE_MAINNET: 'eip155:42161', @@ -133,9 +154,9 @@ export const ALIAS_CHAIN_ID: { }, POLYGONZKEVM: { [ENV.PROD]: 1101, - [ENV.STAGING]: 1442, - [ENV.DEV]: 1442, - [ENV.LOCAL]: 1442, + [ENV.STAGING]: 2442, + [ENV.DEV]: 2442, + [ENV.LOCAL]: 2442, }, ARBITRUMONE: { [ENV.PROD]: 42161, @@ -177,7 +198,7 @@ export const CHAIN_NAME: { [key: number]: string } = { 11155420: 'OPTIMISM', // plygonzkevm 1101: 'POLYGONZKEVM', - 1442: 'POLYGONZKEVM', + 2442: 'POLYGONZKEVM', // arbitrun 421614: 'ARBITRUN', 42161: 'ARBITRUM', @@ -284,7 +305,7 @@ const CONFIG = { }, [BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: { API_BASE_URL: API_BASE_URL[ENV.STAGING], - EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', + EPNS_COMMUNICATOR_CONTRACT: '0x6e489b7af21ceb969f49a90e481274966ce9d74d', }, [BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: { API_BASE_URL: API_BASE_URL[ENV.STAGING], @@ -318,7 +339,7 @@ const CONFIG = { }, [BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: { API_BASE_URL: API_BASE_URL[ENV.DEV], - EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572', + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: { API_BASE_URL: API_BASE_URL[ENV.DEV], @@ -352,7 +373,7 @@ const CONFIG = { }, [BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: { API_BASE_URL: API_BASE_URL[ENV.LOCAL], - EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572', + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: { API_BASE_URL: API_BASE_URL[ENV.LOCAL], @@ -461,9 +482,9 @@ export const VIEM_CONFIG = { EPNS_COMMUNICATOR_CONTRACT: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A', }, [BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: { - NETWORK: polygonZkEvmTestnet, + NETWORK: polygonZkEvmCordona, API_BASE_URL: API_BASE_URL[ENV.STAGING], - EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa', + EPNS_COMMUNICATOR_CONTRACT: '0x6e489b7af21ceb969f49a90e481274966ce9d74d', }, [BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: { NETWORK: arbitrumSepolia, @@ -503,9 +524,9 @@ export const VIEM_CONFIG = { EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317', }, [BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: { - NETWORK: polygonZkEvmTestnet, + NETWORK: polygonZkEvmCordona, API_BASE_URL: API_BASE_URL[ENV.DEV], - EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572', + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: { NETWORK: arbitrumSepolia, @@ -545,9 +566,9 @@ export const VIEM_CONFIG = { EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317', }, [BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: { - NETWORK: polygonZkEvmTestnet, + NETWORK: polygonZkEvmCordona, API_BASE_URL: API_BASE_URL[ENV.DEV], - EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572', + EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550b5c92baa056fc0f08132f49508145f', }, [BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: { NETWORK: arbitrumSepolia, diff --git a/packages/restapi/src/lib/constants.ts b/packages/restapi/src/lib/constants.ts index e31535276..7750adc22 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, 80002, 56, 97, 10, 11155420, 1442, 1101, 421614, 42161, 122, 123, + 137, 80002, 56, 97, 10, 11155420, 2442, 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 4dc57268d..7fde41a26 100644 --- a/packages/restapi/src/lib/payloads/constants.ts +++ b/packages/restapi/src/lib/payloads/constants.ts @@ -11,7 +11,7 @@ export const CHAIN_ID_TO_SOURCE: ChainIdToSourceType = { 97: 'BSC_TESTNET', 10: 'OPTIMISM_MAINNET', 11155420: 'OPTIMISM_TESTNET', - 1442: 'POLYGON_ZK_EVM_TESTNET', + 2442: 'POLYGON_ZK_EVM_TESTNET', 1101: 'POLYGON_ZK_EVM_MAINNET', 421614: "ARBITRUM_TESTNET", 42161: "ARBITRUMONE_MAINNET", diff --git a/packages/restapi/src/lib/payloads/helpers.ts b/packages/restapi/src/lib/payloads/helpers.ts index de1be2071..29adee31e 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, 80002, 56, 97, 10, 11155420, 1442, 1101, 421614, + 1, 11155111, 42, 137, 80002, 56, 97, 10, 11155420, 2442, 1101, 421614, 42161, 122, 123, 80085, ].includes(chainId) ) { diff --git a/packages/restapi/tests/.env.sample b/packages/restapi/tests/.env.sample index fbfbf384a..127ce1739 100644 --- a/packages/restapi/tests/.env.sample +++ b/packages/restapi/tests/.env.sample @@ -8,6 +8,7 @@ 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 +POLYGON_ZKEVM_CHANNEL_PRIVATE_KEY=your_polygon_zkevm_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/polygonZkevm.test.ts b/packages/restapi/tests/lib/alias/polygonZkevm.test.ts new file mode 100644 index 000000000..b071b06c2 --- /dev/null +++ b/packages/restapi/tests/lib/alias/polygonZkevm.test.ts @@ -0,0 +1,85 @@ +import { ethers } from 'ethers'; +import { PushAPI } from '../../../src'; +import { ENV } from '../../../src/lib/constants'; + +describe.only('POLYGON ZKEVM 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.cardona.zkevm-rpc.com/' + ); + const signer = new ethers.Wallet( + `0x${process.env['POLYGON_ZKEVM_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:2442:${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:2442:${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:2442:${account}`, + }); + }); + + it('Should be able to remove delegatee', async () => { + await userAlice.channel.delegate.remove(account2); + }); +}); diff --git a/packages/uiweb/src/lib/config/constants.ts b/packages/uiweb/src/lib/config/constants.ts index 6084e97a5..e96ad6f56 100644 --- a/packages/uiweb/src/lib/config/constants.ts +++ b/packages/uiweb/src/lib/config/constants.ts @@ -56,7 +56,7 @@ const TESTNET_NETWORK = { POLYGON: 'eip155:80002', BSC: 'eip155:97', OPTIMISM: 'eip155:11155420', - POLYGON_ZK_EVM: 'eip155:1442', + POLYGON_ZK_EVM: 'eip155:2442', ARBITRUM: 'eip155:421614', FUSE: 'eip155:123', BERACHAIN: 'eip155:80085', @@ -95,6 +95,7 @@ export const allowedNetworks = { 421614, // for arbitrum testnet 123, // for fuse testnet 80085, // for berachain testnet + 2442 // polygon zkevm ], staging: [ // 42, //for kovan @@ -105,6 +106,7 @@ export const allowedNetworks = { 421614, // for arbitrum testnet 123, // for fuse testnet 80085, // for berachain testnet + 2442 // polygon zkevm ], local: [ 11155111, // for eth sepolia @@ -114,6 +116,7 @@ export const allowedNetworks = { 421614, // for arbitrum testnet 123, // for fuse testnet 80085, // for berachain testnet + 2442 // polygon zkevm ], };