etkframework
Version:
First test release of Etk over colored coins SDK
132 lines (110 loc) • 4.63 kB
JavaScript
/**
* et v1.3.0
* Etk library.
* A wrapper using Colored Coins COLU SDK to create standard token functions that can
* be used to build EarthShares. EarthTokens is a Standardardized Release Candidate proposal.
*
* Copyright (C) 2015 Akul Mathur
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Parts of the software are provided under separate licenses, as follows:
"colu-nodejs" SDK is under the MIT License
"pbkdf2-sha256" is under the BSD License
"bip38" is under the MIT License
"scryptsy" is under the MIT License
"coinstring" is under the MIT License
* Core Developer(s): @codecakes Akul Mathur akul at earthbenign dot com
* Maintainer(s):
* @codecakes Akul Mathur akul at earthbenign dot com
*
* Description:
* The Colu class interacts behind the scenes with:
*
1. The ColoredCoins API: Issuing and Sending transactions and receiving
asset data from the Bitcoin network
2. Financing transactions
3. A local Bitcoin Wallet: Generating addresses and keys and
signing transactions
Note: Transaction fees and issuance costs are currently covered by Colu.
This module is accessed using:
browserify et.js -o etBundle.js
Once the SRP Authentication and Key System and protocols for
TLS Authentication are proven for the client user,
- The etBundle.js is called from Eb9Ex
- Relevant EarthFwd Token Operation is performed using the Business Rules Engine (See documentation on how etk should be used here)
- etBundle.js
EB9EX Business Class functions MUST:
- Use Continuation passing style of JS i.e. Callbacks
- No procedure is allowed to return to its caller--as much as possible!
DO NOT RETURN anything as an LHS Assignment on return.
- Use Non-Blocking, Asynchronous Callback Style extensively.
- Try Catches are good. But Event Handlers are awesome.
- Callback hell can be mitigated with result passing using Promises/Deferred with generators.
- Try to define the Callback earlier, seperately for elegant code design.
*/
;
/**
* Module dependencies
*/
var path = require("path"),
util = require("util"),
/* used for local browser credentials storage */
dbFileName = path.join(__dirname, 'db.json'),
/* import token operation modules */
getAddr = require('../operations/getAddrInfo').getAddr,
getAddrInfo = require('../operations/getAddrInfo').getAddrInfo,
getAsset = require('../operations/getAsset').getAssetData,
getAssetHolder = require('../operations/getAssetHolder').getAssetHolder,
getAssetMeta = require('../operations/getAssetMeta').getAssetMeta,
initializer = require('../operations/initializer').et_int,
issueToken = require('../operations/issueToken').issueToken,
mint = require('../operations/mint').issueSend,
transfer = require('../operations/send').transfer,
getAddrPvtKey = require('../operations/getAddrPvtKey').getAddrPvtKey,
/* import crypto security operations */
passCrypt = require('../crypto_lib/passCrypt').compoundedSalt,
pvtKeyCrypt = require('../crypto_lib/pvtKeyCrypt'),
seedCrypt = require('../crypto_lib/seedCrypt'),
/* import BST tree operations */
rbTree = require("llrbtree");
/**
*
* @param {}
* @return {}
* @api public
*/
var et = (function et() {
return {
/** Basic token Operations */
init: initializer,
issueToken: issueToken,
transfer: transfer,
mint: mint,
getAddr: getAddr,
getAddrInfo: getAddrInfo,
getAddrPvtKey: getAddrPvtKey,
getAssetMeta: getAssetMeta,
getAssetHolder: getAssetHolder,
getAsset: getAsset,
/**Security operations */
salting: passCrypt,
storePvtKey: pvtKeyCrypt,
storeSeed: seedCrypt,
/* BST Ops */
rbTree: rbTree
};
})();
/**
* Module exports
*/
// console.log("this is ET");
// console.log(et);
module.exports = et;