Skip to content

Commit

Permalink
fix: Merge branch 'main' into deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammeds1992 committed Jun 26, 2023
2 parents 183e9c2 + cda9a28 commit a95a1aa
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 56 deletions.
121 changes: 116 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,84 @@
# PUSH-SDK
<h1 align="center">
<a href="https://push.org/#gh-light-mode-only">
<img width='20%' height='10%' src="https://res.cloudinary.com/drdjegqln/image/upload/v1686227557/Push-Logo-Standard-Dark_xap7z5.png">
</a>
<a href="https://push.org/#gh-dark-mode-only">
<img width='20%' height='10%' src="https://res.cloudinary.com/drdjegqln/image/upload/v1686227558/Push-Logo-Standard-White_dlvapc.png">
</a>
</h1>

<p align="center">
<i align="center">Push Protocol is a web3 communication network, enabling cross-chain notifications and messaging for dapps, wallets, and services.🚀</i>
</p>

<h4 align="center">

<a href="discord.gg/pushprotocol">
<img src="https://img.shields.io/badge/discord-7289da.svg?style=flat-square" alt="discord">
</a>
<a href="https://twitter.com/pushprotocol">
<img src="https://img.shields.io/badge/twitter-18a1d6.svg?style=flat-square" alt="twitter">
</a>
<a href="https://www.youtube.com/@pushprotocol">
<img src="https://img.shields.io/badge/youtube-d95652.svg?style=flat-square&" alt="youtube">
</a>
</h4>

<p align="center">
<img src="https://res.cloudinary.com/drdjegqln/image/upload/v1686230764/1500x500_bhmpkc.jpg" alt="dashboard"/>
</p>


## Introduction
#### What is Push Protocol?

Push Protocol, previously known as EPNS, is a Web3 communication protocol that enables any dApps, smart contracts, backends, or protocols to communicate both on-chain and off-chain via user wallet addresses in an open, gasless, multichain, and platform-agnostic fashion.

#### What We Do

Being an open communication middleware, Push is building a suite of products to enable notifications, chats, streaming, and more. We currently have two major products, Push Notifications and Push Chat.

<details open>
<summary>
Features
</summary>
<br>

<p align="center">
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231190/push-notifications_tkjhss.png" alt="apis"/>
&nbsp;
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231185/W2W_20Chat_eurjgu.png" alt="data-models"/>
</p>



<p align="center">
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231164/Untitled-2_fedru3.png" alt="own-your-code"/>
&nbsp;
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231177/Untitled_vhvrfc.png" alt="customize-code"/>
</p>

<p align="center">
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231162/1_LbhU9-qGnE8QPxWBQgNqQQ_xzkmpp.webp" alt="own-your-code"/>
&nbsp;

</p>
</details>

<br>
<br>

## PUSH-SDK

#### Push SDK provides an abstraction layer to integrate Push protocol features with your Frontend as well as Backend

PUSH SDK is a Javascript based Monorepo of packages that helps developers to
- build PUSH features into their DApps
- Notifications
- Chat
- Group Chat
- Push NFT Chat
- Video Calls
- get access to PUSH Push Nodes APIs
- render PUSH Notifications UI

Expand All @@ -11,8 +88,8 @@ The SDK provides a suite of solutions for different problems. It is written in T

*It is also built on top of standard Web3 packages like `ethers`, `@web3-react`*


## Packages available
## Development
### Packages available

Click on the packages to view more details.

Expand All @@ -23,7 +100,11 @@ Click on the packages to view more details.
- [@pushprotocol/reactnative](./packages/reactnative/README.md)


## Sample Usage
<details >
<summary>
Sample Usage
</summary>

*How to use a package from the SDK?*

Let's take `@pushprotocol/restapi` as an example.
Expand Down Expand Up @@ -89,5 +170,35 @@ Then to run this code open terminal and type
```bash
node main
```
</details>
<br>

