Skip to content

Commit

Permalink
fix: minor fix on conditioning
Browse files Browse the repository at this point in the history
  • Loading branch information
akp111 committed Oct 18, 2023
2 parents 9750680 + 0457d03 commit 484096d
Show file tree
Hide file tree
Showing 99 changed files with 7,455 additions and 3,279 deletions.
79 changes: 79 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "🐛 Bug Report"
description: Create a bug report to help us improve.
title: "🐛 [BUG] - <title>"
labels: [
"bug"
]
body:
- type: textarea
id: expected-behaviour
attributes:
label: "Expected Behaviour"
description: Please describe the behavior you are expecting
placeholder: Short and explicit description of your desired behaviour...
validations:
required: true
- type: textarea
id: current-behaviour
attributes:
label: "Current Behaviour"
description: Please describe the current behavior
placeholder: What is the current behavior?...
validations:
required: true
- type: textarea
id: reprod
attributes:
label: "Reproduction steps"
description: Please enter an explicit description of your issue
value: |
1. Go to '...'
2. Invoke function '...'
3. See error
render: bash
validations:
required: true
- type: textarea
id: screenshot
attributes:
label: "Screenshots"
description: If applicable, add screenshots to help explain your problem.
value: |
![DESCRIPTION](LINK.png)
render: bash
validations:
required: false
- type: textarea
id: logs
attributes:
label: "Relevant Logs"
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: bash
validations:
required: false
- type: dropdown
id: dapp-env
attributes:
label: "Dapp Env"
description: What is the impacted DApp environment ?
multiple: true
options:
- Prod (app.push.org)
- Staging (staging.push.org)
- Dev (dev.push.org)
validations:
required: true
- type: dropdown
id: browsers
attributes:
label: "Browsers"
description: What browsers are you seeing the problem on ?
multiple: true
options:
- Firefox
- Chrome
- Safari
- Microsoft Edge
- Opera
validations:
required: false
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/DOCUMENTATION_README_ISSUE.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "✏️ Documentation/Readme Enhancement"
description: Suggest an enhancement in documentation/readme.
title: "✏️ [Documentation/Readme Enhancement] - <title>"
labels: [
"documentation"
]
body:
- type: textarea
id: expected-behaviour
attributes:
label: "Expected Behaviour"
description: Please describe the behavior you are expecting
placeholder: Short and explicit description of your desired behaviour...
validations:
required: false
- type: textarea
id: current-behaviour
attributes:
label: "Current Behaviour"
description: Please describe the current behavior
placeholder: What is the current behavior?...
validations:
required: false
- type: textarea
id: reprod
attributes:
label: "Steps to Reproduce"
description: Please enter an explicit description of your issue
value: |
1. Go to '...'
2. Invoke function '...'
3. See error
render: bash
validations:
required: false
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/IMPROVEMENT_PROPOSAL.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "😈 Improvement Proposal"
description: Suggest improvement,whether new or built upon existing features.
title: "😈 [Improvement Proposal] - <title>"
labels: [
"Improvement proposal"
]
body:
- type: input
id: proposal-name
attributes:
label: "Proposal name"
description: Brief title or summary of the proposed improvement.
placeholder: Summary of the proposal improvement.
validations:
required: true
- type: textarea
id: description
attributes:
label: "Describe the Proposal"
description: Please describe detailed description of the improvement, including the problem it solves and the benefits it brings.
placeholder: Detailed description of your desired proposal...
validations:
required: true
- type: textarea
id: usecase
attributes:
label: "Use Case"
description: Please explain the specific use cases or scenarios where this improvement would be valuable..
placeholder: List down the use case.
validations:
required: true
- type: textarea
id: current-limitations
attributes:
label: "Current Limitations"
description: Any existing limitations, issues, or challenges with the SDK that the proposed improvement aims to address.
placeholder: Overview for the current problem/limitations.
validations:
required: true

27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/OTHER.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "👾 Other"
description: Something that doesn't belong elsewhere.
title: "👾 [Other] - <title>"
labels: [
"Other"
]
body:
- type: textarea
id: description
attributes:
label: "Description"
description: Please describe something
placeholder: Detailed description of what you wanna share...
validations:
required: true
- type: dropdown
id: dapp-env
attributes:
label: "Dapp Env"
description: What is the impacted DApp environment ?
multiple: true
options:
- Prod (app.push.org)
- Staging (staging.push.org)
- Dev (dev.push.org)
validations:
required: false
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/QUESTION_SUPPORT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "❓ Question or Support Request"
description: Questions and requests for support.
title: "❓ [Question/Support] - <title>"
labels: [
"support"
]
body:
- type: textarea
id: support-request
attributes:
label: "Question or Support Request"
description: Describe your question or ask for support.
placeholder: Detailed description of your question/support request...
validations:
required: true
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: 1, 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

0 comments on commit 484096d

Please sign in to comment.