Skip to content

Commit a95a1aa

Browse files
committed
fix: Merge branch 'main' into deployment
2 parents 183e9c2 + cda9a28 commit a95a1aa

File tree

7 files changed

+305
-56
lines changed

7 files changed

+305
-56
lines changed

README.md

Lines changed: 116 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,84 @@
1-
# PUSH-SDK
1+
<h1 align="center">
2+
<a href="https://push.org/#gh-light-mode-only">
3+
<img width='20%' height='10%' src="https://res.cloudinary.com/drdjegqln/image/upload/v1686227557/Push-Logo-Standard-Dark_xap7z5.png">
4+
</a>
5+
<a href="https://push.org/#gh-dark-mode-only">
6+
<img width='20%' height='10%' src="https://res.cloudinary.com/drdjegqln/image/upload/v1686227558/Push-Logo-Standard-White_dlvapc.png">
7+
</a>
8+
</h1>
9+
10+
<p align="center">
11+
<i align="center">Push Protocol is a web3 communication network, enabling cross-chain notifications and messaging for dapps, wallets, and services.🚀</i>
12+
</p>
13+
14+
<h4 align="center">
15+
16+
<a href="discord.gg/pushprotocol">
17+
<img src="https://img.shields.io/badge/discord-7289da.svg?style=flat-square" alt="discord">
18+
</a>
19+
<a href="https://twitter.com/pushprotocol">
20+
<img src="https://img.shields.io/badge/twitter-18a1d6.svg?style=flat-square" alt="twitter">
21+
</a>
22+
<a href="https://www.youtube.com/@pushprotocol">
23+
<img src="https://img.shields.io/badge/youtube-d95652.svg?style=flat-square&" alt="youtube">
24+
</a>
25+
</h4>
26+
27+
<p align="center">
28+
<img src="https://res.cloudinary.com/drdjegqln/image/upload/v1686230764/1500x500_bhmpkc.jpg" alt="dashboard"/>
29+
</p>
30+
31+
32+
## Introduction
33+
#### What is Push Protocol?
34+
35+
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.
36+
37+
#### What We Do
38+
39+
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.
40+
41+
<details open>
42+
<summary>
43+
Features
44+
</summary>
45+
<br>
46+
47+
<p align="center">
48+
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231190/push-notifications_tkjhss.png" alt="apis"/>
49+
&nbsp;
50+
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231185/W2W_20Chat_eurjgu.png" alt="data-models"/>
51+
</p>
52+
53+
54+
55+
<p align="center">
56+
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231164/Untitled-2_fedru3.png" alt="own-your-code"/>
57+
&nbsp;
58+
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231177/Untitled_vhvrfc.png" alt="customize-code"/>
59+
</p>
60+
61+
<p align="center">
62+
<img width="49%" src="https://res.cloudinary.com/drdjegqln/image/upload/v1686231162/1_LbhU9-qGnE8QPxWBQgNqQQ_xzkmpp.webp" alt="own-your-code"/>
63+
&nbsp;
64+
65+
</p>
66+
</details>
67+
68+
<br>
69+
<br>
70+
71+
## PUSH-SDK
72+
73+
#### Push SDK provides an abstraction layer to integrate Push protocol features with your Frontend as well as Backend
274

375
PUSH SDK is a Javascript based Monorepo of packages that helps developers to
476
- build PUSH features into their DApps
77+
- Notifications
78+
- Chat
79+
- Group Chat
80+
- Push NFT Chat
81+
- Video Calls
582
- get access to PUSH Push Nodes APIs
683
- render PUSH Notifications UI
784

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

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

14-
15-
## Packages available
91+
## Development
92+
### Packages available
1693

1794
Click on the packages to view more details.
1895

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

25102

26-
## Sample Usage
103+
<details >
104+
<summary>
105+
Sample Usage
106+
</summary>
107+
27108
*How to use a package from the SDK?*
28109

