-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: created define criteria and add criteria * feat: added some more dropdowns in add criteria * fix: added critera options * feat: worked on criterias * Arbitrum changes (#735) * fix: inital implementation for arbitrum changes * fix: more changes * fix: added final changes * fix: fixed few ui issues * fix: fixed minor issue * fix: added operstor * fix: added dummy 2d data * fix: fixed test * feat: condition type added * feat: adder done * feat: all/any added on condition box * fix: minor fixes * fix: fixed typo * fix: fixed upload group image ui * Multiple group criteria (#747) * fix: fixed multiple criteria Ui * fix: fixed conditions code --------- Co-authored-by: KlausMikhaelson <[email protected]> * docs: added Class Examples (#739) * docs: added documentation * docs: fixed chat class examples * docs: fix notif class * docs: fixed stream examples * docs: fix nft grp update * docs: fixed logs * Message Type Implementations (#730) * fix: added video & audio messages * fix: fixed meta, reaction & added intent & readReceipt * fix: added reply * fix: added composite, fixed receipt * fix: local tests (#744) * fix(env and index): fixes typo RECIPEINT to RECIPIENT (#743) fix #733 * Update README.md (#742) Changed the discord link * feat: add criteria done * fix: fixed themes * feat: rule deletion done * feat: condition update done * feat: add criteria update lablel done * feat: edit rule auto fill done * feat: pr changes done * feat: refactor type and hooks * fix: fixed mobilde view * fix: fixed scroll * feat: added icon in groupinfo to show if it is token gated or not (#748) * feat: added icon in groupinfo to show if it is token gated or not * fix: fixed minor text * feat: created group criteria info modal and fixed dropdown * fix: made changes as per the review * fix: removed more options from conditions in group info * fix: fixed minor issues --------- Co-authored-by: Monalisha Mishra <[email protected]> * feat: drop down labels * fix: fixed * fix: fixed dropdown * Gp states fix (#763) * feat: conditions to chat added * feat: generation of payload done * refactor: rule generation done * feat: operator undefined fix * fix: fixed condition ui * feat: create group rest api call done * fix: fixed dropdown * feat: group detail info fix done * fix: added validation for guild --------- Co-authored-by: Abishek Bashyal <[email protected]> --------- Co-authored-by: KlausMikhaelson <[email protected]> Co-authored-by: Ashis Kumar Pradhan <[email protected]> Co-authored-by: Abishek Bashyal <[email protected]> Co-authored-by: akp111 <[email protected]> Co-authored-by: Aman Gupta <[email protected]> Co-authored-by: strykerin <[email protected]> Co-authored-by: Rahul Pandey <[email protected]> Co-authored-by: dinesh <[email protected]> Co-authored-by: Satyam <[email protected]>
- Loading branch information
1 parent
7252b17
commit 794aa59
Showing
90 changed files
with
5,680 additions
and
985 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
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'); | ||
}; |
Oops, something went wrong.