Git Product home page Git Product logo

abhikumar98 / react-npm-lib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michal-wrzosek/react-component-lib

1.0 1.0 0.0 1.84 MB

Boilerplate repo for creating npm packages with React components written in TypeScript and using styled-components

Home Page: https://medium.com/@xfor/developing-publishing-react-component-library-to-npm-styled-components-typescript-cc8274305f5a

License: MIT License

JavaScript 22.33% TypeScript 71.27% HTML 5.17% CSS 1.23%

react-npm-lib's Introduction

Dakiya SDK

Send messages on chain to any ethereum address.

Usage

npm i @dakiya/sdk

or

yarn add @dakiya/sdk

Steps

  1. On board user before sending messages
import { onboardUser } from "@dakiya/sdk";

const App = () => {

    const handleOnBoard = async () => {

        const account = ""; // current connected account from metamask
        const chainId = "0x1"' // current chain id from metamask

        const user = await onboardUser(account, chainId);
        console.log(user);
    }

    return <button onClick={handleOnBoard}>Let's get started</button>
}

  1. Start sending messages :)
import { createThread } from "@dakiya/sdk";

const App = () => {

    const startNewThread = async () => {

        const createThreadParams = {
            receiver: "someone.eth"
            subject: "Hello world !";
            message: "Basic hello";
            chainId: "0x1";
        }

        const newThread = await createThread(createThreadParams);
    }

    return <button onClick={startNewThread}>Say Hello</button>
}

  1. Start sending messages :)
import { threadReply } from "@dakiya/sdk";

const App = () => {

    const startNewThread = async () => {

        const threadReplyParams = {
            receiver: "",
            message: "",
            threadId: "",
            encryptionKey: "", // thread's encryption key
            senderPubEncKey: "0x...", // sender's public encryption key
            receiverPubEncKey: "", // reciever's public encryption key
            encrypt: true, // is thread encrypted?
            chainId: "0x1"
        }

        /**
        encryptionKey, senderPubEncKey, receiverPubEncKey, encrypt are supposed to be passed from the thread details when decrypted while loading the thread
        */

        const newThread = await createThread(threadReplyParams);
    }

    return <button onClick={startNewThread}>Say Hello</button>
}

  1. Fetching messages from thread
import { getMessagesFromThread } from "@dakiya/sdk";

const App = () => {

    const fetchMessages = async () => {

        const getMessagesParams = {
            account: "", // current connected account from metamask
            threadId: "",
            encryptionKey: "", // thread's encryption key
            chainId: "0x1"
        }

        const newThread = await getMessagesFromThread(getMessagesParams);
    }

    return <button onClick={fetchMessages}>Say Hello</button>
}
  1. Getting subject of Thread while getting messages
import { getSubject } from "@dakiya/sdk";

const App = () => {

    const fetchThreadSubject = async () => {

        const subjectParams = {
            subjectURI: "", // thread's encryption key
            encryptionKey: ""
        }

        const newThread = await getSubject(subjectParams);
    }

    return <button onClick={fetchThreadSubject}>Say Hello</button>
}

react-npm-lib's People

Contributors

michal-wrzosek avatar abhikumar98 avatar brightpixels avatar bmichalowski avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.