29110
Let's take `@pushprotocol/restapi` as an example.
@@ -89,5 +170,35 @@ Then to run this code open terminal and type
89170
```bash
90171
node main
91172
```
173+
</details>
174+
<br>
175+
176+
## Resources
177+
- **[Website](https://push.org)** To checkout our Product.
178+
- **[Docs](https://docs.push.org/developers/)** For comprehensive documentation.
179+
- **[Blog](https://medium.com/push-protocol)** To learn more about our partners, new launches, etc.
180+
- **[Discord](discord.gg/pushprotocol)** for support and discussions with the community and the team.
181+
- **[GitHub](https://github.com/ethereum-push-notification-service)** for source code, project board, issues, and pull requests.
182+
- **[Twitter](https://twitter.com/pushprotocol)** for the latest updates on the product and published blogs.
183+
184+
185+
## Contributing
186+
187+
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.
188+
189+
- Bug Report: Please create a bug report if you encounter any errors or problems while utilising the Push Protocol.
190+
- Feature Request: Please submit a feature request if you have an idea or discover a capability that would make development simpler and more reliable.
191+
- Documentation Request: If you're reading the Push documentation and believe that we're missing something, please create a docs request.
192+
193+
194+
Read how you can contribute <a href="https://github.com/ethereum-push-notification-service/push-sdk/blob/main/contributing.md">HERE</a>
195+
196+
Not sure where to start? Join our discord and we will help you get started!
197+
198+
199+
<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>
200+
201+
## License
202+
Check out our License <a href='https://github.com/ethereum-push-notification-service/push-sdk/blob/main/license-v1.md'>HERE </a>
203+
92204

93-
## [Contributing](./contributing.md)

packages/demoreact/src/app/ChatTest/UpdateUserProfile.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import Loader from '../components/Loader';
99
import { Web3Context, EnvContext } from '../context';
1010
import * as PushAPI from '@pushprotocol/restapi';
1111
import ChatTest from './ChatTest';
12-
import { ethers } from 'ethers';
1312
import { walletToPCAIP10 } from '../helpers';
1413

1514
type ProgressHookType = {
@@ -29,16 +28,14 @@ const UpdateUserProfile = () => {
2928
const [pic, setPic] = useState('');
3029
const [desc, setDesc] = useState('');
3130
const [name, setName] = useState('');
32-
const [pgpPrivKey, setPgpPrivKey] = useState('');
31+
const [blockedUsersList, setblockedUsersList] = useState('');
32+
3333
const [decryptedPrivateKey, setDecryptedPrivateKey] = useState<string | null>(
3434
null
3535
);
3636
const handleProgress = (progress: ProgressHookType) => {
3737
setProgress(progress);
3838
};
39-
const updatePgpPrivKey = (e: React.SyntheticEvent<HTMLElement>) => {
40-
setPgpPrivKey((e.target as HTMLInputElement).value);
41-
};
4239
const updateAccount = (e: React.SyntheticEvent<HTMLElement>) => {
4340
setAccount((e.target as HTMLInputElement).value);
4441
};
@@ -55,6 +52,10 @@ const UpdateUserProfile = () => {
5552
setName((e.target as HTMLInputElement).value);
5653
};
5754

55+
const updateBlockedUsersList = (e: React.SyntheticEvent<HTMLElement>) => {
56+
setblockedUsersList((e.target as HTMLInputElement).value);
57+
};
58+
5859
const testUpdateUserProfile = async (index: number) => {
5960
try {
6061
setLoading(true);
@@ -69,6 +70,9 @@ const UpdateUserProfile = () => {
6970
name: name,
7071
desc: desc,
7172
picture: pic,
73+
blockedUsersList: blockedUsersList
74+
? blockedUsersList.split(',')
75+
: undefined,
7276
},
7377
env,
7478
progressHook: handleProgress,
@@ -82,6 +86,9 @@ const UpdateUserProfile = () => {
8286
name: name,
8387
desc: desc,
8488
picture: pic,
89+
blockedUsersList: blockedUsersList
90+
? blockedUsersList.split(',')
91+
: undefined,
8592
},
8693
env,
8794
progressHook: handleProgress,
@@ -148,6 +155,15 @@ const UpdateUserProfile = () => {
148155
style={{ width: 400, height: 30 }}
149156
/>
150157
</SectionItem>
158+
<SectionItem style={{ marginTop: 20 }}>
159+
<label>Blocked Users (Comma seperated)</label>
160+
<input
161+
type="text"
162+
onChange={updateBlockedUsersList}
163+
value={blockedUsersList}
164+
style={{ width: 400, height: 30 }}
165+
/>
166+
</SectionItem>
151167
<SectionItem style={{ marginTop: 20 }}>
152168
<label>desc</label>
153169
<input

packages/restapi/README.md

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ This package gives access to Push Protocol (Push Nodes) APIs. Visit [Developer D
5757
- [To send a message](#to-send-a-message)
5858
- [To approve a chat request](#to-approve-a-chat-request)
5959
- [To create a group](#to-create-a-group)
60+
- [To create a token gated group](#to-create-a-token-gated-group)
6061
- [To update group details](#to-update-group-details)
62+
- [To update token gated group details](#to-update-token-gated-group-details)
6163
- [To get group details by group name](#to-get-group-details-by-group-name)
6264
- [To get group details by chatId](#to-get-group-details-by-chatid)
6365
- [Chat Helper Utils](#chat-helper-utils)
@@ -3018,6 +3020,34 @@ const response = await PushAPI.chat.createGroup({
30183020
});
30193021
```
30203022

3023+
### **To create a token gated group**
3024+
3025+
```typescript
3026+
// pre-requisite API calls that should be made before
3027+
// need to get user and through that encryptedPvtKey of the user
3028+
const user = await PushAPI.user.get(account: 'eip155:0xFe6C8E9e25f7bcF374412c5C81B2578aC473C0F7', env: 'staging');
3029+
3030+
// need to decrypt the encryptedPvtKey to pass in the api using helper function
3031+
const pgpDecryptedPvtKey = await PushAPI.chat.decryptPGPKey(encryptedPGPPrivateKey: user.encryptedPrivateKey, signer: _signer);
3032+
3033+
// actual api
3034+
const response = await PushAPI.chat.createGroup({
3035+
groupName:'Push Group Chat 3',
3036+
groupDescription: 'This is the oficial group for Push Protocol',
3037+
members: ['0x9e60c47edF21fa5e5Af33347680B3971F2FfD464','0x3829E53A15856d1846e1b52d3Bdf5839705c29e5'],
3038+
groupImage: &lt;group image link&gt; ,
3039+
admins: ['0x3829E53A15856d1846e1b52d3Bdf5839705c29e5'],
3040+
contractAddressERC20: "0x8Afa8FDf9fB545C8412499E8532C958086608b30",
3041+
numberOfERC20: 20,
3042+
contractAddressNFT: "0x42af3147f17239341477113484752D5D3dda997B",
3043+
numberOfNFTTokens: 2,
3044+
isPublic: true,
3045+
account: '0xD993eb61B8843439A23741C0A3b5138763aE11a4',
3046+
env: 'staging',
3047+
pgpPrivateKey: pgpDecryptedPvtKey, //decrypted private key
3048+
});
3049+
```
3050+
30213051
Allowed Options (params with _ are mandatory)
30223052
| Param | Type | Default | Remarks |
30233053
|----------|---------|---------|--------------------------------------------|
@@ -3028,6 +3058,10 @@ Allowed Options (params with _ are mandatory)
30283058
| members* | Array<string> | - | wallet addresses of all members except admins and groupCreator |
30293059
| admins* | Array<string> | - | wallet addresses of all admins except members and groupCreator |
30303060
| isPublic* | boolean | - | true for public group, false for private group |
3061+
| contractAddressERC20 | string | null | ERC20 Contract Address |
3062+
| numberOfERC20 | int | 0 | Minimum number of tokens required to join the group |
3063+
| contractAddressNFT | string | null | NFT Contract Address |
3064+
| numberOfNFTTokens | int | 0 | Minimum number of nfts required to join the group |
30313065
| pgpPrivateKey | string | null | mandatory for users having pgp keys|
30323066
| env | string | 'prod' | API env - 'prod', 'staging', 'dev'|
30333067

@@ -3119,10 +3153,10 @@ Allowed Options (params with _ are mandatory)
31193153
image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAA2ElEQVR4AcXBsYnEMBRF0TsPJSpgsklVg2sxOLKbUAlqQhMMAtfiGlSCC3A4m342EBiW/ec80uvzxdhbxVqnE+t9PBlZpxPrfTyx5mXDEs6EM+Es7K3yn/ZWsYQz4Uw4C/OyYe2tYl0pY83c1CrWvGxYwplwJpyF2AvWyljshZErZax1OrFiL1jCmXAmnAVuulLmLwlnwplwFvjlShlrbxVrXjZG9lax5pSxYi9YwplwJpwFboq9MHQ8uUM4E86Es0d6fb4YsRdGrpQZib0wcqWMJZwJZ8LZDzUmMp+amfSXAAAAAElFTkSuQmCC'
31203154
}
31213155
],
3122-
contractAddressERC20: null,
3123-
numberOfERC20: 0,
3124-
contractAddressNFT: null,
3125-
numberOfNFTTokens: 0,
3156+
contractAddressERC20: "0x8Afa8FDf9fB545C8412499E8532C958086608b30",
3157+
numberOfERC20: 20,
3158+
contractAddressNFT: "0x42af3147f17239341477113484752D5D3dda997B",
3159+
numberOfNFTTokens: 2,
31263160
verificationProof: 'pgp:-----BEGIN PGP SIGNATURE-----\n' +
31273161
'\n' +
31283162
'wsBzBAEBCAAnBYJj+WS9CZCGEDC4tnEnkBYhBOsVjR1d6YVXhTJwoYYQMLi2\n' +
@@ -3175,6 +3209,37 @@ const response = await PushAPI.chat.updateGroup({
31753209
});
31763210
```
31773211

3212+
3213+
### **To update token gated group details**
3214+
3215+
Note - updateGroup is an idompotent call
3216+
3217+
```typescript
3218+
// pre-requisite API calls that should be made before
3219+
// need to get user and through that encryptedPvtKey of the user
3220+
const user = await PushAPI.user.get(account: 'eip155:0xFe6C8E9e25f7bcF374412c5C81B2578aC473C0F7', env: 'staging');
3221+
3222+
// need to decrypt the encryptedPvtKey to pass in the api using helper function
3223+
const pgpDecryptedPvtKey = await PushAPI.chat.decryptPGPKey(encryptedPGPPrivateKey: user.encryptedPrivateKey, signer: _signer);
3224+
3225+
// actual api
3226+
const response = await PushAPI.chat.updateGroup({
3227+
chatId: '870cbb20f0b116d5e461a154dc723dc1485976e97f61a673259698aa7f48371c',
3228+
groupName: 'Push Group Chat 3',
3229+
groupDescription: 'This is the oficial group for Push Protocol',
3230+
members: ['0x2e60c47edF21fa5e5A333347680B3971F1FfD456','0x3829E53A15856d1846e1b52d3Bdf5839705c29e5'],
3231+
groupImage: &lt;group image link&gt; ,
3232+
admins: ['0x3829E53A15856d1846e1b52d3Bdf5839705c29e5'],
3233+
contractAddressERC20: "0x8Afa8FDf9fB545C8412499E8532C958086608b30",
3234+
numberOfERC20: 20,
3235+
contractAddressNFT: "0x42af3147f17239341477113484752D5D3dda997B",
3236+
numberOfNFTTokens: 2,
3237+
account: '0xD993eb61B8843439A23741C0A3b5138763aE11a4',
3238+
env: 'staging',
3239+
pgpPrivateKey: pgpDecryptedPvtKey, //decrypted private key
3240+
});
3241+
```
3242+
31783243
Allowed Options (params with _ are mandatory)
31793244
| Param | Type | Default | Remarks |
31803245
|----------|---------|---------|--------------------------------------------|
@@ -3185,6 +3250,10 @@ Allowed Options (params with _ are mandatory)
31853250
| groupImage* | string | - | group image link |
31863251
| members* | Array<string> | - | wallet addresses of all members except admins and groupCreator |
31873252
| admins* | Array<string> | - | wallet addresses of all admins except members and groupCreator |
3253+
| contractAddressERC20 | string | null | ERC20 Contract Address |
3254+
| numberOfERC20 | int | 0 | Minimum number of tokens required to join the group |
3255+
| contractAddressNFT | string | null | NFT Contract Address |
3256+
| numberOfNFTTokens | int | 0 | Minimum number of nfts required to join the group |
31883257
| pgpPrivateKey | string | null | mandatory for users having pgp keys|
31893258
| env | string | 'prod' | API env - 'prod', 'staging', 'dev'|
31903259

@@ -3291,10 +3360,10 @@ Allowed Options (params with _ are mandatory)
32913360
image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAA2ElEQVR4AcXBsYnEMBRF0TsPJSpgsklVg2sxOLKbUAlqQhMMAtfiGlSCC3A4m342EBiW/ec80uvzxdhbxVqnE+t9PBlZpxPrfTyx5mXDEs6EM+Es7K3yn/ZWsYQz4Uw4C/OyYe2tYl0pY83c1CrWvGxYwplwJpyF2AvWyljshZErZax1OrFiL1jCmXAmnAVuulLmLwlnwplwFvjlShlrbxVrXjZG9lax5pSxYi9YwplwJpwFboq9MHQ8uUM4E86Es0d6fb4YsRdGrpQZib0wcqWMJZwJZ8LZDzUmMp+amfSXAAAAAElFTkSuQmCC'
32923361
}
32933362
],
3294-
contractAddressERC20: null,
3295-
numberOfERC20: 0,
3296-
contractAddressNFT: null,
3297-
numberOfNFTTokens: 0,
3363+
contractAddressERC20: "0x8Afa8FDf9fB545C8412499E8532C958086608b30",
3364+
numberOfERC20: 20,
3365+
contractAddressNFT: "0x42af3147f17239341477113484752D5D3dda997B",
3366+
numberOfNFTTokens: 2,
32983367
verificationProof: 'pgp:-----BEGIN PGP SIGNATURE-----\n' +
32993368
'\n' +
33003369
'wsBzBAEBCAAnBYJj+WlwCZCGEDC4tnEnkBYhBOsVjR1d6YVXhTJwoYYQMLi2\n' +

packages/restapi/src/lib/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export interface IUser {
181181
desc: string | null;
182182
picture: string | null;
183183
profileVerificationProof: string | null;
184+
blockedUsersList: Array<string> | null;
184185
};
185186
encryptedPrivateKey: string;
186187
publicKey: string;

0 commit comments

Comments
 (0)