Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linea Support #1228

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ const NETWORK_MAPPING: NwMappingType = {
122: 'FUSE_MAINNET',
123: 'FUSE_TESTNET',
80085: 'BERACHAIN_TESTNET',
59141: 'LINEA_TESTNET',
59144: 'LINEA_MAINNET',
111557560: 'CYBER_CONNECT_TESTNET',
7560: 'CYBER_CONNECT_MAINNET'
};

const injected = new InjectedConnector({
supportedChainIds: [
1, 3, 4, 11155111, 42, 137, 80002, 56, 97, 10, 11155420, 2442, 1101, 421614,
42161, 122, 123, 80085, 111557560, 7560
42161, 122, 123, 80085, 59144, 59141, 111557560, 7560
],
});

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 @@ -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, 111557560, 7560
80085, 59141, 59144,111557560, 7560
],
ETH_CHAINS: [1, 11155111],
};
Expand Down
55 changes: 52 additions & 3 deletions packages/restapi/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import {
arbitrumSepolia,
fuse,
fuseSparknet,
linea,
} from 'viem/chains';
import { berachainTestnet, polygonAmoy, polygonZkEvmCordona, cyberConnectMainnet, cyberConnectTestnet } from './customChains';
import { berachainTestnet, polygonAmoy, polygonZkEvmCordona, cyberConnectMainnet, cyberConnectTestnet, lineaSepoliaTestnet } from './customChains';


// for methods not needing the entire config
Expand Down Expand Up @@ -47,6 +48,8 @@ const BLOCKCHAIN_NETWORK = {
FUSE_TESTNET: 'eip155:123',
FUSE_MAINNET: 'eip155:122',
BERACHAIN_TESTNET: 'eip155:80085',
LINEA_MAINNET: 'eip155:59144',
LINEA_TESTNET: 'eip155:59141',
CYBER_CONNECT_TESTNET: 'eip155:111557560',
CYBER_CONNECT_MAINNET: 'eip155:7560'
};
Expand All @@ -59,6 +62,7 @@ export type ALIAS_CHAIN =
| 'ARBITRUMONE'
| 'FUSE'
| 'BERACHAIN'
| 'LINEA'
| 'CYBERCONNECT';

