-
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.
Add Berachain support to SDK (#1128)
* feat: berachain support for push-sdk * fix: add Berachain * fix: added tests, fixed address --------- Co-authored-by: Pratham Bhatnagar <[email protected]> Co-authored-by: aman035 <[email protected]>
- Loading branch information
1 parent
c01798a
commit 7c569ee
Showing
17 changed files
with
2,181 additions
and
30 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
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
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,86 @@ | ||
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 { ENV } from '../../../src/lib/constants'; | ||
|
||
describe('ALIAS functionality', () => { | ||
let userAlice: PushAPI; | ||
let userBob: PushAPI; | ||
let account: string; | ||
let account2: string; | ||
before(async () => { | ||
const provider = new ethers.providers.JsonRpcProvider( | ||
'https://artio.rpc.berachain.com' // berachain artio Provider | ||
); | ||
const signer = new ethers.Wallet( | ||
`0x${process.env['BERACHAIN_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:80085:${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:80085:${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:80085:${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
Oops, something went wrong.