## Resources
- **[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.
- **[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.


## Contributing

Push Protocol is an open source Project. We firmly believe in a completely transparent development process and value any contributions. We would love to have you as a member of the community, whether you are assisting us in bug fixes, suggesting new features, enhancing our documentation, or simply spreading the word.

- Bug Report: Please create a bug report if you encounter any errors or problems while utilising the Push Protocol.
- Feature Request: Please submit a feature request if you have an idea or discover a capability that would make development simpler and more reliable.
- Documentation Request: If you're reading the Push documentation and believe that we're missing something, please create a docs request.


Read how you can contribute <a href="https://github.com/ethereum-push-notification-service/push-sdk/blob/main/contributing.md">HERE</a>

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>

## License
Check out our License <a href='https://github.com/ethereum-push-notification-service/push-sdk/blob/main/license-v1.md'>HERE </a>


## [Contributing](./contributing.md)
26 changes: 21 additions & 5 deletions packages/demoreact/src/app/ChatTest/UpdateUserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Loader from '../components/Loader';
import { Web3Context, EnvContext } from '../context';
import * as PushAPI from '@pushprotocol/restapi';
import ChatTest from './ChatTest';
import { ethers } from 'ethers';
import { walletToPCAIP10 } from '../helpers';

type ProgressHookType = {
Expand All @@ -29,16 +28,14 @@ const UpdateUserProfile = () => {
const [pic, setPic] = useState('');
const [desc, setDesc] = useState('');
const [name, setName] = useState('');
const [pgpPrivKey, setPgpPrivKey] = useState('');
const [blockedUsersList, setblockedUsersList] = useState('');

const [decryptedPrivateKey, setDecryptedPrivateKey] = useState<string | null>(
null
);
const handleProgress = (progress: ProgressHookType) => {
setProgress(progress);
};
const updatePgpPrivKey = (e: React.SyntheticEvent<HTMLElement>) => {
setPgpPrivKey((e.target as HTMLInputElement).value);
};
const updateAccount = (e: React.SyntheticEvent<HTMLElement>) => {
setAccount((e.target as HTMLInputElement).value);
};
Expand All @@ -55,6 +52,10 @@ const UpdateUserProfile = () => {
setName((e.target as HTMLInputElement).value);
};

const updateBlockedUsersList = (e: React.SyntheticEvent<HTMLElement>) => {
setblockedUsersList((e.target as HTMLInputElement).value);
};

const testUpdateUserProfile = async (index: number) => {
try {
setLoading(true);
Expand All @@ -69,6 +70,9 @@ const UpdateUserProfile = () => {
name: name,
desc: desc,
picture: pic,
blockedUsersList: blockedUsersList
? blockedUsersList.split(',')
: undefined,
},
env,
progressHook: handleProgress,
Expand All @@ -82,6 +86,9 @@ const UpdateUserProfile = () => {
name: name,
desc: desc,
picture: pic,
blockedUsersList: blockedUsersList
? blockedUsersList.split(',')
: undefined,
},
env,
progressHook: handleProgress,
Expand Down Expand Up @@ -148,6 +155,15 @@ const UpdateUserProfile = () => {
style={{ width: 400, height: 30 }}
/>
</SectionItem>
<SectionItem style={{ marginTop: 20 }}>
<label>Blocked Users (Comma seperated)</label>
<input
type="text"
onChange={updateBlockedUsersList}
value={blockedUsersList}
style={{ width: 400, height: 30 }}
/>
</SectionItem>
<SectionItem style={{ marginTop: 20 }}>
<label>desc</label>
<input
Expand Down
85 changes: 77 additions & 8 deletions packages/restapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ This package gives access to Push Protocol (Push Nodes) APIs. Visit [Developer D
- [To send a message](#to-send-a-message)
- [To approve a chat request](#to-approve-a-chat-request)
- [To create a group](#to-create-a-group)
- [To create a token gated group](#to-create-a-token-gated-group)
- [To update group details](#to-update-group-details)
- [To update token gated group details](#to-update-token-gated-group-details)
- [To get group details by group name](#to-get-group-details-by-group-name)
- [To get group details by chatId](#to-get-group-details-by-chatid)
- [Chat Helper Utils](#chat-helper-utils)
Expand Down Expand Up @@ -3018,6 +3020,34 @@ const response = await PushAPI.chat.createGroup({
});
```

### **To create a token gated group**

```typescript
// pre-requisite API calls that should be made before
// need to get user and through that encryptedPvtKey of the user
const user = await PushAPI.user.get(account: 'eip155:0xFe6C8E9e25f7bcF374412c5C81B2578aC473C0F7', env: 'staging');

// need to decrypt the encryptedPvtKey to pass in the api using helper function
const pgpDecryptedPvtKey = await PushAPI.chat.decryptPGPKey(encryptedPGPPrivateKey: user.encryptedPrivateKey, signer: _signer);

// actual api
const response = await PushAPI.chat.createGroup({
groupName:'Push Group Chat 3',
groupDescription: 'This is the oficial group for Push Protocol',
members: ['0x9e60c47edF21fa5e5Af33347680B3971F2FfD464','0x3829E53A15856d1846e1b52d3Bdf5839705c29e5'],
groupImage: &lt;group image link&gt; ,
admins: ['0x3829E53A15856d1846e1b52d3Bdf5839705c29e5'],
contractAddressERC20: "0x8Afa8FDf9fB545C8412499E8532C958086608b30",
numberOfERC20: 20,
contractAddressNFT: "0x42af3147f17239341477113484752D5D3dda997B",
numberOfNFTTokens: 2,
isPublic: true,
account: '0xD993eb61B8843439A23741C0A3b5138763aE11a4',
env: 'staging',
pgpPrivateKey: pgpDecryptedPvtKey, //decrypted private key
});
```

Allowed Options (params with _ are mandatory)
| Param | Type | Default | Remarks |
|----------|---------|---------|--------------------------------------------|
Expand All @@ -3028,6 +3058,10 @@ Allowed Options (params with _ are mandatory)
| members* | Array<string> | - | wallet addresses of all members except admins and groupCreator |
| admins* | Array<string> | - | wallet addresses of all admins except members and groupCreator |
| isPublic* | boolean | - | true for public group, false for private group |
| contractAddressERC20 | string | null | ERC20 Contract Address |
| numberOfERC20 | int | 0 | Minimum number of tokens required to join the group |
| contractAddressNFT | string | null | NFT Contract Address |
| numberOfNFTTokens | int | 0 | Minimum number of nfts required to join the group |
| pgpPrivateKey | string | null | mandatory for users having pgp keys|
| env | string | 'prod' | API env - 'prod', 'staging', 'dev'|

Expand Down Expand Up @@ -3119,10 +3153,10 @@ Allowed Options (params with _ are mandatory)
image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAA2ElEQVR4AcXBsYnEMBRF0TsPJSpgsklVg2sxOLKbUAlqQhMMAtfiGlSCC3A4m342EBiW/ec80uvzxdhbxVqnE+t9PBlZpxPrfTyx5mXDEs6EM+Es7K3yn/ZWsYQz4Uw4C/OyYe2tYl0pY83c1CrWvGxYwplwJpyF2AvWyljshZErZax1OrFiL1jCmXAmnAVuulLmLwlnwplwFvjlShlrbxVrXjZG9lax5pSxYi9YwplwJpwFboq9MHQ8uUM4E86Es0d6fb4YsRdGrpQZib0wcqWMJZwJZ8LZDzUmMp+amfSXAAAAAElFTkSuQmCC'
}
],
contractAddressERC20: null,
numberOfERC20: 0,
contractAddressNFT: null,
numberOfNFTTokens: 0,
contractAddressERC20: "0x8Afa8FDf9fB545C8412499E8532C958086608b30",
numberOfERC20: 20,
contractAddressNFT: "0x42af3147f17239341477113484752D5D3dda997B",
numberOfNFTTokens: 2,
verificationProof: 'pgp:-----BEGIN PGP SIGNATURE-----\n' +
'\n' +
'wsBzBAEBCAAnBYJj+WS9CZCGEDC4tnEnkBYhBOsVjR1d6YVXhTJwoYYQMLi2\n' +
Expand Down Expand Up @@ -3175,6 +3209,37 @@ const response = await PushAPI.chat.updateGroup({
});
```


### **To update token gated group details**

Note - updateGroup is an idompotent call

```typescript
// pre-requisite API calls that should be made before
// need to get user and through that encryptedPvtKey of the user
const user = await PushAPI.user.get(account: 'eip155:0xFe6C8E9e25f7bcF374412c5C81B2578aC473C0F7', env: 'staging');

// need to decrypt the encryptedPvtKey to pass in the api using helper function
const pgpDecryptedPvtKey = await PushAPI.chat.decryptPGPKey(encryptedPGPPrivateKey: user.encryptedPrivateKey, signer: _signer);

// actual api
const response = await PushAPI.chat.updateGroup({
chatId: '870cbb20f0b116d5e461a154dc723dc1485976e97f61a673259698aa7f48371c',
groupName: 'Push Group Chat 3',
groupDescription: 'This is the oficial group for Push Protocol',
members: ['0x2e60c47edF21fa5e5A333347680B3971F1FfD456','0x3829E53A15856d1846e1b52d3Bdf5839705c29e5'],
groupImage: &lt;group image link&gt; ,
admins: ['0x3829E53A15856d1846e1b52d3Bdf5839705c29e5'],
contractAddressERC20: "0x8Afa8FDf9fB545C8412499E8532C958086608b30",
numberOfERC20: 20,
contractAddressNFT: "0x42af3147f17239341477113484752D5D3dda997B",
numberOfNFTTokens: 2,
account: '0xD993eb61B8843439A23741C0A3b5138763aE11a4',
env: 'staging',
pgpPrivateKey: pgpDecryptedPvtKey, //decrypted private key
});
```

Allowed Options (params with _ are mandatory)
| Param | Type | Default | Remarks |
|----------|---------|---------|--------------------------------------------|
Expand All @@ -3185,6 +3250,10 @@ Allowed Options (params with _ are mandatory)
| groupImage* | string | - | group image link |
| members* | Array<string> | - | wallet addresses of all members except admins and groupCreator |
| admins* | Array<string> | - | wallet addresses of all admins except members and groupCreator |
| contractAddressERC20 | string | null | ERC20 Contract Address |
| numberOfERC20 | int | 0 | Minimum number of tokens required to join the group |
| contractAddressNFT | string | null | NFT Contract Address |
| numberOfNFTTokens | int | 0 | Minimum number of nfts required to join the group |
| pgpPrivateKey | string | null | mandatory for users having pgp keys|
| env | string | 'prod' | API env - 'prod', 'staging', 'dev'|

Expand Down Expand Up @@ -3291,10 +3360,10 @@ Allowed Options (params with _ are mandatory)
image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAA2ElEQVR4AcXBsYnEMBRF0TsPJSpgsklVg2sxOLKbUAlqQhMMAtfiGlSCC3A4m342EBiW/ec80uvzxdhbxVqnE+t9PBlZpxPrfTyx5mXDEs6EM+Es7K3yn/ZWsYQz4Uw4C/OyYe2tYl0pY83c1CrWvGxYwplwJpyF2AvWyljshZErZax1OrFiL1jCmXAmnAVuulLmLwlnwplwFvjlShlrbxVrXjZG9lax5pSxYi9YwplwJpwFboq9MHQ8uUM4E86Es0d6fb4YsRdGrpQZib0wcqWMJZwJZ8LZDzUmMp+amfSXAAAAAElFTkSuQmCC'
}
],
contractAddressERC20: null,
numberOfERC20: 0,
contractAddressNFT: null,
numberOfNFTTokens: 0,
contractAddressERC20: "0x8Afa8FDf9fB545C8412499E8532C958086608b30",
numberOfERC20: 20,
contractAddressNFT: "0x42af3147f17239341477113484752D5D3dda997B",
numberOfNFTTokens: 2,
verificationProof: 'pgp:-----BEGIN PGP SIGNATURE-----\n' +
'\n' +
'wsBzBAEBCAAnBYJj+WlwCZCGEDC4tnEnkBYhBOsVjR1d6YVXhTJwoYYQMLi2\n' +
Expand Down
1 change: 1 addition & 0 deletions packages/restapi/src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export interface IUser {
desc: string | null;
picture: string | null;
profileVerificationProof: string | null;
blockedUsersList: Array<string> | null;
};
encryptedPrivateKey: string;
publicKey: string;
Expand Down
Loading

0 comments on commit a95a1aa

Please sign in to comment.