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

Group criteria states #750

Merged
merged 23 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 21 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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<h4 align="center">

<a href="discord.gg/pushprotocol">
<a href="https://discord.com/invite/pushprotocol">
<img src="https://img.shields.io/badge/discord-7289da.svg?style=flat-square" alt="discord">
</a>
<a href="https://twitter.com/pushprotocol">
Expand Down Expand Up @@ -177,7 +177,7 @@ node main
- **[Website](https://push.org)** To checkout our Product.
- **[Docs](https://docs.push.org/developers/)** For comprehensive documentation.
- **[Blog](https://medium.com/push-protocol)** To learn more about our partners, new launches, etc.
- **[Discord](discord.gg/pushprotocol)** for support and discussions with the community and the team.
- **[Discord](https://discord.com/invite/pushprotocol)** for support and discussions with the community and the team.
- **[GitHub](https://github.com/ethereum-push-notification-service)** for source code, project board, issues, and pull requests.
- **[Twitter](https://twitter.com/pushprotocol)** for the latest updates on the product and published blogs.

Expand All @@ -196,7 +196,7 @@ Read how you can contribute <a href="https://github.com/ethereum-push-notificati
Not sure where to start? Join our discord and we will help you get started!


<a href="discord.gg/pushprotocol" title="Join Our Community"><img src="https://www.freepnglogos.com/uploads/discord-logo-png/playerunknown-battlegrounds-bgparty-15.png" width="200" alt="Discord" /></a>
<a href="https://discord.com/invite/pushprotocol" title="Join Our Community"><img src="https://www.freepnglogos.com/uploads/discord-logo-png/playerunknown-battlegrounds-bgparty-15.png" width="200" alt="Discord" /></a>

## License
Check out our License <a href='https://github.com/ethereum-push-notification-service/push-sdk/blob/main/license-v1.md'>HERE </a>
Expand Down
4 changes: 2 additions & 2 deletions packages/examples/sdk-backend-node/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ VIDEO_CHAIN_ID=your_video_chain_id
# VIDEO SENDER ADDRESS
VIDEO_SENDER_ADDRESS=your_video_sender_address

# VIDEO RECIPEINT ADDRESS
VIDEO_RECIPEINT_ADDRESS=your_video_recipeint_address
# VIDEO RECIPIENT ADDRESS
VIDEO_RECIPIENT_ADDRESS=your_video_recipient_address

# VIDEO CHAT ID
VIDEO_CHAT_ID=your_video_chat_id
4 changes: 2 additions & 2 deletions packages/examples/sdk-backend-node/chat/nftChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ async function PushAPI_nft_chat_updateGroup(
chatId,
groupName: updatedNftGroupName,
groupDescription,
members: [nftAccount2, nftAccount3],
members: [nftAccount2, nftAccount3, nftAccount1],
groupImage,
admins: [nftAccount2],
admins: [nftAccount1],
account: nftAccount1,
signer: nftSigner1,
pgpPrivateKey: pgpDecrpyptedPvtKey,
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/sdk-backend-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@pushprotocol/restapi": "0.0.1-alpha.39",
"@pushprotocol/restapi": "0.0.1-alpha.44",
"@pushprotocol/socket": "^0.5.2"
}
}
192 changes: 192 additions & 0 deletions packages/examples/sdk-backend-node/pushAPI/channel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
import { PushAPI } from '@pushprotocol/restapi';
import { config } from '../config';
import { ethers } from 'ethers';

// CONFIGS
const { env, showAPIResponse } = config;

export const runPushAPIChannelCases = async (): Promise<void> => {
if (!process.env.WALLET_PRIVATE_KEY) {
console.log(
'skipping PushAPI.channel examples, no private key passed in .env'
);
return;
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// Signer Generation
const provider = new ethers.providers.JsonRpcProvider(
'https://goerli.blockpi.network/v1/rpc/public' // Goerli Provider
);
const signer = new ethers.Wallet(
`0x${process.env.WALLET_PRIVATE_KEY}`,
provider
);
const randomWallet1 = ethers.Wallet.createRandom().address;
const randomWallet2 = ethers.Wallet.createRandom().address;
// -------------------------------------------------------------------
// -------------------------------------------------------------------
const userAlice = await PushAPI.initialize(signer, { env });
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.info');
const channelInfo = await userAlice.channel.info();
if (showAPIResponse) {
console.log(channelInfo);
}
console.log('PushAPI.channel.info | Response - 200 OK\n\n');
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.search');
const searchedChannels = await userAlice.channel.search(
'push' // search by name or address
);
if (showAPIResponse) {
console.log(searchedChannels);
}
console.log('PushAPI.channel.search | Response - 200 OK\n\n');
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.subscribers');
const channelSubscribers = await userAlice.channel.subscribers();
if (showAPIResponse) {
console.log(channelSubscribers);
}
console.log('PushAPI.channel.subscribers | Response - 200 OK\n\n');
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.send');
if (channelInfo) {
const broadcastNotif = await userAlice.channel.send(['*'], {
notification: {
title: 'test',
body: 'test',
},
});
const targetedNotif = await userAlice.channel.send([randomWallet1], {
notification: {
title: 'test',
body: 'test',
},
});
const subsetNotif = await userAlice.channel.send(
[randomWallet1, randomWallet2],
{
notification: {
title: 'test',
body: 'test',
},
}
);
if (showAPIResponse) {
console.log(broadcastNotif, targetedNotif, subsetNotif);
}
console.log('PushAPI.channel.send | Response - 200 OK\n\n');
} else {
console.log(
'skipping PushAPI.channel.send as no channel exists with the signer\n\n'
);
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// These Examples requires wallet to hold some ETH & PUSH
const balance = await provider.getBalance(signer.address);
if (parseFloat(ethers.utils.formatEther(balance)) < 0.001) {
console.log(
'skipping PushAPI.channel examples, wallet does not have enough balance to pay fee'
);
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.create');
if (channelInfo) {
console.log('skipping PushAPI.channel.create as it already exists\n\n');
} else {
const createdChannel = await userAlice.channel.create({
name: 'Test Channel',
description: 'Test Description',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAz0lEQVR4AcXBsU0EQQyG0e+saWJ7oACiKYDMEZVs6GgSpC2BIhzRwAS0sgk9HKn3gpFOAv3v3V4/3+4U4Z1q5KTy42Ql940qvFONnFSGmCFmiN2+fj7uCBlihpgh1ngwcvKfwjuVIWaIGWKNB+GdauSk8uNkJfeNKryzYogZYoZY40m5b/wlQ8wQM8TayMlKeKcaOVkJ71QjJyuGmCFmiDUe+HFy4VyEd57hx0mV+0ZliBlihlgL71w4FyMnVXhnZeSkiu93qheuDDFDzBD7BcCyMAOfy204AAAAAElFTkSuQmCC',
url: 'https://push.org',
});
if (showAPIResponse) {
console.log(createdChannel);
}
console.log('PushAPI.channel.create | Response - 200 OK\n\n');
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.update');
const updatedChannel = await userAlice.channel.update({
name: 'Updated Name',
description: 'Testing new description',
url: 'https://google.com',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAz0lEQVR4AcXBsU0EQQyG0e+saWJ7oACiKYDMEZVs6GgSpC2BIhzRwAS0sgk9HKn3gpFOAv3v3V4/3+4U4Z1q5KTy42Ql940qvFONnFSGmCFmiN2+fj7uCBlihpgh1ngwcvKfwjuVIWaIGWKNB+GdauSk8uNkJfeNKryzYogZYoZY40m5b/wlQ8wQM8TayMlKeKcaOVkJ71QjJyuGmCFmiDUe+HFy4VyEd57hx0mV+0ZliBlihlgL71w4FyMnVXhnZeSkiu93qheuDDFDzBD7BcCyMAOfy204AAAAAElFTkSuQmCC',
});
if (showAPIResponse) {
console.log(updatedChannel);
}
console.log('PushAPI.channel.update | Response - 200 OK\n\n');
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.verify');
// only verified channels can verify other channels (otherwise this action is skipped by sdk)
if (channelInfo.verified_status) {
const verifiedTrx = await userAlice.channel.verify(
'0x35B84d6848D16415177c64D64504663b998A6ab4'
);
if (showAPIResponse) {
console.log(verifiedTrx);
}
}
console.log('PushAPI.channel.verify | Response - 200 OK\n\n');
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.setting');
const channelSettingTrx = await userAlice.channel.setting([
{ type: 0, default: 1, description: 'My Notif Settings' },
]);
if (showAPIResponse) {
console.log(channelSettingTrx);
}
console.log('PushAPI.channel.setting | Response - 200 OK\n\n');
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.delegate.add');
const addedDelegate = await userAlice.channel.delegate.add(
`eip155:5:${randomWallet1}`
);

if (showAPIResponse) {
console.log(addedDelegate);
}
console.log('PushAPI.channel.delegate.add | Response - 200 OK\n\n');
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.delegate.get');
const delegates = await userAlice.channel.delegate.get();
if (showAPIResponse) {
console.log(delegates);
}
console.log('PushAPI.channel.delegate.get | Response - 200 OK\n\n');
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.delegate.remove');
const removedDelegate = await userAlice.channel.delegate.remove(
`eip155:5:${randomWallet1}`
);
if (showAPIResponse) {
console.log(removedDelegate);
}
console.log('PushAPI.channel.delegate.remove | Response - 200 OK\n\n');
// -------------------------------------------------------------------
// -------------------------------------------------------------------
console.log('PushAPI.channel.alias.info');
const aliasInfo = await userAlice.channel.alias.info({
alias: '0x35B84d6848D16415177c64D64504663b998A6ab4',
aliasChain: 'POLYGON',
});
if (showAPIResponse) {
console.log(aliasInfo);
}
console.log('PushAPI.channel.alias.info | Response - 200 OK\n\n');
};
Loading