Skip to content

Commit

Permalink
fix: fix contract changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman035 committed Mar 21, 2024
1 parent 75cb526 commit 767633d
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 26 deletions.
40 changes: 20 additions & 20 deletions packages/restapi/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
bsc,
bscTestnet,
optimism,
optimismGoerli,
optimismSepolia,
polygonZkEvm,
polygonZkEvmTestnet,
sepolia,
arbitrum,
arbitrumGoerli,
arbitrumSepolia,
fuse,
fuseSparknet,
} from 'viem/chains';
Expand Down Expand Up @@ -255,15 +255,15 @@ const CONFIG = {
},
[BLOCKCHAIN_NETWORK.OPTIMISM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
EPNS_COMMUNICATOR_CONTRACT: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A',
},
[BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
EPNS_COMMUNICATOR_CONTRACT: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.STAGING],
Expand All @@ -289,15 +289,15 @@ const CONFIG = {
},
[BLOCKCHAIN_NETWORK.OPTIMISM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x4305D572F2bf38Fc2AE8D0172055b1EFd18F57a6',
EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317',
},
[BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x2f6aE0907116A2c50D712e78b48D874fadeB6850',
EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.DEV],
Expand All @@ -323,15 +323,15 @@ const CONFIG = {
},
[BLOCKCHAIN_NETWORK.OPTIMISM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x4305D572F2bf38Fc2AE8D0172055b1EFd18F57a6',
EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317',
},
[BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x2f6aE0907116A2c50D712e78b48D874fadeB6850',
EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
Expand Down Expand Up @@ -431,19 +431,19 @@ export const VIEM_CONFIG = {
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.OPTIMISM_TESTNET]: {
NETWORK: optimismGoerli,
NETWORK: optimismSepolia,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
EPNS_COMMUNICATOR_CONTRACT: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A',
},
[BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: {
NETWORK: polygonZkEvmTestnet,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
NETWORK: arbitrumGoerli,
NETWORK: arbitrumSepolia,
API_BASE_URL: API_BASE_URL[ENV.STAGING],
EPNS_COMMUNICATOR_CONTRACT: '0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa',
EPNS_COMMUNICATOR_CONTRACT: '0x9Dc25996ba72A2FD7E64e7a674232a683f406F1A',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
NETWORK: fuseSparknet,
Expand Down Expand Up @@ -473,19 +473,19 @@ export const VIEM_CONFIG = {
EPNS_COMMUNICATOR_CONTRACT: '0x4132061E3349ff36cFfCadA460E10Bd4f31F7ea8',
},
[BLOCKCHAIN_NETWORK.OPTIMISM_TESTNET]: {
NETWORK: optimismGoerli,
NETWORK: optimismSepolia,
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x4305D572F2bf38Fc2AE8D0172055b1EFd18F57a6',
EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317',
},
[BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: {
NETWORK: polygonZkEvmTestnet,
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
NETWORK: arbitrumGoerli,
NETWORK: arbitrumSepolia,
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x2f6aE0907116A2c50D712e78b48D874fadeB6850',
EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
NETWORK: fuseSparknet,
Expand Down Expand Up @@ -515,19 +515,19 @@ export const VIEM_CONFIG = {
EPNS_COMMUNICATOR_CONTRACT: '0x4132061E3349ff36cFfCadA460E10Bd4f31F7ea8',
},
[BLOCKCHAIN_NETWORK.OPTIMISM_TESTNET]: {
NETWORK: optimismGoerli,
NETWORK: optimismSepolia,
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x4305D572F2bf38Fc2AE8D0172055b1EFd18F57a6',
EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317',
},
[BLOCKCHAIN_NETWORK.POLYGON_ZK_EVM_TESTNET]: {
NETWORK: polygonZkEvmTestnet,
API_BASE_URL: API_BASE_URL[ENV.DEV],
EPNS_COMMUNICATOR_CONTRACT: '0x630b152e4185c63D7177c656b56b26f878C61572',
},
[BLOCKCHAIN_NETWORK.ARBITRUM_TESTNET]: {
NETWORK: arbitrumGoerli,
NETWORK: arbitrumSepolia,
API_BASE_URL: API_BASE_URL[ENV.LOCAL],
EPNS_COMMUNICATOR_CONTRACT: '0x2f6aE0907116A2c50D712e78b48D874fadeB6850',
EPNS_COMMUNICATOR_CONTRACT: '0x754787358fac861ef904c92d54f7adb659779317',
},
[BLOCKCHAIN_NETWORK.FUSE_TESTNET]: {
NETWORK: fuseSparknet,
Expand Down
4 changes: 3 additions & 1 deletion packages/restapi/tests/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
ENV=env_name

## CHANNEL WITH ALIAS
BERACHAIN_CHANNEL_PRIVATE_KEY=
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

WALLET_PRIVATE_KEY=your_wallet_private_key
WALLET_PRIVATE_KEY_2=your_wallet_private_key_2
Expand Down
84 changes: 84 additions & 0 deletions packages/restapi/tests/lib/alias/arbitrum.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import * as path from 'path';
import * as dotenv from 'dotenv';
dotenv.config({ path: path.resolve(__dirname, '../../.env') });
import { ethers } from 'ethers';
import { PushAPI } from '../../../src';
import { ENV } from '../../../src/lib/constants';

describe('ARBITRUM ALIAS functionality', () => {
let userAlice: PushAPI;
let userBob: PushAPI;
let account: string;
let account2: string;
before(async () => {
const provider = new ethers.providers.JsonRpcProvider(
'https://sepolia-rollup.arbitrum.io/rpc'
);
const signer = new ethers.Wallet(
`0x${process.env['ARBITRUM_CHANNEL_PRIVATE_KEY']}`,
provider
);
account = signer.address;
userAlice = await PushAPI.initialize(signer, {
env: ENV.DEV,
});

const signer2 = new ethers.Wallet(ethers.Wallet.createRandom().privateKey);
account2 = signer2.address;
userBob = await PushAPI.initialize(signer2, { env: ENV.DEV });
});

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:421614:${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:421614:${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:421614:${account}`,
});
});

it('Should be able to remove delegatee', async () => {
await userAlice.channel.delegate.remove(account2);
});
});
6 changes: 2 additions & 4 deletions packages/restapi/tests/lib/alias/berachain.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import * as path from 'path';
import * as dotenv from 'dotenv';
dotenv.config({ path: path.resolve(__dirname, '../../.env') });
import * as PUSH_CHANNELS from '../../../src/lib/channels';
import { expect } from 'chai';
import { ethers } from 'ethers';
import { PushAPI, user } from '../../../src';
import { PushAPI } from '../../../src';
import { ENV } from '../../../src/lib/constants';

describe('ALIAS functionality', () => {
describe('BERACHAIN ALIAS functionality', () => {
let userAlice: PushAPI;
let userBob: PushAPI;
let account: string;
Expand Down
84 changes: 84 additions & 0 deletions packages/restapi/tests/lib/alias/optimism.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import * as path from 'path';
import * as dotenv from 'dotenv';
dotenv.config({ path: path.resolve(__dirname, '../../.env') });
import { ethers } from 'ethers';
import { PushAPI } from '../../../src';
import { ENV } from '../../../src/lib/constants';

describe('OPTIMISM ALIAS functionality', () => {
let userAlice: PushAPI;
let userBob: PushAPI;
let account: string;
let account2: string;
before(async () => {
const provider = new ethers.providers.JsonRpcProvider(
'https://sepolia.optimism.io'
);
const signer = new ethers.Wallet(
`0x${process.env['OPTIMISM_CHANNEL_PRIVATE_KEY']}`,
provider
);
account = signer.address;
userAlice = await PushAPI.initialize(signer, {
env: ENV.DEV,
});

const signer2 = new ethers.Wallet(ethers.Wallet.createRandom().privateKey);
account2 = signer2.address;
userBob = await PushAPI.initialize(signer2, { env: ENV.DEV });
});

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:11155420:${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:11155420:${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:11155420:${account}`,
});
});

it('Should be able to remove delegatee', async () => {
await userAlice.channel.delegate.remove(account2);
});
});
2 changes: 1 addition & 1 deletion packages/uiweb/src/lib/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const TESTNET_NETWORK = {
ETHEREUM: 'eip155:11155111',
POLYGON: 'eip155:80001',
BSC: 'eip155:97',
OPTIMISM: 'eip155:420',
OPTIMISM: 'eip155:11155420',
POLYGON_ZK_EVM: 'eip155:1442',
ARBITRUM: 'eip155:421614',
FUSE: 'eip155:123',
Expand Down

0 comments on commit 767633d

Please sign in to comment.