A lotionjs transaction middleware, which take a little part of the donation amount to donate to the non-profit organization you choose.
$ npm i --save celadon
import lotion from 'lotion';
import { handler as CeladonHandler } from 'celadon';
let app = lotion({
devMode: true,
initialState: {
...data
}
});
app.use(CeladonHandler);
app.listen(3000);
// 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
})
}
<!-- customize NPOs -->
donateTo() // default to celadon_wallet
donateTo('cosmos_wallet')
donateTo(['cosmos_wallet', 'impacthub_wallet', 'andy_wallettttttt'])