Giter VIP home page Giter VIP logo

celadon's Introduction

Celadon

A lotionjs transaction middleware, which take a little part of the donation amount to donate to the non-profit organization you choose.

Travis Build Status

Installation

$ npm i --save celadon

Use it as a handler

import lotion from 'lotion';
import { handler as CeladonHandler } from 'celadon';

let app = lotion({ 
  devMode: true,
  initialState: {
    ...data
  }
});

app.use(CeladonHandler);
app.listen(3000);

Use it in your own handler

// app.js
import lotion from 'lotion';
import handler from './handler';

let app = lotion({ 
  devMode: true,
  initialState: {
    ...data
  }
});

app.use(handler);
app.listen(3000);

// in handler.js
import { trasactionWithCeledon, donateTo, NPOs } from 'celadon';
console.log(NPOs);
// ['celadon_wallet', 'cosmos_wallet', 'impacthub_wallet', 'andy_wallettttttt']

export default function handler(state, tx) {
  // verify the tx
  // secp256k1.verify(tx.data, tx.signature, tx.data.from)

  let senderAddress = tx.data.from.toString('hex')
  let receiverAddress = tx.data.to.toString('hex')
  trasactionWithCeledon(state, {
    from: senderAddress,
    to: receiverAddress,
    org: donateTo(NPOs),
    feePortion: tx.data.feePortion,
    amount: tx.data.amount
  })
}

Choose your NPOs

<!-- customize NPOs -->
donateTo() // default to celadon_wallet
donateTo('cosmos_wallet')
donateTo(['cosmos_wallet', 'impacthub_wallet', 'andy_wallettttttt'])

Walkthrough

introduction - celadon middlware

Stack Diagram

Join the NPOs wallet list

Author

reforest

Resources

Standard

JavaScript Style Guide

License

MIT

celadon's People

Contributors

amazingandyyy avatar cheung31 avatar storycoding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.