Skip to content

Typescript SDK for interacting with Notifi APIs

License

Notifications You must be signed in to change notification settings

dm-sierra/notifi-sdk-ts

 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License


Logo

Notifi SDK

Typescript based SDK for React and NodeJS projects.
See our packages for more examples »
Explore the docs »
Join our Discord!!

· Report Bug · Request Feature ·

Usage Scenarios

Direct Push

This type of interaction assumes you have a server already running and want to push a notification to a member of your dapp. In this scenario, we first require the dapp to directly tell Notifi on our Discord SDK channel that they want to leverage our SDK. Notifi will create a tenancy that is owned by the dapp and transfer a SID/Secret pair. For now this is manual, but we will have a self-service admin panel for dapps to use in the future.

For users to sign up for notifications, the dapp will use our React SDK to logInFromDapp and then create/modify notifications. From here, the DApp SVC can send a message to the user's wallet address, where Notifi will take care of any special filtering and routing the user wanted to do. Examples coming soon!

Direct Push Diagram

Monitor and Trigger

In this scenario, Notifi can monitor the blockchain and detect important events that users can subscribe to. This is how Notifi implements DAO proposal notifications today. If you have a dapp that you'd like Notifi to monitor, please join our Discord server and tell us about it! We'll be open sourcing our plugins for DAO proposals in the future to help make this more self service. This can seem like a bit of magic, so feel free to ask any questions in our Discord#SDK.

Monitoring Diagram

(back to top)

Built With ❤️ and ...

(back to top)

Getting Started with Direct Push

  • Join our Notifi Discord
  • Message our SDK channel for access
  • Install our npm package in your React app
  • Create UI for your users to register for notifications
  • Use our GraphQL API from your service to send messages to Notifi (NodeJS SDK coming soon!)

Getting Started with Notifi Monitoring

Note: For Notifi's monitoring scenario, we will be releasing our Notifi Monitoring code in the future so you can simply template and/or extend off of existing patterns

Steps to deploy canary (for local development of SDK and deploying to npm)

npx lerna exec -- npx rimraf dist

npx lerna exec -- npx rimraf node_modules

npx lerna bootstrap

npx lerna run build

npx lerna publish --canary

(back to top)

E2E Test

The E2E test is particularly for @notifi-network/notifi-react-card since it provides a React component (UI/UX) to let developers integrate with notifi's BE more easily.

To ensure all the components are working as expected, we use cypress component test to implement the E2E (end-to-end) test.

Run the command below to start the cypress test runner heedlessly.

npm run test
# or
# npx lerna --scope=@notifi-network/notifi-react-example run test

If you would like to contribute, feel free to create a new test case in packages/notifi-react-example/cypress/component/NotifiSubscriptionCard.cy.tsx, to ensure the implemented new features are working as expected. These test cases will also be included in the CI/CD pipeline when the PR is created & merged.

There is the example format of the test case below.

// ...
describe('New feature', () => {
  it('Flow#1', () => {
    // ... implement the test content for the new feature flow#1
  });

  it('Flow#2', () => {
    // ... implement the test content for the new feature flow#2
  });
});
Notes
  1. It might be useful to run cypress headed mode while developing new test script.
npx lerna --scope=@notifi-network/notifi-react-example run cypress:open
  1. Learn more about cypress from official documentation

We use the exclusive notifi tenant for e2e test, see the details below.

  • tenantId (dappAddress): notifie2e
  • cardId: 718f2bb0fd80401887643764017cc780

For normal test scenario, we are able to simply manipulate card data through cypress intercept and fixture function. Feel free to contact us in case that the feature test requires a new react-card.

More detail for repository maintainer, check the Doc here.

(back to top)

Regenerate docs

npm run docs



Advanced

We understand that not all scenarios can be solved with the current state of the SDK. When adding SDK features, we'd like to ensure we're building exactly what developers want. If you need to break out of the SDK features for more advanced interaction with Notifi, please see our Notifi GraphQL API that you can consume alongside the SDK.

About

Typescript SDK for interacting with Notifi APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 94.2%
  • CSS 5.5%
  • Other 0.3%