-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
194 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters