Skip to content

Commit

Permalink
fix: enabled base network (#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
akp111 authored Jun 6, 2024
1 parent 49cc34c commit c842ac1
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
});

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

Expand Down Expand Up @@ -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 =
Expand All @@ -63,7 +67,8 @@ export type ALIAS_CHAIN =
| 'FUSE'
| 'BERACHAIN'
| 'LINEA'
| 'CYBERCONNECT';
| 'CYBERCONNECT'
| 'BASE';

export const ETH_CHAIN_ID = {
[ENV.PROD]: 1,
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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]: {
Expand Down Expand Up @@ -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]: {
Expand Down Expand Up @@ -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]: {
Expand Down Expand Up @@ -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',
}
},
};

Expand Down Expand Up @@ -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]: {
Expand Down Expand Up @@ -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]: {
Expand Down Expand Up @@ -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]: {
Expand All @@ -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',
}
},
};

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,59141, 59144, 111557560,7560
80085,59141, 59144, 111557560, 7560, 84532, 8453,
],
ETH_CHAINS: [1, 11155111],
ENC_TYPE_V1: 'x25519-xsalsa20-poly1305',
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 @@ -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 = {
Expand All @@ -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 {
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 @@ -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
Expand Down
87 changes: 87 additions & 0 deletions packages/restapi/tests/lib/alias/base.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
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", "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 |
Expand Down
Loading

0 comments on commit c842ac1

Please sign in to comment.