export const ETH_CHAIN_ID = {
Expand Down Expand Up @@ -112,6 +116,12 @@ export const ALIAS_CHAIN_ID: {
[ENV.DEV]: 80085,
[ENV.LOCAL]: 80085,
},
LINEA: {
[ENV.PROD]: 59144,
[ENV.STAGING]: 59141,
[ENV.DEV]: 59141,
[ENV.LOCAL]: 59141,
},
CYBERCONNECT: {
[ENV.PROD]: 7560,
[ENV.STAGING]: 111557560,
Expand Down Expand Up @@ -149,6 +159,9 @@ export const CHAIN_NAME: { [key: number]: string } = {
123: 'FUSE',
// berachain
80085: 'BERACHAIN',
// linea
59144: 'LINEA',
59141: 'LINEA',
// cyberconnect
7560: 'CYBER_CONNECT_MAINNET',
111557560: 'CYBER_CONNECT_TESTNET'
Expand Down Expand Up @@ -232,8 +245,12 @@ const CONFIG = {
},
[BLOCKCHAIN_NETWORK.CYBER_CONNECT_MAINNET]: {
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0xbf895df410b7fcbe093973600950ba392f7e1d8e',
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.LINEA_MAINNET]:{
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0x0d8e75CB5d8873c43c5d9Add71Fd71a09F7Ef890',
}
},
[ENV.STAGING]: {
[BLOCKCHAIN_NETWORK.ETH_SEPOLIA]: {
Expand Down Expand Up @@ -268,6 +285,10 @@ const CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0x7b9C405e261ba671f008c20D0321f62d08C140EC',
},
[BLOCKCHAIN_NETWORK.LINEA_TESTNET]:{
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
},
[BLOCKCHAIN_NETWORK.CYBER_CONNECT_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0x6e489B7af21cEb969f49A90E481274966ce9D74d',
Expand Down Expand Up @@ -306,6 +327,10 @@ const CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0xA1DF3E68D085aa6918bcc2506b24e499830Db0eB',
},
[BLOCKCHAIN_NETWORK.LINEA_TESTNET]:{
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
},
[BLOCKCHAIN_NETWORK.CYBER_CONNECT_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
Expand Down Expand Up @@ -344,6 +369,10 @@ const CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0xA1DF3E68D085aa6918bcc2506b24e499830Db0eB',
},
[BLOCKCHAIN_NETWORK.LINEA_TESTNET]:{
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
},
[BLOCKCHAIN_NETWORK.CYBER_CONNECT_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
Expand Down Expand Up @@ -420,10 +449,15 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.LINEA_MAINNET]:{
NETWORK:linea,
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0x0d8e75CB5d8873c43c5d9Add71Fd71a09F7Ef890',
},
[BLOCKCHAIN_NETWORK.CYBER_CONNECT_MAINNET]: {
NETWORK: cyberConnectMainnet,
API_BASE_URL: API_BASE_URL[ENV.PROD],
EPNS_COMMUNICATOR_CONTRACT: '0xbf895df410b7fcbe093973600950ba392f7e1d8e',
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
},
[ENV.STAGING]: {
Expand Down Expand Up @@ -467,6 +501,11 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0x7b9C405e261ba671f008c20D0321f62d08C140EC',
},
[BLOCKCHAIN_NETWORK.LINEA_TESTNET]:{
NETWORK: lineaSepoliaTestnet,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
},
[BLOCKCHAIN_NETWORK.CYBER_CONNECT_TESTNET]: {
NETWORK: cyberConnectTestnet,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
Expand Down Expand Up @@ -514,6 +553,11 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0xA1DF3E68D085aa6918bcc2506b24e499830Db0eB',
},
[BLOCKCHAIN_NETWORK.LINEA_TESTNET]:{
NETWORK: lineaSepoliaTestnet,
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
},
[BLOCKCHAIN_NETWORK.CYBER_CONNECT_TESTNET]: {
NETWORK: cyberConnectTestnet,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
Expand Down Expand Up @@ -561,6 +605,11 @@ export const VIEM_CONFIG = {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0xA1DF3E68D085aa6918bcc2506b24e499830Db0eB',
},
[BLOCKCHAIN_NETWORK.LINEA_TESTNET]:{
NETWORK: lineaSepoliaTestnet,
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x9cb3bd7550B5c92baA056Fc0F08132f49508145F',
},
[BLOCKCHAIN_NETWORK.CYBER_CONNECT_TESTNET]: {
NETWORK: cyberConnectTestnet,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
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 @@ -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,111557560,7560
80085,59141, 59144, 111557560,7560
],
ETH_CHAINS: [1, 11155111],
ENC_TYPE_V1: 'x25519-xsalsa20-poly1305',
Expand Down
31 changes: 31 additions & 0 deletions packages/restapi/src/lib/customChains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,34 @@ export const cyberConnectMainnet = defineChain({
},
},
});

export const lineaSepoliaTestnet = defineChain({
id: 59_141,
name: 'Linea Sepolia Testnet',
network: 'linea-sepolia-testnet',
nativeCurrency: { name: 'Linea Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: {
http: ['https://rpc.sepolia.linea.build'],
webSocket: ['wss://rpc.sepolia.linea.build'],
},
public: {
http: ['https://rpc.sepolia.linea.build'],
webSocket: ['wss://rpc.sepolia.linea.build'],
}
},
blockExplorers: {
default: {
name: 'Etherscan',
url: 'https://sepolia.lineascan.build',
apiUrl: 'https://api-sepolia.lineascan.build/api',
},
},
contracts: {
multicall3: {
address: '0xca11bde05977b3631167028862be2a173976ca11',
blockCreated: 227427,
},
},
testnet: true,
})
26 changes: 15 additions & 11 deletions packages/restapi/src/lib/payloads/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ export const CHAIN_ID_TO_SOURCE: ChainIdToSourceType = {
11155420: 'OPTIMISM_TESTNET',
2442: 'POLYGON_ZK_EVM_TESTNET',
1101: 'POLYGON_ZK_EVM_MAINNET',
421614: 'ARBITRUM_TESTNET',
42161: 'ARBITRUMONE_MAINNET',
122: 'FUSE_MAINNET',
123: 'FUSE_TESTNET',
80085: 'BERACHAIN_TESTNET',
421614: "ARBITRUM_TESTNET",
42161: "ARBITRUMONE_MAINNET",
122: "FUSE_MAINNET",
123: "FUSE_TESTNET",
80085: "BERACHAIN_TESTNET",
59141: 'LINEA_TESTNET',
59144: 'LINEA_MAINNET',
7560: 'CYBER_CONNECT_MAINNET',
111557560: 'CYBER_CONNECT_TESTNET',
};
Expand All @@ -33,11 +35,13 @@ export const SOURCE_TYPES = {
OPTIMISM_TESTNET: 'OPTIMISM_TESTNET',
POLYGON_ZK_EVM_TESTNET: 'POLYGON_ZK_EVM_TESTNET',
POLYGON_ZK_EVM_MAINNET: 'POLYGON_ZK_EVM_MAINNET',
ARBITRUM_TESTNET: 'ARBITRUM_TESTNET',
ARBITRUMONE_MAINNET: 'ARBITRUMONE_MAINNET',
FUSE_TESTNET: 'FUSE_TESTNET',
FUSE_MAINNET: 'FUSE_MAINNET',
BERACHAIN_TESTNET: 'BERACHAIN_TESTNET',
ARBITRUM_TESTNET: "ARBITRUM_TESTNET",
ARBITRUMONE_MAINNET: "ARBITRUMONE_MAINNET",
FUSE_TESTNET:"FUSE_TESTNET",
FUSE_MAINNET:"FUSE_MAINNET",
BERACHAIN_TESTNET: "BERACHAIN_TESTNET",
LINEA_TESTNET: 'LINEA_TESTNET',
LINEA_MAINNET: 'LINEA_MAINNET',
THE_GRAPH: 'THE_GRAPH',
PUSH_VIDEO: 'PUSH_VIDEO',
SIMULATE: 'SIMULATE',
Expand All @@ -47,7 +51,7 @@ export const SOURCE_TYPES = {

export const SUPPORTED_CHAINS = [
1, 11155111, 42, 137, 80002, 56, 97, 10, 11155420, 2442, 1101, 421614, 42161,
122, 123, 80085, 111557560, 7560,
122, 123, 80085, 111557560, 7560, 59141, 59144
];

export enum IDENTITY_TYPE {
Expand Down
1 change: 1 addition & 0 deletions packages/restapi/tests/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ENV=env_name

## CHANNEL WITH ALIAS
BERACHAIN_CHANNEL_PRIVATE_KEY=your_berachain_channel_private_key
LINEA_CHANNEL_PRIVATE_KEY=your_linea_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
Expand Down
84 changes: 84 additions & 0 deletions packages/restapi/tests/lib/alias/linea.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { ethers } from 'ethers';
import { PushAPI } from '../../../src';
import { ENV } from '../../../src/lib/constants';

describe('LINEA 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.linea.build/'
);
const signer = new ethers.Wallet(
`0x${process.env['LINEA_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:59141:${account}`,
});
});

it('Should be able to remove delegatee', async () => {
await userAlice.channel.delegate.remove(account2);
});
});
2 changes: 1 addition & 1 deletion packages/uiweb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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", "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", "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 |
Expand Down
10 changes: 10 additions & 0 deletions packages/uiweb/src/lib/components/chat/constants/chainDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ 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 { CyberConnectSVG } from "../../../icons/CyberConnectSVG";
const createSVGIcon = (element:any, chainName: string) => {
return (
Expand Down Expand Up @@ -81,6 +83,14 @@ export const NETWORK_ICON_DETAILS = {
label: 'BERACHAIN TESTNET',
icon: createSVGIcon(<BerachainSVG/>, 'Berachain Testnet'),
},
59141 : {
label: 'LINEA TESTNET',
icon: createSVGIcon(<LineaSVG/>, 'Linea Testnet'),
},
59144 : {
label: 'LIENA MAINNET',
icon: createSVGIcon(<LineaSVG/>, 'Linea Mainnet'),
},
111557560: {
label: 'CYBER CONNECT TESTNET',
icon: createSVGIcon(<CyberConnectSVG/>, 'CyberConnect Testnet'),
Expand Down
Loading
Loading